Package org.locationtech.spatial4j.io
Class GeoJSONWriter
- java.lang.Object
-
- org.locationtech.spatial4j.io.GeoJSONWriter
-
- All Implemented Interfaces:
ShapeIO
,ShapeWriter
- Direct Known Subclasses:
JtsGeoJSONWriter
public class GeoJSONWriter extends java.lang.Object implements ShapeWriter
-
-
Constructor Summary
Constructors Constructor Description GeoJSONWriter(SpatialContext ctx, SpatialContextFactory factory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getFormatName()
java.lang.String
toString(Shape shape)
Write a shape to Stringprotected void
write(java.io.Writer output, java.text.NumberFormat nf, double... coords)
void
write(java.io.Writer output, Shape shape)
Write a shape to the output writer(package private) void
writeDistance(java.io.Writer output, java.text.NumberFormat nf, double dist, boolean isGeo, java.lang.String distProperty, java.lang.String distUnitsProperty)
Helper method to encode a distance property (with optional unit).
-
-
-
Constructor Detail
-
GeoJSONWriter
public GeoJSONWriter(SpatialContext ctx, SpatialContextFactory factory)
-
-
Method Detail
-
getFormatName
public java.lang.String getFormatName()
- Specified by:
getFormatName
in interfaceShapeIO
- Returns:
- the format name
-
write
protected void write(java.io.Writer output, java.text.NumberFormat nf, double... coords) throws java.io.IOException
- Throws:
java.io.IOException
-
write
public void write(java.io.Writer output, Shape shape) throws java.io.IOException
Description copied from interface:ShapeWriter
Write a shape to the output writer- Specified by:
write
in interfaceShapeWriter
- Throws:
java.io.IOException
-
writeDistance
void writeDistance(java.io.Writer output, java.text.NumberFormat nf, double dist, boolean isGeo, java.lang.String distProperty, java.lang.String distUnitsProperty) throws java.io.IOException
Helper method to encode a distance property (with optional unit).The distance unit is only encoded when isGeo is true, and it is converted to km.
The distance unit is encoded within a properties object.
- Parameters:
output
- The writer.nf
- The number format.dist
- The distance value to encode.isGeo
- The flag determiningdistProperty
- The distance property name.distUnitsProperty
- The distance unit property name.- Throws:
java.io.IOException
-
toString
public java.lang.String toString(Shape shape)
Description copied from interface:ShapeWriter
Write a shape to String- Specified by:
toString
in interfaceShapeWriter
-
-