public abstract class MultiPolygon extends java.lang.Object implements CoordinateContainer<java.util.List<java.util.List<java.util.List<Point>>>>, java.io.Serializable
This adheres to the RFC 7946 internet standard when serialized into JSON. When deserialized, this class becomes an immutable object which should be initiated using its static factory methods.
When representing a Polygon that crosses the antimeridian, interoperability is improved by modifying their geometry. Any geometry that crosses the antimeridian SHOULD be represented by cutting it in two such that neither part's representation crosses the antimeridian.
For example, a line extending from 45 degrees N, 170 degrees E across the antimeridian to 45 degrees N, 170 degrees W should be cut in two and represented as a MultiLineString.
A sample GeoJson MultiPolygon's provided below (in it's serialized state).
{ "type": "MultiPolygon", "coordinates": [ [ [ [102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0] ] ], [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ], [ [100.2, 0.2], [100.2, 0.8], [100.8, 0.8], [100.8, 0.2], [100.2, 0.2] ] ] ] }Look over the
Polygon
documentation to get more information about
formatting your list of Polygon objects correctly.Constructor and Description |
---|
MultiPolygon() |
Modifier and Type | Method and Description |
---|---|
abstract BoundingBox |
bbox()
A Feature Collection might have a member named
bbox to include information on the
coordinate range for it's Feature s. |
abstract java.util.List<java.util.List<java.util.List<Point>>> |
coordinates()
Provides the list of list of list of
Point s that make up the MultiPolygon geometry. |
static MultiPolygon |
fromJson(java.lang.String json)
Create a new instance of this class by passing in a formatted valid JSON String.
|
static MultiPolygon |
fromLngLats(java.util.List<java.util.List<java.util.List<Point>>> points)
Create a new instance of this class by defining a list of a list of a list of
Point s
which follow the correct specifications described in the Point documentation. |
static MultiPolygon |
fromLngLats(java.util.List<java.util.List<java.util.List<Point>>> points,
BoundingBox bbox)
Create a new instance of this class by defining a list of a list of a list of
Point s
which follow the correct specifications described in the Point documentation. |
static MultiPolygon |
fromPolygon(Polygon polygon)
Create a new instance of this class by defining a single
Polygon objects and passing
it in as a parameter in this method. |
static MultiPolygon |
fromPolygon(Polygon polygon,
BoundingBox bbox)
Create a new instance of this class by defining a single
Polygon objects and passing
it in as a parameter in this method. |
static MultiPolygon |
fromPolygons(java.util.List<Polygon> polygons)
Create a new instance of this class by defining a list of
Polygon objects and passing
that list in as a parameter in this method. |
static MultiPolygon |
fromPolygons(java.util.List<Polygon> polygons,
BoundingBox bbox)
Create a new instance of this class by defining a list of
Polygon objects and passing
that list in as a parameter in this method. |
java.util.List<Polygon> |
polygons()
Returns a list of polygons which make up this MultiPolygon instance.
|
java.lang.String |
toJson()
This takes the currently defined values found inside this instance and converts it to a GeoJson
string.
|
abstract java.lang.String |
type()
This describes the TYPE of GeoJson geometry this object is, thus this will always return
MultiPolygon . |
static com.google.gson.TypeAdapter<MultiPolygon> |
typeAdapter(com.google.gson.Gson gson)
Gson TYPE adapter for parsing Gson to this class.
|
public static MultiPolygon fromJson(java.lang.String json)
fromPolygons(List)
.public static MultiPolygon fromPolygons(@NonNull java.util.List<Polygon> polygons)
Polygon
objects and passing
that list in as a parameter in this method. The Polygons should comply with the GeoJson
specifications described in the documentation.polygons
- a list of Polygons which make up this MultiPolygonpublic static MultiPolygon fromPolygons(@NonNull java.util.List<Polygon> polygons, @Nullable BoundingBox bbox)
Polygon
objects and passing
that list in as a parameter in this method. The Polygons should comply with the GeoJson
specifications described in the documentation. Optionally, pass in an instance of a
BoundingBox
which better describes this MultiPolygon.polygons
- a list of Polygons which make up this MultiPolygonbbox
- optionally include a bbox definitionpublic static MultiPolygon fromPolygon(@NonNull Polygon polygon)
Polygon
objects and passing
it in as a parameter in this method. The Polygon should comply with the GeoJson
specifications described in the documentation.polygon
- a single Polygon which make up this MultiPolygonpublic static MultiPolygon fromPolygon(@NonNull Polygon polygon, @Nullable BoundingBox bbox)
Polygon
objects and passing
it in as a parameter in this method. The Polygon should comply with the GeoJson
specifications described in the documentation.polygon
- a single Polygon which make up this MultiPolygonbbox
- optionally include a bbox definitionpublic static MultiPolygon fromLngLats(@NonNull java.util.List<java.util.List<java.util.List<Point>>> points)
Point
s
which follow the correct specifications described in the Point documentation.points
- a list of Point
s which make up the MultiPolygon geometrypublic static MultiPolygon fromLngLats(@NonNull java.util.List<java.util.List<java.util.List<Point>>> points, @Nullable BoundingBox bbox)
Point
s
which follow the correct specifications described in the Point documentation.points
- a list of Point
s which make up the MultiPolygon geometrybbox
- optionally include a bbox definitionpublic java.util.List<Polygon> polygons()
Polygon
s which make up this MultiPolygon instance@NonNull public abstract java.lang.String type()
MultiPolygon
.@Nullable public abstract 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 abstract java.util.List<java.util.List<java.util.List<Point>>> coordinates()
Point
s that make up the MultiPolygon geometry.coordinates
in interface CoordinateContainer<java.util.List<java.util.List<java.util.List<Point>>>>
public java.lang.String toJson()
public static com.google.gson.TypeAdapter<MultiPolygon> typeAdapter(com.google.gson.Gson gson)
gson
- the built Gson
object