From: maxious Date: Fri, 03 Jun 2011 06:18:21 +0000 Subject: Add stops/stops by suburb geositemap X-Git-Url: https://maxious.lambdacomplex.org/git/?p=busui.git&a=commitdiff&h=b4771f8ba54bc4c8e4d1a27f1cc8e0dfa63fa2f2 --- Add stops/stops by suburb geositemap --- --- /dev/null +++ b/geo/stops.kml.php @@ -1,1 +1,36 @@ - +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); +if ($suburb != "") $result_stops = getStopsBySuburb($suburb); +else $result_stops = getStops(); +foreach ($result_stops as $stop) { + $description = 'http://bus.lambdacomplex.org/' . 'stop.php?stopid=' . $stop['stop_id'] . "
"; + // 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; +?> --- a/include/db/stop-dao.inc.php +++ b/include/db/stop-dao.inc.php @@ -30,7 +30,7 @@ } $query.= " order by stop_name;"; $query = $conn->prepare($query); - $query->bindParam(":firstLetter", $firstLetter); + if ($firstLetter != "") $query->bindParam(":firstLetter", $firstLetter); $query->execute(); if (!$query) { databaseError($conn->errorInfo());