MAPG-44 add Pov class and adjust Place model to store pov
This commit is contained in:
parent
028d8a22a2
commit
4e48e6ae73
@ -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 (
|
||||
|
56
src/Util/Panorama/Pov.php
Normal file
56
src/Util/Panorama/Pov.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php namespace MapGuesser\Util\Panorama;
|
||||
|
||||
class Pov
|
||||
{
|
||||
private float $heading;
|
||||
|
||||
private float $pitch;
|
||||
|
||||
private float $zoom;
|
||||
|
||||
public function __construct(float $heading, float $pitch, float $zoom)
|
||||
{
|
||||
$this->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
|
||||
];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user