MAPG-106 query indoor pano too if no outdoor pano is found

This commit is contained in:
Bence Pőcze 2020-06-03 23:55:09 +02:00
parent e817a34a3a
commit 618f2a4d48

View File

@ -77,7 +77,7 @@ class PlaceRepository
return $place;
}
private function requestPanoId(array $place): ?string
private function requestPanoId(array $place, bool $canBeIndoor = false): ?string
{
if (
$place['pano_id_cached_timestamp'] &&
@ -90,7 +90,7 @@ class PlaceRepository
$request->setQuery([
'key' => $_ENV['GOOGLE_MAPS_SERVER_API_KEY'],
'location' => $place['lat'] . ',' . $place['lng'],
'source' => 'outdoor'
'source' => $canBeIndoor ? 'default' : 'outdoor'
]);
$response = $request->send();
@ -99,6 +99,11 @@ class PlaceRepository
$panoId = $panoData['status'] === 'OK' ? $panoData['pano_id'] : null;
// enable indoor panos if no outdoor found
if ($panoId === null && !$canBeIndoor) {
return $this->requestPanoId($place, true);
}
$this->saveCachedPanoId($place['id'], $panoId);
return $panoId;