Update apps list in about page
[busui.git] / geo / route.kml.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
header('Content-Type: application/vnd.google-earth.kml+xml');
include ('../include/common.inc.php');
header('Content-Disposition: attachment; filename="route.' . urlencode($routeid) . '.kml"');
$debugOkay = Array(); // disable debugging output even on dev server
echo '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"><Document>';
echo '
     <Style id="ylw-pushpin">
    <IconStyle>
      <Icon>
        <href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>
        
      </Icon>
    </IconStyle>
    
  </Style>
          <Style id="blue-pushpin">
    <IconStyle>
      <Icon>
        <href>http://maps.google.com/mapfiles/kml/pushpin/blue-pushpin.png</href>
        
      </Icon>
    </IconStyle>
    
  </Style>
          <Style id="grn-pushpin">
    <IconStyle>
      <Icon>
        <href>http://maps.google.com/mapfiles/kml/pushpin/grn-pushpin.png</href>
        
      </Icon>
    </IconStyle>
  </Style>
    <Style id="yellowLineYellowPoly">
      <LineStyle>
        <color>7f00ebff</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>7f00ebff</color>
      </PolyStyle>
        </Style>
            <Style id="blueLineBluePoly">
      <LineStyle>
        <color>7fff0000</color>
        <width>4</width>
      </LineStyle>
      <PolyStyle>
        <color>7fff0000</color>
      </PolyStyle>
        </Style>
        ';
$route = getRoute($routeid);
echo "\n<Placemark>\n";
$_REQUEST['time'] = "12:00";
$trip = getRouteNextTrip($routeid, 0);
$link = curPageURL() . "/../trip.php?routeid=" . htmlspecialchars($route["route_id"]. "&directionid=0&tripid=".$trip['trip_id']) ;
echo "<name>" . $route['route_short_name'] . " Direction 0 </name>";
echo '<atom:link rel="related" href="' . $link . '"/>';
echo '<description><![CDATA[ <a href="' . $link . '">' . $route['route_short_name'] . " Direction 0</a>]]> </description>";
echo "<styleUrl>#yellowLineYellowPoly</styleUrl>";
 
echo getTripShape($trip['trip_id']);
    echo "</Placemark>\n";
$stops = Array();
foreach (getTripStops($trip['trip_id']) as $stop) {
    $stop['style'] = "#ylw-pushpin";
    $stops[$stop['stop_id']] = $stop;
}
 
 
echo "\n<Placemark>\n";
$trip = getRouteNextTrip($routeid, 1);
$link = curPageURL() . "/../trip.php?routeid=" . htmlspecialchars($route["route_id"]. "&directionid=1&tripid=".$trip['trip_id']) ;
echo "<name>" . $route['route_short_name'] . " Direction 1 </name>";
echo '<atom:link rel="related" href="' . $link . '"/>';
echo '<description><![CDATA[ <a href="' . $link . '">' . $route['route_short_name'] . " Direction 1</a>]]> </description>";
echo "<styleUrl>#blueLineBluePoly</styleUrl>";
 
echo getTripShape($trip['trip_id']);
    echo "</Placemark>\n";
foreach (getTripStops($trip['trip_id']) as $stop) {
    if (isset($stops[$stop['stop_id']])) {
        $stop['style'] = "#grn-pushpin";
    } else {
        $stop['style'] = "#blue-pushpin";
    }
    $stops[$stop['stop_id']] = $stop;
}
foreach ($stops as $stop) {
    echo "\n<Placemark>\n";
    $link = curPageURL() . '/../stop.php?stopid=' . htmlspecialchars($stop['stop_id']);
    echo "<name>" . htmlspecialchars($stop['stop_name']) . "</name>";
    echo '<atom:link rel="related" href="' . $link . '"/>';
    echo '<description><![CDATA[ <a href="' . $link . '">' . htmlspecialchars($stop['stop_name']) . "</a>]]> </description>";
    echo "<styleUrl>" . $stop['style'] . "</styleUrl>";
    echo $stop['positionkml'];
    echo "</Placemark>\n";
}
 
echo "</Document></kml>\n";
?>