From: maxious Date: Mon, 13 Jun 2011 00:56:10 +0000 Subject: Merge branch 'master' of github.com:maxious/ACTBus-ui X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=a558c41fb63013f2c7f208114807ff419ca6e46d --- Merge branch 'master' of github.com:maxious/ACTBus-ui --- --- /dev/null +++ b/geo/route.kml.php @@ -1,1 +1,30 @@ + +'; +echo ' + '; +$route = getRoute($routeid); + echo "\n\n"; + $link = curPageURL()."/../trip.php?routeid=".htmlspecialchars ($route["route_id"]); + echo "".$route['route_short_name'].""; + echo ''; + echo ''.$route['route_short_name']." ".$route['route_long_name']."]]> "; +echo "#yellowLineGreenPoly"; + $trips = getRouteTrips($routeid); + echo getTripShape($trips[0]['trip_id']); + +echo "\n\n"; +?> + + --- a/include/db/route-dao.inc.php +++ b/include/db/route-dao.inc.php @@ -13,6 +13,7 @@ } return $query->fetch(PDO::FETCH_ASSOC); } + function getRoutes() { global $conn; --- a/include/db/trip-dao.inc.php +++ b/include/db/trip-dao.inc.php @@ -16,40 +16,25 @@ } return $query->fetch(PDO::FETCH_ASSOC); } -function getTripShape() -{ - /* def handle_json_GET_tripstopTimes(self, params): - schedule = self.server.schedule - try: - trip = schedule.GetTrip(params.get('trip')) - except KeyError: - # if a non-existent trip is searched for, the return nothing - return - time_stops = trip.GetTimeInterpolatedStops() - stops = [] - times = [] - for arr,ts,is_timingpoint in time_stops: - stops.append(StopToTuple(ts.stop)) - times.append(arr) - return [stops, times] - - def handle_json_GET_tripshape(self, params): - schedule = self.server.schedule - try: - trip = schedule.GetTrip(params.get('trip')) - except KeyError: - # if a non-existent trip is searched for, the return nothing - return - points = [] - if trip.shape_id: - shape = schedule.GetShape(trip.shape_id) - for (lat, lon, dist) in shape.points: - points.append((lat, lon)) - else: - time_stops = trip.GetTimeStops() - for arr,dep,stop in time_stops: - points.append((stop.stop_lat, stop.stop_lon)) - return points*/ +function getTripShape($tripID) +{ + global $conn; + $query = "SELECT ST_AsKML(ST_MakeLine(geometry(a.position))) as the_route +FROM (SELECT position, + stop_sequence, trips.trip_id +FROM stop_times +join trips on trips.trip_id = stop_times.trip_id +join stops on stops.stop_id = stop_times.stop_id +WHERE trips.trip_id = :tripID ORDER BY stop_sequence) as a group by a.trip_id"; + debug($query, "database"); + $query = $conn->prepare($query); + $query->bindParam(":tripID", $tripID); + $query->execute(); + if (!$query) { + databaseError($conn->errorInfo()); + return Array(); + } + return $query->fetchColumn(0); } function getTimeInterpolatedTrip($tripID, $range = "") { --- a/sitemap.xml.php +++ b/sitemap.xml.php @@ -22,6 +22,17 @@ echo "0.9"; echo "\n"; } + + // geosite map + foreach (getRoutes() as $route) { + echo " ".curPageURL()."geo/route.kml.php?routeid=".htmlspecialchars ($route["route_id"]).""; + echo "" . $last_updated . ""; + echo " + kml + "; + echo "\n"; + } + echo ''; ?>