Record Class GeolocationCoordinates

java.lang.Object
java.lang.Record
com.vaadin.flow.component.geolocation.GeolocationCoordinates
Record Components:
latitude - latitude in decimal degrees, positive north, negative south. Always present. Example: 60.1699 for Helsinki
longitude - longitude in decimal degrees, positive east, negative west. Always present. Example: 24.9384 for Helsinki
accuracy - the 1-sigma horizontal accuracy of the reading in metres: the true location lies within this distance of the reported latitude/longitude with ~68% probability. Smaller is better. Always present
altitude - height in metres above the WGS 84 ellipsoid (approximately mean sea level), or null when the device cannot measure it
altitudeAccuracy - the 1-sigma vertical accuracy of altitude in metres, or null when altitude is not available
heading - the direction of travel in degrees clockwise from true north (0 = north, 90 = east, 180 = south, 270 = west), or null when the device cannot measure it or the user is stationary. Not meaningful when speed is 0
speed - ground speed in metres per second, or null when the device cannot measure it
All Implemented Interfaces:
Serializable

public record GeolocationCoordinates(double latitude, double longitude, double accuracy, @Nullable Double altitude, @Nullable Double altitudeAccuracy, @Nullable Double heading, @Nullable Double speed) extends Record implements Serializable
A single point in the world, as reported by the browser.

Latitude, longitude and accuracy are always present. The remaining fields are boxed Double because the device may not measure them: a laptop without GPS typically reports null for altitude, heading and speed, while a mobile phone with GPS typically reports all of them. Applications should either tolerate null or check before using.

See Also:
  • Constructor Details

    • GeolocationCoordinates

      public GeolocationCoordinates(double latitude, double longitude, double accuracy, @Nullable Double altitude, @Nullable Double altitudeAccuracy, @Nullable Double heading, @Nullable Double speed)
      Creates an instance of a GeolocationCoordinates record class.
      Parameters:
      latitude - the value for the latitude record component
      longitude - the value for the longitude record component
      accuracy - the value for the accuracy record component
      altitude - the value for the altitude record component
      altitudeAccuracy - the value for the altitudeAccuracy record component
      heading - the value for the heading record component
      speed - the value for the speed record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • latitude

      public double latitude()
      Returns the value of the latitude record component.
      Returns:
      the value of the latitude record component
    • longitude

      public double longitude()
      Returns the value of the longitude record component.
      Returns:
      the value of the longitude record component
    • accuracy

      public double accuracy()
      Returns the value of the accuracy record component.
      Returns:
      the value of the accuracy record component
    • altitude

      public @Nullable Double altitude()
      Returns the value of the altitude record component.
      Returns:
      the value of the altitude record component
    • altitudeAccuracy

      public @Nullable Double altitudeAccuracy()
      Returns the value of the altitudeAccuracy record component.
      Returns:
      the value of the altitudeAccuracy record component
    • heading

      public @Nullable Double heading()
      Returns the value of the heading record component.
      Returns:
      the value of the heading record component
    • speed

      public @Nullable Double speed()
      Returns the value of the speed record component.
      Returns:
      the value of the speed record component