org.h2gis.functions.io.geojson

## 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.ScalarFunction

`PROP_DETERMINISTIC, PROP_NOBUFFER`

### Fields inherited from interface org.h2gis.api.Function

`PROP_NAME, PROP_REMARKS`

### Constructor Summary

Constructors
Constructor and Description
`ST_AsGeoJSON()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`String` `getJavaStaticMethod()`
`static String` `toGeojson(com.vividsolutions.jts.geom.Geometry geom)` Convert the geometry to a GeoJSON representation.
`static void` `toGeojsonCoordinate(com.vividsolutions.jts.geom.Coordinate coord, StringBuilder sb)` Convert a JTS coordinate to a GeoJSON representation.
`static void` `toGeojsonCoordinates(com.vividsolutions.jts.geom.Coordinate[] coords, StringBuilder sb)` Convert a jts array of coordinates to a GeoJSON coordinates representation.
`String` `toGeoJsonEnvelope(com.vividsolutions.jts.geom.Envelope e)` Convert a JTS Envelope to a GeoJSON representation.
`static void` `toGeojsonGeometry(com.vividsolutions.jts.geom.Geometry geom, StringBuilder sb)` Transform a JTS geometry to a GeoJSON representation.
`static void` `toGeojsonGeometryCollection(com.vividsolutions.jts.geom.GeometryCollection geometryCollection, StringBuilder sb)` A GeoJSON object with type "GeometryCollection" is a geometry object which represents a collection of geometry objects.
`static void` `toGeojsonLineString(com.vividsolutions.jts.geom.LineString lineString, StringBuilder sb)` Coordinates of LineString are an array of positions.
`static void` `toGeojsonMultiLineString(com.vividsolutions.jts.geom.MultiLineString multiLineString, StringBuilder sb)` Coordinates of a MultiLineString are an array of LineString coordinate arrays.
`static void` `toGeojsonMultiPoint(com.vividsolutions.jts.geom.MultiPoint multiPoint, StringBuilder sb)` Coordinates of a MultiPoint are an array of positions.
`static void` `toGeojsonMultiPolygon(com.vividsolutions.jts.geom.MultiPolygon multiPolygon, StringBuilder sb)` Coordinates of a MultiPolygon are an array of Polygon coordinate arrays.
`static void` `toGeojsonPoint(com.vividsolutions.jts.geom.Point point, StringBuilder sb)` For type "Point", the "coordinates" member must be a single position.
`static void` `toGeojsonPolygon(com.vividsolutions.jts.geom.Polygon polygon, 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 Detail

#### ST_AsGeoJSON

    public ST_AsGeoJSON()

### Method Detail

#### getJavaStaticMethod

    public String getJavaStaticMethod()

#### toGeojson

    public static String toGeojson(com.vividsolutions.jts.geom.Geometry geom)

Convert the geometry to a GeoJSON representation.

Parameters:
  `geom` -
Returns:

#### toGeojsonGeometry

    public static void toGeojsonGeometry(com.vividsolutions.jts.geom.Geometry geom,
                                         StringBuilder sb)

Transform a JTS geometry to a GeoJSON representation.

Parameters:
  `geom` -
  `sb` -

#### toGeojsonPoint

    public static void toGeojsonPoint(com.vividsolutions.jts.geom.Point point,
                                      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` -
  `sb` -

#### toGeojsonMultiPoint

    public static void toGeojsonMultiPoint(com.vividsolutions.jts.geom.MultiPoint multiPoint,
                                           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` -
  `sb` -

#### toGeojsonLineString

    public static void toGeojsonLineString(com.vividsolutions.jts.geom.LineString lineString,
                                           StringBuilder sb)

Coordinates of LineString are an array of positions. Syntax: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

Parameters:
  `lineString` -
  `sb` -

#### toGeojsonMultiLineString

    public static void toGeojsonMultiLineString(com.vividsolutions.jts.geom.MultiLineString multiLineString,
                                                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` -
  `sb` -

#### toGeojsonPolygon

    public static void toGeojsonPolygon(com.vividsolutions.jts.geom.Polygon polygon,
                                        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` -
  `sb` -

#### toGeojsonMultiPolygon

    public static void toGeojsonMultiPolygon(com.vividsolutions.jts.geom.MultiPolygon multiPolygon,
                                             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` -
  `sb` -

#### toGeojsonGeometryCollection

    public static void toGeojsonGeometryCollection(com.vividsolutions.jts.geom.GeometryCollection geometryCollection,
                                                   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` -
  `sb` -

#### toGeojsonCoordinates

    public static void toGeojsonCoordinates(com.vividsolutions.jts.geom.Coordinate[] coords,
                                            StringBuilder sb)

Convert a jts array of coordinates to a GeoJSON coordinates representation. Syntax: [[X1,Y1],[X2,Y2]]

Parameters:
  `coords` -
  `sb` -

#### toGeojsonCoordinate

    public static void toGeojsonCoordinate(com.vividsolutions.jts.geom.Coordinate coord,
                                           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` -
  `sb` -

#### toGeoJsonEnvelope

    public String toGeoJsonEnvelope(com.vividsolutions.jts.geom.Envelope e)

Convert a JTS Envelope to a GeoJSON representation.

Parameters:
  `e` - The envelope
Returns:
  The envelope encoded as GeoJSON