Class DSL


  • public class DSL
    extends Object
    Contains a Domain Specific Language for constructing Geometries.

    The DSL has methods for creating Positions, Geometrys and GeometryTokens.

    The methods for creating Positions are:

    • g(lon, lat), g(lon,lat,height), gM(lon,lat, measure), and g(lon,lat,height, measure) for resp. G2D, G3D, G2DM and G3DM Position instances
    • c(x,y), p(x,y,z), cM(x,y,measure), c(x,y,z,m) for resp. P2D, P3D, P2DM and P3DM Position instances

    The methods for creating geometries are named for the geometry the create.

    GeometryTokens are intermediate representations that are handy when creating a Geometry that is composed of Geometrys. It allows the DSL user to specify the coordinate reference system only once.

    Usage example:
     
    
     import static org.geolatte.geom.builder.DSL.*;
    
    
     public Polygon createPolygon() {
         CoordinateReferenceSystem crs = ...
         return polygon(crs, ring(p(0, 0), p(0, 1), p(1, 1), p(1, 0), p(0, 0)));
     }
    
     
     
    Author:
    Karel Maesen, Geovise BVBA creation-date: 11/10/12
    • Method Detail

      • c

        public static C2D c​(double x,
                            double y)
        Creates a projected 2D position token.
        Parameters:
        x - x or easting
        y - y or northing
        Returns:
        a projected 2D PosToken
      • c

        public static C3D c​(double x,
                            double y,
                            double z)
        Creates a projected 3D position token
        Parameters:
        x - x or easting
        y - y or northing
        z - z or height
        Returns:
        a projected 3D PosToken
      • cM

        public static C2DM cM​(double x,
                              double y,
                              double m)
        Creates a projected 2DM position token
        Parameters:
        x - x or easting
        y - y or northing
        m - measure value
        Returns:
        a projected 2DM PosToken
      • c

        public static C3DM c​(double x,
                             double y,
                             double z,
                             double m)
        Creates a projected 3DM position token
        Parameters:
        x - x or easting
        y - y or northing
        z - z or heightitude
        m - measure value
        Returns:
        a projected 3DM PosToken
      • g

        public static G2D g​(double lon,
                            double lat)
        Creates a geographic 2D position token
        Parameters:
        lon - longitude
        lat - latitude
        Returns:
        a geographic 2D PosToken
      • g

        public static G3D g​(double lon,
                            double lat,
                            double height)
        Creates a geographic 3D position token
        Parameters:
        lon - longitude
        lat - latitude
        height - height
        Returns:
        a geographic 3D PosToken
      • gM

        public static G2DM gM​(double lon,
                              double lat,
                              double m)
        Creates a geographic 2DM position token
        Parameters:
        lon - longitude
        lat - latitude
        m - measure value
        Returns:
        a geographic 2DM PosToken
      • g

        public static G3DM g​(double lon,
                             double lat,
                             double height,
                             double m)
        Creates a geographic 3DM position token
        Parameters:
        lon - longitude
        lat - latitude
        height - height
        m - measure value
        Returns:
        a geographic 3DM PosToken
      • point

        public static <P extends PositionPoint<P> point​(CoordinateReferenceSystem<P> crs,
                                                          P p)
        Creates a Point
        Type Parameters:
        P - the Position type
        Parameters:
        crs - the CoordinateReferenceSystem for the Point
        p - the Position for the Point
        Returns:
        a Point having the specified Position and CoordinateReferenceSystem
      • point

        public static <P extends PositionDSL.PointToken<P> point​(P position)
        Creates a PointToken
        Type Parameters:
        P - the Position type
        Parameters:
        position - the Position for the PointToken
        Returns:
        a PointToken having the specified Position
      • linestring

        public static <P extends PositionLineString<P> linestring​(CoordinateReferenceSystem<P> crs,
                                                                    P... positions)
        Creates a LineString
        Type Parameters:
        P - the Position type
        Parameters:
        crs - the CoordinateReferenceSystem for the LineString
        positions - the Positions for the LineString
        Returns:
        a LineString having the specified Positions and CoordinateReferenceSystem
      • linestring

        public static <P extends PositionDSL.LineStringToken<P> linestring​(P... positions)
        Creates a LineStringToken
        Type Parameters:
        P - the Position type
        Parameters:
        positions - the Positions for the LineStringToken
        Returns:
        a LineStringToken having the specified Positions
      • ring

        public static <P extends PositionLinearRing<P> ring​(CoordinateReferenceSystem<P> crs,
                                                              P... positions)
        Creates a LinearRing
        Type Parameters:
        P - the Position type
        Parameters:
        crs - the CoordinateReferenceSystem for the LinearRing
        positions - the Positions for the LinearRing
        Returns:
        a LinearRing having the specified Positions and CoordinateReferenceSystem
      • ring

        @SafeVarargs
        public static <P extends PositionDSL.LinearRingToken<P> ring​(P... positions)
        Creates a LinearRingToken
        Type Parameters:
        P - the Position type
        Parameters:
        positions - the Positions for the LinearRingToken
        Returns:
        a LinearRingToken having the specified Positions
      • geometrycollection

        @SafeVarargs
        public static <P extends PositionGeometryCollection<P> geometrycollection​(Geometry<P> geometry,
                                                                                    Geometry<P>... geometries)
        Creates a GeometryCollection from the specified Geometrys.
        Type Parameters:
        P - the Position type
        Parameters:
        geometry - the first constituent Geometry
        geometries - the rest of the constituent Geometrys
        Returns:
        the GeometryCollection of the specified constituent Geometrys.
      • geometrycollection

        @SafeVarargs
        public static <P extends PositionGeometryCollection<P> geometrycollection​(CoordinateReferenceSystem<P> crs,
                                                                                    DSL.GeometryToken<P>... tokens)
        Creates a GeometryCollection from the specified GeometryTokens and CoordinateReferenceSystem.
        Type Parameters:
        P - the Position type
        Parameters:
        crs - the CoordinateReferenceSystem for the GeometryCollection
        tokens - the GeometryTokens for the constituent Geometrys of the returned GeometryCollection
        Returns:
        the GeometryCollection of the specified constituent Geometrys and CoordinateReferenceSystem
      • geometrycollection

        @SafeVarargs
        public static <P extends PositionDSL.GeometryCollectionToken<P> geometrycollection​(DSL.GeometryToken<P>... tokens)
        Creates a GeometryCollectionToken of the specified GeometryTokens
        Type Parameters:
        P - the Position type
        Parameters:
        tokens - the GeometryTokens that represent the constituent Geometrys of the returned GeometryCollection
        Returns:
        the GeometryCollectionToken of the specified constituent GeometryTokens
      • polygon

        @SafeVarargs
        public static <P extends PositionPolygon<P> polygon​(LinearRing<P> hull,
                                                              LinearRing<P>... rings)
        Creates a Polygon from the specified outer ring (or hull) and inner rings (if any)
        Type Parameters:
        P - the Position type
        Parameters:
        hull - the outer ring of the returned Polygon
        rings - the inner rings of the returned Polygon
        Returns:
        the Polygon defined by the specified outer and inner rings.
      • polygon

        @SafeVarargs
        public static <P extends PositionPolygon<P> polygon​(CoordinateReferenceSystem<P> crs,
                                                              DSL.LinearRingToken<P>... tokens)
        Creates a Polygon from the specified ring tokens and CoordinateReferenceSystem
        Type Parameters:
        P - the Position type
        Parameters:
        crs - the CoordinateReferenceSystem for the returned Polygon
        tokens - the GeometryTokens representing (in order) the outer and any inner rings
        Returns:
        the Polygon defined by the specified coordinate reference system and ring tokens