no.ubicollab.osgi
Class LocationImpl

java.lang.Object
  extended by no.ubicollab.osgi.LocationImpl
All Implemented Interfaces:
LocationService

public class LocationImpl
extends java.lang.Object
implements LocationService


Constructor Summary
LocationImpl(Activator activator)
           
LocationImpl(no.ubicollab.osgi.service.pocketdiscovery.PocketDiscoveryService discoveryService, Activator activator)
           
 
Method Summary
 boolean addLocation(java.lang.String locationName, double[] longitudes, double[] latitudes, int altitude)
          Adds a new location to the service's list of locations.
 java.lang.String getLocation(double longitude, double latitude)
          Returns the name of the location containing the position specified by the parameters, without considering altitude.
 java.lang.String getLocation(double longitude, double latitude, int altitude, int altitudeErrorMargin)
          Returns the name of the location containing the position specified by the parameters.
 boolean removeLocatoin(java.lang.String locationName)
          Removes a location from the service's list of locations.
 void saveLocationListToFile()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LocationImpl

public LocationImpl(Activator activator)

LocationImpl

public LocationImpl(no.ubicollab.osgi.service.pocketdiscovery.PocketDiscoveryService discoveryService,
                    Activator activator)
Method Detail

addLocation

public boolean addLocation(java.lang.String locationName,
                           double[] longitudes,
                           double[] latitudes,
                           int altitude)
Description copied from interface: LocationService
Adds a new location to the service's list of locations. Overrides the old location if locationName already exists.
The location has the shape of a polygon. The first latitude and the first longitude in the lists define the first point of the polygon etc. The two lists must therefore have the same length

Specified by:
addLocation in interface LocationService
Parameters:
locationName - Name of the new location
longitudes - List of longitudes (x-axis) expressed in decimal degrees. Max precision is 6 decimals. Use negative values for west
latitudes - List of latitudes (y-axis) expressed in decimal degrees. Max precision is 6 decimals. Use negative values on the southern hemisphere
Returns:
true
See Also:
Polygon

removeLocatoin

public boolean removeLocatoin(java.lang.String locationName)
Description copied from interface: LocationService
Removes a location from the service's list of locations. Does nothing if the locationName is not found

Specified by:
removeLocatoin in interface LocationService
Parameters:
locationName - Name of the location to remove
Returns:
true

getLocation

public java.lang.String getLocation(double longitude,
                                    double latitude,
                                    int altitude,
                                    int altitudeErrorMargin)
Description copied from interface: LocationService
Returns the name of the location containing the position specified by the parameters.
The first maching location is returned if the position is found in several locations.

Specified by:
getLocation in interface LocationService
Parameters:
longitude - Longitude of the position expressed in decimal degrees. Use negative values for west
latitude - Latitude of the position expressed in decimal degrees. Use negative values for south
altitude - Altitude of the position
altitudeErrorMargin - Allowed altitude error.
Location is returned if Math.abs(correctAltitude-altitude)<=altitudeErrorMargin;
Returns:
Name of the location containing the spesified position, or null if no location contains the position.
The first maching location is returned if the position is found in several locations.

getLocation

public java.lang.String getLocation(double longitude,
                                    double latitude)
Description copied from interface: LocationService
Returns the name of the location containing the position specified by the parameters, without considering altitude.
The first maching location is returned if the position is found in several locations.

Specified by:
getLocation in interface LocationService
Parameters:
longitude - Longitude of the position expressed in decimal degrees. Use negative values for west
latitude - Latitude of the position expressed in decimal degrees. Use negative values for south
Returns:
Name of the location containing the spesified position, or null if no location contains the position.
The first maching location is returned if the position is found in several locations.

saveLocationListToFile

public void saveLocationListToFile()