<?php | <?php |
date_default_timezone_set('Australia/ACT'); | date_default_timezone_set('Australia/ACT'); |
$APIurl = "http://localhost:8765"; | $APIurl = "http://localhost:8765"; |
error_reporting(E_ALL ^ E_NOTICE); | error_reporting(E_ALL ^ E_NOTICE); |
function isDebug() | function isDebug() |
{ | { |
return true; | return true; |
} | } |
function isFastDevice() { | function isFastDevice() { |
return true; | return true; |
} | } |
function include_header($pageTitle, $opendiv = true, $geolocate = false) { | function include_header($pageTitle, $opendiv = true, $geolocate = false) { |
// if (isDebug()) // set php error level high | // if (isDebug()) // set php error level high |
echo ' | echo ' |
<!DOCTYPE html> | <!DOCTYPE html> |
<html> | <html> |
<head> | <head> |
<title>bus.lambdacomplex.org - '.$pageTitle.'</title> | <title>bus.lambdacomplex.org - '.$pageTitle.'</title> |
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" /> | <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.css" /> |
<style type="text/css"> | |
.ui-navbar { | |
padding-bottom: 18px; | |
width: 100%; | |
} | |
</style> | |
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script><script type="text/javascript" | <script src="http://code.jquery.com/jquery-1.4.3.min.js"></script><script type="text/javascript" |
src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script> | src="http://code.jquery.com/mobile/1.0a2/jquery.mobile-1.0a2.min.js"></script> |
<script type="text/javascript" src="docs/docs.js"></script> | |
<meta name="apple-mobile-web-app-capable" content="yes" /> | <meta name="apple-mobile-web-app-capable" content="yes" /> |
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | <meta name="apple-mobile-web-app-status-bar-style" content="black" /> |
<link rel="apple-touch-startup-image" href="startup.png" /> | <link rel="apple-touch-startup-image" href="startup.png" /> |
<link rel="apple-touch-icon" href="apple-touch-icon.png" /> | <link rel="apple-touch-icon" href="apple-touch-icon.png" /> |
</head> | </head> |
<body> | <body> |
'; | '; |
if ($opendiv) echo '<div data-role="page"> | if ($opendiv) echo '<div data-role="page"> |
<div data-role="header"> | <div data-role="header"> |
<h1>'.$pageTitle.'</h1> | <h1>'.$pageTitle.'</h1> |
<a href="index.php" data-icon="back" class="ui-btn-right">Home</a> | |
</div><!-- /header --> | </div><!-- /header --> |
<div data-role="content"> '; | <div data-role="content"> '; |
} | } |
function include_footer() | function include_footer() |
{ | { |
echo '</div>'; | echo '</div>'; |
} | } |
function service_period() | function service_period() |
{ | { |
switch (date('w')){ | switch (date('w')){ |
case 0: | case 0: |
return 'sunday'; | return 'sunday'; |
case 6: | case 6: |
return 'saturday'; | return 'saturday'; |
default: | default: |
return 'weekday'; | return 'weekday'; |
} | } |
} | } |
function midnight_seconds() | function midnight_seconds() |
{ | { |
// from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html | // from http://www.perturb.org/display/Perlfunc__Seconds_Since_Midnight.html |
$secs = (date("G") * 3600) + (date("i") * 60) + date("s"); | $secs = (date("G") * 3600) + (date("i") * 60) + date("s"); |
return $secs; | return $secs; |
} | } |
function midnight_seconds_to_time($seconds) | function midnight_seconds_to_time($seconds) |
{ | { |
$midnight = mktime (0, 0, 0, date("n"), date("j"), date("Y")); | $midnight = mktime (0, 0, 0, date("n"), date("j"), date("Y")); |
return date("h:ia",$midnight+$seconds); | return date("h:ia",$midnight+$seconds); |
} | } |
function getPage($url) | function getPage($url) |
{ | { |
$ch = curl_init($url); | $ch = curl_init($url); |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); |
curl_setopt( $ch, CURLOPT_HEADER, 0 ); | curl_setopt( $ch, CURLOPT_HEADER, 0 ); |
$page = curl_exec($ch); | $page = curl_exec($ch); |
curl_close($ch); | curl_close($ch); |
return $page; | return $page; |
} | } |
function array_flatten($a,$f=array()){ | function array_flatten($a,$f=array()){ |
if(!$a||!is_array($a))return ''; | if(!$a||!is_array($a))return ''; |
foreach($a as $k=>$v){ | foreach($a as $k=>$v){ |
if(is_array($v))$f=array_flatten($v,$f); | if(is_array($v))$f=array_flatten($v,$f); |
else $f[$k]=$v; | else $f[$k]=$v; |
} | } |
return $f; | return $f; |
} | } |
function staticmap($mapPoints) | function staticmap($mapPoints, $zoom = 0, $markerImage = "iconb") |
{ | { |
$width = 300; | $width = 300; |
$height = 300; | $height = 300; |
$zoom = 0; | $metersperpixel[9]=305.492*$width; |
$metersperpixel[10]=152.746*$width; | |
$metersperpixel[11]=76.373*$width; | |
$metersperpixel[12]=38.187*$width; | |
$metersperpixel[13]=19.093*$width; | |
$metersperpixel[14]=9.547*$width; | |
$metersperpixel[15]=4.773*$width; | |
$metersperpixel[16]=2.387*$width; | |
// $metersperpixel[17]=1.193*$width; | |
$center = ""; | $center = ""; |
$markers = ""; | $markers = ""; |
$minlat = 999; | |
if (sizeof($mapPoints) < 1) return ""; | $minlon = 999; |
$maxlat = 0; | |
$maxlon = 0; | |
if (sizeof($mapPoints) < 1) return "map error"; | |
if (sizeof($mapPoints) === 1) { | if (sizeof($mapPoints) === 1) { |
$zoom = 14; | if ($zoom == 0) $zoom = 14; |
$markers .= $mapPoint[0].",".$mapPoint[1].",ol-marker"; | $markers .= "{$mapPoints[0][0]},{$mapPoints[0][1]},$markerimage"; |
$center = "{$mapPoints[0][0]},{$mapPoints[0][1]}"; | $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}"; |
} else { | } else { |
foreach ($mapPoints as $index => $mapPoint) { | foreach ($mapPoints as $index => $mapPoint) { |
$markers .= $mapPoint[0].",".$mapPoint[1].",lightblue".($index+1); | $markers .= $mapPoint[0].",".$mapPoint[1].",".$markerImage.($index+1); |
if ($index+1 != sizeof($mapPoints)) $markers .= "|"; | if ($index+1 != sizeof($mapPoints)) $markers .= "|"; |
if ($mapPoint[0] < $minlat) $minlat = $mapPoint[0]; | |
if ($mapPoint[0] > $maxlat) $maxlat = $mapPoint[0]; | |
if ($mapPoint[1] < $minlon) $minlon = $mapPoint[1]; | |
if ($mapPoint[1] > $maxlon) $maxlon = $mapPoint[1]; | |
$totalLat += $mapPoint[0]; | $totalLat += $mapPoint[0]; |
$totalLon += $mapPoint[1]; | $totalLon += $mapPoint[1]; |
} | } |
$zoom = 11; | if ($zoom == 0) { |
$mapwidthinmeters = distance($minlat,$minlon,$minlat,$maxlon); | |
foreach (array_reverse($metersperpixel,true) as $zoomLevel => $maxdistance) | |
{ | |
if ($zoom == 0 && $mapwidthinmeters < ($maxdistance + 50)) $zoom = $zoomLevel; | |
} | |
} | |
$center = $totalLat/sizeof($mapPoints).",".$totalLon/sizeof($mapPoints); | $center = $totalLat/sizeof($mapPoints).",".$totalLon/sizeof($mapPoints); |
} | } |
return '<img src="staticmaplite/staticmap.php?center='.$center.'&zoom='.$zoom.'&size='.$width.'x'.$height.'&maptype=mapnik&markers='.$markers.'" width='.$width.' height='.$height.'>'; | return '<img src="staticmaplite/staticmap.php?center='.$center.'&zoom='.$zoom.'&size='.$width.'x'.$height.'&maptype=mapnik&markers='.$markers.'" width='.$width.' height='.$height.'>'; |
} | |
function distance($lat1, $lng1, $lat2, $lng2) | |
{ | |
$pi80 = M_PI / 180; | |
$lat1 *= $pi80; | |
$lng1 *= $pi80; | |
$lat2 *= $pi80; | |
$lng2 *= $pi80; | |
$r = 6372.797; // mean radius of Earth in km | |
$dlat = $lat2 - $lat1; | |
$dlng = $lng2 - $lng1; | |
$a = sin($dlat / 2) * sin($dlat / 2) + cos($lat1) * cos($lat2) * sin($dlng / 2) * sin($dlng / 2); | |
$c = 2 * atan2(sqrt($a), sqrt(1 - $a)); | |
$km = $r * $c; | |
return $km * 1000; | |
} | } |
function decodePolylineToArray($encoded) | function decodePolylineToArray($encoded) |
{ | { |
// source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5 | // source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5 |
$length = strlen($encoded); | $length = strlen($encoded); |
$index = 0; | $index = 0; |
$points = array(); | $points = array(); |
$lat = 0; | $lat = 0; |
$lng = 0; | $lng = 0; |
while ($index < $length) | while ($index < $length) |
{ | { |
// Temporary variable to hold each ASCII byte. | // Temporary variable to hold each ASCII byte. |
$b = 0; | $b = 0; |
// The encoded polyline consists of a latitude value followed by a | // The encoded polyline consists of a latitude value followed by a |
// longitude value. They should always come in pairs. Read the | // longitude value. They should always come in pairs. Read the |
// latitude value first. | // latitude value first. |
$shift = 0; | $shift = 0; |
$result = 0; | $result = 0; |
do | do |
{ | { |
// The `ord(substr($encoded, $index++))` statement returns the ASCII | // The `ord(substr($encoded, $index++))` statement returns the ASCII |
// code for the character at $index. Subtract 63 to get the original | // code for the character at $index. Subtract 63 to get the original |
// value. (63 was added to ensure proper ASCII characters are displayed | // value. (63 was added to ensure proper ASCII characters are displayed |
// in the encoded polyline string, which is `human` readable) | // in the encoded polyline string, which is `human` readable) |
$b = ord(substr($encoded, $index++)) - 63; | $b = ord(substr($encoded, $index++)) - 63; |
// AND the bits of the byte with 0x1f to get the original 5-bit `chunk. | // AND the bits of the byte with 0x1f to get the original 5-bit `chunk. |
// Then left shift the bits by the required amount, which increases | // Then left shift the bits by the required amount, which increases |
// by 5 bits each time. | // by 5 bits each time. |
// OR the value into $results, which sums up the individual 5-bit chunks | // OR the value into $results, which sums up the individual 5-bit chunks |
// into the original value. Since the 5-bit chunks were reversed in | // into the original value. Since the 5-bit chunks were reversed in |
// order during encoding, reading them in this way ensures proper | // order during encoding, reading them in this way ensures proper |
// summation. | // summation. |
$result |= ($b & 0x1f) << $shift; | $result |= ($b & 0x1f) << $shift; |
$shift += 5; | $shift += 5; |
} | } |
// Continue while the read byte is >= 0x20 since the last `chunk` | // Continue while the read byte is >= 0x20 since the last `chunk` |
// was not OR'd with 0x20 during the conversion process. (Signals the end) | // was not OR'd with 0x20 during the conversion process. (Signals the end) |
while ($b >= 0x20); | while ($b >= 0x20); |
// Check if negative, and convert. (All negative values have the last bit | // Check if negative, and convert. (All negative values have the last bit |
// set) | // set) |
$dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1)); | $dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1)); |
// Compute actual latitude since value is offset from previous value. | // Compute actual latitude since value is offset from previous value. |
$lat += $dlat; | $lat += $dlat; |
// The next values will correspond to the longitude for this point. | // The next values will correspond to the longitude for this point. |
$shift = 0; | $shift = 0; |
$result = 0; | $result = 0; |
do | do |
{ | { |
$b = ord(substr($encoded, $index++)) - 63; | $b = ord(substr($encoded, $index++)) - 63; |
$result |= ($b & 0x1f) << $shift; | $result |= ($b & 0x1f) << $shift; |
$shift += 5; | $shift += 5; |
} | } |
while ($b >= 0x20); | while ($b >= 0x20); |
$dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1)); | $dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1)); |
$lng += $dlng; | $lng += $dlng; |
// The actual latitude and longitude values were multiplied by | // The actual latitude and longitude values were multiplied by |
// 1e5 before encoding so that they could be converted to a 32-bit | // 1e5 before encoding so that they could be converted to a 32-bit |
// integer representation. (With a decimal accuracy of 5 places) | // integer representation. (With a decimal accuracy of 5 places) |
// Convert back to original values. | // Convert back to original values. |
$points[] = array($lat * 1e-5, $lng * 1e-5); | $points[] = array($lat * 1e-5, $lng * 1e-5); |
} | } |
return $points; | return $points; |
} | } |
function object2array($object) { | function object2array($object) { |
if (is_object($object)) { | if (is_object($object)) { |
foreach ($object as $key => $value) { | foreach ($object as $key => $value) { |
$array[$key] = $value; | $array[$key] = $value; |
} | } |
} | } |
else { | else { |
$array = $object; | $array = $object; |
} | } |
return $array; | return $array; |
} | } |
function geocode($query, $giveOptions) { | function geocode($query, $giveOptions) { |
$url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?query=".$query."&bbox=-35.5,149.00,-35.15,149.1930&return_location=true&bbox_only=true"; | $url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?query=".$query."&bbox=-35.5,149.00,-35.15,149.1930&return_location=true&bbox_only=true"; |
$contents = json_decode(getPage($url)); | $contents = json_decode(getPage($url)); |
if ($giveOptions) return $contents->features; | if ($giveOptions) return $contents->features; |
else return $contents->features[0]->centroid->coordinates[0].",".$contents->features[0]->centroid->coordinates[1]; | elseif (isset($contents->features[0]->centroid)) return $contents->features[0]->centroid->coordinates[0].",".$contents->features[0]->centroid->coordinates[1]; |
else return ""; | |
} | } |
function reverseGeocode($lat,$lng) { | function reverseGeocode($lat,$lng) { |
$url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?around=".$lat.",".$lng."&distance=closest&object_type=road"; | $url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?around=".$lat.",".$lng."&distance=closest&object_type=road"; |
$contents = json_decode(getPage($url)); | $contents = json_decode(getPage($url)); |
return $contents->features[0]->properties->name; | return $contents->features[0]->properties->name; |
} | } |
function startsWith($haystack,$needle,$case=true) { | |
if($case){return (strcmp(substr($haystack, 0, strlen($needle)),$needle)===0);} | |
return (strcasecmp(substr($haystack, 0, strlen($needle)),$needle)===0); | |
} | |
function endsWith($haystack,$needle,$case=true) { | |
if($case){return (strcmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0);} | |
return (strcasecmp(substr($haystack, strlen($haystack) - strlen($needle)),$needle)===0); | |
} | |
?> | ?> |
cache/tiles | |
cache/map | |
[InternetShortcut] | |
URL=http://gplotter.offwhite.net/ | |
[InternetShortcut] | |
URL=http://brennan.offwhite.net/blog/2005/07/23/new-google-maps-icons-free/ | |
Binary files /dev/null and b/busui/staticmaplite/images/markers/Thumbs.db differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb1.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb10.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb11.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb12.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb13.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb14.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb15.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb16.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb17.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb18.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb19.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb2.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb20.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb21.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb22.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb23.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb24.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb25.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb3.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb4.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb5.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb6.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb7.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb8.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconb9.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong1.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong10.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong11.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong12.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong13.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong14.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong15.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong16.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong17.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong18.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong19.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong2.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong20.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong21.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong22.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong23.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong24.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong25.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong3.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong4.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong5.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong6.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong7.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong8.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icong9.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr1.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr10.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr11.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr12.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr13.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr14.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr15.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr16.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr17.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr18.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr19.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr2.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr20.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr21.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr22.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr23.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr24.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr25.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr3.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr4.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr5.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr6.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr7.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr8.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/iconr9.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/icons.psd differ
Binary files a/busui/staticmaplite/images/markers/lightblue1.png and b/busui/staticmaplite/images/markers/lightblue1.png differ
Binary files a/busui/staticmaplite/images/markers/lightblue2.png and b/busui/staticmaplite/images/markers/lightblue2.png differ
Binary files a/busui/staticmaplite/images/markers/lightblue3.png and b/busui/staticmaplite/images/markers/lightblue3.png differ
Binary files a/busui/staticmaplite/images/markers/lightblue4.png and b/busui/staticmaplite/images/markers/lightblue4.png differ
Binary files a/busui/staticmaplite/images/markers/lightblue5.png and b/busui/staticmaplite/images/markers/lightblue5.png differ
Binary files a/busui/staticmaplite/images/markers/ol-marker-blue.png and b/busui/staticmaplite/images/markers/ol-marker-blue.png differ
Binary files a/busui/staticmaplite/images/markers/ol-marker-gold.png and b/busui/staticmaplite/images/markers/ol-marker-gold.png differ
Binary files a/busui/staticmaplite/images/markers/ol-marker-green.png and b/busui/staticmaplite/images/markers/ol-marker-green.png differ
Binary files a/busui/staticmaplite/images/markers/ol-marker.png and b/busui/staticmaplite/images/markers/ol-marker.png differ
Binary files a/busui/staticmaplite/images/osm_logo.png and b/busui/staticmaplite/images/osm_logo.png differ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-de" lang="de-de"> | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de-de" lang="de-de"> |
<head> | <head> |
<!-- | <!-- |
CSS based on template of Dandelion wiki engine by Radomir Dopieralski who released this | CSS based on template of Dandelion wiki engine by Radomir Dopieralski who released this |
template under the terms of GNU GPL. http://dandelion.sheep.art.pl/ | template under the terms of GNU GPL. http://dandelion.sheep.art.pl/ |
--> | --> |
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | <meta http-equiv="content-type" content="text/html; charset=utf-8" /> |
<title>staticMapLite</title> | <title>staticMapLite</title> |
<style type="text/css"> | <style type="text/css"> |
html{font:96% sans-serif;color:#000;background:#f7f7f7;line-height:1.4;} | html{font:96% sans-serif;color:#000;background:#f7f7f7;line-height:1.4;} |
body{color:#333;} | body{color:#333;} |
#wrapper{margin:auto;width:60em;position:relative;} | #wrapper{margin:auto;width:60em;position:relative;} |
#header{padding:0px 0px 7px 0px; height: 1em;} | #header{padding:0px 0px 7px 0px; height: 1em;} |
#header h1 { float:left; width: 40%; } | #header h1 { float:left; width: 40%; } |
#content{background:white;padding:1em;border:1px solid #e0d78a;outline:0.5em solid #fef4a4; margin:0.5em 0;padding:20px;min-height:20em;} | #content{background:white;padding:1em;border:1px solid #e0d78a;outline:0.5em solid #fef4a4; margin:0.5em 0;padding:20px;min-height:20em;} |
h1{margin-top:0px;} | h1{margin-top:0px;} |
h1,h2,h3,h4,h5,h6{letter-spacing:0.05em;color:#1474CA;font-weight:normal;} | h1,h2,h3,h4,h5,h6{letter-spacing:0.05em;color:#1474CA;font-weight:normal;} |
h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{text-decoration:none;} | h1 a:hover,h2 a:hover,h3 a:hover,h4 a:hover,h5 a:hover,h6 a:hover{text-decoration:none;} |
a{color:#1474CA;text-decoration:none;} | a{color:#1474CA;text-decoration:none;} |
a:visited{color:#1474CA;} | a:visited{color:#1474CA;} |
a.pending{color:#c174a0;} | a.pending{color:#c174a0;} |
a:hover{text-decoration:underline;} | a:hover{text-decoration:underline;} |
a img{border:none;} | a img{border:none;} |
input,textarea{font-size:94%;border:1px solid #999;background:#fff;color:#666;outline:0.2em solid #eee;padding:0px;line-height:1.2;margin:0.5em;vertical-align:middle;} | input,textarea{font-size:94%;border:1px solid #999;background:#fff;color:#666;outline:0.2em solid #eee;padding:0px;line-height:1.2;margin:0.5em;vertical-align:middle;} |
textarea{display:block;margin:0.5em auto;width:100%;} | textarea{display:block;margin:0.5em auto;width:100%;} |
pre{outline:0.4em solid #eee;padding:0.5em;margin:0.5em;border:1px solid #e0d78a;background:#fef4a4;color:#644e22;} | pre{outline:0.4em solid #eee;padding:0.5em;margin:0.5em;border:1px solid #e0d78a;background:#fef4a4;color:#644e22;} |
img{border:1px solid #ccc;outline:0.25em solid #eee;padding:0.25em;margin:0.25em 0 0.25em 0.5em;background:#fff;} | img{border:1px solid #ccc;outline:0.25em solid #eee;padding:0.25em;margin:0.25em 0 0.25em 0.5em;background:#fff;} |
hr{height:0;border:none;color:#fff;background:transparent;border-bottom:1px solid #ccc; margin:0.5em 0;} | hr{height:0;border:none;color:#fff;background:transparent;border-bottom:1px solid #ccc; margin:0.5em 0;} |
#diff {outline:none;border:none;} | #diff {outline:none;border:none;} |
#diff ins{color:green;text-decoration:none;font-weight:bold;} | #diff ins{color:green;text-decoration:none;font-weight:bold;} |
#diff del{color:red;text-decoration:line-through;} | #diff del{color:red;text-decoration:line-through;} |
#diff{background:#fff;line-height:1.25;padding:1em;white-space:pre-wrap;word-wrap:break-word; white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;width:97%;} | #diff{background:#fff;line-height:1.25;padding:1em;white-space:pre-wrap;word-wrap:break-word; white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;width:97%;} |
hr{margin:10px 0 10px 0;height:0px;overflow:hidden;border:0px;border-top:2px solid #ccc;} | hr{margin:10px 0 10px 0;height:0px;overflow:hidden;border:0px;border-top:2px solid #ccc;} |
.error{color:#F25A5A;font-weight:bold;} | .error{color:#F25A5A;font-weight:bold;} |
form{display:inline;} | form{display:inline;} |
#contentTextarea{height:44em;} | #contentTextarea{height:44em;} |
#toc{margin:5px 0 5px 10px;padding:6px 5px 7px 0px;float:right;list-style:none;outline:0.4em solid #eee;background:#fef4a4;border:1px solid #e0d78a;} | #toc{margin:5px 0 5px 10px;padding:6px 5px 7px 0px;float:right;list-style:none;outline:0.4em solid #eee;background:#fef4a4;border:1px solid #e0d78a;} |
#toc ul{list-style:none;padding:3px 0 3px 10px;} | #toc ul{list-style:none;padding:3px 0 3px 10px;} |
#toc li{font-size:11px;padding-left:10px;} | #toc li{font-size:11px;padding-left:10px;} |
#toc ul li{font-size:10px;} | #toc ul li{font-size:10px;} |
#toc ul ul li{font-size:9px;} | #toc ul ul li{font-size:9px;} |
#toc ul ul ul li{font-size:8px;} | #toc ul ul ul li{font-size:8px;} |
#toc ul ul ul ul li{font-size:7px;} | #toc ul ul ul ul li{font-size:7px;} |
.pageVersionsList{letter-spacing:0px;font-variant:normal;font-size:12px;} | .pageVersionsList{letter-spacing:0px;font-variant:normal;font-size:12px;} |
#renameForm{float:left;} | #renameForm{float:left;} |
.clear{clear:both;} | .clear{clear:both;} |
.tagList{padding:0.2em 0.4em 0.2em 0.4em;margin-top:0.5em;border:1px dashed #e0d78a;background:#fef4a4;color:#644e22;} | .tagList{padding:0.2em 0.4em 0.2em 0.4em;margin-top:0.5em;border:1px dashed #e0d78a;background:#fef4a4;color:#644e22;} |
.tagCloud{float:right;width:200px;padding:0.5em;margin:1em;border:1px dashed #e0d78a;background:#fef4a4;color:#644e22;} | .tagCloud{float:right;width:200px;padding:0.5em;margin:1em;border:1px dashed #e0d78a;background:#fef4a4;color:#644e22;} |
#fileTable{border-collapse:collapse;} | #fileTable{border-collapse:collapse;} |
#fileTable td{border:1px solid #FEF4A4;padding:2px 6px 2px 6px;} | #fileTable td{border:1px solid #FEF4A4;padding:2px 6px 2px 6px;} |
h2 span.par-edit, h3 span.par-edit, h4 span.par-edit, h5 span.par-edit, h6 span.par-edit {display:none;} | h2 span.par-edit, h3 span.par-edit, h4 span.par-edit, h5 span.par-edit, h6 span.par-edit {display:none;} |
h2:hover span.par-edit, h3:hover span.par-edit, h4:hover span.par-edit, h5:hover span.par-edit, h6:hover span.par-edit {display:inline;font-size:x-small;} | h2:hover span.par-edit, h3:hover span.par-edit, h4:hover span.par-edit, h5:hover span.par-edit, h6:hover span.par-edit {display:inline;font-size:x-small;} |
.comment-item { border:1px solid #999;color:#666;outline:0.2em solid #eee; } | .comment-item { border:1px solid #999;color:#666;outline:0.2em solid #eee; } |
.resizeTextareaDiv { margin-top: 5px;} | .resizeTextareaDiv { margin-top: 5px;} |
a.toolbarTextareaItem { padding-right: 10px; } | a.toolbarTextareaItem { padding-right: 10px; } |
a.external:after { content: "\2197";} | a.external:after { content: "\2197";} |
</style> | </style> |
</head> | </head> |
<body> | <body> |
<div id="wrapper"> | <div id="wrapper"> |
<div id="header"> | <div id="header"> |
</div> | </div> |
<div id="content"> | <div id="content"> |
<div class="par-div"> | <div class="par-div"> |
<h2> | <h2> |
staticMapLite - simple map for your website | staticMapLite - simple map for your website |
</h2> | </h2> |
<p> | <p> |
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" width="865" height="512" /></p> | <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" width="865" height="512" /></p> |
<p> | <p> |
This image was created using the following simple <img> tag: | This image was created using the following simple <img> tag: |
<pre><img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" /></pre> | <pre><img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" /></pre> |
</p> | </p> |
</div> | </div> |
<hr /> | <hr /> |
<div class="par-div"> | <div class="par-div"> |
<h3> | <h3> |
Place Markers | Place Markers |
</h3> | </h3> |
<p> | <p> |
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik&markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3" width="865" height="512" /> | <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik&markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3" width="865" height="512" /> |
</p><p> Add markers by appending them to the image URL: | </p><p> Add markers by appending them to the image URL: |
<pre>markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3</pre> | <pre>markers=40.702147,-74.015794,lightblue1|40.711614,-74.012318,lightblue2|40.718217,-73.998284,lightblue3</pre> |
</p> | </p> |
</div> | </div> |
<hr /> | <hr /> |
<div class="par-div"> | <div class="par-div"> |
<h3> | <h3> |
Use Different Map Styles (Tile Sources) | Use Different Map Styles (Tile Sources) |
</h3> | </h3> |
<p> | <p> |
<div style="float:left; margin-right: 10px"> | <div style="float:left; margin-right: 10px"> |
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=mapnik" width="256" height="256" /> | <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=mapnik" width="256" height="256" /> |
<pre>maptype=mapnik</pre> | <pre>maptype=mapnik</pre> |
</div> | </div> |
<div style="float:left; margin-right: 10px"> | <div style="float:left; margin-right: 10px"> |
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=osmarenderer" width="256" height="256" /> | <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=osmarenderer" width="256" height="256" /> |
<pre>maptype=osmarenderer</pre> | <pre>maptype=osmarenderer</pre> |
</div> | </div> |
<div style="float:left; margin-right: 10px"> | <div style="float:left; margin-right: 10px"> |
<img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=cycle" width="256" height="256" /> | <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=256x256&maptype=cycle" width="256" height="256" /> |
<pre>maptype=cycle</pre> | <pre>maptype=cycle</pre> |
</div> | </div> |
<br style="clear:both" /> | <br style="clear:both" /> |
</p> | </p> |
</div> | </div> |
</div> | </div> |
<div id="footer"> | <div id="footer"> |
<div style="text-align:center;padding:7px;color:#ccc"> | <div style="text-align:center;padding:7px;color:#ccc"> |
sponsored by <a href="http://dfacts.de">dFacts Network</a> | sponsored by <a href="http://dfacts.de">dFacts Network</a> |
</div> | </div> |
</div> | </div> |
</div> | </div> |
</body> | </body> |
</html> | </html> |
chcon -R -t httpd_sys_content_rw_t cache | |
<?php | <?php |
/** | /** |
* staticMapLite 0.02 | * staticMapLite 0.02 |
* | * |
* Copyright 2009 Gerhard Koch | * Copyright 2009 Gerhard Koch |
* | * |
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at | * You may obtain a copy of the License at |
* | * |
* http://www.apache.org/licenses/LICENSE-2.0 | * http://www.apache.org/licenses/LICENSE-2.0 |
* | * |
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and |
* limitations under the License. | * limitations under the License. |
* | * |
* @author Gerhard Koch <gerhard.koch AT ymail.com> | * @author Gerhard Koch <gerhard.koch AT ymail.com> |
* | * |
* USAGE: | * USAGE: |
* | * |
* staticmap.php?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mapnik&markers=40.702147,-74.015794,blues|40.711614,-74.012318,greeng|40.718217,-73.998284,redc | * staticmap.php?center=40.714728,-73.998672&zoom=14&size=512x512&maptype=mapnik&markers=40.702147,-74.015794,blues|40.711614,-74.012318,greeng|40.718217,-73.998284,redc |
* | * |
*/ | */ |
error_reporting(0); | error_reporting(0); |
ini_set('display_errors','off'); | ini_set('display_errors','off'); |
Class staticMapLite { | Class staticMapLite { |
protected $tileSize = 256; | protected $tileSize = 256; |
protected $tileSrcUrl = array( 'mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', | protected $tileSrcUrl = array( 'mapnik' => 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png', |
'osmarenderer' => 'http://c.tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png', | 'osmarenderer' => 'http://c.tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png', |
'cycle' => 'http://c.andy.sandbox.cloudmade.com/tiles/cycle/{Z}/{X}/{Y}.png' | 'cycle' => 'http://c.andy.sandbox.cloudmade.com/tiles/cycle/{Z}/{X}/{Y}.png' |
); | ); |
protected $tileDefaultSrc = 'mapnik'; | protected $tileDefaultSrc = 'mapnik'; |
protected $markerBaseDir = 'images/markers'; | protected $markerBaseDir = 'images/markers'; |
protected $osmLogo = 'images/osm_logo.png'; | protected $osmLogo = 'images/osm_logo.png'; |
protected $useTileCache = true; | protected $useTileCache = true; |
protected $tileCacheBaseDir = 'cache/tiles'; | protected $tileCacheBaseDir = './cache/tiles'; |
protected $useMapCache = true; | protected $useMapCache = true; |
protected $mapCacheBaseDir = 'cache/maps'; | protected $mapCacheBaseDir = './cache/maps'; |
protected $mapCacheID = ''; | protected $mapCacheID = ''; |
protected $mapCacheFile = ''; | protected $mapCacheFile = ''; |
protected $mapCacheExtension = 'png'; | protected $mapCacheExtension = 'png'; |
protected $zoom, $lat, $lon, $width, $height, $markers, $image, $maptype; | protected $zoom, $lat, $lon, $width, $height, $markers, $image, $maptype; |
protected $centerX, $centerY, $offsetX, $offsetY; | protected $centerX, $centerY, $offsetX, $offsetY; |
public function __construct(){ | public function __construct(){ |
$this->zoom = 0; | $this->zoom = 0; |
$this->lat = 0; | $this->lat = 0; |
$this->lon = 0; | $this->lon = 0; |
$this->width = 500; | $this->width = 500; |
$this->height = 350; | $this->height = 350; |
$this->markers = array(); | $this->markers = array(); |
$this->maptype = $this->tileDefaultSrc; | $this->maptype = $this->tileDefaultSrc; |
} | } |
public function parseParams(){ | public function parseParams(){ |
global $_GET; | global $_GET; |
// get zoom from GET paramter | // get zoom from GET paramter |
$this->zoom = $_GET['zoom']?intval($_GET['zoom']):0; | $this->zoom = $_GET['zoom']?intval($_GET['zoom']):0; |
if($this->zoom>18)$this->zoom = 18; | if($this->zoom>18)$this->zoom = 18; |
// get lat and lon from GET paramter | // get lat and lon from GET paramter |
list($this->lat,$this->lon) = split(',',$_GET['center']); | list($this->lat,$this->lon) = split(',',$_GET['center']); |
$this->lat = floatval($this->lat); | $this->lat = floatval($this->lat); |
$this->lon = floatval($this->lon); | $this->lon = floatval($this->lon); |
// get zoom from GET paramter | // get zoom from GET paramter |
if($_GET['size']){ | if($_GET['size']){ |
list($this->width, $this->height) = split('x',$_GET['size']); | list($this->width, $this->height) = split('x',$_GET['size']); |
$this->width = intval($this->width); | $this->width = intval($this->width); |
$this->height = intval($this->height); | $this->height = intval($this->height); |
} | } |
if($_GET['markers']){ | if($_GET['markers']){ |
$markers = split('%7C|\|',$_GET['markers']); | $markers = split('%7C|\|',$_GET['markers']); |
foreach($markers as $marker){ | foreach($markers as $marker){ |
list($markerLat, $markerLon, $markerImage) = split(',',$marker); | list($markerLat, $markerLon, $markerImage) = split(',',$marker); |
$markerLat = floatval($markerLat); | $markerLat = floatval($markerLat); |
$markerLon = floatval($markerLon); | $markerLon = floatval($markerLon); |
$markerImage = basename($markerImage); | $markerImage = basename($markerImage); |
$this->markers[] = array('lat'=>$markerLat, 'lon'=>$markerLon, 'image'=>$markerImage); | $this->markers[] = array('lat'=>$markerLat, 'lon'=>$markerLon, 'image'=>$markerImage); |
} | } |
} | } |
if($_GET['maptype']){ | if($_GET['maptype']){ |
if(array_key_exists($_GET['maptype'],$this->tileSrcUrl)) $this->maptype = $_GET['maptype']; | if(array_key_exists($_GET['maptype'],$this->tileSrcUrl)) $this->maptype = $_GET['maptype']; |
} | } |
} | } |
public function lonToTile($long, $zoom){ | public function lonToTile($long, $zoom){ |
return (($long + 180) / 360) * pow(2, $zoom); | return (($long + 180) / 360) * pow(2, $zoom); |
} | } |
public function latToTile($lat, $zoom){ | public function latToTile($lat, $zoom){ |
return (1 - log(tan($lat * pi()/180) + 1 / cos($lat* pi()/180)) / pi()) /2 * pow(2, $zoom); | return (1 - log(tan($lat * pi()/180) + 1 / cos($lat* pi()/180)) / pi()) /2 * pow(2, $zoom); |
} | } |
public function initCoords(){ | public function initCoords(){ |
$this->centerX = $this->lonToTile($this->lon, $this->zoom); | $this->centerX = $this->lonToTile($this->lon, $this->zoom); |
$this->centerY = $this->latToTile($this->lat, $this->zoom); | $this->centerY = $this->latToTile($this->lat, $this->zoom); |
$this->offsetX = floor((floor($this->centerX)-$this->centerX)*$this->tileSize); | $this->offsetX = floor((floor($this->centerX)-$this->centerX)*$this->tileSize); |
$this->offsetY = floor((floor($this->centerY)-$this->centerY)*$this->tileSize); | $this->offsetY = floor((floor($this->centerY)-$this->centerY)*$this->tileSize); |
} | } |
public function createBaseMap(){ | public function createBaseMap(){ |
$this->image = imagecreatetruecolor($this->width, $this->height); | $this->image = imagecreatetruecolor($this->width, $this->height); |
$startX = floor($this->centerX-($this->width/$this->tileSize)/2); | $startX = floor($this->centerX-($this->width/$this->tileSize)/2); |
$startY = floor($this->centerY-($this->height/$this->tileSize)/2); | $startY = floor($this->centerY-($this->height/$this->tileSize)/2); |
$endX = ceil($this->centerX+($this->width/$this->tileSize)/2); | $endX = ceil($this->centerX+($this->width/$this->tileSize)/2); |
$endY = ceil($this->centerY+($this->height/$this->tileSize)/2); | $endY = ceil($this->centerY+($this->height/$this->tileSize)/2); |
$this->offsetX = -floor(($this->centerX-floor($this->centerX))*$this->tileSize); | $this->offsetX = -floor(($this->centerX-floor($this->centerX))*$this->tileSize); |
$this->offsetY = -floor(($this->centerY-floor($this->centerY))*$this->tileSize); | $this->offsetY = -floor(($this->centerY-floor($this->centerY))*$this->tileSize); |
$this->offsetX += floor($this->width/2); | $this->offsetX += floor($this->width/2); |
$this->offsetY += floor($this->height/2); | $this->offsetY += floor($this->height/2); |
$this->offsetX += floor($startX-floor($this->centerX))*$this->tileSize; | $this->offsetX += floor($startX-floor($this->centerX))*$this->tileSize; |
$this->offsetY += floor($startY-floor($this->centerY))*$this->tileSize; | $this->offsetY += floor($startY-floor($this->centerY))*$this->tileSize; |
for($x=$startX; $x<=$endX; $x++){ | for($x=$startX; $x<=$endX; $x++){ |
for($y=$startY; $y<=$endY; $y++){ | for($y=$startY; $y<=$endY; $y++){ |
$url = str_replace(array('{Z}','{X}','{Y}'),array($this->zoom, $x, $y), $this->tileSrcUrl[$this->maptype]); | $url = str_replace(array('{Z}','{X}','{Y}'),array($this->zoom, $x, $y), $this->tileSrcUrl[$this->maptype]); |
$tileImage = imagecreatefromstring($this->fetchTile($url)); | $tileImage = imagecreatefromstring($this->fetchTile($url)); |
$destX = ($x-$startX)*$this->tileSize+$this->offsetX; | $destX = ($x-$startX)*$this->tileSize+$this->offsetX; |
$destY = ($y-$startY)*$this->tileSize+$this->offsetY; | $destY = ($y-$startY)*$this->tileSize+$this->offsetY; |
imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize); | imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize); |
} | } |
} | } |
} | } |
public function placeMarkers(){ | public function placeMarkers(){ |
foreach($this->markers as $marker){ | foreach($this->markers as $marker){ |
$markerLat = $marker['lat']; | $markerLat = $marker['lat']; |
$markerLon = $marker['lon']; | $markerLon = $marker['lon']; |
$markerImage = $marker['image']; | $markerImage = $marker['image']; |
$markerIndex++; | $markerIndex++; |
$markerFilename = $markerImage?(file_exists($this->markerBaseDir.'/'.$markerImage.".png")?$markerImage:'lightblue'.$markerIndex):'lightblue'.$markerIndex; | $markerFilename = $markerImage?(file_exists($this->markerBaseDir.'/'.$markerImage.".png")?$markerImage:'lightblue'.$markerIndex):'lightblue'.$markerIndex; |
if(file_exists($this->markerBaseDir.'/'.$markerFilename.".png")){ | if(file_exists($this->markerBaseDir.'/'.$markerFilename.".png")){ |
$markerImg = imagecreatefrompng($this->markerBaseDir.'/'.$markerFilename.".png"); | $markerImg = imagecreatefrompng($this->markerBaseDir.'/'.$markerFilename.".png"); |
} else { | } else { |
$markerImg = imagecreatefrompng($this->markerBaseDir.'/lightblue1.png'); | $markerImg = imagecreatefrompng($this->markerBaseDir.'/lightblue1.png'); |
} | } |
$destX = floor(($this->width/2)-$this->tileSize*($this->centerX-$this->lonToTile($markerLon, $this->zoom))); | $destX = floor(($this->width/2)-$this->tileSize*($this->centerX-$this->lonToTile($markerLon, $this->zoom))); |
$destY = floor(($this->height/2)-$this->tileSize*($this->centerY-$this->latToTile($markerLat, $this->zoom))); | $destY = floor(($this->height/2)-$this->tileSize*($this->centerY-$this->latToTile($markerLat, $this->zoom))); |
$destY = $destY - imagesy($markerImg); | $destY = $destY - imagesy($markerImg); |
imagecopy($this->image, $markerImg, $destX, $destY, 0, 0, imagesx($markerImg), imagesy($markerImg)); | imagecopy($this->image, $markerImg, $destX, $destY, 0, 0, imagesx($markerImg), imagesy($markerImg)); |
}; | }; |
} | } |
public function tileUrlToFilename($url){ | public function tileUrlToFilename($url){ |
return $this->tileCacheBaseDir."/".str_replace(array('http://'),'',$url); | return $this->tileCacheBaseDir."/".str_replace(array('http://'),'',$url); |
} | } |
public function checkTileCache($url){ | public function checkTileCache($url){ |
$filename = $this->tileUrlToFilename($url); | $filename = $this->tileUrlToFilename($url); |
if(file_exists($filename)){ | if(file_exists($filename)){ |
return file_get_contents($filename); | return file_get_contents($filename); |
} | } |
} | } |
public function checkMapCache(){ | public function checkMapCache(){ |
$this->mapCacheID = md5($this->serializeParams()); | $this->mapCacheID = md5($this->serializeParams()); |
$filename = $this->mapCacheIDToFilename(); | $filename = $this->mapCacheIDToFilename(); |
if(file_exists($filename)) return true; | if(file_exists($filename)) return true; |
} | } |
public function serializeParams(){ | public function serializeParams(){ |
return join("&",array($this->zoom,$this->lat,$this->lon,$this->width,$this->height, serialize($this->markers),$this->maptype)); | return join("&",array($this->zoom,$this->lat,$this->lon,$this->width,$this->height, serialize($this->markers),$this->maptype)); |
} | } |
public function mapCacheIDToFilename(){ | public function mapCacheIDToFilename(){ |
if(!$this->mapCacheFile){ | if(!$this->mapCacheFile){ |
$this->mapCacheFile = $this->mapCacheBaseDir."/".substr($this->mapCacheID,0,2)."/".substr($this->mapCacheID,2,2)."/".substr($this->mapCacheID,4); | $this->mapCacheFile = $this->mapCacheBaseDir."/".substr($this->mapCacheID,0,2)."/".substr($this->mapCacheID,2,2)."/".substr($this->mapCacheID,4); |
} | } |
return $this->mapCacheFile.".".$this->mapCacheExtension; | return $this->mapCacheFile.".".$this->mapCacheExtension; |
} | } |
public function mkdir_recursive($pathname, $mode){ | public function mkdir_recursive($pathname, $mode){ |
is_dir(dirname($pathname)) || $this->mkdir_recursive(dirname($pathname), $mode); | return mkdir($pathname, $mode, true); |
return is_dir($pathname) || @mkdir($pathname, $mode); | |
} | } |
public function writeTileToCache($url, $data){ | public function writeTileToCache($url, $data){ |
$filename = $this->tileUrlToFilename($url); | $filename = $this->tileUrlToFilename($url); |
$this->mkdir_recursive(dirname($filename),0777); | $this->mkdir_recursive(dirname($filename),0777); |
file_put_contents($filename, $data); | file_put_contents($filename, $data); |
} | } |
public function fetchTile($url){ | public function fetchTile($url){ |
if($this->useTileCache && ($cached = $this->checkTileCache($url))) return $cached; | if($this->useTileCache && ($cached = $this->checkTileCache($url))) return $cached; |
$ch = curl_init(); | $ch = curl_init(); |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0"); | curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0"); |
curl_setopt($ch, CURLOPT_URL, $url); | curl_setopt($ch, CURLOPT_URL, $url); |
$tile = curl_exec($ch); | $tile = curl_exec($ch); |
curl_close($ch); | curl_close($ch); |
if($this->useTileCache){ | if($this->useTileCache){ |
$this->writeTileToCache($url,$tile); | $this->writeTileToCache($url,$tile); |
} | } |
return $tile; | return $tile; |
} | } |
public function copyrightNotice(){ | public function copyrightNotice(){ |
$logoImg = imagecreatefrompng($this->osmLogo); | $logoImg = imagecreatefrompng($this->osmLogo); |
imagecopy($this->image, $logoImg, imagesx($this->image)-imagesx($logoImg), imagesy($this->image)-imagesy($logoImg), 0, 0, imagesx($logoImg), imagesy($logoImg)); | imagecopy($this->image, $logoImg, imagesx($this->image)-imagesx($logoImg), imagesy($this->image)-imagesy($logoImg), 0, 0, imagesx($logoImg), imagesy($logoImg)); |
} | } |
public function sendHeader(){ | public function sendHeader(){ |
header('Content-Type: image/png'); | header('Content-Type: image/png'); |
$expires = 60*60*24*14; | $expires = 60*60*24*14; |
header("Pragma: public"); | header("Pragma: public"); |
header("Cache-Control: maxage=".$expires); | header("Cache-Control: maxage=".$expires); |
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); | header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); |
} | } |
public function makeMap(){ | public function makeMap(){ |
$this->initCoords(); | $this->initCoords(); |
$this->createBaseMap(); | $this->createBaseMap(); |
if(count($this->markers))$this->placeMarkers(); | if(count($this->markers))$this->placeMarkers(); |
if($this->osmLogo) $this->copyrightNotice(); | if($this->osmLogo) $this->copyrightNotice(); |
} | } |
public function showMap(){ | public function showMap(){ |
$this->parseParams(); | $this->parseParams(); |
if($this->useMapCache){ | if($this->useMapCache){ |
// use map cache, so check cache for map | // use map cache, so check cache for map |
if(!$this->checkMapCache()){ | if(!$this->checkMapCache()){ |
// map is not in cache, needs to be build | // map is not in cache, needs to be build |
$this->makeMap(); | $this->makeMap(); |
$this->mkdir_recursive(dirname($this->mapCacheIDToFilename()),0777); | $this->mkdir_recursive(dirname($this->mapCacheIDToFilename()),0777); |
imagepng($this->image,$this->mapCacheIDToFilename(),9); | imagepng($this->image,$this->mapCacheIDToFilename(),9); |
$this->sendHeader(); | $this->sendHeader(); |
if(file_exists($this->mapCacheIDToFilename())){ | if(file_exists($this->mapCacheIDToFilename())){ |
return file_get_contents($this->mapCacheIDToFilename()); | return file_get_contents($this->mapCacheIDToFilename()); |
} else { | } else { |
return imagepng($this->image); | return imagepng($this->image); |
} | } |
} else { | } else { |
// map is in cache | // map is in cache |
$this->sendHeader(); | $this->sendHeader(); |
return file_get_contents($this->mapCacheIDToFilename()); | return file_get_contents($this->mapCacheIDToFilename()); |
} | } |
} else { | } else { |
// no cache, make map, send headers and deliver png | // no cache, make map, send headers and deliver png |
$this->makeMap(); | $this->makeMap(); |
$this->sendHeader(); | $this->sendHeader(); |
return imagepng($this->image); | return imagepng($this->image); |
} | } |
} | } |
} | } |
$map = new staticMapLite(); | $map = new staticMapLite(); |
print $map->showMap(); | print $map->showMap(); |
?> | ?> |
<?php | <?php |
include('common.inc.php'); | include('common.inc.php'); |
include_header("Stops"); | include_header("Stops"); |
echo' | |
<div data-role="navbar"> | |
<ul> | |
<li><a href="stopList.php" class="ui-btn-active">Timing Points</a></li> | |
<li><a href="stopList.php?allstops=yes">All Stops</a></li> | |
</ul> | |
</div> | |
'; | |
echo ' <ul data-role="listview" data-filter="true">'; | echo ' <ul data-role="listview" data-filter="true">'; |
$url = $APIurl."/json/timingpoints"; | $url = $APIurl."/json/timingpoints"; |
if ($_REQUEST['allstops']) $url = $APIurl."/json/stops"; | if ($_REQUEST['allstops']) $url = $APIurl."/json/stops"; |
if ($_REQUEST['lat'] && $_REQUEST['lon']) $url = $APIurl."/json/neareststops?lat={$_REQUEST['lat']}&lon={$_REQUEST['lon']}&limit=15"; | if ($_REQUEST['lat'] && $_REQUEST['lon']) $url = $APIurl."/json/neareststops?lat={$_REQUEST['lat']}&lon={$_REQUEST['lon']}&limit=15"; |
$contents = json_decode(getPage($url)); | $contents = json_decode(getPage($url)); |
foreach ($contents as $key => $row) { | foreach ($contents as $key => $row) { |
$stopName[$key] = $row[1]; | $stopName[$key] = $row[1]; |
} | } |
// Sort the data with volume descending, edition ascending | // Sort the data with volume descending, edition ascending |
// Add $data as the last parameter, to sort by the common key | // Add $data as the last parameter, to sort by the common key |
array_multisort($stopName, SORT_ASC, $contents); | array_multisort($stopName, SORT_ASC, $contents); |
foreach ($contents as $row) | foreach ($contents as $row) |
{ | { |
echo '<li><a href="stop.php?stopid='.$row[0].'">'.$row[1].'</a></li>'; | echo '<li><a href="stop.php?stopid='.$row[0].'">'.$row[1].'</a></li>'; |
} | } |
echo '</ul>'; | echo '</ul>'; |
echo' | |
<div data-role="footer" data-id="foo1" data-position="fixed"> | |
<div data-role="navbar"> | |
<ul> | |
<li><a href="stopList.php" class="ui-btn-active">Timing Points</a></li> | |
<li><a href="stopList.php?allstops=yes">All Stops</a></li> | |
</ul> | |
'; | |
include_footer(); | include_footer(); |
?> | ?> |
<?php | <?php |
include('common.inc.php'); | include('common.inc.php'); |
if ($_REQUEST['time']) { | include_header("Trip Planner"); |
$toPlace = geocode($_REQUEST['to'],false); | function tripPlanForm($errorMessage = "") |
$fromPlace = geocode($_REQUEST['from'],false); | { |
$url = "http://localhost:8080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=11%2F17%2F2010&time=1%3A06%20pm&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; | $from = (isset($_REQUEST['from']) ? $_REQUEST['from'] : "Brigalow"); |
$ch = curl_init($url); | $to = (isset($_REQUEST['to']) ? $_REQUEST['to'] : "Barry"); |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 ); | $date = (isset($_REQUEST['date']) ? $_REQUEST['date'] : date("m/d/Y")); |
curl_setopt( $ch, CURLOPT_HEADER, 0 ); | $time = (isset($_REQUEST['time']) ? $_REQUEST['time'] : date("h:ia")); |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); | echo "<font color=red>$errorMessage</font>"; |
$page = curl_exec($ch); | echo '<form action="tripPlanner.php" method="post"> |
curl_close($ch); | <div data-role="fieldcontain"> |
$tripplan = json_decode($page); | <label for="from">I would like to go from</label> |
echo "<h1> From: {$tripplan->plan->from->name} </h1>"; | <input type="text" name="from" id="from" value="' . $from . '" /> |
echo "<h1> To: {$tripplan->plan->to->name} </h1>"; | </div> |
echo "<h1> At: {$tripplan->plan->date} </h1>"; | <div data-role="fieldcontain"> |
foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary ){ | <label for="to"> to </label> |
echo "<hr> <h2> Option #".($itineraryNumber+1)."<h2>"; | <input type="text" name="to" id="to" value="' . $to . '" /> |
echo "Duration: ".floor($itinerary->duration/60000)." minutes ({$itinerary->startTime} to {$itinerary->endTime})<br>\n"; | </div> |
echo "Walking time: ".floor($itinerary->walkTime/60000)." minutes ({$itinerary->walkDistance} meters)<br>\n"; | <div data-role="fieldcontain"> |
echo "Transit time: ".floor($itinerary->transitTime/60000)." minutes<br>\n"; | <label for="date"> on </label> |
echo "Waiting time: ".floor($itinerary->waitingTime/60000)." minutes<br>\n"; | <input type="text" name="date" id="date" value="' . $date . '" /> |
$legMarkers = Array(); | </div> |
foreach ($itinerary->legs->leg as $legNumber => $leg ){ | <div data-role="fieldcontain"> |
$legMarkers[] = Array($leg->from->lat,$leg->from->lon); | <label for="time"> at </label> |
} | <input type="text" name="time" id="time" value="' . $time . '" /> |
echo staticmap($legMarkers)."<br>\n"; | </div> |
foreach ($itinerary->legs->leg as $legNumber => $leg ){ | <input type="submit" value="Go!"></form>'; |
echo "Leg #".($legNumber+1)." (from: {$leg->from->name} to {$leg->to->name}, ".floor($leg->duration/60000)." minutes) <br>\n"; | } |
$legArray = object2array($leg); | |
if ($legArray["@mode"] === "BUS") { | function processItinerary($itineraryNumber, $itinerary) |
echo "Take bus {$legArray['@route']} ".str_replace("To","towards",$legArray['@headsign'])."<br>"; | { |
} | echo '<div data-role="collapsible" ' . ($itineraryNumber > 0 ? 'data-collapsed="true"' : "") . '> <h3> Option #' . ($itineraryNumber + 1) . ": " . floor($itinerary->duration / 60000) . " minutes ({$itinerary->startTime} to {$itinerary->endTime})</h3><p>"; |
else { | echo "Walking time: " . floor($itinerary->walkTime / 60000) . " minutes (" . floor($itinerary->walkDistance) . " meters)<br>\n"; |
foreach ($leg->steps->walkSteps as $stepNumber => $step ){ | echo "Transit time: " . floor($itinerary->transitTime / 60000) . " minutes<br>\n"; |
echo "Walking step $stepNumber $step->absoluteDirection / $step->relativeDirection on $step->streetName for $step->distance meters / ".floor($step->duration/60000)." minutes<br>\n"; | echo "Waiting time: " . floor($itinerary->waitingTime / 60000) . " minutes<br>\n"; |
} | |
} | |
} | |
} | |
} else { | |
echo '<form> I would like to go from <input type="text" name="from" value="Brigalow"></input> to | |
<input type="text" name="to" value="Barry"></input> on <input type="text" name="date" value="1:00pm"> at <input type="text" name="time" value="1:00pm"></input> | |
<input type="submit"></form>'; | |
} | |
include_footer(); | if (is_array($itinerary->legs->leg)) { |
$legMarkers = array(); | |
foreach ($itinerary->legs->leg as $legNumber => $leg) { | |
$legMarkers[] = array($leg->from->lat, $leg->from->lon); | |
} | |
echo '' . staticmap($legMarkers) . "<br>\n"; | |
echo '<ul>'; | |
foreach ($itinerary->legs->leg as $legNumber => $leg) { | |
echo '<li>'; | |
processLeg($legNumber, $leg); | |
echo "</li>"; | |
} | |
echo "</ul>"; | |
} else { | |
echo '' . staticmap(array(array($itinerary->legs->leg->from->lat, $itinerary->legs->leg->from->lon))) . "<br>\n"; | |
processLeg(0, $itinerary->legs->leg); | |
} | |
echo "</p></div>"; | |
} | |
function processLeg($legNumber, $leg) { | |
$legArray = object2array($leg); | |
echo '<h3>Leg #' . ($legNumber + 1) . " ( {$legArray['@mode']} from: {$leg->from->name} to {$leg->to->name}, " . floor($leg->duration / 60000) . " minutes) </h3>\n"; | |
if ($legArray["@mode"] === "BUS") { | |
echo "Take bus {$legArray['@route']} " . str_replace("To", "towards", $legArray['@headsign']) . "<br>"; | |
} else { | |
$walkStepMarkers = array(); | |
foreach ($leg->steps->walkSteps as $stepNumber => $step) { | |
$walkStepMarkers[] = array($step->lat, $step->lon); | |
} | |
echo "" . staticmap($walkStepMarkers, "icong") . "<br>\n"; | |
foreach ($leg->steps->walkSteps as $stepNumber => $step) { | |
echo "Walking step " . ($stepNumber + 1) . " $step->absoluteDirection / $step->relativeDirection on $step->streetName for " . floor($step->distance) . " meters<br>\n"; | |
} | |
} | |
} | |
if ($_REQUEST['time']) { | |
$toPlace = (startsWith($_REQUEST['to'], "-") ? $_REQUEST['to'] : geocode(urlencode($_REQUEST['to']), false)); | |
$fromPlace = (startsWith($_REQUEST['from'], "-") ? $_REQUEST['from'] : geocode(urlencode($_REQUEST['from']), false)); | |
if ($toPlace == "" || $fromPlace == "") { | |
$errorMessage = ""; | |
if ($toPlace === "") | |
$errorMessage .= urlencode($_REQUEST['to']) . " not found.<br>\n"; | |
if ($fromPlace === "") | |
$errorMessage .= urlencode($_REQUEST['from']) . " not found.<br>\n"; | |
tripPlanForm($errorMessage); | |
} else { | |
$url = "http://localhost:8080/opentripplanner-api-webapp/ws/plan?_dc=1290254798856&arriveBy=false&date=" . urlencode($_REQUEST['date']) . "&time=" . urlencode($_REQUEST['time']) . "&mode=TRANSIT%2CWALK&optimize=QUICK&maxWalkDistance=840&wheelchair=false&toPlace=$toPlace&fromPlace=$fromPlace&intermediatePlaces="; | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: application/json")); | |
$page = curl_exec($ch); | |
curl_close($ch); | |
$tripplan = json_decode($page); | |
echo "<h1> From: {$tripplan->plan->from->name} To: {$tripplan->plan->to->name} </h1>"; | |
echo "<h1> At: {$tripplan->plan->date} </h1>"; | |
if (is_array($tripplan->plan->itineraries->itinerary)) { | |
echo '<div data-role="collapsible-set">'; | |
foreach ($tripplan->plan->itineraries->itinerary as $itineraryNumber => $itinerary) { | |
processItinerary($itineraryNumber, $itinerary); | |
} | |
echo "</div>"; | |
} else { | |
processItinerary(0, $tripplan->plan->itineraries->itinerary); | |
} | |
} | |
} else { | |
tripPlanForm(); | |
} | |
include_footer(); | |
?> | ?> |