public class GeometryJSON extends Object
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");
Constructor and Description |
---|
GeometryJSON()
Constructs a geometry json instance.
|
GeometryJSON(int decimals)
Constructs a geometry json instance specifying the number of decimals to use when encoding
floating point numbers.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isTrace()
Tracing flag.
|
Geometry |
read(InputStream input)
Reads a Geometry instance from GeoJSON.
|
Geometry |
read(Object input)
Reads a Geometry instance from GeoJSON.
|
GeometryCollection |
readGeometryCollection(InputStream input)
Reads a GeometryCollection from GeoJSON.
|
GeometryCollection |
readGeometryCollection(Object input)
Reads a GeometryCollection from GeoJSON.
|
LineString |
readLine(InputStream input)
Reads a LineString from GeoJSON.
|
LineString |
readLine(Object input)
Reads a LineString from GeoJSON.
|
MultiLineString |
readMultiLine(InputStream input)
Reads a MultiLineString from GeoJSON.
|
MultiLineString |
readMultiLine(Object input)
Reads a MultiLineString from GeoJSON.
|
MultiPoint |
readMultiPoint(InputStream input)
Reads a MultiPoint from GeoJSON.
|
MultiPoint |
readMultiPoint(Object input)
Reads a MultiPoint from GeoJSON.
|
MultiPolygon |
readMultiPolygon(InputStream input)
Reads a MultiPolygon from GeoJSON.
|
MultiPolygon |
readMultiPolygon(Object input)
Reads a MultiPolygon from GeoJSON.
|
Point |
readPoint(InputStream input)
Reads a Point from GeoJSON.
|
Point |
readPoint(Object input)
Reads a Point from GeoJSON.
|
Polygon |
readPolygon(InputStream input)
Reads a Polygon from GeoJSON.
|
Polygon |
readPolygon(Object input)
Reads a Polygon from GeoJSON.
|
void |
setTrace(boolean trace)
Sets trace flag.
|
String |
toString(BoundingBox bbox)
Writes an BoundingBox instance as GeoJSON returning the result as a string.
|
String |
toString(Envelope e)
Writes an Envelope instance as GeoJSON returning the result as a string.
|
String |
toString(Geometry geometry)
Writes a Geometry instance as GeoJSON returning the result as a string.
|
void |
write(Geometry geometry,
Object output)
Writes a Geometry instance as GeoJSON.
|
void |
write(Geometry geometry,
OutputStream output)
Writes a Geometry instance as GeoJSON.
|
void |
writeGeometryCollection(GeometryCollection gcol,
Object output)
Writes a GeometryCollection as GeoJSON.
|
void |
writeGeometryCollection(GeometryCollection gcol,
OutputStream output)
Writes a GeometryCollection as GeoJSON.
|
void |
writeLine(LineString line,
Object output)
Writes a LineString as GeoJSON.
|
void |
writeLine(LineString line,
OutputStream output)
Writes a LineString as GeoJSON.
|
void |
writeMultiLine(MultiLineString mline,
Object output)
Writes a MultiLineString as GeoJSON.
|
void |
writeMultiLine(MultiLineString mline,
OutputStream output)
Writes a MultiLineString as GeoJSON.
|
void |
writeMultiPoint(MultiPoint mpoint,
Object output)
Writes a MultiPoint as GeoJSON.
|
void |
writeMultiPoint(MultiPoint mpoint,
OutputStream output)
Writes a MultiPoint as GeoJSON.
|
void |
writeMultiPolygon(MultiPolygon mpoly,
Object output)
Writes a MultiPolygon as GeoJSON.
|
void |
writeMultiPolygon(MultiPolygon mpoly,
OutputStream output)
Writes a MultiPolygon as GeoJSON.
|
void |
writePoint(Point point,
Object output)
Writes a Point as GeoJSON.
|
void |
writePoint(Point point,
OutputStream output)
Writes a Point as GeoJSON.
|
void |
writePolygon(Polygon poly,
Object output)
Writes a Polygon as GeoJSON.
|
void |
writePolygon(Polygon poly,
OutputStream output)
Writes a Polygon as GeoJSON.
|
public GeometryJSON()
public GeometryJSON(int decimals)
public void setTrace(boolean trace)
public boolean isTrace()
When this flag is set parsed documents will be echoed to stdout during parsing.
public void write(Geometry geometry, Object output) throws IOException
geometry
- The geometry.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void write(Geometry geometry, OutputStream output) throws IOException
This method calls through to write(Geometry, Object)
geometry
- The geometry.output
- The output stream.IOException
public String toString(Geometry geometry)
geometry
- The geometry.public Geometry read(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
public Geometry read(InputStream input) throws IOException
This method calls through to read(Object)
input
- The input stream.IOException
public void writePoint(Point point, Object output) throws IOException
point
- The point.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public void writePoint(Point point, OutputStream output) throws IOException
This method calls through to writePoint(Point, Object)
point
- The point.output
- The output stream.IOException
- In the event of a parsing error or if the input json is invalid.public Point readPoint(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public Point readPoint(InputStream input) throws IOException
This method calls through to readPoint(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeLine(LineString line, Object output) throws IOException
line
- The line string.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeLine(LineString line, OutputStream output) throws IOException
This method calls through to writeLine(LineString, Object)
line
- The line string.output
- The output stream.IOException
public LineString readLine(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public LineString readLine(InputStream input) throws IOException
This method calls through to readLine(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writePolygon(Polygon poly, Object output) throws IOException
poly
- The polygon.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writePolygon(Polygon poly, OutputStream output) throws IOException
This method calls through to writePolygon(Polygon, Object)
poly
- The polygon.output
- The output stream.IOException
public Polygon readPolygon(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public Polygon readPolygon(InputStream input) throws IOException
This method calls through to readPolygon(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeMultiPoint(MultiPoint mpoint, Object output) throws IOException
mpoint
- The multi point.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeMultiPoint(MultiPoint mpoint, OutputStream output) throws IOException
This method calls through to writeMultiPoint(MultiPoint, Object)
mpoint
- The multi point.output
- The output stream.IOException
public MultiPoint readMultiPoint(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public MultiPoint readMultiPoint(InputStream input) throws IOException
This method calls through to readMultiPoint(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeMultiLine(MultiLineString mline, Object output) throws IOException
mline
- The multi line string.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeMultiLine(MultiLineString mline, OutputStream output) throws IOException
This method calls through to writeMultiLine(MultiLineString, Object)
mline
- The multi line string.output
- The output stream.IOException
public MultiLineString readMultiLine(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public MultiLineString readMultiLine(InputStream input) throws IOException
This method calls through to readMultiLine(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeMultiPolygon(MultiPolygon mpoly, Object output) throws IOException
mpoly
- The multi polygon.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeMultiPolygon(MultiPolygon mpoly, OutputStream output) throws IOException
This method calls through to writeMultiPolygon(MultiPolygon, Object)
mpoly
- The multi polygon.output
- The output stream.IOException
public MultiPolygon readMultiPolygon(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public MultiPolygon readMultiPolygon(InputStream input) throws IOException
This method calls through to readMultiPolygon(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeGeometryCollection(GeometryCollection gcol, Object output) throws IOException
gcol
- The geometry collection.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeGeometryCollection(GeometryCollection gcol, OutputStream output) throws IOException
This method calls through to writeGeometryCollection(GeometryCollection, Object)
gcol
- The geometry collection.output
- The output stream.IOException
public GeometryCollection readGeometryCollection(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public GeometryCollection readGeometryCollection(InputStream input) throws IOException
This method calls through to readGeometryCollection(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public String toString(BoundingBox bbox)
bbox
- The bounding box.public String toString(Envelope e)
e
- The envelopeCopyright © 1996–2019 Geotools. All rights reserved.