From 6efd0bda59730bf97da367ef7d7c7093ec69b0df Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Fri, 30 Nov 2018 18:33:02 +0100 Subject: [PATCH] api/alfred: Only use single hood for V1 This removes code to evaluate the position of a V1 router. Distinction between Default and NoCoordinates is dropped. Signed-off-by: Adrian Schmutzler --- ffmap/db/hoods.py | 2 +- ffmap/routertools.py | 29 ++--------------------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/ffmap/db/hoods.py b/ffmap/db/hoods.py index 7376c70..1c65750 100755 --- a/ffmap/db/hoods.py +++ b/ffmap/db/hoods.py @@ -33,7 +33,7 @@ mysql.execute(""" mysql.execute(""" INSERT INTO hoods (id, name) VALUES (%s, %s) -""",(10000,NoCoordinates,)) +""",(10100,Legacy,)) mysql.execute(""" CREATE TABLE `hoodsv1` ( diff --git a/ffmap/routertools.py b/ffmap/routertools.py index d3ee10a..229dbbc 100644 --- a/ffmap/routertools.py +++ b/ffmap/routertools.py @@ -105,34 +105,9 @@ def import_nodewatcher_xml(mysql, mac, xml, banned, hoodsv2, netifdict, hoodsdic if router_update["hood"] == "": router_update["hood"] = "NoHood" if not router_update["hood"]: - # router didn't send his hood in XML - lat = router_update.get("lat") - lng = router_update.get("lng") - #if olddata and not lat and not lng: - # # hoods might change as well - # lat = olddata.get("lat") - # lng = olddata.get("lng") - if lat and lng: - router_update["hood"] = mysql.findone(""" - SELECT name, - ( acos( cos( radians(%s) ) - * cos_lat - * cos( radians( lng ) - radians(%s) ) - + sin( radians(%s) ) * sin_lat - ) - ) AS distance - FROM - hoodsv1 - WHERE lat IS NOT NULL AND lng IS NOT NULL - ORDER BY - distance ASC - LIMIT 1 - """,(lat,lng,lat,),"name") + # V1 Router + router_update["hood"] = "Legacy" - if not router_update["hood"]: - router_update["hood"] = "DefaultV1" - if router_update["neighbours"] and not router_update["has_wan_uplink"]: - router_update["hood"] = "NoCoordinates" if not router_update['lat'] and not router_update['lng'] and olddata and olddata['lat'] and olddata['lng']: # Enable reset state; do before variable fallback reset = True