2015-01-07 18:58:52 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package dev
|
|
|
|
|
* @author David Molineus <david.molineus@netzmacht.de>
|
|
|
|
|
* @copyright 2015 netzmacht creative David Molineus
|
|
|
|
|
* @license LGPL 3.0
|
|
|
|
|
* @filesource
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
|
|
|
|
|
|
2015-01-24 21:37:25 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Filter\Filter;
|
2015-01-07 18:58:52 +01:00
|
|
|
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
|
|
|
|
|
use Netzmacht\LeafletPHP\Definition;
|
|
|
|
|
use Netzmacht\LeafletPHP\Definition\Type\LatLng;
|
|
|
|
|
use Netzmacht\LeafletPHP\Definition\Type\LatLngBounds;
|
|
|
|
|
|
2015-01-12 19:03:29 +01:00
|
|
|
/**
|
|
|
|
|
* Class RectangleMapper maps a database model to its rectangle vector definition.
|
|
|
|
|
*
|
|
|
|
|
* @package Netzmacht\Contao\Leaflet\Mapper\Vector
|
|
|
|
|
*/
|
2015-01-07 18:58:52 +01:00
|
|
|
class RectangleMapper extends AbstractVectorMapper
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Class of the definition being created.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected static $definitionClass = 'Netzmacht\LeafletPHP\Definition\Vector\Rectangle';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Layer type.
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected static $type = 'rectangle';
|
|
|
|
|
|
2015-01-12 19:03:29 +01:00
|
|
|
/**
|
|
|
|
|
* {@inheritdoc}
|
|
|
|
|
*/
|
2015-01-09 13:41:09 +01:00
|
|
|
protected function buildConstructArguments(
|
|
|
|
|
\Model $model,
|
|
|
|
|
DefinitionMapper $mapper,
|
2015-01-24 21:37:25 +01:00
|
|
|
Filter $filter = null,
|
2015-01-09 13:41:09 +01:00
|
|
|
$elementId = null
|
|
|
|
|
) {
|
2015-01-07 18:58:52 +01:00
|
|
|
$latLngs = array_map(
|
2015-01-12 19:03:29 +01:00
|
|
|
function ($latLng) {
|
2015-01-07 18:58:52 +01:00
|
|
|
return LatLng::fromString($latLng);
|
|
|
|
|
},
|
|
|
|
|
deserialize($model->bounds, true)
|
|
|
|
|
);
|
|
|
|
|
|
2015-01-24 21:37:25 +01:00
|
|
|
$arguments = parent::buildConstructArguments($model, $mapper, $filter, $elementId);
|
2015-01-07 18:58:52 +01:00
|
|
|
$arguments[] = new LatLngBounds($latLngs[0], $latLngs[1]);
|
|
|
|
|
|
|
|
|
|
return $arguments;
|
|
|
|
|
}
|
|
|
|
|
}
|