Lines Matching refs:this

11  * you may not use this file except in compliance with the License.
140 $this->zoom = $zoom;
141 $this->lat = $lat;
142 $this->lon = $lon;
143 $this->width = $width;
144 $this->height = $height;
146 $this->maptype = $this->tileDefaultSrc;
147 if (array_key_exists($maptype, $this->tileInfo)) {
148 $this->maptype = $maptype;
150 $this->markers = $markers;
151 $this->kmlFileName = $kml;
152 $this->gpxFileName = $gpx;
153 $this->geojsonFileName = $geojson;
154 $this->mediaBaseDir = $mediaDir;
155 $this->tileCacheBaseDir = $tileCacheBaseDir . '/olmaptiles';
156 $this->useTileCache = $this->tileCacheBaseDir !== '';
157 $this->mapCacheBaseDir = $mediaDir . '/olmapmaps';
158 $this->autoZoomExtent = $autoZoomExtent;
159 $this->apikey = $apikey;
163 * get the map, this may return a reference to a cached copy.
170 if ($this->autoZoomExtent) {
171 $this->autoZoom();
178 if (!$this->checkMapCache()) {
180 $this->makeMap();
181 $this->mkdirRecursive(dirname($this->mapCacheIDToFilename()), 0777);
182 imagepng($this->image, $this->mapCacheIDToFilename(), 9);
184 $doc = $this->mapCacheIDToFilename();
186 return str_replace($this->mediaBaseDir, '', $doc);
199 $geoms [] = new Point($this->lon, $this->lat);
200 if ($this->markers !== []) {
201 foreach ($this->markers as $marker) {
205 if (file_exists($this->kmlFileName)) {
206 $g = geoPHP::load(file_get_contents($this->kmlFileName), 'kml');
211 if (file_exists($this->gpxFileName)) {
212 $g = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx');
217 if (file_exists($this->geojsonFileName)) {
218 $g = geoPHP::load(file_get_contents($this->geojsonFileName), 'geojson');
233 // determine vertical resolution, this depends on the distance from the equator
242 $zoomFactorPowered = ($this->height / 2) / (40.7436654315252 * ($vy1 - $vy0));
243 $resolutionVertical = 360 / ($zoomFactorPowered * $this->tileSize);
246 $resolutionHorizontal = ($bbox ['maxx'] - $bbox ['minx']) / $this->width;
249 $zoom = $this->zoom;
251 $zoom = log(360 / ($resolution * $this->tileSize), 2);
255 $this->zoom = floor($zoom);
257 $this->lon = $centroid->getX();
258 $this->lat = $centroid->getY();
259 Logger::debug("StaticMap::autoZoom: Set autozoom options to: z: $this->zoom, lon: $this->lon, lat: $this->lat");
265 $this->mapCacheID = md5($this->serializeParams());
266 $filename = $this->mapCacheIDToFilename();
274 [$this->zoom, $this->lat, $this->lon, $this->width, $this->height, serialize($this->markers), $this->maptype, $this->kmlFileName, $this->gpxFileName, $this->geojsonFileName]
280 if (!$this->mapCacheFile) {
281 $this->mapCacheFile = $this->mapCacheBaseDir . "/" . $this->maptype . "/" . $this->zoom . "/cache_"
282 . substr($this->mapCacheID, 0, 2) . "/" . substr($this->mapCacheID, 2, 2)
283 . "/" . substr($this->mapCacheID, 4);
285 return $this->mapCacheFile . "." . $this->mapCacheExtension;
293 $this->initCoords();
294 $this->createBaseMap();
295 if ($this->markers !== []) {
296 $this->placeMarkers();
298 if (file_exists($this->kmlFileName)) {
300 $this->drawKML();
305 if (file_exists($this->gpxFileName)) {
307 $this->drawGPX();
312 if (file_exists($this->geojsonFileName)) {
314 $this->drawGeojson();
320 $this->drawCopyright();
327 $this->centerX = $this->lonToTile($this->lon, $this->zoom);
328 $this->centerY = $this->latToTile($this->lat, $this->zoom);
329 $this->offsetX = floor((floor($this->centerX) - $this->centerX) * $this->tileSize);
330 $this->offsetY = floor((floor($this->centerY) - $this->centerY) * $this->tileSize);
360 $this->image = imagecreatetruecolor($this->width, $this->height);
361 $startX = floor($this->centerX - ($this->width / $this->tileSize) / 2);
362 $startY = floor($this->centerY - ($this->height / $this->tileSize) / 2);
363 $endX = ceil($this->centerX + ($this->width / $this->tileSize) / 2);
364 $endY = ceil($this->centerY + ($this->height / $this->tileSize) / 2);
365 $this->offsetX = -floor(($this->centerX - floor($this->centerX)) * $this->tileSize);
366 $this->offsetY = -floor(($this->centerY - floor($this->centerY)) * $this->tileSize);
367 $this->offsetX += floor($this->width / 2);
368 $this->offsetY += floor($this->height / 2);
369 $this->offsetX += floor($startX - floor($this->centerX)) * $this->tileSize;
370 $this->offsetY += floor($startY - floor($this->centerY)) * $this->tileSize;
376 [$this->zoom, $x, $y],
377 $this->tileInfo [$this->maptype] ['url']
380 $tileData = $this->fetchTile($url);
384 $tileImage = imagecreate($this->tileSize, $this->tileSize);
388 $destX = ($x - $startX) * $this->tileSize + $this->offsetX;
389 $destY = ($y - $startY) * $this->tileSize + $this->offsetY;
390 Logger::debug("imagecopy tile into image: $destX, $destY", $this->tileSize);
392 $this->image,
398 $this->tileSize,
399 $this->tileSize
409 * @todo refactor this to use dokuwiki\HTTP\HTTPClient or dokuwiki\HTTP\DokuHTTPClient
414 if ($this->useTileCache && ($cached = $this->checkTileCache($url)))
424 curl_setopt($ch, CURLOPT_URL, $url . $this->apikey);
442 "StaticMap::fetchTile: getting: $url . $this->apikey using file_get_contents and options $opts"
444 $tile = file_get_contents($url . $this->apikey, false, $context);
446 if ($tile && $this->useTileCache) {
447 $this->writeTileToCache($url, $tile);
459 $filename = $this->tileUrlToFilename($url);
472 return $this->tileCacheBaseDir . "/" . substr($url, strpos($url, '/') + 1);
483 $filename = $this->tileUrlToFilename($url);
484 $this->mkdirRecursive(dirname($filename), 0777);
499 $this->mkdirRecursive(dirname($pathname), $mode);
510 $color = imagecolorallocate($this->image, 0, 0, 0);
511 $bgcolor = imagecolorallocate($this->image, 200, 200, 200);
519 foreach ($this->markers as $marker) {
530 foreach ($this->markerPrototypes as $markerPrototype) {
561 ($this->width / 2) -
562 $this->tileSize * ($this->centerX - $this->lonToTile($markerLon, $this->zoom))
565 ($this->height / 2) -
566 $this->tileSize * ($this->centerY - $this->latToTile($markerLat, $this->zoom))
571 $this->image,
583 $this->image,
594 $this->image,
602 $this->image,
619 $col = imagecolorallocatealpha($this->image, 255, 0, 0, .4 * 127);
620 $kmlgeom = geoPHP::load(file_get_contents($this->kmlFileName), 'kml');
621 $this->drawGeometry($kmlgeom, $col);
642 $this->drawGeometry($_geom, $colour);
646 $this->drawPolygon($geom, $colour);
649 $this->drawLineString($geom, $colour);
652 $this->drawPoint($geom, $colour);
685 ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))
688 ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p1->y(), $this->zoom))
695 // imagepolygon ($this->image, $extPoints, $i-1, $colour );
696 imagefilledpolygon($this->image, $extPoints, $i - 1, $colour);
708 imagesetthickness($this->image, 2);
715 ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p1->x(), $this->zoom))
718 ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p1->y(), $this->zoom))
721 ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($p2->x(), $this->zoom))
724 ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($p2->y(), $this->zoom))
727 imageline($this->image, $x1, $y1, $x2, $y2, $colour);
729 imagesetthickness($this->image, 1);
741 imagesetthickness($this->image, 2);
744 ($this->width / 2) - $this->tileSize * ($this->centerX - $this->lonToTile($point->x(), $this->zoom))
747 ($this->height / 2) - $this->tileSize * ($this->centerY - $this->latToTile($point->y(), $this->zoom))
751 // imageellipse($this->image, $cx, $cy,$r, $r, $colour);
752 imagefilledellipse($this->image, $cx, $cy, $r, $r, $colour);
755 imagearc($this->image, $cx, $cy, $r, $r, 0, 359, $colour);
756 imagesetthickness($this->image, 1);
765 $col = imagecolorallocatealpha($this->image, 0, 0, 255, .4 * 127);
766 $gpxgeom = geoPHP::load(file_get_contents($this->gpxFileName), 'gpx');
767 $this->drawGeometry($gpxgeom, $col);
776 $col = imagecolorallocatealpha($this->image, 255, 0, 255, .4 * 127);
777 $gpxgeom = geoPHP::load(file_get_contents($this->geojsonFileName), 'json');
778 $this->drawGeometry($gpxgeom, $col);
787 $logoImg = imagecreatefrompng($logoBaseDir . $this->tileInfo ['openstreetmap'] ['logo']);
788 $textcolor = imagecolorallocate($this->image, 0, 0, 0);
789 $bgcolor = imagecolorallocate($this->image, 200, 200, 200);
792 $this->image,
795 imagesy($this->image) - imagesy($logoImg),
802 $this->image,
805 imagesy($this->image) - imagesy($logoImg) + 1,
806 $this->tileInfo ['openstreetmap'] ['txt'],
810 $this->image,
813 imagesy($this->image) - imagesy($logoImg),
814 $this->tileInfo ['openstreetmap'] ['txt'],
820 if ($this->maptype === 'openstreetmap') {
823 $mapAuthor = $this->tileInfo [$this->maptype] ['txt'];
824 $iconImg = imagecreatefrompng($logoBaseDir . $this->tileInfo [$this->maptype] ['logo']);
827 $this->image,
830 imagesy($this->image) - imagesy($iconImg),
838 $this->image,
841 imagesy($this->image) - ceil(imagesy($logoImg) / 2) + 1,
846 $this->image,
849 imagesy($this->image) - ceil(imagesy($logoImg) / 2),