Permalink
Browse files
update graph_to_kml to render from the paths table
- Loading branch information...
Showing
with
4 additions
and
6 deletions.
-
+1
−1
graph_reduction.txt
-
+3
−5
graph_to_kml.py
|
@@ -102,4 +102,4 @@ python add_linestrings.py traingraph |
|
|
|
|
|
10) Output as KML
|
|
|
|
|
|
-python graph_to_kml.py > railways.kml
|
|
|
+python graph_to_kml.py traingraph > railways.kml
|
|
|
@@ -1,8 +1,9 @@ |
|
|
+from sys import argv
|
|
|
import psycopg2
|
|
|
import random
|
|
|
from xml.sax import saxutils
|
|
|
|
|
|
-conn = psycopg2.connect("dbname=traingraph user=postgres")
|
|
|
+conn = psycopg2.connect("dbname=%s user=postgres" % argv[1])
|
|
|
cur = conn.cursor()
|
|
|
|
|
|
COLOURS = ['ff0000', '00ff00', '0000ff', 'ffff00', 'ff00ff', '00ffff']
|
|
@@ -22,11 +23,8 @@ |
|
|
|
|
|
# extract railway lines
|
|
|
cur.execute('''
|
|
|
- -- SELECT ST_ASKML(ST_MAKELINE(node1.geom, node2.geom))
|
|
|
SELECT ST_ASKML(linestring)
|
|
|
- FROM rail_segments
|
|
|
- INNER JOIN nodes AS node1 ON (node1_id = node1.id)
|
|
|
- INNER JOIN nodes AS node2 ON (node2_id = node2.id)
|
|
|
+ FROM paths
|
|
|
''')
|
|
|
for (kml,) in cur:
|
|
|
print '<Placemark>%s<Style><LineStyle><width>2</width><color>ff%s</color></LineStyle></Style></Placemark>' % (kml, random.choice(COLOURS))
|
|
|
0 comments on commit
439e89a