|
<?php |
|
header('Content-Type: application/xml'); |
|
echo '<?xml version="1.0" encoding="utf-8"?> |
|
<feed xmlns="http://www.w3.org/2005/Atom" |
|
xmlns:georss="http://www.georss.org/georss"><title>Bus Stops from OSM</title>'; |
|
$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<entry>\n"; |
|
echo "<summary>"; |
|
$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 "</summary>"; |
|
echo "<title>$name</title>"; |
|
|
|
echo "<georss:point> ";echo ($stop['latitude']/10000000)." ".($stop['longitude']/10000000); |
|
echo " </georss:point>"; |
|
echo '</entry>'; |
|
} |
|
|
|
echo "\n</feed>\n"; |
|
?> |
|
|