MAPG-44 modify MapAdminController to get/save place pov data
This commit is contained in:
parent
4e48e6ae73
commit
b736ce8970
@ -16,6 +16,7 @@ use MapGuesser\Response\HtmlContent;
|
|||||||
use MapGuesser\Response\JsonContent;
|
use MapGuesser\Response\JsonContent;
|
||||||
use MapGuesser\Util\Geo\Bounds;
|
use MapGuesser\Util\Geo\Bounds;
|
||||||
use MapGuesser\Util\Geo\Position;
|
use MapGuesser\Util\Geo\Position;
|
||||||
|
use MapGuesser\Util\Panorama\Pov;
|
||||||
|
|
||||||
class MapAdminController implements ISecured
|
class MapAdminController implements ISecured
|
||||||
{
|
{
|
||||||
@ -94,6 +95,11 @@ class MapAdminController implements ISecured
|
|||||||
$place->setMap($map);
|
$place->setMap($map);
|
||||||
$place->setLat((float) $placeRaw['lat']);
|
$place->setLat((float) $placeRaw['lat']);
|
||||||
$place->setLng((float) $placeRaw['lng']);
|
$place->setLng((float) $placeRaw['lng']);
|
||||||
|
$place->setPov(new Pov(
|
||||||
|
(float) $placeRaw['pov']['heading'],
|
||||||
|
(float) $placeRaw['pov']['pitch'],
|
||||||
|
(float) $placeRaw['pov']['zoom']
|
||||||
|
));
|
||||||
|
|
||||||
if ($placeRaw['panoId'] === -1) {
|
if ($placeRaw['panoId'] === -1) {
|
||||||
$place->setPanoIdCachedTimestampDate(new DateTime('-1 day'));
|
$place->setPanoIdCachedTimestampDate(new DateTime('-1 day'));
|
||||||
@ -114,6 +120,11 @@ class MapAdminController implements ISecured
|
|||||||
$place = $this->placeRepository->getById((int) $placeRaw['id']);
|
$place = $this->placeRepository->getById((int) $placeRaw['id']);
|
||||||
$place->setLat((float) $placeRaw['lat']);
|
$place->setLat((float) $placeRaw['lat']);
|
||||||
$place->setLng((float) $placeRaw['lng']);
|
$place->setLng((float) $placeRaw['lng']);
|
||||||
|
$place->setPov(new Pov(
|
||||||
|
(float) $placeRaw['pov']['heading'],
|
||||||
|
(float) $placeRaw['pov']['pitch'],
|
||||||
|
(float) $placeRaw['pov']['zoom']
|
||||||
|
));
|
||||||
$place->setPanoIdCachedTimestampDate(new DateTime('-1 day'));
|
$place->setPanoIdCachedTimestampDate(new DateTime('-1 day'));
|
||||||
|
|
||||||
$this->pdm->saveToDb($place);
|
$this->pdm->saveToDb($place);
|
||||||
@ -150,7 +161,8 @@ class MapAdminController implements ISecured
|
|||||||
return new JsonContent($data);
|
return new JsonContent($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteMap() {
|
public function deleteMap()
|
||||||
|
{
|
||||||
$mapId = (int) $this->request->query('mapId');
|
$mapId = (int) $this->request->query('mapId');
|
||||||
|
|
||||||
$map = $this->mapRepository->getById($mapId);
|
$map = $this->mapRepository->getById($mapId);
|
||||||
@ -206,7 +218,7 @@ class MapAdminController implements ISecured
|
|||||||
{
|
{
|
||||||
//TODO: from repository or relations
|
//TODO: from repository or relations
|
||||||
$select = new Select(\Container::$dbConnection, 'places');
|
$select = new Select(\Container::$dbConnection, 'places');
|
||||||
$select->columns(['id', 'lat', 'lng', 'pano_id_cached', 'pano_id_cached_timestamp']);
|
$select->columns(['id', 'lat', 'lng', 'pano_id_cached', 'pano_id_cached_timestamp', 'pov_heading', 'pov_pitch', 'pov_zoom']);
|
||||||
$select->where('map_id', '=', $map->getId());
|
$select->where('map_id', '=', $map->getId());
|
||||||
|
|
||||||
$result = $select->execute();
|
$result = $select->execute();
|
||||||
@ -214,8 +226,6 @@ class MapAdminController implements ISecured
|
|||||||
$places = [];
|
$places = [];
|
||||||
|
|
||||||
while ($place = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
while ($place = $result->fetch(IResultSet::FETCH_ASSOC)) {
|
||||||
//$panoId = ???
|
|
||||||
//$pov = ???
|
|
||||||
$noPano = $place['pano_id_cached_timestamp'] && $place['pano_id_cached'] === null;
|
$noPano = $place['pano_id_cached_timestamp'] && $place['pano_id_cached'] === null;
|
||||||
|
|
||||||
$places[$place['id']] = [
|
$places[$place['id']] = [
|
||||||
@ -223,7 +233,11 @@ class MapAdminController implements ISecured
|
|||||||
'lat' => $place['lat'],
|
'lat' => $place['lat'],
|
||||||
'lng' => $place['lng'],
|
'lng' => $place['lng'],
|
||||||
'panoId' => null,
|
'panoId' => null,
|
||||||
'pov' => ['heading' => 0.0, 'pitch' => 0.0, 'zoom' => 0.0],
|
'pov' => [
|
||||||
|
'heading' => (float) $place['pov_heading'],
|
||||||
|
'pitch' => (float) $place['pov_pitch'],
|
||||||
|
'zoom' => (float) $place['pov_zoom']
|
||||||
|
],
|
||||||
'noPano' => $noPano
|
'noPano' => $noPano
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user