From: Maxious Date: Thu, 02 Jun 2011 09:51:29 +0000 Subject: Stop Browser Map X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=2d9f08afc1e69943d6dc62b795425dff81000728 --- Stop Browser Map --- --- a/include/common.inc.php +++ b/include/common.inc.php @@ -163,7 +163,7 @@ $key => $val )); } - if ($sort_ascending) $array = array_reverse($temp_array); + if ($sort_ascending && isset($temp_array)) $array = array_reverse($temp_array); else $array = $temp_array; } function r_implode( $glue, $pieces ) --- a/labs/index.php +++ b/labs/index.php @@ -10,6 +10,8 @@

Analysis of route timing points

  • Bus Stop Density Map

    Analysis of bus stop coverage

  • +
  • Bus Stop Browser Map

    +

    Bus stop location/route browser

  • More coming soon!
  • --- /dev/null +++ b/labs/stopBrowser.kml.php @@ -1,1 +1,62 @@ +createElementNS('http://earth.google.com/kml/2.1', 'kml'); + $parNode = $dom->appendChild($node); + + // Creates a KML Document element and append it to the KML element. + $dnode = $dom->createElement('Document'); + $docNode = $parNode->appendChild($dnode); + + +$bbox = $_GET['bbox']; // get the bbox param from google earth +list($bbox_south, $bbox_west, $bbox_north,$bbox_east) = explode(",", $bbox); // west, south, east, north + +include ('../include/common.inc.php'); +$debugOkay = Array(); +$contents = getNearbyStops( (($bbox_west+ $bbox_east) /2), ($bbox_south + $bbox_north)/2 ,50, 3000); +foreach ($contents as $stop) { + $description = 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $stop['stop_id'] ."
    "; + $trips = getStopTripsWithTimes($stop['stop_id'], "", "", "", 3); + if ($trips) { + foreach ($trips as $key => $row) { + if ($key < 3) { + $description .= $row['route_short_name'] . ' ' . $row['route_long_name'] . ' @ ' . $row['arrival_time'] . "
    "; + } + } + } else { + $description .= "No more trips today"; + } + // Creates a Placemark and append it to the Document. + $node = $dom->createElement('Placemark'); + $placeNode = $docNode->appendChild($node); + + // Creates an id attribute and assign it the value of id column. + $placeNode->setAttribute('id', 'placemark' . $stop['stop_id']); + + // Create name, and description elements and assigns them the values of the name and address columns from the results. + $nameNode = $dom->createElement('name',htmlentities($stop['stop_name'])); + $descriptionNode = $dom->createElement('description',$description); + $placeNode->appendChild($nameNode); + $placeNode->appendChild($descriptionNode); + + // Creates a Point element. + $pointNode = $dom->createElement('Point'); + $placeNode->appendChild($pointNode); + + // Creates a coordinates element and gives it the value of the lng and lat columns from the results. + $coorStr = $stop['stop_lon'] . ',' . $stop['stop_lat']; + $coorNode = $dom->createElement('coordinates', $coorStr); + $pointNode->appendChild($coorNode); + } + + + $kmlOutput = $dom->saveXML(); + echo $kmlOutput; +?> + --- /dev/null +++ b/labs/stopBrowser.php @@ -1,1 +1,102 @@ + + + + + + + + +
    + + + +