public class GeoJSONWriter extends Object implements AutoCloseable
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_DATE_FORMAT
Date format (ISO 8601)
|
static FastDateFormat |
DEFAULT_DATE_FORMATTER |
static TimeZone |
DEFAULT_TIME_ZONE
Default time zone, GMT
|
Constructor and Description |
---|
GeoJSONWriter(OutputStream outputStream)
Prepares a writer over the target output stream.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
String |
getDatePattern()
Returns the date formatter pattern.
|
int |
getMaxDecimals()
Returns the max number of decimals used for encoding
|
TimeZone |
getTimeZone(TimeZone tz)
Returns the timezone used to format dates.
|
boolean |
isEncodeFeatureBounds() |
boolean |
isEncodeFeatureCollectionCRS() |
boolean |
isPrettyPrinting()
Returns true if pretty printing is enabled, false otherwise.
|
boolean |
isSingleFeature()
Returns true if the generated JSON is for a single feature, without a feature collection
wrapper around it.
|
void |
setBounds(ReferencedEnvelope bbox) |
void |
setDatePattern(String pattern)
Sets the date format for time encoding
|
void |
setEncodeFeatureBounds(boolean encodeFeatureCollectionBounds) |
void |
setEncodeFeatureCollectionCRS(boolean b)
Set to true to encode the feature collection CRS field.
|
void |
setMaxDecimals(int number)
Set how many decimals should be used in writing out the coordinates.
|
void |
setPrettyPrinting(boolean prettyPrint)
Enables/disables pretty printing.
|
void |
setSingleFeature(boolean singleFeature)
Turns on and off the single feature mode.
|
void |
setTimeZone(TimeZone tz)
Sets the Timezone used to format the date fields.
|
static String |
toGeoJSON(Geometry geometry)
Utility encoding a single JTS geometry in GeoJSON, and returning it as a string
|
static String |
toGeoJSON(SimpleFeature f)
Utility encoding a single
SimpleFeature , and returning it as a string |
static String |
toGeoJSON(SimpleFeatureCollection fc)
Utility encoding a @link
SimpleFeatureCollection }, and returning it as a string |
void |
write(SimpleFeature currentFeature)
Writes a single feature onto the output.
|
void |
writeFeatureCollection(SimpleFeatureCollection features)
Encodes the whole feature collection onto the output
|
public static final String DEFAULT_DATE_FORMAT
public static final TimeZone DEFAULT_TIME_ZONE
public static final FastDateFormat DEFAULT_DATE_FORMATTER
public GeoJSONWriter(OutputStream outputStream) throws IOException
outputStream
- IOException
public void write(SimpleFeature currentFeature) throws IOException
currentFeature
- IOException
public void close() throws IOException
close
in interface AutoCloseable
IOException
public boolean isEncodeFeatureBounds()
public void setEncodeFeatureBounds(boolean encodeFeatureCollectionBounds)
encodeFeatureCollectionBounds
- the encodeFeatureCollectionBounds to setpublic static String toGeoJSON(Geometry geometry)
public static String toGeoJSON(SimpleFeature f)
SimpleFeature
, and returning it as a stringpublic static String toGeoJSON(SimpleFeatureCollection fc)
SimpleFeatureCollection
}, and returning it as a stringpublic void setEncodeFeatureCollectionCRS(boolean b)
public boolean isEncodeFeatureCollectionCRS()
public int getMaxDecimals()
public void setMaxDecimals(int number)
number
- - the number of digits after the decimal place markerpublic void writeFeatureCollection(SimpleFeatureCollection features) throws IOException
IOException
public void setBounds(ReferencedEnvelope bbox)
public boolean isSingleFeature()
public void setSingleFeature(boolean singleFeature)
singleFeature
- public void setPrettyPrinting(boolean prettyPrint)
public boolean isPrettyPrinting()
public void setTimeZone(TimeZone tz)
null
is a valid value, the JVM
local timezone will be used in that case.public TimeZone getTimeZone(TimeZone tz)
public void setDatePattern(String pattern)
pattern
- SimpleDateFormat
compatible * patternpublic String getDatePattern()
Copyright © 1996–2023 Geotools. All rights reserved.