2015-09-01 16:39:56 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
from pymongo import MongoClient
|
|
|
|
client = MongoClient()
|
|
|
|
|
|
|
|
db = client.freifunk
|
|
|
|
|
|
|
|
with open("csv/routers.csv", "w") as csv:
|
|
|
|
csv.write("lng,lat,status\n")
|
2015-09-03 16:44:05 +02:00
|
|
|
for router in db.routers.find({"position.coordinates": {"$exists": True}}):
|
2015-09-02 11:26:39 +02:00
|
|
|
csv.write("%f,%f,%s\n" % (
|
2015-09-03 00:13:52 +02:00
|
|
|
router["position"]["coordinates"][0],
|
|
|
|
router["position"]["coordinates"][1],
|
2015-09-02 11:26:39 +02:00
|
|
|
router.get("status", "unknown")
|
|
|
|
))
|
2015-09-01 16:39:56 +02:00
|
|
|
|
|
|
|
with open("csv/links.csv", "w") as csv:
|
|
|
|
csv.write("WKT,quality\n")
|
2015-09-03 16:44:05 +02:00
|
|
|
for router in db.routers.find({"position.coordinates": {"$exists": True}, "neighbours": {"$exists": True}}):
|
2015-09-01 16:39:56 +02:00
|
|
|
for neighbour in router["neighbours"]:
|
2015-09-03 00:13:52 +02:00
|
|
|
if "position" in neighbour:
|
2015-09-01 16:39:56 +02:00
|
|
|
csv.write("\"LINESTRING (%f %f,%f %f)\",%i\n" % (
|
2015-09-03 00:13:52 +02:00
|
|
|
router["position"]["coordinates"][0],
|
|
|
|
router["position"]["coordinates"][1],
|
|
|
|
neighbour["position"]["coordinates"][0],
|
|
|
|
neighbour["position"]["coordinates"][1],
|
2015-09-01 16:39:56 +02:00
|
|
|
neighbour["quality"]
|
|
|
|
))
|