Package org.h2gis.functions.io.geojson

## Class GJGeometryReader

- java.lang.Object
- - org.h2gis.functions.io.geojson.GJGeometryReader

    public class GJGeometryReader
    extends Object

This class is used to convert a geojon geometry to a JTS geometry.

Author:
  Erwan Bocher

### Constructor Summary

Constructors
`GJGeometryReader​(org.locationtech.jts.geom.GeometryFactory GF)`

### Method Summary

All Methods Instance Methods Concrete Methods
`String` `getGeomType()`
`org.locationtech.jts.geom.Coordinate` `parseCoordinate​(com.fasterxml.jackson.core.JsonParser jp)` Parses a GeoJSON coordinate array and returns a JTS coordinate.
`org.locationtech.jts.geom.Coordinate[]` `parseCoordinates​(com.fasterxml.jackson.core.JsonParser jp)` Parses a sequence of coordinates array expressed as [ [100.0, 0.0], [101.0, 1.0] ]
`org.locationtech.jts.geom.Geometry` `parseGeometry​(com.fasterxml.jackson.core.JsonParser jsParser)` Parses a GeoJSON geometry and returns its JTS representation.
`org.locationtech.jts.geom.GeometryCollection` `parseGeometryCollection​(com.fasterxml.jackson.core.JsonParser jp)` Each element in the geometries array of a GeometryCollection is one of the geometry objects described above: { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ]}
`org.locationtech.jts.geom.LineString` `parseLinestring​(com.fasterxml.jackson.core.JsonParser jp)` Parse the array of positions.
`org.locationtech.jts.geom.MultiLineString` `parseMultiLinestring​(com.fasterxml.jackson.core.JsonParser jp)` Parses an array of positions defined as: { "type": "MultiLineString", "coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] }
`org.locationtech.jts.geom.MultiPoint` `parseMultiPoint​(com.fasterxml.jackson.core.JsonParser jp)` Parses an array of positions Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

`org.locationtech.jts.geom.MultiPolygon`

`parseMultiPolygon​(com.fasterxml.jackson.core.JsonParser jp)`

Coordinates of a MultiPolygon are an array of Polygon coordinate arrays: { "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]]] ] }

`org.locationtech.jts.geom.Point` `parsePoint​(com.fasterxml.jackson.core.JsonParser jp)` Parses one position Syntax: { "type": "Point", "coordinates": [100.0, 0.0] }
`org.locationtech.jts.geom.Polygon` `parsePolygon​(com.fasterxml.jackson.core.JsonParser jp)` Coordinates of a Polygon are an array of LinearRing coordinate arrays.

### Methods inherited from class java.lang.Object

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

### Constructor Detail

#### GJGeometryReader

    public GJGeometryReader​(org.locationtech.jts.geom.GeometryFactory GF)

### Method Detail

#### parseGeometry

    public org.locationtech.jts.geom.Geometry parseGeometry​(com.fasterxml.jackson.core.JsonParser jsParser)
                                                     throws IOException,
                                                            SQLException

Parses a GeoJSON geometry and returns its JTS representation. Syntax: "geometry":{"type": "Point", "coordinates": [102.0,0.5]}

Parameters:
  `jsParser` - `JsonParser`
Returns:
  Geometry
Throws:
  `IOException`
  `SQLException`

#### parsePoint

    public org.locationtech.jts.geom.Point parsePoint​(com.fasterxml.jackson.core.JsonParser jp)
                                               throws IOException,
                                                      SQLException

Parses one position Syntax: { "type": "Point", "coordinates": [100.0, 0.0] }

Parameters:
  `jp` - `JsonParser`
Returns:
  Point
Throws:
  `IOException`
  `SQLException`

#### parseMultiPoint

    public org.locationtech.jts.geom.MultiPoint parseMultiPoint​(com.fasterxml.jackson.core.JsonParser jp)
                                                         throws IOException,
                                                                SQLException

Parses an array of positions Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

Parameters:
  `jp` - `JsonParser`
Returns:
  MultiPoint
Throws:
  `IOException`
  `SQLException`

#### parseLinestring

    public org.locationtech.jts.geom.LineString parseLinestring​(com.fasterxml.jackson.core.JsonParser jp)
                                                         throws IOException,
                                                                SQLException

Parse the array of positions. Syntax: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }

Parameters:
  `jp` - `JsonParser`
Throws:
  `IOException`
  `SQLException`

#### parseMultiLinestring

    public org.locationtech.jts.geom.MultiLineString parseMultiLinestring​(com.fasterxml.jackson.core.JsonParser jp)
                                                                   throws IOException,
                                                                          SQLException

Parses an array of positions defined as: { "type": "MultiLineString", "coordinates": [ [ [100.0, 0.0], [101.0, 1.0] ], [ [102.0, 2.0], [103.0, 3.0] ] ] }

Parameters:
  `jp` - `JsonParser`
Returns:
  MultiLineString
Throws:
  `IOException`
  `SQLException`

#### parsePolygon

    public org.locationtech.jts.geom.Polygon parsePolygon​(com.fasterxml.jackson.core.JsonParser jp)
                                                   throws IOException,
                                                          SQLException

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:
  `jp` - `JsonParser`
Returns:
  Polygon
Throws:
  `IOException`
  `SQLException`

#### parseMultiPolygon

    public org.locationtech.jts.geom.MultiPolygon parseMultiPolygon​(com.fasterxml.jackson.core.JsonParser jp)
                                                             throws IOException,
                                                                    SQLException

Coordinates of a MultiPolygon are an array of Polygon coordinate arrays: { "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:
  `jp` - `JsonParser`
Returns:
  MultiPolygon
Throws:
  `IOException`
  `SQLException`

#### parseGeometryCollection

    public org.locationtech.jts.geom.GeometryCollection parseGeometryCollection​(com.fasterxml.jackson.core.JsonParser jp)
                                                                         throws IOException,
                                                                                SQLException

Each element in the geometries array of a GeometryCollection is one of the geometry objects described above: { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [100.0, 0.0] }, { "type": "LineString", "coordinates": [ [101.0, 0.0], [102.0, 1.0] ] } ]}

Parameters:
  `jp` - `JsonParser`
Returns:
  GeometryCollection
Throws:
  `IOException`
  `SQLException`

#### parseCoordinates

    public org.locationtech.jts.geom.Coordinate[] parseCoordinates​(com.fasterxml.jackson.core.JsonParser jp)
                                                            throws IOException

Parses a sequence of coordinates array expressed as [ [100.0, 0.0], [101.0, 1.0] ]

Parameters:
  `jp` - `JsonParser`
Returns:
  Coordinate[]
Throws:
  `IOException`

#### parseCoordinate

    public org.locationtech.jts.geom.Coordinate parseCoordinate​(com.fasterxml.jackson.core.JsonParser jp)
                                                         throws IOException

Parses a GeoJSON coordinate array and returns a JTS coordinate. The first token corresponds to the first X value. The last token correponds to the end of the coordinate array "]". Parsed syntax: 100.0, 0.0]

Parameters:
  `jp` - `JsonParser`
Returns:
  Coordinate
Throws:
  `IOException`

#### getGeomType

    public String getGeomType()

Returns:
  GeoJSON geometry type