public class

Location

extends Object
java.lang.Object
   ↳ com.neomades.location.Location

Class Overview

A data class representing a geographic location.

It consists of a latitude, longitude, altitude, speed, bearing and accuracy information.

Summary

Public Constructors
Location(double latitude, double longitude)
Constructs a new location object with the attributes specified in parameters.
Protected Constructors
Location()
Constructs a new Location object.
Public Methods
float distanceTo(Location dest)
Returns the approximate distance in meters between this location and the given location.
float getAccuracy()
Returns the estimated accuracy of this location, in meters.
double getAltitude()
Returns the altitude if available, in meters above sea level.
float getBearing()
Returns the bearing, in degrees.
double getLatitude()
Returns the latitude, in degrees.
double getLongitude()
Returns the longitude, in degrees.
float getSpeed()
Returns the speed if it is available, in meters/second over ground.
long getTime()
Returns the UTC time of this fix, in milliseconds since January 1, 1970.
void setAccuracy(float accuracy)
Sets the estimated accuracy of this location, in meters.
void setAltitude(double altitude)
Sets the altitude, in meters above sea level.
void setBearing(float bearing)
Sets the bearing, in degrees.
void setLatitude(double latitude)
Sets the latitude, in degrees.
void setLongitude(double longitude)
Sets the longitude, in degrees.
void setProvider(String provider)
Sets the name of the provider that generated this fix.
void setSpeed(float speed)
Sets the speed, in meters/second over ground.
void setTime(long time)
Sets the UTC time of this fix, in milliseconds since January 1, 1970.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Location (double latitude, double longitude)

Constructs a new location object with the attributes specified in parameters.

Parameters
latitude Represents the location's latitude. Must be between -90 and 90
longitude Represents the location's longitude. Must be between -180 and 180
Throws
IllegalArgumentException if the given latitude or longitude is invalid

Protected Constructors

protected Location ()

Constructs a new Location object.

This constructor is for internal use only.

Public Methods

public float distanceTo (Location dest)

Returns the approximate distance in meters between this location and the given location.

Parameters
dest Represents the given location
Returns
  • A float containing the distance value in meters.

public float getAccuracy ()

Returns the estimated accuracy of this location, in meters.

Returns
  • A float containing the estimated accuracy in meters.

public double getAltitude ()

Returns the altitude if available, in meters above sea level.

Returns
  • A float containing the altitude in meters above sea level.

public float getBearing ()

Returns the bearing, in degrees.

Returns
  • A float containing the bearing in degrees.

public double getLatitude ()

Returns the latitude, in degrees.

Returns
  • A double containing the latitude in degrees.

public double getLongitude ()

Returns the longitude, in degrees.

Returns
  • A double containing the longitude in degrees.

public float getSpeed ()

Returns the speed if it is available, in meters/second over ground.

Returns
  • A float containing the speed in meters/second over ground.

public long getTime ()

Returns the UTC time of this fix, in milliseconds since January 1, 1970.

Returns
  • A long containing the time of the fix in milliseconds since January 1, 1970.

public void setAccuracy (float accuracy)

Sets the estimated accuracy of this location, in meters.

Parameters
accuracy the accuracy in meters

public void setAltitude (double altitude)

Sets the altitude, in meters above sea level.

Parameters
altitude the altitude in meters

public void setBearing (float bearing)

Sets the bearing, in degrees.

Parameters
bearing the bearing in degrees

public void setLatitude (double latitude)

Sets the latitude, in degrees.

Parameters
latitude the latitude in degrees. Must be between -90 and 90
Throws
IllegalArgumentException if the given latitude is invalid

public void setLongitude (double longitude)

Sets the longitude, in degrees.

Parameters
longitude the longitude in degrees. Must be between -180 and 180
Throws
IllegalArgumentException if the given longitude is invalid

public void setProvider (String provider)

Sets the name of the provider that generated this fix.

Parameters
provider the name of the provider

public void setSpeed (float speed)

Sets the speed, in meters/second over ground.

Parameters
speed the speedi in meters/second

public void setTime (long time)

Sets the UTC time of this fix, in milliseconds since January 1, 1970.

Parameters
time the time in milliseconds since January 1, 1970