public class CoordinateManager extends GenericService
| Modifier and Type | Class and Description |
|---|---|
protected class |
CoordinateManager.DistanceComparator
Compares two repository items to see which one is closer to the provided distance.
|
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected static double |
EARTH_RADIUS_METERS |
SERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
CoordinateManager() |
| Modifier and Type | Method and Description |
|---|---|
double |
addMetersToLatitude(Coordinate pCoordinate,
double pMeters)
Finds a latitude that is pMeters away from the given latitude.
|
double |
addMetersToLongitude(Coordinate pCoordinate,
double pMeters)
Finds a longitude that is pMeters away from the given longitude.
|
void |
doStartService()
Verify the default configuration a bit to ensure we aren't screwing anything up
|
protected RepositoryItem[] |
filterByDistance(RepositoryItem[] pItems,
Coordinate pCoordinate,
double pDistance)
Filter a set of items by distance to a given coordinate.
|
protected RepositoryItem[] |
filterByDistance(RepositoryItem[] pItems,
RepositoryItem pItem,
double pDistance)
Filter a set of items by distance to a given coordinate.
|
java.lang.String |
getCoordinateLatitudePropertyName() |
java.lang.String |
getCoordinateLongitudePropertyName() |
java.lang.String |
getCoordinatePropertyName() |
protected Query |
getCoordinateRadiusQuery(Coordinate pCoordinate,
double pRadius,
RepositoryView pView,
java.lang.String pItemCoordinatePropertyName,
java.util.Collection<java.lang.String> pSiteIds)
Gets a query for items specified by the provided view that are within a certain radius of
a given coordinate.
|
java.lang.String |
getDefaultItemType() |
static double |
getDistanceBetween(double lat1,
double lng1,
double lat2,
double lng2)
Gets the distance (in meters) between two points
|
double |
getDistanceBetweenCoordinates(Coordinate pCoordinate,
RepositoryItem pItem)
Gets the distance in meters between two coordinates
|
double |
getDistanceBetweenCoordinates(RepositoryItem pItem1,
RepositoryItem pItem2)
Gets the distance in meters between two coordinates.
|
java.lang.String |
getDistancePropertyName()
Name of a distance property where the results of distance calculation should be
set for any results of a getNearest call.
|
Coordinate |
getItemCoordinates(RepositoryItem pItem)
Creates a coordinate object from a given repository item
|
double |
getLatitude(RepositoryItem pItem)
Gets the latitude of the item either from the item itself or from the
child specified by coordinatePropertyName
|
double |
getLongitude(RepositoryItem pItem)
Gets the longitude of the item either from the item itself or from the
child specified by coordinatePropertyName
|
RepositoryItem[] |
getNearest(Coordinate pCoordinate,
double pRadius,
java.util.Collection<java.lang.String> pSiteIds)
Returns all items within a given distance from a coordinate, ordered by proximity
|
RepositoryItem[] |
getNearest(Coordinate pCoordinate,
double pRadius,
java.util.Collection<java.lang.String> pSiteIds,
java.lang.String pItemType)
Returns all items within a given distance from a coordinate, ordered by proximity
|
RepositoryItem[] |
getNearest(RepositoryItem pItem,
double pRadius,
java.util.Collection<java.lang.String> pSiteIds)
Returns all items within the given distance from a coordinate, ordered by proximity
|
RepositoryItem[] |
getNearest(RepositoryItem pItem,
double pRadius,
java.util.Collection<java.lang.String> pSiteIds,
java.lang.String pItemType)
Returns all items within a given distance from a coordinate, ordered by proximity
|
Repository |
getRepository() |
SiteGroupManager |
getSiteGroupManager() |
java.lang.String |
getSiteGroupsPropertyName() |
java.lang.String |
getSiteIdPropertyName() |
java.lang.String |
getSiteIdsPropertyName() |
protected Query |
getSiteQuery(RepositoryView pView,
java.util.Collection<java.lang.String> pSiteIds)
Constructs the site constraint portion of the query.
|
void |
setCoordinateLatitudePropertyName(java.lang.String pCoordinateLatitudePropertyName) |
void |
setCoordinateLongitudePropertyName(java.lang.String pCoordinateLongitudePropertyName) |
void |
setCoordinatePropertyName(java.lang.String pCoordinatePropertyName) |
void |
setDefaultItemType(java.lang.String pDefaultItemType) |
void |
setDistancePropertyName(java.lang.String pDistancePropertyName) |
void |
setRepository(Repository pRepository) |
void |
setSiteGroupManager(SiteGroupManager pSiteGroupManager) |
void |
setSiteGroupsPropertyName(java.lang.String pSiteGroupsPropertyName) |
void |
setSiteIdPropertyName(java.lang.String pSiteIdPropertyName) |
void |
setSiteIdsPropertyName(java.lang.String pSiteIdsPropertyName) |
addLogListener, clearAbsoluteNameAndContext, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, isStartServiceComplete, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService, toStringvlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningpublic static java.lang.String CLASS_VERSION
protected static final double EARTH_RADIUS_METERS
public SiteGroupManager getSiteGroupManager()
public void setSiteGroupManager(SiteGroupManager pSiteGroupManager)
pSiteGroupManager - the SiteGroupManager to setpublic java.lang.String getSiteIdPropertyName()
public void setSiteIdPropertyName(java.lang.String pSiteIdPropertyName)
pSiteIdPropertyName - the siteIdPropertyName to setpublic java.lang.String getSiteIdsPropertyName()
public void setSiteIdsPropertyName(java.lang.String pSiteIdsPropertyName)
pSiteIdsPropertyName - the siteIdsPropertyName to setpublic java.lang.String getSiteGroupsPropertyName()
public void setSiteGroupsPropertyName(java.lang.String pSiteGroupsPropertyName)
pSiteGroupsPropertyName - the siteGroupsPropertyName to setpublic java.lang.String getCoordinatePropertyName()
public void setCoordinatePropertyName(java.lang.String pCoordinatePropertyName)
pCoordinatePropertyName - the coordinatePropertyName to setpublic java.lang.String getDistancePropertyName()
public void setDistancePropertyName(java.lang.String pDistancePropertyName)
pDistancePropertyName - The name of the distance property to setpublic java.lang.String getDefaultItemType()
public void setDefaultItemType(java.lang.String pDefaultItemType)
pItemType - the defaultItemType to setpublic Repository getRepository()
public void setRepository(Repository pRepository)
pRepository - the repository to setpublic java.lang.String getCoordinateLatitudePropertyName()
public void setCoordinateLatitudePropertyName(java.lang.String pCoordinateLatitudePropertyName)
pCoordinateLatitudePropertyName - the name of the latitude property to setpublic java.lang.String getCoordinateLongitudePropertyName()
public void setCoordinateLongitudePropertyName(java.lang.String pCoordinateLongitudePropertyName)
pCoordinateLongitudePropertyName - the longitude property name to setpublic void doStartService()
throws ServiceException
doStartService in class GenericServiceServiceException - if the Service had a problem starting uppublic double getLatitude(RepositoryItem pItem)
pItem: - The item to get the latitude forpublic double getLongitude(RepositoryItem pItem)
pItem: - The item to get the longitude forpublic Coordinate getItemCoordinates(RepositoryItem pItem)
pItem - the item to create a coordinate forpublic RepositoryItem[] getNearest(RepositoryItem pItem, double pRadius, java.util.Collection<java.lang.String> pSiteIds) throws RepositoryException
pItem - The coordinate to search from as a repository itempRadius - The radius to search within (in meters)pSiteIds - Only return items belong to these site ids.RepositoryExceptionpublic RepositoryItem[] getNearest(RepositoryItem pItem, double pRadius, java.util.Collection<java.lang.String> pSiteIds, java.lang.String pItemType) throws RepositoryException
pItem - The coordinate to search from as a repository itempRadius - the distance to search for items in metersRepositoryExceptionpublic RepositoryItem[] getNearest(Coordinate pCoordinate, double pRadius, java.util.Collection<java.lang.String> pSiteIds) throws RepositoryException
pCoordinate - the coordinate to search frompRadius - the distance to search within in meterspSiteIds - Only return items for the given site ids.RepositoryExceptionpublic RepositoryItem[] getNearest(Coordinate pCoordinate, double pRadius, java.util.Collection<java.lang.String> pSiteIds, java.lang.String pItemType) throws RepositoryException
pCoordinate - the coordinate to search frompRadius - The distance to search within (in meters)pSiteIds - Only return items that belong to one of the given site idspItemType - The item descriptor to return results forRepositoryExceptionprotected RepositoryItem[] filterByDistance(RepositoryItem[] pItems, RepositoryItem pItem, double pDistance)
pItems - items to filterpItem - the center coordinate as a repository itempDistance - the distance to search for items (in meters)protected RepositoryItem[] filterByDistance(RepositoryItem[] pItems, Coordinate pCoordinate, double pDistance)
pItems - items to filterpCoordinate - the center coordinatepDistance - the distance to search for items (in meters)protected Query getCoordinateRadiusQuery(Coordinate pCoordinate, double pRadius, RepositoryView pView, java.lang.String pItemCoordinatePropertyName, java.util.Collection<java.lang.String> pSiteIds) throws RepositoryException
pCoordinate - The coordinate to search frompRadius - The distance to search forpView - The view specifying what item/repository this query will run againstpItemCoordinatePropertyName - The name of the coordinate property for the item type being searchedRepositoryExceptionprotected Query getSiteQuery(RepositoryView pView, java.util.Collection<java.lang.String> pSiteIds) throws RepositoryException
pView - the view to usepSiteIds - the siteIds to constrain by.RepositoryExceptionpublic double getDistanceBetweenCoordinates(RepositoryItem pItem1, RepositoryItem pItem2)
pItem1 - first item that contains a coordinatepItem2 - second item that contains a coordinatepublic double getDistanceBetweenCoordinates(Coordinate pCoordinate, RepositoryItem pItem)
pLatitude - latitude of the 1st coordinatepLongitude - longitude of the 1st coordinatepItem - item that contains a coordinatepublic double addMetersToLatitude(Coordinate pCoordinate, double pMeters)
pCoordinate - the starting coordinatepMeters - The distance to movepublic double addMetersToLongitude(Coordinate pCoordinate, double pMeters)
pCoordinate - the starting coordinatepMeters - The distance to movepublic static double getDistanceBetween(double lat1,
double lng1,
double lat2,
double lng2)
lat1 - latitude of point 1lng1 - longitude of point 1lat2 - latitude of point 2lng2 - longitude of point 2