mirror of
https://github.com/Schrolli91/BOSWatch.git
synced 2026-04-06 06:53:32 +00:00
Dedicated on/off switch for location coordinate finding functionality
This commit is contained in:
parent
1fc2980f6d
commit
a76e54211f
4 changed files with 37 additions and 29 deletions
|
|
@ -163,7 +163,8 @@ def decode(freq, decoded):
|
|||
data["lon"] = lon
|
||||
data["lat"] = lat
|
||||
else:
|
||||
locationCoordinates.findCoordinates(data)
|
||||
if globalVars.config.getboolean("LocationCoordinates", "locationCoordinates"):
|
||||
locationCoordinates.findCoordinates(data)
|
||||
|
||||
# Add function as character a-d to dataset
|
||||
data["functionChar"] = data["function"].replace("1", "a").replace("2", "b").replace("3", "c").replace("4", "d")
|
||||
|
|
|
|||
|
|
@ -20,28 +20,27 @@ filterList = []
|
|||
|
||||
def loadFilters():
|
||||
try:
|
||||
if globalVars.config.has_section("LocationCoordinates"):
|
||||
logging.debug("Loading location coordinates")
|
||||
|
||||
for key,val in globalVars.config.items("LocationCoordinates"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
filterData = val.split(";")
|
||||
|
||||
# at least 3 items needed (field1;pattern1;lat,lon), and in any case an uneven count of items
|
||||
if len(filterData) < 3 and len(filterData) % 2 == 0:
|
||||
logging.debug("Invalid argument count; skipping")
|
||||
else:
|
||||
# first store all regular expressions in list
|
||||
filterItem = []
|
||||
i = 0
|
||||
logging.debug("Loading location coordinates")
|
||||
|
||||
for key,val in globalVars.config.items("LocationCoordinates"):
|
||||
logging.debug(" - %s = %s", key, val)
|
||||
filterData = val.split(";")
|
||||
|
||||
# at least 3 items needed (field1;pattern1;lat,lon), and in any case an uneven count of items
|
||||
if len(filterData) < 3 and len(filterData) % 2 == 0:
|
||||
logging.debug("Invalid argument count; skipping")
|
||||
else:
|
||||
# first store all regular expressions in list
|
||||
filterItem = []
|
||||
i = 0
|
||||
|
||||
while i < len(filterData) - 2:
|
||||
filterItem.append({"field": filterData[i], "pattern": filterData[i+1]})
|
||||
|
||||
while i < len(filterData) - 2:
|
||||
filterItem.append({"field": filterData[i], "pattern": filterData[i+1]})
|
||||
|
||||
# step to next field
|
||||
i += 2
|
||||
# then transfer to filterList; include coordinates
|
||||
filterList.append({"name": key, "filterItem": filterItem, "coordinates": filterData[len(filterData) - 1]})
|
||||
# step to next field
|
||||
i += 2
|
||||
# then transfer to filterList; include coordinates
|
||||
filterList.append({"name": key, "filterItem": filterItem, "coordinates": filterData[len(filterData) - 1]})
|
||||
except:
|
||||
logging.error("cannot read config file")
|
||||
logging.debug("cannot read config file", exc_info=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue