From f380b808e1288c9fc5cf17d45d884d0e4f8a6b87 Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 12 Jun 2012 01:59:03 +0200 Subject: [PATCH] remove geomap builder --- bat2geomap.py | 43 ------------------ geomapbuilder.py | 116 ----------------------------------------------- mkmap.sh | 2 - 3 files changed, 161 deletions(-) delete mode 100755 bat2geomap.py delete mode 100644 geomapbuilder.py diff --git a/bat2geomap.py b/bat2geomap.py deleted file mode 100755 index 873557b..0000000 --- a/bat2geomap.py +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -# TODO -# Gatewayliste -# aliases.json - -import json -import fileinput -import argparse - -from nodedb import NodeDB -from geomapbuilder import GeoMapBuilder - -parser = argparse.ArgumentParser() - -parser.add_argument('-a', '--aliases', - help='read aliases from FILE', - metavar='FILE') - -parser.add_argument('-g', '--gateway', action='append', - help='MAC of a gateway') - -parser.add_argument('batmanjson', help='output of batman vd json') - -args = parser.parse_args() - -options = vars(args) - -db = NodeDB() - -db.import_batman(list(fileinput.input(options['batmanjson']))) - -if options['aliases']: - db.import_aliases(json.load(open(options['aliases']))) - -if options['gateway']: - db.mark_gateways(options['gateway']) - -db.import_wikigps("http://freifunk.metameute.de/Knoten") - -m = GeoMapBuilder(db) - -print(m.build()) diff --git a/geomapbuilder.py b/geomapbuilder.py deleted file mode 100644 index 3557ecc..0000000 --- a/geomapbuilder.py +++ /dev/null @@ -1,116 +0,0 @@ -class GeoMapBuilder: - kml_template = """ - - - - - - - - %s - -""" - - def __init__(self, db): - self._db = db - - def build(self): - text = [] - - nodes = self._db.get_nodes() - - for node in nodes: - try: - text.append(GeoNode(node).render()) - except: - continue - - for link in self._db.get_links(): - if link.type == "vpn": - continue - - try: - text.append(GeoEdge(nodes, link).render()) - except: - continue - - return self.kml_template % "".join(text) - -def gps_format(s): - return ",".join(s.split(" ")[::-1]) - -class GeoNode: - kml_template = """ - %s - #router-%s - - %s,0 - - %s -""" - - def __init__(self, node): - self._node = node - - def render(self): - if not self._node.gps: - raise - - name = self._node.name - status = "up" if self._node.flags['online'] else "down" - gps = gps_format(self._node.gps) - text = " ".join(self._node.macs) - - return self.kml_template % (name, status, gps, text) - -class GeoEdge: - kml_template = """ - - %s,0. %s,0. - - #%s -""" - - def __init__(self, nodes, link): - self._link = link - self.pair = [nodes[k.id] for k in (link.source, link.target)] - - def render(self): - if not (self.pair[0].gps and self.pair[1].gps): - raise - - a = gps_format(self.pair[0].gps) - b = gps_format(self.pair[1].gps) - - return self.kml_template % (a, b, "wifi-link") diff --git a/mkmap.sh b/mkmap.sh index 6daafab..f43886c 100755 --- a/mkmap.sh +++ b/mkmap.sh @@ -18,8 +18,6 @@ if [ `cat /sys/class/net/bat0/mesh/gw_mode` = server ]; then fi batctl vd json | "$(dirname "$0")"/bat2nodes.py -a "$(dirname "$0")"/aliases.json $GWS - > $DEST/nodes.json.new -batctl vd json | "$(dirname "$0")"/bat2geomap.py -a "$(dirname "$0")"/aliases.json $GWS - > $DEST/geomap.kml.new mv $DEST/nodes.json.new $DEST/nodes.json -mv $DEST/geomap.kml.new $DEST/geomap.kml