Archived
1
0
Fork 0

erste Version

This commit is contained in:
Lukas Winkler 2016-05-31 14:06:15 +02:00
commit 2504513428
4 changed files with 1953 additions and 0 deletions

41
iterations.py Executable file
View file

@ -0,0 +1,41 @@
#!/usr/bin/python3
import itertools
import os
import re
from pprint import pprint
import MySQLdb
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="Findus", # your password
db="citybike") # name of the data base
cur = db.cursor()
cur.execute("SELECT lat, lon,ref FROM stationen ORDER BY ref DESC")
list = cur.fetchall()
i = 1
for way in itertools.combinations(list, 2):
# command = "routino-router --dir=/home/lukas/router/data" \
# " --lat1={}".format(way[0][0]) + \
# " --lon1={}".format(way[0][1]) + \
# " --lat2={}".format(way[1][0]) + \
# " --lon2={}".format(way[1][1]) + \
# " --quickest --transport=bicycle --output-text --output-gpx-track --quiet"
# success = os.system(command)
# if success == 0:
# os.rename("quickest-track.gpx", "file/" + str(i) + ".gpx")
# with open('quickest.txt') as f:
# lines = f.readlines()
# last = lines[-1]
# duration = re.findall("(\d+) min", last)[1]
# length = re.findall("(\d+\.\d+) km", last)[1]
# length = re.findall("(\d+\.\d+) km", last)[1]
# cur.execute("REPLACE INTO connections (id, start, goal, length, duration) VALUES (%s,%s,%s,%s,%s)",
# (i, way[0][2], way[1][2], length, duration))
# db.commit()
print(i)
i += 1
db.commit()

21
quickest.txt Normal file
View file

@ -0,0 +1,21 @@
# Creator : Routino - http://www.routino.org/
# Source : Based on OpenStreetMap data from http://www.openstreetmap.org/
# License : http://www.openstreetmap.org/copyright
#
#Latitude Longitude Section Section Total Total Point Turn Bearing Highway
# Distance Duration Distance Duration Type
48.209571 16.366047 0.000 km 0.0 min 0.0 km 0 min Waypt#1 -3 (null)
48.209503 16.365879 0.014 km 0.0 min 0.0 km 0 min Junct -1 -4 (null)
48.208199 16.366503 0.150 km 0.4 min 0.2 km 0 min Junct -1 +2 (null)
48.207799 16.366741 0.057 km 0.2 min 0.2 km 1 min Junct +0 +3 (null)
48.207410 16.367038 0.048 km 0.1 min 0.3 km 1 min Junct -1 +2 (null)
48.209774 16.370167 0.400 km 1.2 min 0.7 km 2 min Junct +0 -1 (null)
48.210116 16.369914 0.042 km 0.1 min 0.7 km 2 min Junct +2 +2 (null)
48.210252 16.370551 0.048 km 0.1 min 0.8 km 2 min Junct +1 +3 (null)
48.209646 16.373491 0.278 km 0.8 min 1.0 km 3 min Junct +2 +3 (null)
48.208029 16.377449 0.341 km 1.0 min 1.4 km 4 min Junct +2 -3 (null)
48.207623 16.377132 0.049 km 0.1 min 1.4 km 4 min Junct +2 -1 (null)
48.208112 16.375944 0.102 km 0.3 min 1.5 km 5 min Junct +0 -2 (null)
48.208407 16.374831 0.088 km 0.3 min 1.6 km 5 min Junct +0 -1 (null)
48.208629 16.374032 0.061 km 0.2 min 1.7 km 5 min Junct -1 -3 (null)
48.208546 16.374092 0.036 km 0.1 min 1.7 km 5 min Waypt#2

1859
stations.json Normal file

File diff suppressed because it is too large Load diff

32
test.py Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/python3
import json
import sys
from pprint import pprint
import MySQLdb
try:
db = MySQLdb.connect(host="localhost", # your host, usually localhost
user="root", # your username
passwd="Findus", # your password
db="citybike") # name of the data base
cur = db.cursor()
with open('stations.json') as data_file:
data = json.load(data_file)
for station in data["elements"]:
if station["type"] == "node":
tags=station["tags"]
cur.execute("INSERT INTO stationen (ref, lon, lat, name) VALUES (%s,%s,%s,%s)", (tags["ref"], station["lon"], station["lat"], tags["name"]))
print(tags["name"])
print("Commiting")
db.commit()
db.close()
except MySQLdb.Error as e:
print("Error %d: %s" % (e.args[0], e.args[1]))
sys.exit(1)