Add Polyline object.

This commit is contained in:
Malte Hübner 2017-05-26 17:28:30 +02:00
parent 5bbf9c6283
commit aae0ada3c6
2 changed files with 51 additions and 18 deletions

View File

@ -0,0 +1,40 @@
<?php
namespace StaticMapLite\Element\Polyline;
class Polyline
{
protected $polyline = null;
protected $colorRed = 0;
protected $colorGreen = 0;
protected $colorBlue = 0;
public function __construct(string $polyline, int $colorRed, int $colorGreen, int $colorBlue)
{
$this->polyline = $polyline;
$this->colorRed = $colorRed;
$this->colorGreen = $colorGreen;
$this->colorBlue = $colorBlue;
}
public function getPolyline(): string
{
return $this->polyline;
}
public function getColorRed(): int
{
return $this->colorRed;
}
public function getColorGreen(): int
{
return $this->colorGreen;
}
public function getColorBlue(): int
{
return $this->colorBlue;
}
}

View File

@ -4,6 +4,7 @@ namespace StaticMapLite;
use StaticMapLite\Canvas\Canvas;
use StaticMapLite\Element\Marker\Marker;
use StaticMapLite\Element\Polyline\Polyline;
use StaticMapLite\TileResolver\CachedTileResolver;
class Printer
@ -34,29 +35,29 @@ class Printer
'extension' => '.png',
'shadow' => false,
'offsetImage' => '0,-19',
'offsetShadow' => false
'offsetShadow' => false,
),
// openlayers std markers
'ol-marker' => array('regex' => '/^ol-marker(|-blue|-gold|-green)+$/',
'extension' => '.png',
'shadow' => '../marker_shadow.png',
'offsetImage' => '-10,-25',
'offsetShadow' => '-1,-13'
'offsetShadow' => '-1,-13',
),
// taken from http://www.visual-case.it/cgi-bin/vc/GMapsIcons.pl
'ylw' => array('regex' => '/^(pink|purple|red|ltblu|ylw)-pushpin$/',
'extension' => '.png',
'shadow' => '../marker_shadow.png',
'offsetImage' => '-10,-32',
'offsetShadow' => '-1,-13'
'offsetShadow' => '-1,-13',
),
// http://svn.openstreetmap.org/sites/other/StaticMap/symbols/0.png
'ojw' => array('regex' => '/^bullseye$/',
'extension' => '.png',
'shadow' => false,
'offsetImage' => '-20,-20',
'offsetShadow' => false
)
'offsetShadow' => false,
),
);
@ -95,11 +96,9 @@ class Printer
return $this;
}
public function addPolyline(string $polylineString, int $colorRed, int $colorGreen, int $colorBlue): Printer
public function addPolyline(Polyline $polyline): Printer
{
$polyline = ['polyline' => $polylineString, 'colorRed' => $colorRed, 'colorGreen' => $colorGreen, 'colorBlue' => $colorBlue];
array_push($this->polylines, $polyline);
$this->polylines[] = $polyline;
return $this;
}
@ -253,22 +252,16 @@ class Printer
public function placePolylines()
{
// loop thru marker array
/** @var Polyline $polyline */
foreach ($this->polylines as $polyline) {
// set some local variables
$polylineString = $polyline['polyline'];
$colorRed = $polyline['colorRed'];
$colorGreen = $polyline['colorGreen'];
$colorBlue = $polyline['colorBlue'];
$polylineList = \Polyline::decode($polylineString);
$polylineList = \Polyline::decode($polyline->getPolyline());
$sourceLatitude = null;
$sourceLongitude = null;
$destinationLatitude = null;
$destinationLongitude = null;
$color = imagecolorallocate($this->canvas->getImage(), $colorRed, $colorGreen, $colorBlue);
$color = imagecolorallocate($this->canvas->getImage(), $polyline->getColorRed(), $polyline->getColorGreen(), $polyline->getColorBlue());
imagesetthickness($this->image, 3);
//imageantialias($this->image, true);