Zdieľať cez


GeoPosition Class

  • java.lang.Object
    • com.azure.core.models.GeoPosition

Implements

public final class GeoPosition
implements 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 jsonWriter) method to serialize the geographic position to JSON, and a fromJson(JsonReader 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.

Constructor Summary

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 and Description
int count()

Gets the number of coordinates used to compose the position.

boolean equals(Object obj)
static GeoPosition fromJson(JsonReader jsonReader)

Reads a JSON stream into a GeoPosition.

Double getAltitude()

The altitude of the geometric position.

double getLatitude()

The latitudinal position of the geometric position.

double getLongitude()

The longitudinal position of the geometric position.

int hashCode()
JsonWriter toJson(JsonWriter jsonWriter)
String toString()

Methods inherited from java.lang.Object

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

count

public int count()

Gets the number of coordinates used to compose the position.

This will return either 2 or 3 depending on whether getAltitude().

Returns:

The number of coordinates used to compose the position.

equals

public boolean equals(Object obj)

Overrides:

GeoPosition.equals(Object obj)

Parameters:

obj

fromJson

public static GeoPosition fromJson(JsonReader jsonReader)

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:

IOException

- If the GeoPosition has less than two or more than three positions in the array.

getAltitude

public Double getAltitude()

The altitude of the geometric position.

Returns:

The altitude.

getLatitude

public double getLatitude()

The latitudinal position of the geometric position.

Returns:

The latitudinal position.

getLongitude

public double getLongitude()

The longitudinal position of the geometric position.

Returns:

The longitudinal position.

hashCode

public int hashCode()

Overrides:

GeoPosition.hashCode()

toJson

public JsonWriter toJson(JsonWriter jsonWriter)

Parameters:

jsonWriter

Throws:

toString

public String toString()

Overrides:

GeoPosition.toString()

Applies to