Class ST_AsGeoJSON

java.lang.Object
org.h2gis.api.AbstractFunction
org.h2gis.api.DeterministicScalarFunction
org.h2gis.functions.io.geojson.ST_AsGeoJSON
All Implemented Interfaces:
org.h2gis.api.Function, org.h2gis.api.ScalarFunction

public class ST_AsGeoJSON extends org.h2gis.api.DeterministicScalarFunction
Transform a JTS geometry to a GeoJSON geometry representation.
Author:
Erwan Bocher
  • Field Summary

    Fields inherited from interface org.h2gis.api.Function

    PROP_NAME, PROP_REMARKS

    Fields inherited from interface org.h2gis.api.ScalarFunction

    PROP_DETERMINISTIC
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    static String
    toGeojson(org.locationtech.jts.geom.Geometry geom)
    Convert the geometry to a GeoJSON representation.
    static String
    toGeojson(org.locationtech.jts.geom.Geometry geom, int maxdecimaldigits)
    Convert the geometry to a GeoJSON representation.
    static void
    toGeojsonCoordinate(org.locationtech.jts.geom.Coordinate coord, int maxdecimaldigits, StringBuilder sb)
    Convert a JTS coordinate to a GeoJSON representation.
    static void
    toGeojsonCoordinates(org.locationtech.jts.geom.Coordinate[] coords, int maxdecimaldigits, StringBuilder sb)
    Convert a jts array of coordinates to a GeoJSON coordinates representation.
    toGeoJsonEnvelope(org.locationtech.jts.geom.Envelope e, int maxdecimaldigits)
    Convert a JTS Envelope to a GeoJSON representation.
    static void
    toGeojsonGeometry(org.locationtech.jts.geom.Geometry geom, int maxdecimaldigits, StringBuilder sb)
    Transform a JTS geometry to a GeoJSON representation.
    static void
    toGeojsonGeometryCollection(org.locationtech.jts.geom.GeometryCollection geometryCollection, int maxdecimaldigits, StringBuilder sb)
    A GeoJSON object with type "GeometryCollection" is a geometry object which represents a collection of geometry objects.
    static void
    toGeojsonLineString(org.locationtech.jts.geom.LineString lineString, int maxdecimaldigits, StringBuilder sb)
    Coordinates of LineString are an array of positions.
    static void
    toGeojsonMultiLineString(org.locationtech.jts.geom.MultiLineString multiLineString, int maxdecimaldigits, StringBuilder sb)
    Coordinates of a MultiLineString are an array of LineString coordinate arrays.
    static void
    toGeojsonMultiPoint(org.locationtech.jts.geom.MultiPoint multiPoint, int maxdecimaldigits, StringBuilder sb)
    Coordinates of a MultiPoint are an array of positions.
    static void
    toGeojsonMultiPolygon(org.locationtech.jts.geom.MultiPolygon multiPolygon, int maxdecimaldigits, StringBuilder sb)
    Coordinates of a MultiPolygon are an array of Polygon coordinate arrays.
    static void
    toGeojsonPoint(org.locationtech.jts.geom.Point point, int maxdecimaldigits, StringBuilder sb)
    For type "Point", the "coordinates" member must be a single position.
    static void
    toGeojsonPolygon(org.locationtech.jts.geom.Polygon polygon, int maxdecimaldigits, StringBuilder sb)
    Coordinates of a Polygon are an array of LinearRing coordinate arrays.

    Methods inherited from class org.h2gis.api.AbstractFunction

    addProperty, getProperty, removeProperty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.h2gis.api.Function

    getProperty
  • Constructor Details

    • ST_AsGeoJSON

      public ST_AsGeoJSON()
  • Method Details

    • getJavaStaticMethod

      public String getJavaStaticMethod()
    • toGeojson

      public static String toGeojson(org.locationtech.jts.geom.Geometry geom)
      Convert the geometry to a GeoJSON representation.
      Parameters:
      geom -
      Returns:
    • toGeojson

      public static String toGeojson(org.locationtech.jts.geom.Geometry geom, int maxdecimaldigits)
      Convert the geometry to a GeoJSON representation.
      Parameters:
      geom - input geometry
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      Returns:
    • toGeojsonGeometry

      public static void toGeojsonGeometry(org.locationtech.jts.geom.Geometry geom, int maxdecimaldigits, StringBuilder sb)
      Transform a JTS geometry to a GeoJSON representation.
      Parameters:
      geom - input geometry
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonPoint

      public static void toGeojsonPoint(org.locationtech.jts.geom.Point point, int maxdecimaldigits, StringBuilder sb)
      For type "Point", the "coordinates" member must be a single position. A position is the fundamental geometry construct. The "coordinates" member of a geometry object is composed of one position (in the case of a Point geometry), an array of positions (LineString or MultiPoint geometries), an array of arrays of positions (Polygons, MultiLineStrings), or a multidimensional array of positions (MultiPolygon). A position is represented by an array of numbers. There must be at least two elements, and may be more. The order of elements must follow x, y, z order (easting, northing, altitude for coordinates in a projected coordinate reference system, or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of additional elements are allowed -- interpretation and meaning of additional elements is beyond the scope of this specification. Syntax: { "type": "Point", "coordinates": [100.0, 0.0] }
      Parameters:
      point -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonMultiPoint

      public static void toGeojsonMultiPoint(org.locationtech.jts.geom.MultiPoint multiPoint, int maxdecimaldigits, StringBuilder sb)
      Coordinates of a MultiPoint are an array of positions. Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }
      Parameters:
      multiPoint -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonLineString

      public static void toGeojsonLineString(org.locationtech.jts.geom.LineString lineString, int maxdecimaldigits, StringBuilder sb)
      Coordinates of LineString are an array of positions. Syntax: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }
      Parameters:
      lineString -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonMultiLineString

      public static void toGeojsonMultiLineString(org.locationtech.jts.geom.MultiLineString multiLineString, int maxdecimaldigits, StringBuilder sb)
      Coordinates of a MultiLineString are an array of LineString coordinate arrays. Syntax: { "type": "MultiLineString", "coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] }
      Parameters:
      multiLineString -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonPolygon

      public static void toGeojsonPolygon(org.locationtech.jts.geom.Polygon polygon, int maxdecimaldigits, StringBuilder sb)
      Coordinates of a Polygon are an array of LinearRing coordinate arrays. The first element in the array represents the exterior ring. Any subsequent elements represent interior rings (or holes). Syntax: No holes: { "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ] ] } With holes: { "type": "Polygon", "coordinates": [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ], [ [100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2] ] ] }
      Parameters:
      polygon -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonMultiPolygon

      public static void toGeojsonMultiPolygon(org.locationtech.jts.geom.MultiPolygon multiPolygon, int maxdecimaldigits, StringBuilder sb)
      Coordinates of a MultiPolygon are an array of Polygon coordinate arrays. Syntax: { "type": "MultiPolygon", "coordinates": [ [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]] ] }
      Parameters:
      multiPolygon -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonGeometryCollection

      public static void toGeojsonGeometryCollection(org.locationtech.jts.geom.GeometryCollection geometryCollection, int maxdecimaldigits, StringBuilder sb)
      A GeoJSON object with type "GeometryCollection" is a geometry object which represents a collection of geometry objects. A geometry collection must have a member with the name "geometries". The value corresponding to "geometries"is an array. Each element in this array is a GeoJSON geometry object. Syntax: { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ] }
      Parameters:
      geometryCollection -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonCoordinates

      public static void toGeojsonCoordinates(org.locationtech.jts.geom.Coordinate[] coords, int maxdecimaldigits, StringBuilder sb)
      Convert a jts array of coordinates to a GeoJSON coordinates representation. Syntax: [[X1,Y1],[X2,Y2]]
      Parameters:
      coords -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeojsonCoordinate

      public static void toGeojsonCoordinate(org.locationtech.jts.geom.Coordinate coord, int maxdecimaldigits, StringBuilder sb)
      Convert a JTS coordinate to a GeoJSON representation. Only x, y and z values are supported. Syntax: [X,Y] or [X,Y,Z]
      Parameters:
      coord -
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      sb -
    • toGeoJsonEnvelope

      public String toGeoJsonEnvelope(org.locationtech.jts.geom.Envelope e, int maxdecimaldigits)
      Convert a JTS Envelope to a GeoJSON representation.
      Parameters:
      e - The envelope
      maxdecimaldigits - argument may be used to reduce the maximum number of decimal places
      Returns:
      The envelope encoded as GeoJSON