public class GeoJSONReader extends Object implements AutoCloseable
Modifier and Type | Class and Description |
---|---|
static class |
GeoJSONReader.IdStrategy
ID Strategy.
|
Modifier and Type | Field and Description |
---|---|
static String |
GEOMETRY_NAME
GEOMETRY_NAME
|
static Object |
TOP_LEVEL_ATTRIBUTES
Top Level Attributes Not Included in Properties
|
Constructor and Description |
---|
GeoJSONReader(InputStream is)
Builds a GeoJSON parser from a GeoJSON document, provided as an
InputStream |
GeoJSONReader(String json)
Builds a GeoJSON parser from a GeoJSON document, provided as a string
|
GeoJSONReader(URL url)
Builds a GeoJSON parser from a GeoJSON source, located at the specified URL.
|
GeoJSONReader(URL url,
GeoJSONReader.IdStrategy idStrategy)
Builds a GeoJSON parser from a GeoJSON source, located at the specified URL.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
SimpleFeature |
getFeature()
Parses and returns a single feature from the source
|
SimpleFeatureCollection |
getFeatures()
Parses all features in the source and returns them as an in-memory feature collection with a
stable
FeatureType . |
String |
getIdFieldName()
Get the Field Name to use for IDs
|
String |
getIdPrefix()
Get the Prefix to use for IDs
|
GeoJSONReader.IdStrategy |
getIdStrategy()
Returns the Strategy Used to Generate IDs
|
SimpleFeatureIterator |
getIterator()
Returns a
FeatureIterator streaming over the provided source. |
protected PagingFeatureCollection |
getPagingFeatureCollection(SimpleFeatureCollection result,
Integer matched,
ObjectNode next) |
FeatureType |
getSchema()
Returns the current feature type, with the structure discovered so far while parsing features
(parse them all in order to get a final, stable feature type):
|
boolean |
isConnected()
Returns true if the source is still connected, false otherwise.
|
boolean |
isGuessingDates()
Returns true if the parser is trying to convert string formatted as dates into
java.util.Date, false otherwise.
|
boolean |
isSchemaChanged() |
static SimpleFeature |
parseFeature(String json)
Pares and returns a single feature out of a GeoJSON document
|
static SimpleFeature |
parseFeature(String json,
GeoJSONReader.IdStrategy idStrategy,
String idPrefix,
String idFieldName)
Parses and returns a single feature out of a GeoJSON document with id generation strategies
|
static SimpleFeatureCollection |
parseFeatureCollection(String jsonString)
Parses and returns a feature collection from a GeoJSON
|
static Geometry |
parseGeometry(String input)
Parses and returns a single geometry
|
void |
setGuessingDates(boolean guessingDates)
Enables/Disables guessing strings formatted as dates into java.util.Date.
|
void |
setIdFieldName(String idFieldName)
Set the Field Name to use for IDs
|
void |
setIdPrefix(String idPrefix)
Set the Prefix to use for IDs
|
void |
setIdStrategy(GeoJSONReader.IdStrategy idStrategy)
Sets the Strategy Used to Generate IDs
|
void |
setSchema(SimpleFeatureType schema) |
void |
setSchemaChanged(boolean schemaChanged) |
public static final String GEOMETRY_NAME
public static final Object TOP_LEVEL_ATTRIBUTES
public GeoJSONReader(URL url) throws IOException
url
- IOException
public GeoJSONReader(URL url, GeoJSONReader.IdStrategy idStrategy) throws IOException
url
- idStrategy
- the strategy to use for generating IDs. AUTO is autogenerated using
basename and incremented integer. PREFIX uses a provided ID and prefix string. PROVIDED
uses a provided ID without a prefix.IOException
public GeoJSONReader(InputStream is) throws IOException
InputStream
IOException
public GeoJSONReader(String json) throws IOException
IOException
public GeoJSONReader.IdStrategy getIdStrategy()
public void setIdStrategy(GeoJSONReader.IdStrategy idStrategy)
idStrategy
- the idStrategy to setpublic String getIdPrefix()
public void setIdPrefix(String idPrefix)
idPrefix
- the idPrefix to setpublic String getIdFieldName()
public void setIdFieldName(String idFieldName)
idFieldName
- the idFieldName to setpublic boolean isGuessingDates()
public void setGuessingDates(boolean guessingDates)
public boolean isConnected()
public static SimpleFeature parseFeature(String json) throws JsonParseException, IOException
JsonParseException
IOException
public static SimpleFeature parseFeature(String json, GeoJSONReader.IdStrategy idStrategy, String idPrefix, String idFieldName) throws JsonParseException, IOException
json
- json to parseidStrategy
- Auto generated, prefixed or provided ididPrefix
- Prefix for ididFieldName
- Field name for existing id in jsonJsonParseException
- JSON Parsing IssueIOException
- IO Exception reading jsonpublic static SimpleFeatureCollection parseFeatureCollection(String jsonString)
public static Geometry parseGeometry(String input)
public SimpleFeature getFeature() throws IOException
IOException
public SimpleFeatureCollection getFeatures() throws IOException
FeatureType
. In order to stream use getIterator()
instead.IOException
protected PagingFeatureCollection getPagingFeatureCollection(SimpleFeatureCollection result, Integer matched, ObjectNode next)
public SimpleFeatureIterator getIterator() throws IOException
FeatureIterator
streaming over the provided source. The feature type may
evolve feature by feature, discovering new attributes that were not previosly encountered.IOException
public FeatureType getSchema() throws IOException
IOException
public void setSchema(SimpleFeatureType schema)
schema
- the schema to setpublic boolean isSchemaChanged()
public void setSchemaChanged(boolean schemaChanged)
schemaChanged
- the schemaChanged to setpublic void close() throws IOException
close
in interface AutoCloseable
IOException
Copyright © 1996–2023 Geotools. All rights reserved.