Class GeometryJSON
Point point = new Point(1,2); GeometryJSON g = new GeometryJSON(); g.writePoint(point, "point.json")); Point point2 = g.readPoint("point.json"); Geometry geometry = ...; g.write(geometry, new File("geometry.json")); geometry = g.read("geometry.json");
- Author:
- Justin Deoliveira, OpenGeo
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a geometry json instance.GeometryJSON
(int decimals) Constructs a geometry json instance specifying the number of decimals to use when encoding floating point numbers. -
Method Summary
Modifier and TypeMethodDescriptionboolean
isTrace()
Tracing flag.read
(InputStream input) Reads a Geometry instance from GeoJSON.Reads a Geometry instance from GeoJSON.Reads a GeometryCollection from GeoJSON.readGeometryCollection
(Object input) Reads a GeometryCollection from GeoJSON.readLine
(InputStream input) Reads a LineString from GeoJSON.Reads a LineString from GeoJSON.readMultiLine
(InputStream input) Reads a MultiLineString from GeoJSON.readMultiLine
(Object input) Reads a MultiLineString from GeoJSON.readMultiPoint
(InputStream input) Reads a MultiPoint from GeoJSON.readMultiPoint
(Object input) Reads a MultiPoint from GeoJSON.readMultiPolygon
(InputStream input) Reads a MultiPolygon from GeoJSON.readMultiPolygon
(Object input) Reads a MultiPolygon from GeoJSON.readPoint
(InputStream input) Reads a Point from GeoJSON.Reads a Point from GeoJSON.readPolygon
(InputStream input) Reads a Polygon from GeoJSON.readPolygon
(Object input) Reads a Polygon from GeoJSON.void
setTrace
(boolean trace) Sets trace flag.toString
(BoundingBox bbox) Writes an BoundingBox instance as GeoJSON returning the result as a string.Writes an Envelope instance as GeoJSON returning the result as a string.Writes a Geometry instance as GeoJSON returning the result as a string.void
write
(Geometry geometry, OutputStream output) Writes a Geometry instance as GeoJSON.void
Writes a Geometry instance as GeoJSON.void
writeGeometryCollection
(GeometryCollection gcol, OutputStream output) Writes a GeometryCollection as GeoJSON.void
writeGeometryCollection
(GeometryCollection gcol, Object output) Writes a GeometryCollection as GeoJSON.void
writeLine
(LineString line, OutputStream output) Writes a LineString as GeoJSON.void
writeLine
(LineString line, Object output) Writes a LineString as GeoJSON.void
writeMultiLine
(MultiLineString mline, OutputStream output) Writes a MultiLineString as GeoJSON.void
writeMultiLine
(MultiLineString mline, Object output) Writes a MultiLineString as GeoJSON.void
writeMultiPoint
(MultiPoint mpoint, OutputStream output) Writes a MultiPoint as GeoJSON.void
writeMultiPoint
(MultiPoint mpoint, Object output) Writes a MultiPoint as GeoJSON.void
writeMultiPolygon
(MultiPolygon mpoly, OutputStream output) Writes a MultiPolygon as GeoJSON.void
writeMultiPolygon
(MultiPolygon mpoly, Object output) Writes a MultiPolygon as GeoJSON.void
writePoint
(Point point, OutputStream output) Writes a Point as GeoJSON.void
writePoint
(Point point, Object output) Writes a Point as GeoJSON.void
writePolygon
(Polygon poly, OutputStream output) Writes a Polygon as GeoJSON.void
writePolygon
(Polygon poly, Object output) Writes a Polygon as GeoJSON.
-
Constructor Details
-
GeometryJSON
public GeometryJSON()Constructs a geometry json instance. -
GeometryJSON
public GeometryJSON(int decimals) Constructs a geometry json instance specifying the number of decimals to use when encoding floating point numbers.
-
-
Method Details
-
setTrace
public void setTrace(boolean trace) Sets trace flag. -
isTrace
public boolean isTrace()Tracing flag.When this flag is set parsed documents will be echoed to stdout during parsing.
-
write
Writes a Geometry instance as GeoJSON.- Parameters:
geometry
- The geometry.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
write
Writes a Geometry instance as GeoJSON.This method calls through to
write(Geometry, Object)
- Parameters:
geometry
- The geometry.output
- The output stream.- Throws:
IOException
-
toString
Writes a Geometry instance as GeoJSON returning the result as a string.- Parameters:
geometry
- The geometry.- Returns:
- The geometry encoded as GeoJSON
-
read
Reads a Geometry instance from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The geometry instance.
- Throws:
IOException
-
read
Reads a Geometry instance from GeoJSON.This method calls through to
read(Object)
- Parameters:
input
- The input stream.- Returns:
- The geometry instance.
- Throws:
IOException
-
writePoint
Writes a Point as GeoJSON.- Parameters:
point
- The point.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writePoint
Writes a Point as GeoJSON.This method calls through to
writePoint(Point, Object)
- Parameters:
point
- The point.output
- The output stream.- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readPoint
Reads a Point from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The point.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readPoint
Reads a Point from GeoJSON.This method calls through to
readPoint(Object)
- Parameters:
input
- The input stream.- Returns:
- The point.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writeLine
Writes a LineString as GeoJSON.- Parameters:
line
- The line string.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writeLine
Writes a LineString as GeoJSON.This method calls through to
writeLine(LineString, Object)
- Parameters:
line
- The line string.output
- The output stream.- Throws:
IOException
-
readLine
Reads a LineString from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The line string.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readLine
Reads a LineString from GeoJSON.This method calls through to
readLine(Object)
- Parameters:
input
- The input stream.- Returns:
- The line string.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writePolygon
Writes a Polygon as GeoJSON.- Parameters:
poly
- The polygon.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writePolygon
Writes a Polygon as GeoJSON.This method calls through to
writePolygon(Polygon, Object)
- Parameters:
poly
- The polygon.output
- The output stream.- Throws:
IOException
-
readPolygon
Reads a Polygon from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The polygon.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readPolygon
Reads a Polygon from GeoJSON.This method calls through to
readPolygon(Object)
- Parameters:
input
- The input stream.- Returns:
- The polygon.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writeMultiPoint
Writes a MultiPoint as GeoJSON.- Parameters:
mpoint
- The multi point.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writeMultiPoint
Writes a MultiPoint as GeoJSON.This method calls through to
writeMultiPoint(MultiPoint, Object)
- Parameters:
mpoint
- The multi point.output
- The output stream.- Throws:
IOException
-
readMultiPoint
Reads a MultiPoint from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The multi point.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readMultiPoint
Reads a MultiPoint from GeoJSON.This method calls through to
readMultiPoint(Object)
- Parameters:
input
- The input stream.- Returns:
- The multi point.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writeMultiLine
Writes a MultiLineString as GeoJSON.- Parameters:
mline
- The multi line string.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writeMultiLine
Writes a MultiLineString as GeoJSON.This method calls through to
writeMultiLine(MultiLineString, Object)
- Parameters:
mline
- The multi line string.output
- The output stream.- Throws:
IOException
-
readMultiLine
Reads a MultiLineString from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The multi line string.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readMultiLine
Reads a MultiLineString from GeoJSON.This method calls through to
readMultiLine(Object)
- Parameters:
input
- The input stream.- Returns:
- The multi line string.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writeMultiPolygon
Writes a MultiPolygon as GeoJSON.- Parameters:
mpoly
- The multi polygon.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writeMultiPolygon
Writes a MultiPolygon as GeoJSON.This method calls through to
writeMultiPolygon(MultiPolygon, Object)
- Parameters:
mpoly
- The multi polygon.output
- The output stream.- Throws:
IOException
-
readMultiPolygon
Reads a MultiPolygon from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The multi polygon.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readMultiPolygon
Reads a MultiPolygon from GeoJSON.This method calls through to
readMultiPolygon(Object)
- Parameters:
input
- The input stream.- Returns:
- The multi polygon.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
writeGeometryCollection
Writes a GeometryCollection as GeoJSON.- Parameters:
gcol
- The geometry collection.output
- The output. SeeGeoJSONUtil.toWriter(Object)
for details.- Throws:
IOException
-
writeGeometryCollection
public void writeGeometryCollection(GeometryCollection gcol, OutputStream output) throws IOException Writes a GeometryCollection as GeoJSON.This method calls through to
writeGeometryCollection(GeometryCollection, Object)
- Parameters:
gcol
- The geometry collection.output
- The output stream.- Throws:
IOException
-
readGeometryCollection
Reads a GeometryCollection from GeoJSON.- Parameters:
input
- The input. SeeGeoJSONUtil.toReader(Object)
for details.- Returns:
- The geometry collection.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
readGeometryCollection
Reads a GeometryCollection from GeoJSON.This method calls through to
readGeometryCollection(Object)
- Parameters:
input
- The input stream.- Returns:
- The geometry collection.
- Throws:
IOException
- In the event of a parsing error or if the input json is invalid.
-
toString
Writes an BoundingBox instance as GeoJSON returning the result as a string.- Parameters:
bbox
- The bounding box.- Returns:
- The bounding box encoded as GeoJSON
-
toString
Writes an Envelope instance as GeoJSON returning the result as a string.- Parameters:
e
- The envelope- Returns:
- The envelope encoded as GeoJSON
-