MAPG-47 add toArray() method to Bounds

This commit is contained in:
Bence Pőcze 2020-05-25 18:54:37 +02:00
parent 55d5cad40a
commit 8eb3dcf2e2

View File

@ -75,18 +75,23 @@ class Bounds
return $m * ($a + $c) / 2;
}
public function toJson(): string
public function toArray(): array
{
if (!$this->initialized) {
throw new \Exception("Bounds are not initialized!");
}
return json_encode([
return [
'south' => $this->southLat,
'west' => $this->westLng,
'north' => $this->northLat,
'east' => $this->eastLng,
]);
];
}
public function toJson(): string
{
return json_encode($this->toArray());
}
private function initialize(Position $position)