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 geo position.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GeoPosition(double longitude, double latitude)
    Constructs a geo position.
    GeoPosition(double longitude, double latitude, Double altitude)
    Constructs a geo position.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the number of coordinates used to compose the position.
    boolean
     
    fromJson(com.azure.json.JsonReader jsonReader)
    Reads a JSON stream into a GeoPosition.
    The altitude of the geometric position.
    double
    The latitudinal position of the geometric position.
    double
    The longitudinal position of the geometric position.
    int
     
    com.azure.json.JsonWriter
    toJson(com.azure.json.JsonWriter jsonWriter)
    Writes the object to the passed JsonWriter.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GeoPosition

      public GeoPosition(double longitude, double latitude)
      Constructs a geo position.
      Parameters:
      longitude - Longitudinal position.
      latitude - Latitudinal position.
    • GeoPosition

      public GeoPosition(double longitude, double latitude, Double altitude)
      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

      public Double 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()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toJson

      public com.azure.json.JsonWriter toJson(com.azure.json.JsonWriter jsonWriter) throws IOException
      Description copied from interface: com.azure.json.JsonSerializable
      Writes the object to the passed JsonWriter.

      The contract for writing JSON to JsonWriter is that the object being written will handle opening and closing its own JSON object. So, for objects calling out to other JsonSerializable objects for serialization, they'll write the field name only then pass the JsonWriter to the other JsonSerializable object. This way objects writing JSON will be self-encapsulated for writing properly formatted JSON.

      Specified by:
      toJson in interface com.azure.json.JsonSerializable<GeoPosition>
      Parameters:
      jsonWriter - Where the object's JSON will be written.
      Returns:
      The JsonWriter where the JSON was written.
      Throws:
      IOException - If the object fails to be written to the jsonWriter.
    • fromJson

      public static GeoPosition fromJson(com.azure.json.JsonReader jsonReader) throws IOException
      Reads a JSON stream into a GeoPosition.
      Parameters:
      jsonReader - The JsonReader being read.
      Returns:
      The GeoPosition that the JSON stream represented, or null if it pointed to JSON null.
      Throws:
      IllegalStateException - If the GeoPosition has less than two or more than three positions in the array.
      IOException - If a GeoPosition fails to be read from the jsonReader.