com.mymed.utils.locator
Class Locator

java.lang.Object
  extended by com.mymed.utils.locator.Locator

public class Locator
extends java.lang.Object

Expose the methods to handle the geographical identifiers.

Author:
iacopo

Constructor Summary
Locator()
           
 
Method Summary
static long getAreaId(long locationId)
          Gets the area Id corresponding to a certain location Id.
static java.util.List<long[]> getCoveringLocationId(double latitude, double longitude, int radius)
          Returns a list of location Id ranges, that cover the area defined by latitude longitude and radius.
static Location getLocationFromId(long locationId)
          Decode the location Id and returns the corresponding location (latitude and longitude in degrees).
static long getLocationId(double latitude, double longitude)
          Returns the location Id that corresponds to the specified position.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Locator

public Locator()
Method Detail

getLocationId

public static long getLocationId(double latitude,
                                 double longitude)
                          throws GeoLocationOutOfBoundException
Returns the location Id that corresponds to the specified position.

Parameters:
latitude - Latitude of the position.
longitude - Longitude of the position.
Returns:
Throws:
GeoLocationOutOfBoundException

getAreaId

public static long getAreaId(long locationId)
                      throws java.lang.IllegalArgumentException
Gets the area Id corresponding to a certain location Id.

Parameters:
locationId -
Returns:
Throws:
java.lang.IllegalArgumentException

getCoveringLocationId

public static java.util.List<long[]> getCoveringLocationId(double latitude,
                                                           double longitude,
                                                           int radius)
                                                    throws GeoLocationOutOfBoundException,
                                                           java.lang.IllegalArgumentException
Returns a list of location Id ranges, that cover the area defined by latitude longitude and radius.

Parameters:
latitude - Latitude of the center of the covered area. (degrees)
longitude - Longitude of the center of the covered area. (degrees)
radius - Diameter of the covered area (km)
Returns:
Throws:
GeoLocationOutOfBoundException - Center of the area is out of bounds.
java.lang.IllegalArgumentException - The radius exceeds the maximum size.

getLocationFromId

public static Location getLocationFromId(long locationId)
                                  throws java.lang.IllegalArgumentException,
                                         GeoLocationOutOfBoundException
Decode the location Id and returns the corresponding location (latitude and longitude in degrees).

Parameters:
locationId -
Returns:
Throws:
java.lang.IllegalArgumentException
GeoLocationOutOfBoundException