openrvdas.logger.transforms.geofence_transform
Read lat/lon from passed records and compare to a geofence loaded at initialization time. Emit pre-defined messages if lat/lon transition between inside and outside of fence.
EEZ files in GML format can be downloaded from https://marineregions.org/eezsearch.php
Sample logger that switches modes when entering/exiting EEZ:
# Read parsed DASRecords from UDP
readers:
class: UDPReader
kwargs:
port: 6224
# Look for lat/lon values in the DASRecords and emit appropriate commands
# when entering/leaving EEZ. Note that EEZ files in GML format can be
# downloaded from https://marineregions.org/eezsearch.php.
transforms:
- class: GeofenceTransform
module: logger.transforms.geofence_transform
kwargs:
latitude_field_name: s330Latitude,
longitude_field_name: s330Longitude
boundary_file_name: /tmp/eez.gml
leaving_boundary_message: set_active_mode write+influx
entering_boundary_message: set_active_mode no_write+influx
# Send the messages that we get from geofence to the LoggerManager
writers:
- class: LoggerManagerWriter
module: logger.writers.logger_manager_writer
kwargs:
database: django
allowed_prefixes:
- 'set_active_mode '
- 'sleep '
Some questions:
- Should messages be emitted when first record is received? That is, when transform first fires up, should it send the "entering_boundary_message" if the first record it receives indicates it's inside? DECISION: Yes.
NOTE: optional parameter distance_from_boundary is in degrees. Computing the appropriate value in km/nm is nontrivial and requires figuring out the right UTM projection for each location and recomputing it for each point and switching when lat/lon moved to a new UTM projection area, possibly resulting in discontinuities. Simpler and less error-prone to just require degrees.
1#!/usr/bin/env python3 2"""Read lat/lon from passed records and compare to a geofence loaded at initialization 3time. Emit pre-defined messages if lat/lon transition between inside and outside of 4fence. 5 6EEZ files in GML format can be downloaded from https://marineregions.org/eezsearch.php 7 8Sample logger that switches modes when entering/exiting EEZ: 9``` 10# Read parsed DASRecords from UDP 11readers: 12 class: UDPReader 13 kwargs: 14 port: 6224 15# Look for lat/lon values in the DASRecords and emit appropriate commands 16# when entering/leaving EEZ. Note that EEZ files in GML format can be 17# downloaded from https://marineregions.org/eezsearch.php. 18transforms: 19 - class: GeofenceTransform 20 module: logger.transforms.geofence_transform 21 kwargs: 22 latitude_field_name: s330Latitude, 23 longitude_field_name: s330Longitude 24 boundary_file_name: /tmp/eez.gml 25 leaving_boundary_message: set_active_mode write+influx 26 entering_boundary_message: set_active_mode no_write+influx 27# Send the messages that we get from geofence to the LoggerManager 28writers: 29 - class: LoggerManagerWriter 30 module: logger.writers.logger_manager_writer 31 kwargs: 32 database: django 33 allowed_prefixes: 34 - 'set_active_mode ' 35 - 'sleep ' 36``` 37Some questions: 38- Should messages be emitted when first record is received? That is, when transform 39 first fires up, should it send the "entering_boundary_message" if the first record 40 it receives indicates it's inside? DECISION: Yes. 41 42NOTE: optional parameter distance_from_boundary is in degrees. Computing the appropriate 43value in km/nm is nontrivial and requires figuring out the right UTM projection for each 44location and recomputing it for each point and switching when lat/lon moved to a new UTM 45projection area, possibly resulting in discontinuities. Simpler and less error-prone 46to just require degrees. 47""" 48import logging 49import os 50import time 51 52from typing import Union 53from logger.utils.das_record import DASRecord # noqa: E402 54from logger.transforms.transform import Transform # noqa: E402 55 56# Load the transform-specific packages we need 57import_errors = False 58try: 59 import geopandas as gpd 60except ImportError: 61 import_errors = True 62try: 63 from shapely.geometry import Point 64except ImportError: 65 import_errors = True 66 67# Exported so that callers and tests can check whether geofencing is 68# available without having to import geopandas/shapely themselves. 69GEOFENCE_ENABLED = not import_errors 70 71import_pandas_errors = False 72try: 73 import pandas as pd 74except ImportError: 75 import_pandas_errors = True 76 77 78################################################################################ 79class GeofenceTransform(Transform): 80 """Class that reads lat/lon from passed records and compare to a geofence loaded at 81 initialization time. Emit pre-defined messages if lat/lon transition between inside 82 and outside of fence. 83 """ 84 def __init__(self, 85 latitude_field_name, 86 longitude_field_name, 87 boundary_file_name=None, 88 boundary_dir_name=None, 89 distance_from_boundary_in_degrees=0, 90 leaving_boundary_message=None, 91 entering_boundary_message=None, 92 seconds_between_checks=0, 93 **kwargs): 94 """ 95 latitude_field_name 96 longitude_field_name 97 Field names to read for lat/lon values.# what fields to listen 98 to for lat/lon values. Format is assumed to be decimal, with 99 negative values representing south latitude and west longitude. 100 101 boundary_file_name 102 Path to file from which to load GML boundary definition.. 103 104 boundary_dir_name 105 Path to directory from which to load multiple GML boundary definitions. 106 107 distance_from_boundary_in_degrees 108 Optional distance from boundary to place the fence, in degrees. 109 Negative means inside the boundary. 110 111 leaving_boundary_message 112 Optional message to emit when boundary is crossed, outbound 113 entering_boundary_message, 114 Optional message to emit when boundary is crossed, inbound 115 116 seconds_between_checks 117 Optional number of seconds to wait between doing checks, 118 computation overhead 119 """ 120 # Only throw this error if user tries to actually use this code 121 if import_errors: 122 raise ImportError('GeofenceTransform requires installation of geopandas and ' 123 'shapely packages. Please run "pip install \'.[geofence]\'" ' 124 '(or "pip install geopandas shapely") and retry.') 125 126 super().__init__(**kwargs) # processes 'quiet' and type hints 127 128 self.latitude_field_name = latitude_field_name 129 self.longitude_field_name = longitude_field_name 130 self.leaving_boundary_message = leaving_boundary_message 131 self.entering_boundary_message = entering_boundary_message 132 self.seconds_between_checks = seconds_between_checks 133 134 # Once we start receiving data, this will either be True or False 135 self.last_position_inside = None 136 137 self.last_check = 0 # timestamp: the last time we checked 138 139 if (boundary_file_name and boundary_dir_name 140 or not (boundary_file_name or boundary_dir_name)): 141 raise ValueError('Please specify a boundary_file_name OR a boundary_dir_name ' 142 'containing multiple gml files.') 143 144 eez_data = None 145 146 if boundary_file_name: 147 # Load the EEZ data from the GML file 148 eez_data = gpd.read_file(boundary_file_name) 149 150 if boundary_dir_name: 151 if import_pandas_errors: 152 raise ImportError('GeofenceTransform using "boundary_dir_name" requires ' 153 'installation of the pandas packages. Please run "pip ' 154 'install pandas" and retry.') 155 156 # List all GML files in the directory 157 gml_files = [os.path.join(boundary_dir_name, file) 158 for file in os.listdir(boundary_dir_name) 159 if file.endswith('.gml')] 160 161 # Initialize an empty list to store GeoDataFrames 162 dfs = [] 163 164 # Read each GML file into a GeoDataFrame and store it in the list 165 for gml in gml_files: 166 dfs.append(gpd.read_file(gml)) 167 168 # Combine all GeoDataFrames into a single GeoDataFrame 169 combined_gdf = gpd.GeoDataFrame(pd.concat(dfs, ignore_index=True), crs=dfs[0].crs) 170 171 # Combine all polygons into a single polygon 172 # Handle deprecation of unary_union in newer geopandas/shapely versions 173 try: 174 union_polygon = combined_gdf.union_all() 175 except AttributeError: 176 # Fallback for older versions 177 union_polygon = combined_gdf.unary_union 178 179 # Convert the union polygon into a GeoDataFrame 180 eez_data = gpd.GeoDataFrame(geometry=[union_polygon]) 181 182 # Buffer the country's EEZ by distance in degrees 183 self.buffered_eez = eez_data.buffer(distance_from_boundary_in_degrees) 184 185 ############################ 186 def _get_lat_lon(self, record: Union[DASRecord, dict]): 187 """If the DASRecord or dict contains a lat/lon pair, return it as a tuple, 188 otherwise return (None, None).""" 189 190 if type(record) is dict: 191 # Is it a simple dict with lat/lon defined at the top level? 192 lat = record.get(self.latitude_field_name, None) 193 lon = record.get(self.longitude_field_name, None) 194 if lat is not None and lon is not None: 195 return (lat, lon) 196 197 # Is it a dict with a 'fields' subdict? 198 if record.get('fields') is not None: 199 lat = record['fields'].get(self.latitude_field_name, None) 200 lon = record['fields'].get(self.longitude_field_name, None) 201 if lat is not None and lon is not None: 202 return (lat, lon) 203 204 # No lat/lon pairs we can find in this dict 205 return (None, None) 206 207 # Maybe they've passed us a DASRecord 208 if type(record) is DASRecord: 209 lat = record.fields.get(self.latitude_field_name, None) 210 lon = record.fields.get(self.longitude_field_name, None) 211 if lat is not None and lon is not None: 212 return (lat, lon) 213 else: 214 return (None, None) 215 216 # Define a function to check if a point is within N nautical miles of the geofenced area 217 def _is_inside_boundary(self, lat, lon): 218 # Note that Point() takes longitude as first arg, not latitude 219 point = Point(lon, lat) 220 return self.buffered_eez.contains(point).any() 221 222 ############################ 223 def transform(self, record: Union[DASRecord, dict]): 224 """Look for the named lat/lon fields in the passed dict. If the previous 225 lat/lon pair was on one side of the geofence and this lat/lon pair is on 226 the other, return the appropriate string defined in either 227 leaving_boundary_message or entering_boundary_message. Otherwise, return 228 None. 229 230 record 231 A DASRecord, dict of {field_name: field_value} pairs, or a list of 232 DASRecords/dicts in which to look for the specified latitude_field_name 233 and longitude_field_name. 234 """ 235 # See if it's something we can process, and if not, try digesting 236 if not self.can_process_record(record): # BaseModule 237 return self.digest_record(record) # BaseModule 238 239 # If we've checked too recently, skip check. Note that because this decision 240 # is made for computational efficiency rather than data efficiency, it is made 241 # based on system time, not the timestamp of the record. 242 now = time.time() 243 time_since_last = now - self.last_check 244 if self.seconds_between_checks and time_since_last < self.seconds_between_checks: 245 logging.debug(f'Only {time_since_last} seconds since last GeofenceTransform check; ' 246 f'less than the {self.seconds_between_checks} required.') 247 return None 248 249 # Does this record have a lat/lon? 250 (lat, lon) = self._get_lat_lon(record) 251 if lat is None or lon is None: 252 return None 253 254 # We have a lat and lon, so we're going ahead and checking 255 self.last_check = now 256 257 is_inside = self._is_inside_boundary(lat, lon) 258 if is_inside == self.last_position_inside: 259 return None 260 261 self.last_position_inside = is_inside 262 if is_inside: 263 logging.info('GeofenceTransform entered boundary') 264 logging.info(f'Issuing message: {self.entering_boundary_message}') 265 return self.entering_boundary_message 266 else: 267 logging.info('GeofenceTransform exited boundary') 268 logging.info(f'Issuing message: {self.leaving_boundary_message}') 269 return self.leaving_boundary_message
80class GeofenceTransform(Transform): 81 """Class that reads lat/lon from passed records and compare to a geofence loaded at 82 initialization time. Emit pre-defined messages if lat/lon transition between inside 83 and outside of fence. 84 """ 85 def __init__(self, 86 latitude_field_name, 87 longitude_field_name, 88 boundary_file_name=None, 89 boundary_dir_name=None, 90 distance_from_boundary_in_degrees=0, 91 leaving_boundary_message=None, 92 entering_boundary_message=None, 93 seconds_between_checks=0, 94 **kwargs): 95 """ 96 latitude_field_name 97 longitude_field_name 98 Field names to read for lat/lon values.# what fields to listen 99 to for lat/lon values. Format is assumed to be decimal, with 100 negative values representing south latitude and west longitude. 101 102 boundary_file_name 103 Path to file from which to load GML boundary definition.. 104 105 boundary_dir_name 106 Path to directory from which to load multiple GML boundary definitions. 107 108 distance_from_boundary_in_degrees 109 Optional distance from boundary to place the fence, in degrees. 110 Negative means inside the boundary. 111 112 leaving_boundary_message 113 Optional message to emit when boundary is crossed, outbound 114 entering_boundary_message, 115 Optional message to emit when boundary is crossed, inbound 116 117 seconds_between_checks 118 Optional number of seconds to wait between doing checks, 119 computation overhead 120 """ 121 # Only throw this error if user tries to actually use this code 122 if import_errors: 123 raise ImportError('GeofenceTransform requires installation of geopandas and ' 124 'shapely packages. Please run "pip install \'.[geofence]\'" ' 125 '(or "pip install geopandas shapely") and retry.') 126 127 super().__init__(**kwargs) # processes 'quiet' and type hints 128 129 self.latitude_field_name = latitude_field_name 130 self.longitude_field_name = longitude_field_name 131 self.leaving_boundary_message = leaving_boundary_message 132 self.entering_boundary_message = entering_boundary_message 133 self.seconds_between_checks = seconds_between_checks 134 135 # Once we start receiving data, this will either be True or False 136 self.last_position_inside = None 137 138 self.last_check = 0 # timestamp: the last time we checked 139 140 if (boundary_file_name and boundary_dir_name 141 or not (boundary_file_name or boundary_dir_name)): 142 raise ValueError('Please specify a boundary_file_name OR a boundary_dir_name ' 143 'containing multiple gml files.') 144 145 eez_data = None 146 147 if boundary_file_name: 148 # Load the EEZ data from the GML file 149 eez_data = gpd.read_file(boundary_file_name) 150 151 if boundary_dir_name: 152 if import_pandas_errors: 153 raise ImportError('GeofenceTransform using "boundary_dir_name" requires ' 154 'installation of the pandas packages. Please run "pip ' 155 'install pandas" and retry.') 156 157 # List all GML files in the directory 158 gml_files = [os.path.join(boundary_dir_name, file) 159 for file in os.listdir(boundary_dir_name) 160 if file.endswith('.gml')] 161 162 # Initialize an empty list to store GeoDataFrames 163 dfs = [] 164 165 # Read each GML file into a GeoDataFrame and store it in the list 166 for gml in gml_files: 167 dfs.append(gpd.read_file(gml)) 168 169 # Combine all GeoDataFrames into a single GeoDataFrame 170 combined_gdf = gpd.GeoDataFrame(pd.concat(dfs, ignore_index=True), crs=dfs[0].crs) 171 172 # Combine all polygons into a single polygon 173 # Handle deprecation of unary_union in newer geopandas/shapely versions 174 try: 175 union_polygon = combined_gdf.union_all() 176 except AttributeError: 177 # Fallback for older versions 178 union_polygon = combined_gdf.unary_union 179 180 # Convert the union polygon into a GeoDataFrame 181 eez_data = gpd.GeoDataFrame(geometry=[union_polygon]) 182 183 # Buffer the country's EEZ by distance in degrees 184 self.buffered_eez = eez_data.buffer(distance_from_boundary_in_degrees) 185 186 ############################ 187 def _get_lat_lon(self, record: Union[DASRecord, dict]): 188 """If the DASRecord or dict contains a lat/lon pair, return it as a tuple, 189 otherwise return (None, None).""" 190 191 if type(record) is dict: 192 # Is it a simple dict with lat/lon defined at the top level? 193 lat = record.get(self.latitude_field_name, None) 194 lon = record.get(self.longitude_field_name, None) 195 if lat is not None and lon is not None: 196 return (lat, lon) 197 198 # Is it a dict with a 'fields' subdict? 199 if record.get('fields') is not None: 200 lat = record['fields'].get(self.latitude_field_name, None) 201 lon = record['fields'].get(self.longitude_field_name, None) 202 if lat is not None and lon is not None: 203 return (lat, lon) 204 205 # No lat/lon pairs we can find in this dict 206 return (None, None) 207 208 # Maybe they've passed us a DASRecord 209 if type(record) is DASRecord: 210 lat = record.fields.get(self.latitude_field_name, None) 211 lon = record.fields.get(self.longitude_field_name, None) 212 if lat is not None and lon is not None: 213 return (lat, lon) 214 else: 215 return (None, None) 216 217 # Define a function to check if a point is within N nautical miles of the geofenced area 218 def _is_inside_boundary(self, lat, lon): 219 # Note that Point() takes longitude as first arg, not latitude 220 point = Point(lon, lat) 221 return self.buffered_eez.contains(point).any() 222 223 ############################ 224 def transform(self, record: Union[DASRecord, dict]): 225 """Look for the named lat/lon fields in the passed dict. If the previous 226 lat/lon pair was on one side of the geofence and this lat/lon pair is on 227 the other, return the appropriate string defined in either 228 leaving_boundary_message or entering_boundary_message. Otherwise, return 229 None. 230 231 record 232 A DASRecord, dict of {field_name: field_value} pairs, or a list of 233 DASRecords/dicts in which to look for the specified latitude_field_name 234 and longitude_field_name. 235 """ 236 # See if it's something we can process, and if not, try digesting 237 if not self.can_process_record(record): # BaseModule 238 return self.digest_record(record) # BaseModule 239 240 # If we've checked too recently, skip check. Note that because this decision 241 # is made for computational efficiency rather than data efficiency, it is made 242 # based on system time, not the timestamp of the record. 243 now = time.time() 244 time_since_last = now - self.last_check 245 if self.seconds_between_checks and time_since_last < self.seconds_between_checks: 246 logging.debug(f'Only {time_since_last} seconds since last GeofenceTransform check; ' 247 f'less than the {self.seconds_between_checks} required.') 248 return None 249 250 # Does this record have a lat/lon? 251 (lat, lon) = self._get_lat_lon(record) 252 if lat is None or lon is None: 253 return None 254 255 # We have a lat and lon, so we're going ahead and checking 256 self.last_check = now 257 258 is_inside = self._is_inside_boundary(lat, lon) 259 if is_inside == self.last_position_inside: 260 return None 261 262 self.last_position_inside = is_inside 263 if is_inside: 264 logging.info('GeofenceTransform entered boundary') 265 logging.info(f'Issuing message: {self.entering_boundary_message}') 266 return self.entering_boundary_message 267 else: 268 logging.info('GeofenceTransform exited boundary') 269 logging.info(f'Issuing message: {self.leaving_boundary_message}') 270 return self.leaving_boundary_message
Class that reads lat/lon from passed records and compare to a geofence loaded at initialization time. Emit pre-defined messages if lat/lon transition between inside and outside of fence.
85 def __init__(self, 86 latitude_field_name, 87 longitude_field_name, 88 boundary_file_name=None, 89 boundary_dir_name=None, 90 distance_from_boundary_in_degrees=0, 91 leaving_boundary_message=None, 92 entering_boundary_message=None, 93 seconds_between_checks=0, 94 **kwargs): 95 """ 96 latitude_field_name 97 longitude_field_name 98 Field names to read for lat/lon values.# what fields to listen 99 to for lat/lon values. Format is assumed to be decimal, with 100 negative values representing south latitude and west longitude. 101 102 boundary_file_name 103 Path to file from which to load GML boundary definition.. 104 105 boundary_dir_name 106 Path to directory from which to load multiple GML boundary definitions. 107 108 distance_from_boundary_in_degrees 109 Optional distance from boundary to place the fence, in degrees. 110 Negative means inside the boundary. 111 112 leaving_boundary_message 113 Optional message to emit when boundary is crossed, outbound 114 entering_boundary_message, 115 Optional message to emit when boundary is crossed, inbound 116 117 seconds_between_checks 118 Optional number of seconds to wait between doing checks, 119 computation overhead 120 """ 121 # Only throw this error if user tries to actually use this code 122 if import_errors: 123 raise ImportError('GeofenceTransform requires installation of geopandas and ' 124 'shapely packages. Please run "pip install \'.[geofence]\'" ' 125 '(or "pip install geopandas shapely") and retry.') 126 127 super().__init__(**kwargs) # processes 'quiet' and type hints 128 129 self.latitude_field_name = latitude_field_name 130 self.longitude_field_name = longitude_field_name 131 self.leaving_boundary_message = leaving_boundary_message 132 self.entering_boundary_message = entering_boundary_message 133 self.seconds_between_checks = seconds_between_checks 134 135 # Once we start receiving data, this will either be True or False 136 self.last_position_inside = None 137 138 self.last_check = 0 # timestamp: the last time we checked 139 140 if (boundary_file_name and boundary_dir_name 141 or not (boundary_file_name or boundary_dir_name)): 142 raise ValueError('Please specify a boundary_file_name OR a boundary_dir_name ' 143 'containing multiple gml files.') 144 145 eez_data = None 146 147 if boundary_file_name: 148 # Load the EEZ data from the GML file 149 eez_data = gpd.read_file(boundary_file_name) 150 151 if boundary_dir_name: 152 if import_pandas_errors: 153 raise ImportError('GeofenceTransform using "boundary_dir_name" requires ' 154 'installation of the pandas packages. Please run "pip ' 155 'install pandas" and retry.') 156 157 # List all GML files in the directory 158 gml_files = [os.path.join(boundary_dir_name, file) 159 for file in os.listdir(boundary_dir_name) 160 if file.endswith('.gml')] 161 162 # Initialize an empty list to store GeoDataFrames 163 dfs = [] 164 165 # Read each GML file into a GeoDataFrame and store it in the list 166 for gml in gml_files: 167 dfs.append(gpd.read_file(gml)) 168 169 # Combine all GeoDataFrames into a single GeoDataFrame 170 combined_gdf = gpd.GeoDataFrame(pd.concat(dfs, ignore_index=True), crs=dfs[0].crs) 171 172 # Combine all polygons into a single polygon 173 # Handle deprecation of unary_union in newer geopandas/shapely versions 174 try: 175 union_polygon = combined_gdf.union_all() 176 except AttributeError: 177 # Fallback for older versions 178 union_polygon = combined_gdf.unary_union 179 180 # Convert the union polygon into a GeoDataFrame 181 eez_data = gpd.GeoDataFrame(geometry=[union_polygon]) 182 183 # Buffer the country's EEZ by distance in degrees 184 self.buffered_eez = eez_data.buffer(distance_from_boundary_in_degrees)
latitude_field_name longitude_field_name Field names to read for lat/lon values.# what fields to listen to for lat/lon values. Format is assumed to be decimal, with negative values representing south latitude and west longitude.
boundary_file_name Path to file from which to load GML boundary definition..
boundary_dir_name Path to directory from which to load multiple GML boundary definitions.
distance_from_boundary_in_degrees Optional distance from boundary to place the fence, in degrees. Negative means inside the boundary.
leaving_boundary_message Optional message to emit when boundary is crossed, outbound entering_boundary_message, Optional message to emit when boundary is crossed, inbound
seconds_between_checks Optional number of seconds to wait between doing checks, computation overhead
224 def transform(self, record: Union[DASRecord, dict]): 225 """Look for the named lat/lon fields in the passed dict. If the previous 226 lat/lon pair was on one side of the geofence and this lat/lon pair is on 227 the other, return the appropriate string defined in either 228 leaving_boundary_message or entering_boundary_message. Otherwise, return 229 None. 230 231 record 232 A DASRecord, dict of {field_name: field_value} pairs, or a list of 233 DASRecords/dicts in which to look for the specified latitude_field_name 234 and longitude_field_name. 235 """ 236 # See if it's something we can process, and if not, try digesting 237 if not self.can_process_record(record): # BaseModule 238 return self.digest_record(record) # BaseModule 239 240 # If we've checked too recently, skip check. Note that because this decision 241 # is made for computational efficiency rather than data efficiency, it is made 242 # based on system time, not the timestamp of the record. 243 now = time.time() 244 time_since_last = now - self.last_check 245 if self.seconds_between_checks and time_since_last < self.seconds_between_checks: 246 logging.debug(f'Only {time_since_last} seconds since last GeofenceTransform check; ' 247 f'less than the {self.seconds_between_checks} required.') 248 return None 249 250 # Does this record have a lat/lon? 251 (lat, lon) = self._get_lat_lon(record) 252 if lat is None or lon is None: 253 return None 254 255 # We have a lat and lon, so we're going ahead and checking 256 self.last_check = now 257 258 is_inside = self._is_inside_boundary(lat, lon) 259 if is_inside == self.last_position_inside: 260 return None 261 262 self.last_position_inside = is_inside 263 if is_inside: 264 logging.info('GeofenceTransform entered boundary') 265 logging.info(f'Issuing message: {self.entering_boundary_message}') 266 return self.entering_boundary_message 267 else: 268 logging.info('GeofenceTransform exited boundary') 269 logging.info(f'Issuing message: {self.leaving_boundary_message}') 270 return self.leaving_boundary_message
Look for the named lat/lon fields in the passed dict. If the previous lat/lon pair was on one side of the geofence and this lat/lon pair is on the other, return the appropriate string defined in either leaving_boundary_message or entering_boundary_message. Otherwise, return None.
record A DASRecord, dict of {field_name: field_value} pairs, or a list of DASRecords/dicts in which to look for the specified latitude_field_name and longitude_field_name.