Add initial between point adding prototype
[bus.git] / displaystops.georss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?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";
?>