Merge branch 'enhancement' of https://github.com/calderacc/staticmaplite into enhancement

* 'enhancement' of https://github.com/calderacc/staticmaplite:
  Commit all the old stuff.

# Conflicts:
#	src/Printer.php
This commit is contained in:
Malte Hübner 2017-09-30 19:02:09 +02:00
commit 233b291df8
7 changed files with 95 additions and 15 deletions

BIN
images/extramarkers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

View File

@ -0,0 +1,26 @@
<?php
/**
* Created by PhpStorm.
* User: maltehuebner
* Date: 29.09.17
* Time: 15:46
*/
namespace StaticMapLite\Element\Marker;
class AbstractMarker
{
protected $latitude;
protected $longitude;
public function getLatitude(): float
{
return $this->latitude;
}
public function getLongitude(): float
{
return $this->longitude;
}
}

View File

@ -0,0 +1,38 @@
<?php
namespace StaticMapLite\Element\Marker;
class ExtraMarker extends AbstractMarker
{
const SHAPE_CIRCLE = 0;
const SHAPE_SQUARE = 1;
const SHAPE_STAR = 2;
const SHAPE_PENTA = 3;
const COLOR_RED = 0;
const COLOR_ORANGEDARK = 1;
const COLOR_ORANGE = 2;
const COLOR_YELLOW = 3;
const COLOR_BLUEDARK = 4;
const COLOR_CYAN = 5;
const COLOR_PURPLE = 6;
const COLOR_VIOLET = 7;
const COLOR_PINK = 8;
const COLOR_GREENDARK = 9;
const COLOR_GREEN = 10;
const COLOR_GREENLIGHT = 11;
const COLOR_BLACK = 12;
const COLOR_WHITE = 13;
protected $shape;
protected $color;
public function __construct(int $shape, int $color, float $latitude, float $longitude)
{
$this->shape = $shape;
$this->color = $color;
$this->latitude = $latitude;
$this->longitude = $longitude;
}
}

View File

@ -2,10 +2,8 @@
namespace StaticMapLite\Element\Marker;
class Marker
class Marker extends AbstractMarker
{
protected $latitude;
protected $longitude;
protected $markerType;
public function __construct(string $markerType, float $latitude, float $longitude)
@ -20,13 +18,5 @@ class Marker
return $this->markerType;
}
public function getLatitude(): float
{
return $this->latitude;
}
public function getLongitude(): float
{
return $this->longitude;
}
}

View File

@ -3,6 +3,7 @@
namespace StaticMapLite\ElementPrinter\Marker;
use StaticMapLite\Canvas\Canvas;
use StaticMapLite\Element\Marker\ExtraMarker;
use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Util;
@ -56,6 +57,30 @@ class MarkerPrinter
return $this;
}
/**
public function placeExtraMarker(ExtraMarker $extraMarker)
{
$extramarkers = imagecreatefrompng($this->markerBaseDir . '/../extramarkers.png');
$markerImage = imagecreatetruecolor(75, 100);
$trans_colour = imagecolorallocatealpha($markerImage, 0, 0, 0, 127);
imagefill($markerImage, 0, 0, $trans_colour);
$destX = floor(($this->width / 2) - $this->tileSize * ($this->centerX - Util::lonToTile($extraMarker->getLongitude(), $this->zoom)));
$destY = floor(($this->height / 2) - $this->tileSize * ($this->centerY - Util::latToTile($extraMarker->getLatitude(), $this->zoom)));
$markerWidth = imagesx($markerImage);
$markerHeight = imagesy($markerImage);
$destX -= $markerWidth / 2;
$destY -= $markerHeight;
imagecopy($markerImage, $extramarkers, 0, 0, 0, 0, $markerWidth, $markerHeight);
imagecopy($this->canvas->getImage(), $markerImage, $destX, $destY, 0, 0, imagesx($markerImage), imagesy($markerImage));
}
**/
public function paint(Canvas $canvas): MarkerPrinter
{
$markerFilename = '';
@ -118,4 +143,4 @@ class MarkerPrinter
return $this;
}
}
}

View File

@ -4,7 +4,7 @@ namespace StaticMapLite;
use StaticMapLite\Canvas\Canvas;
use StaticMapLite\CanvasTilePainter\CanvasTilePainter;
use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Marker\AbstractMarker;
use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\ElementPrinter\Marker\MarkerPrinter;
use StaticMapLite\ElementPrinter\Polyline\PolylinePrinter;
@ -61,7 +61,7 @@ class Printer
$this->tileResolver->setTileLayerUrl($this->tileSrcUrl[$this->maptype]);
}
public function addMarker(Marker $marker): Printer
public function addMarker(AbstractMarker $marker): Printer
{
$this->markers[] = $marker;

View File

@ -27,6 +27,7 @@
require_once '../vendor/autoload.php';
use StaticMapLite\Element\Marker\ExtraMarker;
use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\Printer;
@ -51,7 +52,7 @@ if ($markers) {
foreach ($markerList as $markerData) {
list($markerLatitude, $markerLongitude, $markerType) = explode(',', $markerData);
$marker = new Marker($markerType, $markerLatitude, $markerLongitude);
$marker = new ExtraMarker(ExtraMarker::SHAPE_CIRCLE, ExtraMarker::COLOR_GREEN, $markerLatitude, $markerLongitude);
$printer->addMarker($marker);
}