Package com.mapbox.geojson
Class FeatureCollection
- java.lang.Object
-
- com.mapbox.geojson.FeatureCollection
-
- All Implemented Interfaces:
GeoJson,java.io.Serializable
public final class FeatureCollection extends java.lang.Object implements GeoJson
This represents a GeoJson Feature Collection which holds a list ofFeatureobjects (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
Featureclass.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:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundingBoxbbox()A Feature Collection might have a member namedbboxto include information on the coordinate range for it'sFeatures.booleanequals(java.lang.Object obj)java.util.List<Feature>features()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(java.util.List<Feature> features)Create a new instance of this class by giving the feature collection a list ofFeatures.static FeatureCollectionfromFeatures(java.util.List<Feature> features, BoundingBox bbox)Create a new instance of this class by giving the feature collection a list ofFeatures.static FeatureCollectionfromJson(java.lang.String json)Create a new instance of this class by passing in a formatted valid JSON String.inthashCode()java.lang.StringtoJson()This takes the currently defined values found inside this instance and converts it to a GeoJson string.java.lang.StringtoString()java.lang.Stringtype()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 Detail
-
fromJson
public static FeatureCollection fromJson(@NonNull java.lang.String json)
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
public static FeatureCollection fromFeatures(@NonNull Feature[] features)
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
public static FeatureCollection fromFeatures(@NonNull java.util.List<Feature> features)
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 java.util.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
public static FeatureCollection fromFeature(@NonNull Feature feature)
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
public static FeatureCollection fromFeature(@NonNull Feature feature, @Nullable BoundingBox bbox)
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
@NonNull public java.lang.String type()
This describes the type of GeoJson this object is, thus this will always returnFeatureCollection.
-
bbox
@Nullable public BoundingBox 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
@Nullable public java.util.List<Feature> 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
public java.lang.String toJson()
This takes the currently defined values found inside this instance and converts it to a GeoJson string.
-
typeAdapter
public static com.google.gson.TypeAdapter<FeatureCollection> typeAdapter(com.google.gson.Gson gson)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-