Package com.massifmaps.geometry
Class GeoJSONGeometryWriter
java.lang.Object
com.massifmaps.geometry.GeoJSONGeometryWriter
A GeoJSON writer. Generates human-readable GeoJSON representation of the geometry, feature or feature collection.
Supports both 2D and 3D coordinate serialization.
Supports both 2D and 3D coordinate serialization.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new GeoJSONGeometryWriter object with default settings. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current source projection.booleangetZ()Returns the state of Z coordinate serialization.voidSets the current source projection.voidsetZ(boolean z) Sets the state of Z coordinate serialization.writeFeature(Feature feature) Creates a GeoJSON string corresponding to the specified feature.writeFeatureCollection(FeatureCollection featureCollection) Creates a GeoJSON string corresponding to the specified feature collection.writeGeometry(Geometry geometry) Creates a GeoJSON string corresponding to the specified geometry.
-
Constructor Details
-
GeoJSONGeometryWriter
public GeoJSONGeometryWriter()Constructs a new GeoJSONGeometryWriter object with default settings.
-
-
Method Details
-
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.
-
setSourceProjection
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.
-
getZ
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.
-
setZ
public void setZ(boolean z) Sets the state of Z coordinate serialization.- Parameters:
z- True when Z coordinate should be serialized, false otherwise.
-
writeGeometry
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.
-
writeFeature
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.
-
writeFeatureCollection
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.
-