| @@ 23-106 (lines=84) @@ | ||
| 20 | /** |
|
| 21 | * @author GeLo <[email protected]> |
|
| 22 | */ |
|
| 23 | class HeatmapLayer implements ExtendableInterface, OptionsAwareInterface |
|
| 24 | { |
|
| 25 | use OptionsAwareTrait; |
|
| 26 | use VariableAwareTrait; |
|
| 27 | ||
| 28 | /** |
|
| 29 | * @var Coordinate[] |
|
| 30 | */ |
|
| 31 | private $coordinates = []; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param Coordinate[] $coordinates |
|
| 35 | * @param mixed[] $options |
|
| 36 | */ |
|
| 37 | public function __construct(array $coordinates = [], array $options = []) |
|
| 38 | { |
|
| 39 | $this->setCoordinates($coordinates); |
|
| 40 | $this->setOptions($options); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @return bool |
|
| 45 | */ |
|
| 46 | public function hasCoordinates() |
|
| 47 | { |
|
| 48 | return !empty($this->coordinates); |
|
| 49 | } |
|
| 50 | ||
| 51 | /** |
|
| 52 | * @return Coordinate[] |
|
| 53 | */ |
|
| 54 | public function getCoordinates() |
|
| 55 | { |
|
| 56 | return $this->coordinates; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @param Coordinate[] $coordinates |
|
| 61 | */ |
|
| 62 | public function setCoordinates(array $coordinates) |
|
| 63 | { |
|
| 64 | $this->coordinates = []; |
|
| 65 | $this->addCoordinates($coordinates); |
|
| 66 | } |
|
| 67 | ||
| 68 | /** |
|
| 69 | * @param Coordinate[] $coordinates |
|
| 70 | */ |
|
| 71 | public function addCoordinates(array $coordinates) |
|
| 72 | { |
|
| 73 | foreach ($coordinates as $coordinate) { |
|
| 74 | $this->addCoordinate($coordinate); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * @return bool |
|
| 80 | */ |
|
| 81 | public function hasCoordinate(Coordinate $coordinate) |
|
| 82 | { |
|
| 83 | return in_array($coordinate, $this->coordinates, true); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function addCoordinate(Coordinate $coordinate) |
|
| 87 | { |
|
| 88 | if (!$this->hasCoordinate($coordinate)) { |
|
| 89 | $this->coordinates[] = $coordinate; |
|
| 90 | } |
|
| 91 | } |
|
| 92 | ||
| 93 | public function removeCoordinate(Coordinate $coordinate) |
|
| 94 | { |
|
| 95 | unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]); |
|
| 96 | $this->coordinates = empty($this->coordinates) ? [] : array_values($this->coordinates); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 24-105 (lines=82) @@ | ||
| 21 | * |
|
| 22 | * @author GeLo <[email protected]> |
|
| 23 | */ |
|
| 24 | class Polygon implements ExtendableInterface, OptionsAwareInterface |
|
| 25 | { |
|
| 26 | use OptionsAwareTrait; |
|
| 27 | use VariableAwareTrait; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @var Coordinate[] |
|
| 31 | */ |
|
| 32 | private $coordinates = []; |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Coordinate[] $coordinates |
|
| 36 | * @param mixed[] $options |
|
| 37 | */ |
|
| 38 | public function __construct(array $coordinates = [], array $options = []) |
|
| 39 | { |
|
| 40 | $this->addCoordinates($coordinates); |
|
| 41 | $this->addOptions($options); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return bool |
|
| 46 | */ |
|
| 47 | public function hasCoordinates() |
|
| 48 | { |
|
| 49 | return !empty($this->coordinates); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @return Coordinate[] |
|
| 54 | */ |
|
| 55 | public function getCoordinates() |
|
| 56 | { |
|
| 57 | return $this->coordinates; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * @param Coordinate[] $coordinates |
|
| 62 | */ |
|
| 63 | public function setCoordinates(array $coordinates) |
|
| 64 | { |
|
| 65 | $this->coordinates = []; |
|
| 66 | $this->addCoordinates($coordinates); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @param Coordinate[] $coordinates |
|
| 71 | */ |
|
| 72 | public function addCoordinates(array $coordinates) |
|
| 73 | { |
|
| 74 | foreach ($coordinates as $coordinate) { |
|
| 75 | $this->addCoordinate($coordinate); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| 79 | /** |
|
| 80 | * @return bool |
|
| 81 | */ |
|
| 82 | public function hasCoordinate(Coordinate $coordinate) |
|
| 83 | { |
|
| 84 | return in_array($coordinate, $this->coordinates, true); |
|
| 85 | } |
|
| 86 | ||
| 87 | public function addCoordinate(Coordinate $coordinate) |
|
| 88 | { |
|
| 89 | $this->coordinates[] = $coordinate; |
|
| 90 | } |
|
| 91 | ||
| 92 | public function removeCoordinate(Coordinate $coordinate) |
|
| 93 | { |
|
| 94 | unset($this->coordinates[array_search($coordinate, $this->coordinates, true)]); |
|
| 95 | $this->coordinates = empty($this->coordinates) ? [] : array_values($this->coordinates); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||