Package com.mapbox.geojson
Class FeatureCollection
java.lang.Object
com.mapbox.geojson.FeatureCollection
- All Implemented Interfaces:
GeoJson,Serializable
This represents a GeoJson Feature Collection which holds a list of
Feature objects (when
serialized the feature list becomes a JSON array).
Note that the feature list could potentially be empty. Features within the list must follow the
specifications defined inside the Feature class.
An example of a Feature Collections given below:
{
"TYPE": "FeatureCollection",
"bbox": [100.0, 0.0, -100.0, 105.0, 1.0, 0.0],
"features": [
//...
]
}
- Since:
- 1.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbbox()A Feature Collection might have a member namedbboxto include information on the coordinate range for it'sFeatures.booleanfeatures()This provides the list of feature making up this Feature Collection.static FeatureCollectionfromFeature(Feature feature) Create a new instance of this class by giving the feature collection a singleFeature.static FeatureCollectionfromFeature(Feature feature, BoundingBox bbox) Create a new instance of this class by giving the feature collection a singleFeature.static FeatureCollectionfromFeatures(Feature[] features) Create a new instance of this class by giving the feature collection an array ofFeatures.static FeatureCollectionfromFeatures(Feature[] features, BoundingBox bbox) Create a new instance of this class by giving the feature collection an array ofFeatures.static FeatureCollectionfromFeatures(List<Feature> features) Create a new instance of this class by giving the feature collection a list ofFeatures.static FeatureCollectionfromFeatures(List<Feature> features, BoundingBox bbox) Create a new instance of this class by giving the feature collection a list ofFeatures.static FeatureCollectionCreate a new instance of this class by passing in a formatted valid JSON String.inthashCode()toJson()This takes the currently defined values found inside this instance and converts it to a GeoJson string.toString()type()This describes the type of GeoJson this object is, thus this will always returnFeatureCollection.static com.google.gson.TypeAdapter<FeatureCollection>typeAdapter(com.google.gson.Gson gson) Gson type adapter for parsing Gson to this class.
-
Method Details
-
fromJson
Create a new instance of this class by passing in a formatted valid JSON String. If you are creating a FeatureCollection object from scratch it is better to use one of the other provided static factory methods such asfromFeatures(List).- Parameters:
json- a formatted valid JSON string defining a GeoJson Feature Collection- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromFeatures
Create a new instance of this class by giving the feature collection an array ofFeatures. The array of features itself isn't null but it can be empty and have a length of 0.- Parameters:
features- an array of features- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromFeatures
Create a new instance of this class by giving the feature collection a list ofFeatures. The list of features itself isn't null but it can empty and have a size of 0.- Parameters:
features- a list of features- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromFeatures
public static FeatureCollection fromFeatures(@NonNull Feature[] features, @Nullable BoundingBox bbox) Create a new instance of this class by giving the feature collection an array ofFeatures. The array of features itself isn't null but it can be empty and have a length of 0.- Parameters:
features- an array of featuresbbox- optionally include a bbox definition as a double array- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromFeatures
public static FeatureCollection fromFeatures(@NonNull List<Feature> features, @Nullable BoundingBox bbox) Create a new instance of this class by giving the feature collection a list ofFeatures. The list of features itself isn't null but it can be empty and have a size of 0.- Parameters:
features- a list of featuresbbox- optionally include a bbox definition as a double array- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromFeature
Create a new instance of this class by giving the feature collection a singleFeature.- Parameters:
feature- a single feature- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromFeature
Create a new instance of this class by giving the feature collection a singleFeature.- Parameters:
feature- a single featurebbox- optionally include a bbox definition as a double array- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
type
This describes the type of GeoJson this object is, thus this will always returnFeatureCollection. -
bbox
A Feature Collection might have a member namedbboxto include information on the coordinate range for it'sFeatures. The value of the bbox member MUST be a list of size 2*n where n is the number of dimensions represented in the contained feature geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries. -
features
This provides the list of feature making up this Feature Collection. Note that if the FeatureCollection was created throughfromJson(String)this list could be null. Otherwise, the list can't be null but the size of the list can equal 0.- Returns:
- a list of
Features which make up this Feature Collection - Since:
- 1.0.0
-
toJson
This takes the currently defined values found inside this instance and converts it to a GeoJson string. -
typeAdapter
Gson type adapter for parsing Gson to this class.- Parameters:
gson- the builtGsonobject- Returns:
- the TYPE adapter for this class
- Since:
- 3.0.0
-
toString
-
equals
-
hashCode
public int hashCode()
-