Package com.azure.core.models
Class GeoPosition
java.lang.Object
com.azure.core.models.GeoPosition
- All Implemented Interfaces:
com.azure.json.JsonSerializable<GeoPosition>
public final class GeoPosition
extends Object
implements com.azure.json.JsonSerializable<GeoPosition>
Represents a geographic position in GeoJSON format.
This class encapsulates a geographic position defined by longitude, latitude, and optionally altitude. It provides methods to access these properties.
This class also provides a toJson(JsonWriter) method to serialize the geographic position to JSON,
and a fromJson(JsonReader) method to deserialize a geographic position from JSON.
This class is useful when you want to work with a geographic position in a geographic context. For example, you can use it to represent a location on a map or a point in a geographic dataset.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionGeoPosition(double longitude, double latitude) Constructs a geo position.GeoPosition(double longitude, double latitude, Double altitude) Constructs a geo position. -
Method Summary
Modifier and TypeMethodDescriptionintcount()Gets the number of coordinates used to compose the position.booleanstatic GeoPositionfromJson(com.azure.json.JsonReader jsonReader) Reads a JSON stream into aGeoPosition.The altitude of the geometric position.doubleThe latitudinal position of the geometric position.doubleThe longitudinal position of the geometric position.inthashCode()com.azure.json.JsonWritertoJson(com.azure.json.JsonWriter jsonWriter) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.azure.json.JsonSerializable
toJson, toJson, toJsonBytes, toJsonString
-
Constructor Details
-
GeoPosition
public GeoPosition(double longitude, double latitude) Constructs a geo position.- Parameters:
longitude- Longitudinal position.latitude- Latitudinal position.
-
GeoPosition
Constructs a geo position.- Parameters:
longitude- Longitudinal position.latitude- Latitudinal position.altitude- Altitude position.
-
-
Method Details
-
getLongitude
public double getLongitude()The longitudinal position of the geometric position.- Returns:
- The longitudinal position.
-
getLatitude
public double getLatitude()The latitudinal position of the geometric position.- Returns:
- The latitudinal position.
-
getAltitude
The altitude of the geometric position.- Returns:
- The altitude.
-
count
public int count()Gets the number of coordinates used to compose the position.This will return either 2 or 3 depending on whether
altitude is set.- Returns:
- The number of coordinates used to compose the position.
-
hashCode
public int hashCode() -
equals
-
toString
-
toJson
- Specified by:
toJsonin interfacecom.azure.json.JsonSerializable<GeoPosition>- Throws:
IOException
-
fromJson
Reads a JSON stream into aGeoPosition.- Parameters:
jsonReader- TheJsonReaderbeing read.- Returns:
- The
GeoPositionthat the JSON stream represented, or null if it pointed to JSON null. - Throws:
IllegalStateException- If theGeoPositionhas less than two or more than three positions in the array.IOException- If aGeoPositionfails to be read from thejsonReader.
-