com.parse
Class ParseGeoPoint

Object
  extended by com.parse.ParseGeoPoint

public class ParseGeoPoint
extends Object

ParseGeoPoint represents a latitude / longitude point that may be associated with a key in a ParseObject or used as a reference point for geo queries. This allows proximity based queries on the key.

Only one key in a class may contain a GeoPoint.

Example: ParseGeoPoint point = new ParseGeoPoint(30.0, -20.0); ParseObject object = new ParseObject("PlaceObject"); object.put("location", point); object.save();


Constructor Summary
ParseGeoPoint()
          Creates a new default point with latitude and longitude set to 0.0.
ParseGeoPoint(double latitude, double longitude)
          Creates a new point with the specified latitude and longitude.
 
Method Summary
 double distanceInKilometersTo(ParseGeoPoint point)
          Get distance between this point and another geopoint in kilometers.
 double distanceInMilesTo(ParseGeoPoint point)
          Get distance between this point and another geopoint in kilometers.
 double distanceInRadiansTo(ParseGeoPoint point)
          Get distance in radians between this point and another GeoPoint.
static bolts.Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout)
          Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.
static bolts.Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout, Criteria criteria)
          Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.
static void getCurrentLocationInBackground(long timeout, Criteria criteria, LocationCallback callback)
          Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.
static void getCurrentLocationInBackground(long timeout, LocationCallback callback)
          Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.
 double getLatitude()
          Get latitude.
 double getLongitude()
          Get longitude.
 void setLatitude(double latitude)
          Set latitude.
 void setLongitude(double longitude)
          Set longitude.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParseGeoPoint

public ParseGeoPoint()
Creates a new default point with latitude and longitude set to 0.0.


ParseGeoPoint

public ParseGeoPoint(double latitude,
                     double longitude)
Creates a new point with the specified latitude and longitude.

Parameters:
latitude - The point's latitude.
longitude - The point's longitude.
Method Detail

setLatitude

public void setLatitude(double latitude)
Set latitude. Valid range is (-90.0, 90.0). Extremes should not be used.

Parameters:
latitude - The point's latitude.

getLatitude

public double getLatitude()
Get latitude.


setLongitude

public void setLongitude(double longitude)
Set longitude. Valid range is (-180.0, 180.0). Extremes should not be used.

Parameters:
longitude - The point's longitude.

getLongitude

public double getLongitude()
Get longitude.


distanceInRadiansTo

public double distanceInRadiansTo(ParseGeoPoint point)
Get distance in radians between this point and another GeoPoint. This is the smallest angular distance between the two points.

Parameters:
point - GeoPoint describing the other point being measured against.

distanceInKilometersTo

public double distanceInKilometersTo(ParseGeoPoint point)
Get distance between this point and another geopoint in kilometers.

Parameters:
point - GeoPoint describing the other point being measured against.

distanceInMilesTo

public double distanceInMilesTo(ParseGeoPoint point)
Get distance between this point and another geopoint in kilometers.

Parameters:
point - GeoPoint describing the other point being measured against.

getCurrentLocationInBackground

public static bolts.Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout)
Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback. Defaults to a Location Criteria with no accuracy or power requirements.

Parameters:
timeout - The number of milliseconds to allow before timing out.
Returns:
A Task that is resolved when a location is found.

getCurrentLocationInBackground

public static void getCurrentLocationInBackground(long timeout,
                                                  LocationCallback callback)
Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback. Defaults to a Location Criteria with no accuracy or power requirements.

Parameters:
timeout - The number of milliseconds to allow before timing out.
callback - callback.done(geoPoint, error) is called when a location is found.

getCurrentLocationInBackground

public static bolts.Task<ParseGeoPoint> getCurrentLocationInBackground(long timeout,
                                                                       Criteria criteria)
Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.

Parameters:
timeout - The number of milliseconds to allow before timing out.
criteria - The application criteria for selecting a location provider.
Returns:
A Task that is resolved when a location is found.

getCurrentLocationInBackground

public static void getCurrentLocationInBackground(long timeout,
                                                  Criteria criteria,
                                                  LocationCallback callback)
Fetches the user's current location and returns a new ParseGeoPoint via the provided LocationCallback.

Parameters:
timeout - The number of milliseconds to allow before timing out.
criteria - The application criteria for selecting a location provider.
callback - callback.done(geoPoint, error) is called when a location is found.