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 Constructor Description GJGeometryReader(org.locationtech.jts.geom.GeometryFactory GF)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetGeomType()org.locationtech.jts.geom.CoordinateparseCoordinate(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.GeometryparseGeometry(com.fasterxml.jackson.core.JsonParser jsParser)Parses a GeoJSON geometry and returns its JTS representation.org.locationtech.jts.geom.GeometryCollectionparseGeometryCollection(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.LineStringparseLinestring(com.fasterxml.jackson.core.JsonParser jp)Parse the array of positions.org.locationtech.jts.geom.MultiLineStringparseMultiLinestring(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.MultiPointparseMultiPoint(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.MultiPolygonparseMultiPolygon(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.PointparsePoint(com.fasterxml.jackson.core.JsonParser jp)Parses one position Syntax: { "type": "Point", "coordinates": [100.0, 0.0] }org.locationtech.jts.geom.PolygonparsePolygon(com.fasterxml.jackson.core.JsonParser jp)Coordinates of a Polygon are an array of LinearRing coordinate arrays.
-
-
-
Method Detail
-
parseGeometry
public org.locationtech.jts.geom.Geometry parseGeometry(com.fasterxml.jackson.core.JsonParser jsParser) throws IOException, SQLExceptionParses a GeoJSON geometry and returns its JTS representation. Syntax: "geometry":{"type": "Point", "coordinates": [102.0,0.5]}- Parameters:
jsParser-JsonParser- Returns:
- Geometry
- Throws:
IOExceptionSQLException
-
parsePoint
public org.locationtech.jts.geom.Point parsePoint(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionParses one position Syntax: { "type": "Point", "coordinates": [100.0, 0.0] }- Parameters:
jp-JsonParser- Returns:
- Point
- Throws:
IOExceptionSQLException
-
parseMultiPoint
public org.locationtech.jts.geom.MultiPoint parseMultiPoint(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionParses an array of positions Syntax: { "type": "MultiPoint", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }- Parameters:
jp-JsonParser- Returns:
- MultiPoint
- Throws:
IOExceptionSQLException
-
parseLinestring
public org.locationtech.jts.geom.LineString parseLinestring(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionParse the array of positions. Syntax: { "type": "LineString", "coordinates": [ [100.0, 0.0], [101.0, 1.0] ] }- Parameters:
jp-JsonParser- Throws:
IOExceptionSQLException
-
parseMultiLinestring
public org.locationtech.jts.geom.MultiLineString parseMultiLinestring(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionParses 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:
IOExceptionSQLException
-
parsePolygon
public org.locationtech.jts.geom.Polygon parsePolygon(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionCoordinates 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:
IOExceptionSQLException
-
parseMultiPolygon
public org.locationtech.jts.geom.MultiPolygon parseMultiPolygon(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionCoordinates 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:
IOExceptionSQLException
-
parseGeometryCollection
public org.locationtech.jts.geom.GeometryCollection parseGeometryCollection(com.fasterxml.jackson.core.JsonParser jp) throws IOException, SQLExceptionEach 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:
IOExceptionSQLException
-
parseCoordinates
public org.locationtech.jts.geom.Coordinate[] parseCoordinates(com.fasterxml.jackson.core.JsonParser jp) throws IOExceptionParses 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 IOExceptionParses 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
-
-