Add initial between point adding prototype
[bus.git] / displaystops.georss.php
blob:a/displaystops.georss.php -> blob:b/displaystops.georss.php
<?php <?php
header('Content-Type: application/xml'); header('Content-Type: application/xml');
echo '<?xml version="1.0" encoding="utf-8"?> echo '<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" <feed xmlns="http://www.w3.org/2005/Atom"
xmlns:georss="http://www.georss.org/georss"><title>Bus Stops from OSM</title>'; xmlns:georss="http://www.georss.org/georss"><title>Bus Stops from OSM</title>';
$conn = pg_connect("dbname=openstreetmap user=postgres password=snmc"); $conn = pg_connect("dbname=bus user=postgres password=snmc");
if (!$conn) { if (!$conn) {
echo "An error occured.\n"; echo "An error occured.\n";
exit; exit;
} }
/*SELECT * from current_node_tags, (Select id FROM current_node_tags WHERE "v" LIKE '%bus%') as a $result_stops = pg_query($conn, "Select * FROM stops ");
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) { if (!$result_stops) {
echo "An stops retirieve error occured.\n"; echo "An stops retirieve error occured.\n";
exit; exit;
} }
while ($stop = pg_fetch_assoc($result_stops)) { while ($stop = pg_fetch_assoc($result_stops)) {
echo "\n<entry>\n"; echo "\n<entry>\n";
echo "<summary>"; echo "<summary> {$stop['geohash']}</summary>";
$result_stopkeys = pg_query($conn, "SELECT * from current_node_tags where id = {$stop['id']};"); echo "<title>{$stop['geohash']}</title>";
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 ($stop['lat']/10000000)." ".($stop['lng']/10000000);
echo " </georss:point>"; echo " </georss:point>";
echo '</entry>'; echo '</entry>';
} }
echo "\n</feed>\n"; echo "\n</feed>\n";
?> ?>