Package org.openstreetmap.josm.io
Class GeoJSONWriter
- java.lang.Object
-
- org.openstreetmap.josm.io.GeoJSONWriter
-
public class GeoJSONWriter extends Object
Writes OSM data as a GeoJSON string, using JSR 353: Java API for JSON Processing (JSON-P).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
GeoJSONWriter.GeometryPrimitiveVisitor
-
Field Summary
Fields Modifier and Type Field Description private DataSet
data
(package private) static String
JSON_VALUE_END_MARKER
This is used to determine that a tag should be interpreted as a json object or array.(package private) static String
JSON_VALUE_START_MARKER
This is used to determine that a tag should be interpreted as a json object or array.private static Set<Way>
processedMultipolygonWays
private Projection
projection
private static BooleanProperty
SKIP_EMPTY_NODES
private static BooleanProperty
UNTAGGED_CLOSED_IS_POLYGON
-
Constructor Summary
Constructors Constructor Description GeoJSONWriter(DataSet ds)
Constructs a newGeoJSONWriter
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
appendBounds(Bounds b, javax.json.JsonObjectBuilder object)
protected void
appendLayerBounds(DataSet ds, javax.json.JsonObjectBuilder object)
protected void
appendLayerFeatures(DataSet ds, javax.json.JsonObjectBuilder object)
protected void
appendPrimitive(OsmPrimitive p, javax.json.JsonArrayBuilder array)
private static javax.json.JsonValue
convertValueToJson(String value)
private static javax.json.JsonArrayBuilder
getCoorArray(javax.json.JsonArrayBuilder builder, EastNorth c)
private javax.json.JsonArrayBuilder
getCoorArray(javax.json.JsonArrayBuilder builder, LatLon c)
String
write()
Writes OSM data as a GeoJSON string (prettified).String
write(boolean pretty)
Writes OSM data as a GeoJSON string (prettified or not).void
write(boolean pretty, Writer writer)
Writes OSM data as a GeoJSON string (prettified or not).
-
-
-
Field Detail
-
projection
private final Projection projection
-
SKIP_EMPTY_NODES
private static final BooleanProperty SKIP_EMPTY_NODES
-
UNTAGGED_CLOSED_IS_POLYGON
private static final BooleanProperty UNTAGGED_CLOSED_IS_POLYGON
-
processedMultipolygonWays
private static final Set<Way> processedMultipolygonWays
-
JSON_VALUE_START_MARKER
static final String JSON_VALUE_START_MARKER
This is used to determine that a tag should be interpreted as a json object or array. The tag should have bothJSON_VALUE_START_MARKER
andJSON_VALUE_END_MARKER
.- See Also:
- Constant Field Values
-
JSON_VALUE_END_MARKER
static final String JSON_VALUE_END_MARKER
This is used to determine that a tag should be interpreted as a json object or array. The tag should have bothJSON_VALUE_START_MARKER
andJSON_VALUE_END_MARKER
.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeoJSONWriter
public GeoJSONWriter(DataSet ds)
Constructs a newGeoJSONWriter
.- Parameters:
ds
- The OSM data set to save- Since:
- 12806
-
-
Method Detail
-
write
public String write()
Writes OSM data as a GeoJSON string (prettified).- Returns:
- The GeoJSON data
-
write
public String write(boolean pretty)
Writes OSM data as a GeoJSON string (prettified or not).- Parameters:
pretty
-true
to have pretty output,false
otherwise- Returns:
- The GeoJSON data
- Since:
- 6756
-
write
public void write(boolean pretty, Writer writer)
Writes OSM data as a GeoJSON string (prettified or not).- Parameters:
pretty
-true
to have pretty output,false
otherwisewriter
- The writer used to write results
-
getCoorArray
private javax.json.JsonArrayBuilder getCoorArray(javax.json.JsonArrayBuilder builder, LatLon c)
-
getCoorArray
private static javax.json.JsonArrayBuilder getCoorArray(javax.json.JsonArrayBuilder builder, EastNorth c)
-
appendPrimitive
protected void appendPrimitive(OsmPrimitive p, javax.json.JsonArrayBuilder array)
-
convertValueToJson
private static javax.json.JsonValue convertValueToJson(String value)
-
appendLayerBounds
protected void appendLayerBounds(DataSet ds, javax.json.JsonObjectBuilder object)
-
appendBounds
protected void appendBounds(Bounds b, javax.json.JsonObjectBuilder object)
-
appendLayerFeatures
protected void appendLayerFeatures(DataSet ds, javax.json.JsonObjectBuilder object)
-
-