diff --git a/src/Controller/MapAdminController.php b/src/Controller/MapAdminController.php index d12ccbf..0d7ad02 100644 --- a/src/Controller/MapAdminController.php +++ b/src/Controller/MapAdminController.php @@ -16,6 +16,7 @@ use MapGuesser\Response\HtmlContent; use MapGuesser\Response\JsonContent; use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Position; +use MapGuesser\Util\Panorama\Pov; class MapAdminController implements ISecured { @@ -94,6 +95,11 @@ class MapAdminController implements ISecured $place->setMap($map); $place->setLat((float) $placeRaw['lat']); $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) { $place->setPanoIdCachedTimestampDate(new DateTime('-1 day')); @@ -114,6 +120,11 @@ class MapAdminController implements ISecured $place = $this->placeRepository->getById((int) $placeRaw['id']); $place->setLat((float) $placeRaw['lat']); $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')); $this->pdm->saveToDb($place); @@ -150,7 +161,8 @@ class MapAdminController implements ISecured return new JsonContent($data); } - public function deleteMap() { + public function deleteMap() + { $mapId = (int) $this->request->query('mapId'); $map = $this->mapRepository->getById($mapId); @@ -206,7 +218,7 @@ class MapAdminController implements ISecured { //TODO: from repository or relations $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()); $result = $select->execute(); @@ -214,8 +226,6 @@ class MapAdminController implements ISecured $places = []; while ($place = $result->fetch(IResultSet::FETCH_ASSOC)) { - //$panoId = ??? - //$pov = ??? $noPano = $place['pano_id_cached_timestamp'] && $place['pano_id_cached'] === null; $places[$place['id']] = [ @@ -223,7 +233,11 @@ class MapAdminController implements ISecured 'lat' => $place['lat'], 'lng' => $place['lng'], '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 ]; }