public final class GeometryCollection extends java.lang.Object implements Geometry
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] ] }] }
Modifier and Type | Method and Description |
---|---|
BoundingBox |
bbox()
A Feature Collection might have a member named
bbox to include information on the
coordinate range for it's Feature s. |
boolean |
equals(java.lang.Object obj) |
static GeometryCollection |
fromGeometries(java.util.List<Geometry> geometries)
Create a new instance of this class by giving the collection a list of
Geometry . |
static GeometryCollection |
fromGeometries(java.util.List<Geometry> geometries,
BoundingBox bbox)
Create a new instance of this class by giving the collection a list of
Geometry . |
static GeometryCollection |
fromGeometry(Geometry geometry)
Create a new instance of this class by giving the collection a single GeoJSON
Geometry . |
static GeometryCollection |
fromGeometry(Geometry geometry,
BoundingBox bbox)
Create a new instance of this class by giving the collection a single GeoJSON
Geometry . |
static GeometryCollection |
fromJson(java.lang.String json)
Create a new instance of this class by passing in a formatted valid JSON String.
|
java.util.List<Geometry> |
geometries()
This provides the list of geometry making up this Geometry Collection.
|
int |
hashCode() |
java.lang.String |
toJson()
This takes the currently defined values found inside this instance and converts it to a GeoJson
string.
|
java.lang.String |
toString() |
java.lang.String |
type()
This describes the TYPE of GeoJson this object is, thus this will always return
GeometryCollection . |
static com.google.gson.TypeAdapter<GeometryCollection> |
typeAdapter(com.google.gson.Gson gson)
Gson TYPE adapter for parsing Gson to this class.
|
public static GeometryCollection fromJson(java.lang.String json)
fromGeometries(List)
.json
- a formatted valid JSON string defining a GeoJson Geometry Collectionpublic static GeometryCollection fromGeometries(@NonNull java.util.List<Geometry> geometries)
Geometry
.geometries
- a non-null list of geometry which makes up this collectionpublic static GeometryCollection fromGeometries(@NonNull java.util.List<Geometry> geometries, @Nullable BoundingBox bbox)
Geometry
.geometries
- a non-null list of geometry which makes up this collectionbbox
- optionally include a bbox definition as a double arraypublic static GeometryCollection fromGeometry(@NonNull Geometry geometry)
Geometry
.geometry
- a non-null object of type geometry which makes up this collectionpublic static GeometryCollection fromGeometry(@NonNull Geometry geometry, @Nullable BoundingBox bbox)
Geometry
.geometry
- a non-null object of type geometry which makes up this collectionbbox
- optionally include a bbox definition as a double array@NonNull public java.lang.String type()
GeometryCollection
.@Nullable public BoundingBox bbox()
bbox
to include information on the
coordinate range for it's Feature
s. 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.@NonNull public java.util.List<Geometry> geometries()
fromJson(String)
this list could be null.
Otherwise, the list can't be null but the size of the list can equal 0.Geometry
which make up this Geometry Collectionpublic java.lang.String toJson()
public static com.google.gson.TypeAdapter<GeometryCollection> typeAdapter(com.google.gson.Gson gson)
gson
- the built Gson
objectpublic java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object