From: root Date: Tue, 27 Apr 2010 14:18:53 +0000 Subject: Convert to GeoRSS for nice popups X-Git-Url: http://maxious.lambdacomplex.org/git/?p=bus.git&a=commitdiff&h=9fc21293feea4a168499442e5c501cc9a0ed4e40 --- Convert to GeoRSS for nice popups --- --- a/display.php +++ b/display.php @@ -1,23 +1,8 @@ - --- /dev/null +++ b/displaystops.georss.php @@ -1,1 +1,43 @@ + +Bus Stops from OSM'; +$conn = pg_connect("dbname=openstreetmap user=postgres password=snmc"); +if (!$conn) { + echo "An error occured.\n"; + exit; +} +/*SELECT * from current_node_tags, (Select id FROM current_node_tags WHERE "v" LIKE '%bus%') as a +where a.id = current_node_tags.id; */ +$result_stops = pg_query($conn, "Select * FROM current_node_tags INNER JOIN current_nodes ON +current_node_tags.id=current_nodes.id WHERE v LIKE '%bus%' "); +if (!$result_stops) { + echo "An stops retirieve error occured.\n"; + exit; +} + +while ($stop = pg_fetch_assoc($result_stops)) { + echo "\n\n"; + echo ""; +$result_stopkeys = pg_query($conn, "SELECT * from current_node_tags where id = {$stop['id']};"); +if (!$result_stopkeys) { + echo "An stops keys retirieve error occured.\n"; + exit; +} +$name = ""; +while ($stopkeys = pg_fetch_assoc($result_stopkeys)) { +echo htmlspecialchars(print_r($stopkeys,true)); +$name .= htmlspecialchars($stopkeys['v']); +} +echo ""; + echo "$name"; + +echo " ";echo ($stop['latitude']/10000000)." ".($stop['longitude']/10000000); +echo " "; +echo ''; +} + +echo "\n\n"; +?> --- a/displaystops.kml.php +++ /dev/null @@ -1,58 +1,1 @@ - -'; -echo ''; -echo ''; -$conn = pg_connect("dbname=openstreetmap user=postgres password=snmc"); -if (!$conn) { - echo "An error occured.\n"; - exit; -} -/*SELECT * from current_node_tags, (Select id FROM current_node_tags WHERE "v" LIKE '%bus%') as a -where a.id = current_node_tags.id; */ -$result_stops = pg_query($conn, "Select * FROM current_node_tags INNER JOIN current_nodes ON -current_node_tags.id=current_nodes.id WHERE v LIKE '%bus%' "); -if (!$result_stops) { - echo "An stops retirieve error occured.\n"; - exit; -} - -while ($stop = pg_fetch_assoc($result_stops)) { - echo "\n\n"; - echo ""; -$result_stopkeys = pg_query($conn, "SELECT * from current_node_tags where id = {$stop['id']};"); -if (!$result_stopkeys) { - echo "An stops keys retirieve error occured.\n"; - exit; -} -$name = ""; -while ($stopkeys = pg_fetch_assoc($result_stopkeys)) { -echo htmlspecialchars(print_r($stopkeys,true)); -$name .= htmlspecialchars($stopkeys['v']); -} -echo ""; - echo "$name"; - -echo "#target"; -echo "\n "; - echo ($stop['longitude']/10000000).",".($stop['latitude']/10000000)."\n"; -echo " "; -echo ''; -} - -echo "\n\n"; -?> --- /dev/null +++ b/displaytimepoints.georss.php @@ -1,1 +1,26 @@ + '; +echo ' Points'; +$conn = pg_connect("dbname=bus user=postgres password=snmc"); +if (!$conn) { + echo "An error occured.\n"; + exit; +} +$result_timepoints = pg_query($conn, "Select * FROM timing_point where lat is not null and lng is not null "); +if (!$result_timepoints) { + echo "An timepoints retirieve error occured.\n"; + exit; +} + +while ($timepoint = pg_fetch_assoc($result_timepoints)) { + echo ""; + echo "".htmlspecialchars ($timepoint['name']).""; + echo "".htmlspecialchars($timepoint['name']).""; +echo " ".($timepoint['lat']/10000000)." ".($timepoint['lng']/10000000).""; +echo "\n"; +} + +echo "\n\n"; +?> --- a/displaytimepoints.kml.php +++ /dev/null @@ -1,58 +1,1 @@ - -'; -echo ''; -echo ''; -$conn = pg_connect("dbname=openstreetmap user=postgres password=snmc"); -if (!$conn) { - echo "An error occured.\n"; - exit; -} -/*SELECT * from current_node_tags, (Select id FROM current_node_tags WHERE "v" LIKE '%bus%') as a -where a.id = current_node_tags.id; */ -$result_stops = pg_query($conn, "Select * FROM current_node_tags INNER JOIN current_nodes ON -current_node_tags.id=current_nodes.id WHERE v LIKE '%bus%' "); -if (!$result_stops) { - echo "An stops retirieve error occured.\n"; - exit; -} - -while ($stop = pg_fetch_assoc($result_stops)) { - echo "\n\n"; - echo ""; -$result_stopkeys = pg_query($conn, "SELECT * from current_node_tags where id = {$stop['id']};"); -if (!$result_stopkeys) { - echo "An stops keys retirieve error occured.\n"; - exit; -} -$name = ""; -while ($stopkeys = pg_fetch_assoc($result_stopkeys)) { -echo htmlspecialchars(print_r($stopkeys,true)); -$name .= htmlspecialchars($stopkeys['v']); -} -echo ""; - echo "$name"; - -echo "#target"; -echo "\n "; - echo ($stop['longitude']/10000000).",".($stop['latitude']/10000000)."\n"; -echo " "; -echo ''; -} - -echo "\n\n"; -?> --- a/maxious-canberra-transit-feed/03-locatetimepoints.rb +++ b/maxious-canberra-transit-feed/03-locatetimepoints.rb @@ -51,7 +51,7 @@ if ask_if("Insert Timing Point names to database?") $time_points.each do |time_point| begin - time_point = time_point.gsub(/\\/, '\&\&').gsub(/'/, "''") + time_point = time_point.gsub(/\\/, '\&\&').gsub(/'/, "''").gsub("St", "%") res = connbus.exec("INSERT INTO timing_point (name) VALUES ('#{time_point}')") puts "Put '#{time_point}' into DB" rescue PGError => e @@ -140,11 +140,10 @@ nodeID = ask("Enter selected node ID:", :integer) if results['features'].at(nodeID) != nil node = results['features'][nodeID] - guess = ask_if("Is this a guess?") puts "Location #{node['centroid']['coordinates'][0]},#{node['centroid']['coordinates'][1]} for #{null_point_name}" begin res = connbus.exec("UPDATE timing_point SET lat = #{node['centroid']['coordinates'][0]*10000000}, lng = - #{node['centroid']['coordinates'][1]*10000000},guess = #{guess} WHERE name = '#{name}'") + #{node['centroid']['coordinates'][1]*10000000},guess = true WHERE name = '#{name}'") puts "Put '#{null_point_name}' into DB" rescue PGError => e puts "Error inserting '#{null_point_name}' to DB #{e}"