Class GeoJsonWriter

java.lang.Object
org.locationtech.jts.io.geojson.GeoJsonWriter

public class GeoJsonWriter extends Object
Writes Geometrys as JSON fragments in GeoJson format.
  • Field Details

    • EPSG_PREFIX

      public static final String EPSG_PREFIX
      See Also:
    • scale

      private double scale
    • isEncodeCRS

      private boolean isEncodeCRS
  • Constructor Details

    • GeoJsonWriter

      public GeoJsonWriter()
      Constructs a GeoJsonWriter instance.
    • GeoJsonWriter

      public GeoJsonWriter(int decimals)
      Constructs a GeoJsonWriter instance specifying the number of decimals to use when encoding floating point numbers.
  • Method Details

    • setEncodeCRS

      public void setEncodeCRS(boolean isEncodeCRS)
    • write

      public String write(Geometry geometry)
      Writes a Geometry in GeoJson format to a String.
      Parameters:
      geometry -
      Returns:
      String GeoJson Encoded Geometry
    • write

      public void write(Geometry geometry, Writer writer) throws IOException
      Writes a Geometry in GeoJson format into a Writer.
      Parameters:
      geometry - Geometry to encode
      writer - Stream to encode to.
      Throws:
      IOException - throws an IOException when unable to write the JSON string
    • create

      private Map<String,Object> create(Geometry geometry, boolean encodeCRS)
    • createCRS

      private Map<String,Object> createCRS(int srid)
    • makeJsonAware

      private List<org.json.simple.JSONAware> makeJsonAware(Polygon poly)
    • makeJsonAware

      private List<Object> makeJsonAware(GeometryCollection geometryCollection)
    • getJsonString

      private String getJsonString(CoordinateSequence coordinateSequence)
    • formatOrdinate

      private String formatOrdinate(double x)