use of org.geotoolkit.internal.geojson.binding.GeoJSONGeometry.GeoJSONMultiPoint in project geotoolkit by Geomatys.
the class GeoJSONWriter method writeGeoJSONGeometry.
/**
* Write a GeoJSONGeometry
*
* @param jsonGeometry
* @throws IOException
*/
private void writeGeoJSONGeometry(GeoJSONGeometry jsonGeometry) throws IOException {
writer.writeStartObject();
writer.writeStringField(TYPE, jsonGeometry.getType());
if (jsonGeometry instanceof GeoJSONGeometryCollection) {
List<GeoJSONGeometry> geometries = ((GeoJSONGeometryCollection) jsonGeometry).getGeometries();
// "geometries" : [
writer.writeArrayFieldStart(GEOMETRIES);
for (GeoJSONGeometry geometry : geometries) {
writeGeoJSONGeometry(geometry);
}
// "]"
writer.writeEndArray();
} else {
// "coordinates" : [
writer.writeArrayFieldStart(COORDINATES);
if (jsonGeometry instanceof GeoJSONPoint) {
writeArray(((GeoJSONPoint) jsonGeometry).getCoordinates());
} else if (jsonGeometry instanceof GeoJSONLineString) {
writeArray(((GeoJSONLineString) jsonGeometry).getCoordinates());
} else if (jsonGeometry instanceof GeoJSONPolygon) {
writeArray(((GeoJSONPolygon) jsonGeometry).getCoordinates());
} else if (jsonGeometry instanceof GeoJSONMultiPoint) {
writeArray(((GeoJSONMultiPoint) jsonGeometry).getCoordinates());
} else if (jsonGeometry instanceof GeoJSONMultiLineString) {
writeArray(((GeoJSONMultiLineString) jsonGeometry).getCoordinates());
} else if (jsonGeometry instanceof GeoJSONMultiPolygon) {
writeArray(((GeoJSONMultiPolygon) jsonGeometry).getCoordinates());
} else {
throw new IllegalArgumentException("Unsupported geometry type : " + jsonGeometry);
}
// "]"
writer.writeEndArray();
}
writer.writeEndObject();
}
Aggregations