Class CoordSys

java.lang.Object
adql.db.region.CoordSys

public class CoordSys extends Object
Object representation of an STC coordinate system.

A coordinate system is composed of three parts: a frame (frame), a reference position (refpos) and a flavor (flavor).

The default value - also corresponding to an empty string - should be: CoordSys.Frame.UNKNOWNFRAME CoordSys.RefPos.UNKNOWNREFPOS CoordSys.Flavor.SPHERICAL2. Once built, it is possible to know whether the coordinate system is the default one or not thanks to function isDefault().

An instance of this class can be easily serialized into STC-S using toSTCS(), toFullSTCS() or toString(). toFullSTCS() will display default values explicitly on the contrary to toSTCS() which will replace them by empty strings.

Important note: The flavors CARTESIAN2 and CARTESIAN3 can not be used with other frame and reference position than UNKNOWNFRAME and UNKNOWNREFPOS. In the contrary case an IllegalArgumentException is throw.

Since:
1.3
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    List of all possible flavors in an STC expression.
    static enum 
    List of all possible frames in an STC expression.
    static enum 
    List of all possible reference positions in an STC expression.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Human description of the syntax of a full coordinate system expression.
    Third and last item of a coordinate system expression: the flavor.
    First item of a coordinate system expression: the frame.
    Second item of a coordinate system expression: the reference position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Build a default coordinate system (UNKNOWNFRAME UNKNOWNREFPOS SPHERICAL2).
    Build a coordinate system with the given parts.
    CoordSys(String coordsys)
    Build a coordinate system by parsing the given STC-S expression.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    buildCoordSysRegExp(String[] allowedCoordSys)
    Build a big regular expression gathering all of the given coordinate system syntaxes.
    final boolean
    Tell whether this is the default coordinate system (UNKNOWNFRAME UNKNOWNREFPOS SPHERICAL2).
    Get the STC-S expression of this coordinate system, in which default values are explicitly written.
    Get the STC-S expression of this coordinate system, in which default values are not written (they are replaced by empty strings).
    Convert this coordinate system into a STC-S expression.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • COORD_SYS_SYNTAX

      public static final String COORD_SYS_SYNTAX
      Human description of the syntax of a full coordinate system expression.
    • frame

      public final CoordSys.Frame frame
      First item of a coordinate system expression: the frame.
    • refpos

      public final CoordSys.RefPos refpos
      Second item of a coordinate system expression: the reference position.
    • flavor

      public final CoordSys.Flavor flavor
      Third and last item of a coordinate system expression: the flavor.
  • Constructor Details

    • CoordSys

      public CoordSys()
      Build a default coordinate system (UNKNOWNFRAME UNKNOWNREFPOS SPHERICAL2).
    • CoordSys

      Build a coordinate system with the given parts.
      Parameters:
      fr - Frame part.
      rp - Reference position part.
      fl - Flavor part.
      Throws:
      IllegalArgumentException - If a cartesian flavor is used with a frame and reference position other than UNKNOWNFRAME and UNKNOWNREFPOS.
    • CoordSys

      public CoordSys(String coordsys) throws ParseException
      Build a coordinate system by parsing the given STC-S expression.
      Parameters:
      coordsys - STC-S expression representing a coordinate system. Empty string and NULL are allowed values ; they correspond to a default coordinate system.
      Throws:
      ParseException - If the syntax of the given STC-S expression is wrong or if it is not a coordinate system only.
  • Method Details

    • buildCoordSysRegExp

      public static String buildCoordSysRegExp(String[] allowedCoordSys) throws ParseException
      Build a big regular expression gathering all of the given coordinate system syntaxes.

      Each item of the given list must respect a strict syntax. Each part of the coordinate system may be a single value, a list of values or a '*' (meaning all values are allowed). A list of values must have the following syntax: ({value1}|{value2}|...). An empty string is NOT here accepted.

      Example: (ICRS|FK4|FK5) * SPHERICAL2 is OK, but (ICRS|FK4|FK5) * is not valid because the flavor value is not defined.

      Since the default value of each part of a coordinate system should always be possible, this function ensure these default values are always possible in the returned regular expression. Thus, if some values except the default one are specified, the default value is automatically appended.

      Note: If the given array is NULL, all coordinate systems are allowed. But if the given array is empty, none except an empty string or the default value will be allowed.

      Parameters:
      allowedCoordSys - List of all coordinate systems that are allowed.
      Returns:
      The corresponding regular expression.
      Throws:
      ParseException - If the syntax of one of the given allowed coordinate system is wrong.
    • isDefault

      public final boolean isDefault()
      Tell whether this is the default coordinate system (UNKNOWNFRAME UNKNOWNREFPOS SPHERICAL2).
      Returns:
      true if it is the default coordinate system, false otherwise.
    • toSTCS

      public String toSTCS()
      Get the STC-S expression of this coordinate system, in which default values are not written (they are replaced by empty strings).
      Returns:
      STC-S representation of this coordinate system.
    • toFullSTCS

      public String toFullSTCS()
      Get the STC-S expression of this coordinate system, in which default values are explicitly written.
      Returns:
      STC-S representation of this coordinate system.
    • toString

      public String toString()
      Convert this coordinate system into a STC-S expression.
      Overrides:
      toString in class Object
      See Also: