Add trip planner, fix weekend routes appearing on weekdays in network 10
--- /dev/null
+++ b/busui/about.php
@@ -1,1 +1,9 @@
+<?php
+include('common.inc.php');
+?>
+<p>
+Some icons by Joseph Wain / glyphish.com
+<?
+include_footer();
+?>
--- a/busui/common.inc.php
+++ b/busui/common.inc.php
@@ -91,18 +91,124 @@
{
$width = 300;
$height = 300;
+$zoom = 0;
+$center = "";
+$markers = "";
+
if (sizeof($mapPoints) < 1) return "";
- if (sizeof($mapPoints) === 1) $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
- if (sizeof($mapPoints) > 1) $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}"; //TODO average points
- $markers = "";
- foreach ($mapPoints as $index => $mapPoint) {
- if (sizeof($mapPoints) === 1) {
+ if (sizeof($mapPoints) === 1) {
+ $zoom = 14;
$markers .= $mapPoint[0].",".$mapPoint[1].",ol-marker";
- } else {
+ $center = "{$mapPoints[0][0]},{$mapPoints[0][1]}";
+ } else {
+ foreach ($mapPoints as $index => $mapPoint) {
$markers .= $mapPoint[0].",".$mapPoint[1].",lightblue".($index+1);
+ if ($index+1 != sizeof($mapPoints)) $markers .= "|";
+ $totalLat += $mapPoint[0];
+ $totalLon += $mapPoint[1];
}
- }
- return '<img src="staticmaplite/staticmap.php?center='.$center.'&zoom=14&size='.$width.'x'.$height.'&maptype=mapnik&markers='.$markers.'" width=$width height=$height>';
+ $zoom = 11;
+ $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.'>';
+}
+
+function decodePolylineToArray($encoded)
+{
+// source: http://latlongeeks.com/forum/viewtopic.php?f=4&t=5
+ $length = strlen($encoded);
+ $index = 0;
+ $points = array();
+ $lat = 0;
+ $lng = 0;
+
+ while ($index < $length)
+ {
+ // Temporary variable to hold each ASCII byte.
+ $b = 0;
+
+ // The encoded polyline consists of a latitude value followed by a
+ // longitude value. They should always come in pairs. Read the
+ // latitude value first.
+ $shift = 0;
+ $result = 0;
+ do
+ {
+ // The `ord(substr($encoded, $index++))` statement returns the ASCII
+ // code for the character at $index. Subtract 63 to get the original
+ // value. (63 was added to ensure proper ASCII characters are displayed
+ // in the encoded polyline string, which is `human` readable)
+ $b = ord(substr($encoded, $index++)) - 63;
+
+ // 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
+ // by 5 bits each time.
+ // 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
+ // order during encoding, reading them in this way ensures proper
+ // summation.
+ $result |= ($b & 0x1f) << $shift;
+ $shift += 5;
+ }
+ // Continue while the read byte is >= 0x20 since the last `chunk`
+ // was not OR'd with 0x20 during the conversion process. (Signals the end)
+ while ($b >= 0x20);
+
+ // Check if negative, and convert. (All negative values have the last bit
+ // set)
+ $dlat = (($result & 1) ? ~($result >> 1) : ($result >> 1));
+
+ // Compute actual latitude since value is offset from previous value.
+ $lat += $dlat;
+
+ // The next values will correspond to the longitude for this point.
+ $shift = 0;
+ $result = 0;
+ do
+ {
+ $b = ord(substr($encoded, $index++)) - 63;
+ $result |= ($b & 0x1f) << $shift;
+ $shift += 5;
+ }
+ while ($b >= 0x20);
+
+ $dlng = (($result & 1) ? ~($result >> 1) : ($result >> 1));
+ $lng += $dlng;
+
+ // The actual latitude and longitude values were multiplied by
+ // 1e5 before encoding so that they could be converted to a 32-bit
+ // integer representation. (With a decimal accuracy of 5 places)
+ // Convert back to original values.
+ $points[] = array($lat * 1e-5, $lng * 1e-5);
+ }
+
+ return $points;
+}
+
+function object2array($object) {
+ if (is_object($object)) {
+ foreach ($object as $key => $value) {
+ $array[$key] = $value;
+ }
+ }
+ else {
+ $array = $object;
+ }
+ return $array;
+}
+
+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";
+ $contents = json_decode(getPage($url));
+ if ($giveOptions) return $contents->features;
+ else return $contents->features[0]->centroid->coordinates[0].",".$contents->features[0]->centroid->coordinates[1];
+}
+
+function reverseGeocode($lat,$lng) {
+ $url = "http://geocoding.cloudmade.com/daa03470bb8740298d4b10e3f03d63e6/geocoding/v2/find.js?around=".$lat.",".$lng."&distance=closest&object_type=road";
+ $contents = json_decode(getPage($url));
+ return $contents->features[0]->properties->name;
}
?>
Binary files /dev/null and b/busui/images/01-refresh.png differ
Binary files /dev/null and b/busui/images/02-redo.png differ
Binary files /dev/null and b/busui/images/06-magnify.png differ
Binary files /dev/null and b/busui/images/07-map-marker.png differ
Binary files /dev/null and b/busui/images/101-gameplan.png differ
Binary files /dev/null and b/busui/images/102-walk.png differ
Binary files /dev/null and b/busui/images/103-map.png differ
Binary files /dev/null and b/busui/images/113-navigation.png differ
Binary files /dev/null and b/busui/images/121-landscape.png differ
Binary files /dev/null and b/busui/images/13-target.png differ
Binary files /dev/null and b/busui/images/139-flags.png differ
Binary files /dev/null and b/busui/images/145-persondot.png differ
Binary files /dev/null and b/busui/images/184-warning.png differ
Binary files /dev/null and b/busui/images/193-location-arrow.png differ
Binary files /dev/null and b/busui/images/28-star.png differ
Binary files /dev/null and b/busui/images/53-house.png differ
Binary files /dev/null and b/busui/images/55-network.png differ
Binary files /dev/null and b/busui/images/57-download.png differ
Binary files /dev/null and b/busui/images/58-bookmark.png differ
Binary files /dev/null and b/busui/images/59-flag.png differ
Binary files /dev/null and b/busui/images/60-signpost.png differ
Binary files /dev/null and b/busui/images/73-radar.png differ
Binary files /dev/null and b/busui/images/74-location.png differ
Binary files /dev/null and b/busui/images/83-calendar.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/lightblue1.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/lightblue2.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/lightblue3.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/lightblue4.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/lightblue5.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/ol-marker-blue.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/ol-marker-gold.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/ol-marker-green.png differ
Binary files /dev/null and b/busui/staticmaplite/images/markers/ol-marker.png differ
Binary files /dev/null and b/busui/staticmaplite/images/osm_logo.png differ
--- /dev/null
+++ b/busui/staticmaplite/index.html
@@ -1,1 +1,122 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "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">
+<head>
+ <!--
+ 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/
+ -->
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <title>staticMapLite</title>
+ <style type="text/css">
+html{font:96% sans-serif;color:#000;background:#f7f7f7;line-height:1.4;}
+body{color:#333;}
+#wrapper{margin:auto;width:60em;position:relative;}
+#header{padding:0px 0px 7px 0px; height: 1em;}
+#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;}
+h1{margin-top:0px;}
+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;}
+a{color:#1474CA;text-decoration:none;}
+a:visited{color:#1474CA;}
+a.pending{color:#c174a0;}
+a:hover{text-decoration:underline;}
+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;}
+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;}
+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;}
+#diff {outline:none;border:none;}
+#diff ins{color:green;text-decoration:none;font-weight:bold;}
+#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%;}
+hr{margin:10px 0 10px 0;height:0px;overflow:hidden;border:0px;border-top:2px solid #ccc;}
+.error{color:#F25A5A;font-weight:bold;}
+form{display:inline;}
+#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 ul{list-style:none;padding:3px 0 3px 10px;}
+#toc li{font-size:11px;padding-left:10px;}
+#toc ul li{font-size:10px;}
+#toc ul ul li{font-size:9px;}
+#toc ul ul ul li{font-size:8px;}
+#toc ul ul ul ul li{font-size:7px;}
+.pageVersionsList{letter-spacing:0px;font-variant:normal;font-size:12px;}
+#renameForm{float:left;}
+.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;}
+.tagCloud{float:right;width:200px;padding:0.5em;margin:1em;border:1px dashed #e0d78a;background:#fef4a4;color:#644e22;}
+#fileTable{border-collapse:collapse;}
+#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: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; }
+.resizeTextareaDiv { margin-top: 5px;}
+a.toolbarTextareaItem { padding-right: 10px; }
+a.external:after { content: "\2197";}
+ </style>
+ </head>
+<body>
+ <div id="wrapper">
+ <div id="header">
+ </div>
+ <div id="content">
+
+ <div class="par-div">
+ <h2>
+ staticMapLite - simple map for your website
+ </h2>
+ <p>
+ <img src="staticmap.php?center=40.714728,-73.998672&zoom=14&size=865x512&maptype=mapnik" width="865" height="512" /></p>
+ <p>
+ 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>
+ </p>
+ </div>
+ <hr />
+ <div class="par-div">
+ <h3>
+ Place Markers
+ </h3>
+
+ <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" />
+</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>
+ </p>
+ </div>
+ <hr />
+ <div class="par-div">
+ <h3>
+ Use Different Map Styles (Tile Sources)
+ </h3>
+
+ <p>
+ <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" />
+ <pre>maptype=mapnik</pre>
+ </div>
+ <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" />
+ <pre>maptype=osmarenderer</pre>
+ </div>
+ <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" />
+ <pre>maptype=cycle</pre>
+ </div>
+ <br style="clear:both" />
+ </p>
+ </div>
+
+ </div>
+ <div id="footer">
+ <div style="text-align:center;padding:7px;color:#ccc">
+ sponsored by <a href="http://dfacts.de">dFacts Network</a>
+ </div>
+ </div>
+</div>
+</body>
+</html>
--- /dev/null
+++ b/busui/staticmaplite/staticmap.php
@@ -1,1 +1,273 @@
-
+<?php
+
+/**
+ * staticMapLite 0.02
+ *
+ * Copyright 2009 Gerhard Koch
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @author Gerhard Koch <gerhard.koch AT ymail.com>
+ *
+ * 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
+ *
+ */
+
+error_reporting(0);
+ini_set('display_errors','off');
+
+Class staticMapLite {
+
+ protected $tileSize = 256;
+ protected $tileSrcUrl = array( 'mapnik' => 'http://tile.openstreetmap.org/{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'
+ );
+
+ protected $tileDefaultSrc = 'mapnik';
+ protected $markerBaseDir = 'images/markers';
+ protected $osmLogo = 'images/osm_logo.png';
+
+ protected $useTileCache = true;
+ protected $tileCacheBaseDir = 'cache/tiles';
+
+ protected $useMapCache = true;
+ protected $mapCacheBaseDir = 'cache/maps';
+ protected $mapCacheID = '';
+ protected $mapCacheFile = '';
+ protected $mapCacheExtension = 'png';
+
+ protected $zoom, $lat, $lon, $width, $height, $markers, $image, $maptype;
+ protected $centerX, $centerY, $offsetX, $offsetY;
+
+ public function __construct(){
+ $this->zoom = 0;
+ $this->lat = 0;
+ $this->lon = 0;
+ $this->width = 500;
+ $this->height = 350;
+ $this->markers = array();
+ $this->maptype = $this->tileDefaultSrc;
+ }
+
+ public function parseParams(){
+ global $_GET;
+
+ // get zoom from GET paramter
+ $this->zoom = $_GET['zoom']?intval($_GET['zoom']):0;
+ if($this->zoom>18)$this->zoom = 18;
+
+ // get lat and lon from GET paramter
+ list($this->lat,$this->lon) = split(',',$_GET['center']);
+ $this->lat = floatval($this->lat);
+ $this->lon = floatval($this->lon);
+
+ // get zoom from GET paramter
+ if($_GET['size']){
+ list($this->width, $this->height) = split('x',$_GET['size']);
+ $this->width = intval($this->width);
+ $this->height = intval($this->height);
+ }
+ if($_GET['markers']){
+ $markers = split('%7C|\|',$_GET['markers']);
+ foreach($markers as $marker){
+ list($markerLat, $markerLon, $markerImage) = split(',',$marker);
+ $markerLat = floatval($markerLat);
+ $markerLon = floatval($markerLon);
+ $markerImage = basename($markerImage);
+ $this->markers[] = array('lat'=>$markerLat, 'lon'=>$markerLon, 'image'=>$markerImage);
+ }
+
+ }
+ if($_GET['maptype']){
+ if(array_key_exists($_GET['maptype'],$this->tileSrcUrl)) $this->maptype = $_GET['maptype'];
+ }
+ }
+
+ public function lonToTile($long, $zoom){
+ return (($long + 180) / 360) * pow(2, $zoom);
+ }
+
+ public function latToTile($lat, $zoom){
+ return (1 - log(tan($lat * pi()/180) + 1 / cos($lat* pi()/180)) / pi()) /2 * pow(2, $zoom);
+ }
+
+ public function initCoords(){
+ $this->centerX = $this->lonToTile($this->lon, $this->zoom);
+ $this->centerY = $this->latToTile($this->lat, $this->zoom);
+ $this->offsetX = floor((floor($this->centerX)-$this->centerX)*$this->tileSize);
+ $this->offsetY = floor((floor($this->centerY)-$this->centerY)*$this->tileSize);
+ }
+
+ public function createBaseMap(){
+ $this->image = imagecreatetruecolor($this->width, $this->height);
+ $startX = floor($this->centerX-($this->width/$this->tileSize)/2);
+ $startY = floor($this->centerY-($this->height/$this->tileSize)/2);
+ $endX = ceil($this->centerX+($this->width/$this->tileSize)/2);
+ $endY = ceil($this->centerY+($this->height/$this->tileSize)/2);
+ $this->offsetX = -floor(($this->centerX-floor($this->centerX))*$this->tileSize);
+ $this->offsetY = -floor(($this->centerY-floor($this->centerY))*$this->tileSize);
+ $this->offsetX += floor($this->width/2);
+ $this->offsetY += floor($this->height/2);
+ $this->offsetX += floor($startX-floor($this->centerX))*$this->tileSize;
+ $this->offsetY += floor($startY-floor($this->centerY))*$this->tileSize;
+
+ for($x=$startX; $x<=$endX; $x++){
+ for($y=$startY; $y<=$endY; $y++){
+ $url = str_replace(array('{Z}','{X}','{Y}'),array($this->zoom, $x, $y), $this->tileSrcUrl[$this->maptype]);
+ $tileImage = imagecreatefromstring($this->fetchTile($url));
+ $destX = ($x-$startX)*$this->tileSize+$this->offsetX;
+ $destY = ($y-$startY)*$this->tileSize+$this->offsetY;
+ imagecopy($this->image, $tileImage, $destX, $destY, 0, 0, $this->tileSize, $this->tileSize);
+ }
+ }
+ }
+
+
+ public function placeMarkers(){
+ foreach($this->markers as $marker){
+ $markerLat = $marker['lat'];
+ $markerLon = $marker['lon'];
+ $markerImage = $marker['image'];
+ $markerIndex++;
+ $markerFilename = $markerImage?(file_exists($this->markerBaseDir.'/'.$markerImage.".png")?$markerImage:'lightblue'.$markerIndex):'lightblue'.$markerIndex;
+ if(file_exists($this->markerBaseDir.'/'.$markerFilename.".png")){
+ $markerImg = imagecreatefrompng($this->markerBaseDir.'/'.$markerFilename.".png");
+ } else {
+ $markerImg = imagecreatefrompng($this->markerBaseDir.'/lightblue1.png');
+ }
+ $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 = $destY - imagesy($markerImg);
+
+ imagecopy($this->image, $markerImg, $destX, $destY, 0, 0, imagesx($markerImg), imagesy($markerImg));
+
+ };
+}
+
+
+
+ public function tileUrlToFilename($url){
+ return $this->tileCacheBaseDir."/".str_replace(array('http://'),'',$url);
+ }
+
+ public function checkTileCache($url){
+ $filename = $this->tileUrlToFilename($url);
+ if(file_exists($filename)){
+ return file_get_contents($filename);
+ }
+ }
+
+ public function checkMapCache(){
+ $this->mapCacheID = md5($this->serializeParams());
+ $filename = $this->mapCacheIDToFilename();
+ if(file_exists($filename)) return true;
+ }
+
+ public function serializeParams(){
+ return join("&",array($this->zoom,$this->lat,$this->lon,$this->width,$this->height, serialize($this->markers),$this->maptype));
+ }
+
+ public function mapCacheIDToFilename(){
+ if(!$this->mapCacheFile){
+ $this->mapCacheFile = $this->mapCacheBaseDir."/".substr($this->mapCacheID,0,2)."/".substr($this->mapCacheID,2,2)."/".substr($this->mapCacheID,4);
+ }
+ return $this->mapCacheFile.".".$this->mapCacheExtension;
+ }
+
+
+
+ public function mkdir_recursive($pathname, $mode){
+ is_dir(dirname($pathname)) || $this->mkdir_recursive(dirname($pathname), $mode);
+ return is_dir($pathname) || @mkdir($pathname, $mode);
+ }
+ public function writeTileToCache($url, $data){
+ $filename = $this->tileUrlToFilename($url);
+ $this->mkdir_recursive(dirname($filename),0777);
+ file_put_contents($filename, $data);
+ }
+
+ public function fetchTile($url){
+ if($this->useTileCache && ($cached = $this->checkTileCache($url))) return $cached;
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0");
+ curl_setopt($ch, CURLOPT_URL, $url);
+ $tile = curl_exec($ch);
+ curl_close($ch);
+ if($this->useTileCache){
+ $this->writeTileToCache($url,$tile);
+ }
+ return $tile;
+
+ }
+
+ public function copyrightNotice(){
+ $logoImg = imagecreatefrompng($this->osmLogo);
+ imagecopy($this->image, $logoImg, imagesx($this->image)-imagesx($logoImg), imagesy($this->image)-imagesy($logoImg), 0, 0, imagesx($logoImg), imagesy($logoImg));
+
+ }
+
+ public function sendHeader(){
+ header('Content-Type: image/png');
+ $expires = 60*60*24*14;
+ header("Pragma: public");
+ header("Cache-Control: maxage=".$expires);
+ header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
+ }
+
+ public function makeMap(){
+ $this->initCoords();
+ $this->createBaseMap();
+ if(count($this->markers))$this->placeMarkers();
+ if($this->osmLogo) $this->copyrightNotice();
+ }
+
+ public function showMap(){
+ $this->parseParams();
+ if($this->useMapCache){
+ // use map cache, so check cache for map
+ if(!$this->checkMapCache()){
+ // map is not in cache, needs to be build
+ $this->makeMap();
+ $this->mkdir_recursive(dirname($this->mapCacheIDToFilename()),0777);
+ imagepng($this->image,$this->mapCacheIDToFilename(),9);
+ $this->sendHeader();
+ if(file_exists($this->mapCacheIDToFilename())){
+ return file_get_contents($this->mapCacheIDToFilename());
+ } else {
+ return imagepng($this->image);
+ }
+ } else {
+ // map is in cache
+ $this->sendHeader();
+ return file_get_contents($this->mapCacheIDToFilename());
+ }
+
+ } else {
+ // no cache, make map, send headers and deliver png
+ $this->makeMap();
+ $this->sendHeader();
+ return imagepng($this->image);
+
+ }
+ }
+
+}
+
+$map = new staticMapLite();
+print $map->showMap();
+
+?>