public class FeatureJSON extends Object
SimpleFeature feature = ...; FeatureJSON io = new FeatureJSON(); io.writeFeature(feature, "feature.json")); Iteratorfeatures = io.streamFeatureCollection("features.json"); while(features.hasNext()) { feature = features.next(); ... }
Constructor and Description |
---|
FeatureJSON() |
FeatureJSON(GeometryJSON gjson) |
Modifier and Type | Method and Description |
---|---|
boolean |
isEncodeFeatureBounds()
The flag controlling whether feature bounds are encoded.
|
boolean |
isEncodeFeatureCollectionBounds()
The flag controlling whether feature collection bounds are encoded.
|
boolean |
isEncodeFeatureCollectionCRS()
The flag controlling whether feature collection coordinate reference systems are encoded.
|
boolean |
isEncodeFeatureCRS()
The flag controlling whether feature coordinate reference systems are encoded.
|
boolean |
isEncodeNullValues()
The flag controlling whether properties with null values are encoded.
|
CoordinateReferenceSystem |
readCRS(InputStream input)
Reads a coordinate reference system from GeoJSON.
|
CoordinateReferenceSystem |
readCRS(Object input)
Reads a coordinate reference system from GeoJSON.
|
SimpleFeature |
readFeature(InputStream input)
Reads a feature from GeoJSON.
|
SimpleFeature |
readFeature(Object input)
Reads a feature from GeoJSON.
|
FeatureCollection |
readFeatureCollection(InputStream input)
Reads a feature collection from GeoJSON.
|
FeatureCollection |
readFeatureCollection(Object input)
Reads a feature collection from GeoJSON.
|
SimpleFeatureType |
readFeatureCollectionSchema(InputStream input,
boolean nullValuesEncoded)
Reads the
SimpleFeatureType of a GeoJSON feature collection. |
SimpleFeatureType |
readFeatureCollectionSchema(Object input,
boolean nullValuesEncoded)
Reads the
SimpleFeatureType of a GeoJSON feature collection. |
void |
setEncodeFeatureBounds(boolean encodeFeatureBounds)
Sets the flag controlling whether feature bounds are encoded.
|
void |
setEncodeFeatureCollectionBounds(boolean encodeFeatureCollectionBounds)
Sets the flag controlling whether feature collection bounds are encoded.
|
void |
setEncodeFeatureCollectionCRS(boolean encodeFeatureCollectionCRS)
Sets the flag controlling whether feature collection coordinate reference systems are
encoded.
|
void |
setEncodeFeatureCRS(boolean encodeFeatureCRS)
Sets the flag controlling whether feature coordinate reference systems are encoded.
|
void |
setEncodeNullValues(boolean encodeNullValues)
Sets the flag controlling whether properties with null values are encoded.
|
void |
setFeatureType(SimpleFeatureType featureType)
Sets the target feature type for parsing.
|
FeatureIterator<SimpleFeature> |
streamFeatureCollection(Object input)
Reads a feature collection from GeoJSON streaming back the contents via an iterator.
|
String |
toString(CoordinateReferenceSystem crs)
Writes a coordinate reference system as GeoJSON returning the result as a string.
|
String |
toString(FeatureCollection features)
Writes a feature collection as GeoJSON returning the result as a string.
|
String |
toString(SimpleFeature feature)
Writes a feature as GeoJSON returning the result as a string.
|
void |
writeCRS(CoordinateReferenceSystem crs,
Object output)
Writes a coordinate reference system as GeoJSON.
|
void |
writeCRS(CoordinateReferenceSystem crs,
OutputStream output)
Writes a coordinate reference system as GeoJSON.
|
void |
writeFeature(SimpleFeature feature,
Object output)
Writes a feature as GeoJSON.
|
void |
writeFeature(SimpleFeature feature,
OutputStream output)
Writes a feature as GeoJSON.
|
void |
writeFeatureCollection(FeatureCollection features,
Object output)
Writes a feature collection as GeoJSON.
|
void |
writeFeatureCollection(FeatureCollection features,
OutputStream output)
Writes a feature collection as GeoJSON.
|
public FeatureJSON()
public FeatureJSON(GeometryJSON gjson)
public void setFeatureType(SimpleFeatureType featureType)
Setting the target feature type will help the geojson parser determine the type of feature properties during properties. When the type is not around all properties are returned as a string.
featureType
- The feature type. Parsed features will reference this feature type.public void setEncodeFeatureBounds(boolean encodeFeatureBounds)
isEncodeFeatureBounds()
public boolean isEncodeFeatureBounds()
When set each feature object will contain a "bbox" attribute whose value is an array containing the elements of the bounding box (in x1,y1,x2,y2 order) of the feature
public void setEncodeFeatureCollectionBounds(boolean encodeFeatureCollectionBounds)
isEncodeFeatureCollectionBounds()
public boolean isEncodeFeatureCollectionBounds()
When set the feature collection object will contain a "bbox" attribute whose value is an array containing elements of the bounding box (in x1,y1,x2,y2 order) of the feature collection.
public void setEncodeFeatureCRS(boolean encodeFeatureCRS)
isEncodeFeatureCRS()
public boolean isEncodeFeatureCRS()
When set each feature object will contain a "crs" attribute describing the coordinate reference system of the feature.
public void setEncodeFeatureCollectionCRS(boolean encodeFeatureCollectionCRS)
isEncodeFeatureCollectionCRS()
public boolean isEncodeFeatureCollectionCRS()
When set the feature collection object will contain a "crs" attribute describing the coordinate reference system of the feature collection.
public void setEncodeNullValues(boolean encodeNullValues)
isEncodeNullValues()
public boolean isEncodeNullValues()
When set, properties with null values are encoded as null in the GeoJSON document.
public void writeFeature(SimpleFeature feature, Object output) throws IOException
feature
- The feature.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeFeature(SimpleFeature feature, OutputStream output) throws IOException
This method calls through to #writeFeature(FeatureCollection, Object)
feature
- The feature.output
- The output stream.IOException
public String toString(SimpleFeature feature) throws IOException
geometry
- The geometry.IOException
public SimpleFeature readFeature(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public SimpleFeature readFeature(InputStream input) throws IOException
This method calls through to readFeature(Object)
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public void writeFeatureCollection(FeatureCollection features, Object output) throws IOException
features
- The feature collection.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeFeatureCollection(FeatureCollection features, OutputStream output) throws IOException
This method calls through to writeFeatureCollection(FeatureCollection, Object)
features
- The feature collection.output
- The output strema to write to.IOException
public FeatureCollection readFeatureCollection(Object input) throws IOException
Warning that this method will load the entire feature collection into memory. For large
feature collections streamFeatureCollection(Object)
should be used.
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public FeatureCollection readFeatureCollection(InputStream input) throws IOException
Warning that this method will load the entire feature collection into memory. For large
feature collections streamFeatureCollection(Object)
should be used.
This method calls through to readFeatureCollection(Object)
.
input
- The input stream.IOException
- In the event of a parsing error or if the input json is invalid.public FeatureIterator<SimpleFeature> streamFeatureCollection(Object input) throws IOException
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public String toString(FeatureCollection features) throws IOException
features
- The feature collection.IOException
public void writeCRS(CoordinateReferenceSystem crs, Object output) throws IOException
crs
- The coordinate reference system.output
- The output. See GeoJSONUtil.toWriter(Object)
for details.IOException
public void writeCRS(CoordinateReferenceSystem crs, OutputStream output) throws IOException
This method calls through to writeCRS(CoordinateReferenceSystem, Object)
crs
- The coordinate reference system.output
- The output stream.IOException
public CoordinateReferenceSystem readCRS(Object input) throws IOException
This method only handles named coordinate reference system objects.
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public CoordinateReferenceSystem readCRS(InputStream input) throws IOException
This method only handles named coordinate reference system objects.
This method calls through to readCRS(Object)
input
- The input. See GeoJSONUtil.toReader(Object)
for details.IOException
- In the event of a parsing error or if the input json is invalid.public SimpleFeatureType readFeatureCollectionSchema(Object input, boolean nullValuesEncoded) throws IOException
SimpleFeatureType
of a GeoJSON feature collection. In the worst case, it
will parse all features searching for attributes not present in previous features.input
- The input. See GeoJSONUtil.toReader(Object)
for details.nullValuesEncoded
- if the input has null values encoded. If this flag is set to true
and the GeoJSON doesn't actually encode null values, only the first feature attributes
will be discovered.IOException
- In the event of a parsing error or if the input json is invalid.public SimpleFeatureType readFeatureCollectionSchema(InputStream input, boolean nullValuesEncoded) throws IOException
SimpleFeatureType
of a GeoJSON feature collection. In the worst case, it
will parse all features searching for attributes not present in previous features.input
- The input. See GeoJSONUtil.toReader(Object)
for details.nullValuesEncoded
- if the input has null values encoded. If this flag is set to true
and the GeoJSON doesn't actually encode null values, only the first feature attributes
will be discovered.IOException
- In the event of a parsing error or if the input json is invalid.public String toString(CoordinateReferenceSystem crs) throws IOException
crs
- The coordinate reference system.IOException
Copyright © 1996–2019 Geotools. All rights reserved.