public class GeoJsonWriter
extends java.lang.Object
Geometry
s as JSON fragments in GeoJson format.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EPSG_PREFIX |
private boolean |
isEncodeCRS |
private double |
scale |
Constructor and Description |
---|
GeoJsonWriter()
Constructs a GeoJsonWriter instance.
|
GeoJsonWriter(int decimals)
Constructs a GeoJsonWriter instance specifying the number of decimals to
use when encoding floating point numbers.
|
Modifier and Type | Method and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
create(Geometry geometry,
boolean encodeCRS) |
private java.util.Map<java.lang.String,java.lang.Object> |
createCRS(int srid) |
private java.lang.String |
formatOrdinate(double x) |
private java.lang.String |
getJsonString(CoordinateSequence coordinateSequence) |
private java.util.List<java.lang.Object> |
makeJsonAware(GeometryCollection geometryCollection) |
private java.util.List<org.json.simple.JSONAware> |
makeJsonAware(Polygon poly) |
void |
setEncodeCRS(boolean isEncodeCRS) |
java.lang.String |
write(Geometry geometry)
Writes a
Geometry in GeoJson format to a String. |
void |
write(Geometry geometry,
java.io.Writer writer)
Writes a
Geometry in GeoJson format into a Writer . |
public static final java.lang.String EPSG_PREFIX
private double scale
private boolean isEncodeCRS
public GeoJsonWriter()
public GeoJsonWriter(int decimals)
public void setEncodeCRS(boolean isEncodeCRS)
public java.lang.String write(Geometry geometry)
Geometry
in GeoJson format to a String.geometry
- public void write(Geometry geometry, java.io.Writer writer) throws java.io.IOException
Geometry
in GeoJson format into a Writer
.geometry
- Geometry to encodewriter
- Stream to encode to.java.io.IOException
- throws an IOException when unable to write the JSON stringprivate java.util.Map<java.lang.String,java.lang.Object> create(Geometry geometry, boolean encodeCRS)
private java.util.Map<java.lang.String,java.lang.Object> createCRS(int srid)
private java.util.List<org.json.simple.JSONAware> makeJsonAware(Polygon poly)
private java.util.List<java.lang.Object> makeJsonAware(GeometryCollection geometryCollection)
private java.lang.String getJsonString(CoordinateSequence coordinateSequence)
private java.lang.String formatOrdinate(double x)