Package com.azure.core.models
Class GeoPolygon
java.lang.Object
com.azure.core.models.GeoObject
com.azure.core.models.GeoPolygon
- All Implemented Interfaces:
com.azure.json.JsonSerializable<GeoObject>
Represents a geometric polygon in GeoJSON format.
This class encapsulates a polygon defined by a list of GeoLinearRing instances. Each ring represents a
closed loop of coordinates forming the boundary of the polygon.
This class also provides a toJson(JsonWriter) method to serialize the geometric polygon to JSON, and a
fromJson(JsonReader) method to deserialize a geometric polygon from JSON.
This class is useful when you want to work with a polygon in a geographic context. For example, you can use it to represent a geographic area on a map.
Note: A polygon requires at least one ring, and each ring requires at least 4 coordinates (with the first and last coordinates being the same to form a closed loop).
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGeoPolygon(GeoLinearRing ring) Constructs a geometric polygon.GeoPolygon(GeoLinearRing ring, GeoBoundingBox boundingBox, Map<String, Object> customProperties) Constructs a geometric polygon.GeoPolygon(List<GeoLinearRing> rings) Constructs a geometric polygon.GeoPolygon(List<GeoLinearRing> rings, GeoBoundingBox boundingBox, Map<String, Object> customProperties) Constructs a geometric polygon. -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic GeoPolygonfromJson(com.azure.json.JsonReader jsonReader) Reads a JSON stream into aGeoPolygon.Gets the outer ring of the polygon.getRings()Unmodifiable representation of thegeometric ringsrepresenting this polygon.getType()Gets the GeoJSON type for this object.inthashCode()com.azure.json.JsonWritertoJson(com.azure.json.JsonWriter jsonWriter) Methods inherited from class com.azure.core.models.GeoObject
getBoundingBox, getCustomPropertiesMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes, toJsonString
-
Constructor Details
-
GeoPolygon
Constructs a geometric polygon.- Parameters:
ring- Theringthat defines the polygon.- Throws:
NullPointerException- Ifringisnull.
-
GeoPolygon
public GeoPolygon(GeoLinearRing ring, GeoBoundingBox boundingBox, Map<String, Object> customProperties) Constructs a geometric polygon.- Parameters:
ring- Theringthat defines the polygon.boundingBox- Bounding box for the polygon.customProperties- Additional properties of the polygon.- Throws:
NullPointerException- Ifringisnull.
-
GeoPolygon
Constructs a geometric polygon.- Parameters:
rings- Theringsthat define the polygon.- Throws:
NullPointerException- Ifringsisnull.
-
GeoPolygon
public GeoPolygon(List<GeoLinearRing> rings, GeoBoundingBox boundingBox, Map<String, Object> customProperties) Constructs a geometric polygon.- Parameters:
rings- Theringsthat define the polygon.boundingBox- Bounding box for the polygon.customProperties- Additional properties of the polygon.- Throws:
NullPointerException- Ifringsisnull.
-
-
Method Details
-
getRings
Unmodifiable representation of thegeometric ringsrepresenting this polygon.- Returns:
- An unmodifiable representation of the
geometric ringsrepresenting this polygon.
-
getOuterRing
Gets the outer ring of the polygon.- Returns:
- Outer ring of the polygon.
-
getType
Description copied from class:GeoObjectGets the GeoJSON type for this object. -
hashCode
public int hashCode() -
equals
-
toJson
- Specified by:
toJsonin interfacecom.azure.json.JsonSerializable<GeoObject>- Overrides:
toJsonin classGeoObject- Throws:
IOException
-
fromJson
Reads a JSON stream into aGeoPolygon.- Parameters:
jsonReader- TheJsonReaderbeing read.- Returns:
- The
GeoPolygonthat the JSON stream represented, or null if it pointed to JSON null. - Throws:
IllegalStateException- If thetypenode exists and isn't equal toPolygon.IOException- If aGeoPolygonfails to be read from thejsonReader.
-