public class

GeoJSONGeometryWriter

extends Object
java.lang.Object
   ↳ com.carto.geometry.GeoJSONGeometryWriter

Class Overview

A GeoJSON writer. Generates human-readable GeoJSON representation of the geometry, feature or feature collection.
Supports both 2D and 3D coordinate serialization.

Summary

Public Constructors
GeoJSONGeometryWriter()
Constructs a new GeoJSONGeometryWriter object with default settings.
Public Methods
synchronized void delete()
Projection getSourceProjection()
Returns the current source projection.
boolean getZ()
Returns the state of Z coordinate serialization.
void setSourceProjection(Projection proj)
Sets the current source projection.
void setZ(boolean z)
Sets the state of Z coordinate serialization.
String writeFeature(Feature feature)
Creates a GeoJSON string corresponding to the specified feature.
String writeFeatureCollection(FeatureCollection featureCollection)
Creates a GeoJSON string corresponding to the specified feature collection.
String writeGeometry(Geometry geometry)
Creates a GeoJSON string corresponding to the specified geometry.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GeoJSONGeometryWriter ()

Constructs a new GeoJSONGeometryWriter object with default settings.

Public Methods

public synchronized void delete ()

public Projection getSourceProjection ()

Returns the current source projection. If source projection is set, all geometry
coordinates will be converted from given coordinate system to WGS84.

Returns
  • The current source projection or null.

public boolean getZ ()

Returns the state of Z coordinate serialization.

Returns
  • True if Z coordinate is stored in GeoJSON output, false otherwise. The default is false.

public void setSourceProjection (Projection proj)

Sets the current source projection. If source projection is set, all geometry
coordinates will be converted from given coordinate system to WGS84.

Parameters
proj The new source projection or null.

public void setZ (boolean z)

Sets the state of Z coordinate serialization.

Parameters
z True when Z coordinate should be serialized, false otherwise.

public String writeFeature (Feature feature)

Creates a GeoJSON string corresponding to the specified feature.

Parameters
feature The feature to write.
Returns
  • The corresponding GeoJSON string.
Throws
Exception If string could not be generated.

public String writeFeatureCollection (FeatureCollection featureCollection)

Creates a GeoJSON string corresponding to the specified feature collection.

Parameters
featureCollection The feature collection to write.
Returns
  • The corresponding GeoJSON string.
Throws
Exception If string could not be generated.

public String writeGeometry (Geometry geometry)

Creates a GeoJSON string corresponding to the specified geometry.

Parameters
geometry The geometry to write.
Returns
  • The corresponding GeoJSON string.
Throws
Exception If string could not be generated.