class documentation

class LocationManager(object):

View In Hierarchy

The LocationManager class implements the location service and helper functions.

Method addLocationPolicy Add a location policy.
Method checkGeofence Check if a location is inside or outside the polygon of a location policy.
Method checkGeoLocation Check if a resource's location confirms to a geo location.
Method configure Configure the WebSocket server.
Method getGeoPolygon Get the geo-polygon from a geoJSON object. This is just a wrapper for the getGeoPolygon function in GeoTools.
Method getNewLocation Get the new location for a location policy. Also, update the internal policy info if necessary.
Method handleLatestRetrieve Handle a latest RETRIEVE request for a CNT with a location policy.
Method init Initialization of the LocationManager module.
Method locationWorker Worker function for location policies. This will be called periodically to update the location.
Method removeLocationPolicy Remove a location policy. This will stop the worker and remove the LCP from the internal list.
Method restart Restart the LocationManager.
Method stop Shutdown the LocationManager.
Method updateLocationEvent Update the location event for a location policy if the location has changed and/or the event criteria is met.
Method updateLocationPolicy Update a location policy. This will remove the old location policy and add a new one.
Class Variable __slots__ Slots for LocationManager class.
Class Variable dispatcher Injected IDispatcher instance.
Instance Variable deviceDefaultPosition The default position type for device-based location sources. This is used when the location information type is not set.
Instance Variable locationPolicyInfos A dictionary of location policy information, keyed by the location policy resource ID.
def addLocationPolicy(self, lcp: LCP):

Add a location policy.

Parameters
lcp:LCPThe location policy to add.
def checkGeofence(self, lcpRi: str, location: tuple[float, float]) -> GeofencePositionType:

Check if a location is inside or outside the polygon of a location policy.

Parameters
lcpRi:strThe resource ID of the location policy
location:tuple[float, float]The location to check
Returns
GeofencePositionTypeThe geofence position of the location. Either inside or outside.
def checkGeoLocation(self, r: Resource, gmty: GeometryType, geom: list, gsf: GeoSpatialFunctionType) -> bool:

Check if a resource's location confirms to a geo location.

Parameters
r:ResourceThe resource to check.
gmty:GeometryTypeThe geometry type.
geom:listThe geometry.
gsf:GeoSpatialFunctionTypeThe geo spatial function.
Returns
boolTrue if the resource's location confirms to the geo location, False otherwise.
def configure(self, config: Configuration):

Configure the WebSocket server.

Parameters
config:ConfigurationThe configuration object to update with the location manager configuration.
def getGeoPolygon(self, jsn: dict | str | None) -> list[tuple[float, float]] | None:

Get the geo-polygon from a geoJSON object. This is just a wrapper for the getGeoPolygon function in GeoTools.

Parameters
jsn:dict | str | NoneThe geoJSON object as a dictionary or a string.
Returns
list[tuple[float, float]] | NoneA list of tuples of the geo-polygon (latitude, longitude). None if not found.
def getNewLocation(self, lcpRi: str, content: str | None = None) -> tuple[LocationType, LocationType] | None:

Get the new location for a location policy. Also, update the internal policy info if necessary.

Parameters
lcpRi:strThe resource ID of the location policy
content:str | NoneThe content of the latest CIN of the location policy's container resource
Returns
tuple[LocationType, LocationType] | NoneThe new and old locations as a tuple of (latitude, longitude), or None if the location is invalid or not found
def handleLatestRetrieve(self, latest: CIN, lcpRi: str):

Handle a latest RETRIEVE request for a CNT with a location policy.

Parameters
latest:CINThe latest CIN
lcpRi:strThe location policy resource ID
def init(self):

Initialization of the LocationManager module.

def locationWorker(self, lcpRi: str) -> bool:

Worker function for location policies. This will be called periodically to update the location.

Parameters
lcpRi:strThe resource ID of the location policy
Returns
boolTrue if the worker should be continued, False otherwise.
def removeLocationPolicy(self, lcp: LCP):

Remove a location policy. This will stop the worker and remove the LCP from the internal list.

Parameters
lcp:LCPThe LCP to remove.
def restart(self):

Restart the LocationManager.

def stop(self) -> bool:

Shutdown the LocationManager.

Returns
boolBoolean that indicates the success of the operation
def updateLocationEvent(self, newLocation: LocationType, oldLocation: LocationType, lcpRi: str):

Update the location event for a location policy if the location has changed and/or the event criteria is met.

Parameters
newLocation:LocationTypeThe new location
oldLocation:LocationTypeThe old location
lcpRi:strThe resource ID of the location policy
def updateLocationPolicy(self, lcp: LCP):

Update a location policy. This will remove the old location policy and add a new one.

__slots__: tuple[str, ...] =

Slots for LocationManager class.

dispatcher: Dispatcher =

Injected IDispatcher instance.

deviceDefaultPosition: GeofencePositionType =

The default position type for device-based location sources. This is used when the location information type is not set.

locationPolicyInfos: dict[str, LocationInformation] =

A dictionary of location policy information, keyed by the location policy resource ID.