Permalink
Browse files

update graph_to_kml to render from the paths table

  • Loading branch information...
gasman committed Oct 30, 2012
1 parent 4ee71af commit 439e89a3a494e10f6c9fb31be387a33f39d4c3a9
Showing with 4 additions and 6 deletions.
  1. +1 −1 graph_reduction.txt
  2. +3 −5 graph_to_kml.py
View
@@ -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
View
@@ -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

Please sign in to comment.