From 4e48e6ae7319735bf315d9e4826c75915df2e6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sat, 4 Jul 2020 01:09:00 +0200 Subject: [PATCH] MAPG-44 add Pov class and adjust Place model to store pov --- src/PersistentData/Model/Place.php | 46 +++++++++++++++++++++++- src/Util/Panorama/Pov.php | 56 ++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 src/Util/Panorama/Pov.php diff --git a/src/PersistentData/Model/Place.php b/src/PersistentData/Model/Place.php index d8d26b1..033f05e 100644 --- a/src/PersistentData/Model/Place.php +++ b/src/PersistentData/Model/Place.php @@ -5,12 +5,13 @@ use DateTime; use MapGuesser\Http\Request; use MapGuesser\PersistentData\PersistentDataManager; use MapGuesser\Util\Geo\Position; +use MapGuesser\Util\Panorama\Pov; class Place extends Model { protected static string $table = 'places'; - protected static array $fields = ['map_id', 'lat', 'lng', 'pano_id_cached', 'pano_id_cached_timestamp']; + protected static array $fields = ['map_id', 'lat', 'lng', 'pano_id_cached', 'pano_id_cached_timestamp', 'pov_heading', 'pov_pitch', 'pov_zoom']; protected static array $relations = ['map' => Map::class]; @@ -24,9 +25,12 @@ class Place extends Model private ?DateTime $panoIdCachedTimestamp = null; + private Pov $pov; + public function __construct() { $this->position = new Position(0.0, 0.0); + $this->pov = new Pov(0.0, 0.0, 0.0); } public function setMap(Map $map): void @@ -54,6 +58,26 @@ class Place extends Model $this->position->setLng($lng); } + public function setPov(Pov $pov): void + { + $this->pov = $pov; + } + + public function setPovHeading(float $heading): void + { + $this->pov->setHeading($heading); + } + + public function setPovPitch(float $pitch): void + { + $this->pov->setPitch($pitch); + } + + public function setPovZoom(float $zoom): void + { + $this->pov->setZoom($zoom); + } + public function setPanoIdCached(?string $panoIdCached): void { $this->panoIdCached = $panoIdCached; @@ -96,6 +120,26 @@ class Place extends Model return $this->position->getLng(); } + public function getPov(): Pov + { + return $this->pov; + } + + public function getPovHeading(): float + { + return $this->pov->getHeading(); + } + + public function getPovPitch(): float + { + return $this->pov->getPitch(); + } + + public function getPovZoom(): float + { + return $this->pov->getZoom(); + } + public function getFreshPanoId(bool $canBeIndoor = false): ?string { if ( diff --git a/src/Util/Panorama/Pov.php b/src/Util/Panorama/Pov.php new file mode 100644 index 0000000..8aaaf8f --- /dev/null +++ b/src/Util/Panorama/Pov.php @@ -0,0 +1,56 @@ +heading = $heading; + $this->pitch = $pitch; + $this->zoom = $zoom; + } + + public function setHeading(float $heading): void + { + $this->heading = $heading; + } + + public function setPitch(float $pitch): void + { + $this->pitch = $pitch; + } + + public function setZoom(float $zoom): void + { + $this->zoom = $zoom; + } + + public function getHeading(): float + { + return $this->heading; + } + + public function getPitch(): float + { + return $this->pitch; + } + + public function getZoom(): float + { + return $this->zoom; + } + + public function toArray(): array + { + return [ + 'heading' => $this->heading, + 'pitch' => $this->pitch, + 'zoom' => $this->zoom + ]; + } +}