Class GeometryCollection
- All Implemented Interfaces:
GeoJson,Geometry,Serializable
A GeometryCollection has a member with the name "geometries". The value of "geometries" is a List Each element of this list is a GeoJson Geometry object. It is possible for this list to be empty.
Unlike the other geometry types, a GeometryCollection can be a heterogeneous composition of smaller Geometry objects. For example, a Geometry object in the shape of a lowercase roman "i" can be composed of one point and one LineString.
GeometryCollections have a different syntax from single TYPE Geometry objects (Point, LineString, and Polygon) and homogeneously typed multipart Geometry objects (MultiPoint, MultiLineString, and MultiPolygon) but have no different semantics. Although a GeometryCollection object has no "coordinates" member, it does have coordinates: the coordinates of all its parts belong to the collection. The "geometries" member of a GeometryCollection describes the parts of this composition. Implementations SHOULD NOT apply any additional semantics to the "geometries" array.
To maximize interoperability, implementations SHOULD avoid nested GeometryCollections. Furthermore, GeometryCollections composed of a single part or a number of parts of a single TYPE SHOULD be avoided when that single part or a single object of multipart TYPE (MultiPoint, MultiLineString, or MultiPolygon) could be used instead.
An example of a serialized GeometryCollections given below:
{
"TYPE": "GeometryCollection",
"geometries": [{
"TYPE": "Point",
"coordinates": [100.0, 0.0]
}, {
"TYPE": "LineString",
"coordinates": [
[101.0, 0.0],
[102.0, 1.0]
]
}]
}
- 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.booleanstatic GeometryCollectionfromGeometries(List<Geometry> geometries) Create a new instance of this class by giving the collection a list ofGeometry.static GeometryCollectionfromGeometries(List<Geometry> geometries, BoundingBox bbox) Create a new instance of this class by giving the collection a list ofGeometry.static GeometryCollectionfromGeometry(Geometry geometry) Create a new instance of this class by giving the collection a single GeoJSONGeometry.static GeometryCollectionfromGeometry(Geometry geometry, BoundingBox bbox) Create a new instance of this class by giving the collection a single GeoJSONGeometry.static GeometryCollectionCreate a new instance of this class by passing in a formatted valid JSON String.This provides the list of geometry making up this Geometry Collection.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 returnGeometryCollection.static com.google.gson.TypeAdapter<GeometryCollection>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 GeometryCollection object from scratch it is better to use one of the other provided static factory methods such asfromGeometries(List).- Parameters:
json- a formatted valid JSON string defining a GeoJson Geometry Collection- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromGeometries
Create a new instance of this class by giving the collection a list ofGeometry.- Parameters:
geometries- a non-null list of geometry which makes up this collection- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 1.0.0
-
fromGeometries
public static GeometryCollection fromGeometries(@NonNull List<Geometry> geometries, @Nullable BoundingBox bbox) Create a new instance of this class by giving the collection a list ofGeometry.- Parameters:
geometries- a non-null list of geometry which makes up this collectionbbox- 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:
- 1.0.0
-
fromGeometry
Create a new instance of this class by giving the collection a single GeoJSONGeometry.- Parameters:
geometry- a non-null object of type geometry which makes up this collection- Returns:
- a new instance of this class defined by the values passed inside this static factory method
- Since:
- 3.0.0
-
fromGeometry
public static GeometryCollection fromGeometry(@NonNull Geometry geometry, @Nullable BoundingBox bbox) Create a new instance of this class by giving the collection a single GeoJSONGeometry.- Parameters:
geometry- a non-null object of type geometry which makes up this collectionbbox- 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 returnGeometryCollection. -
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. -
geometries
This provides the list of geometry making up this Geometry Collection. Note that if the Geometry Collection 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
Geometrywhich make up this Geometry Collection - Since:
- 1.0.0
-
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<GeometryCollection> 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
-
equals
-
hashCode
public int hashCode()
-