Add spherical photo
This commit is contained in:
49
src/Controller/SphericalPhotoController.php
Normal file
49
src/Controller/SphericalPhotoController.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\SphericalPhoto;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
class SphericalPhotoController extends AbstractController
|
||||
{
|
||||
#[Route('/spherical', name: 'app_spherical')]
|
||||
public function index(
|
||||
EntityManagerInterface $em
|
||||
): JsonResponse
|
||||
{
|
||||
$repo = $em->getRepository(SphericalPhoto::class);
|
||||
$photos = $repo->findAll();
|
||||
|
||||
foreach ($photos as $key => $photo) {
|
||||
$coords = $repo->coordinates($photo->getId());
|
||||
$photo->setLat($coords['lat']);
|
||||
$photo->setLng($coords['lng']);
|
||||
$photos[$key] = $photo;
|
||||
}
|
||||
|
||||
return $this->json($photos);
|
||||
}
|
||||
|
||||
#[Route('/spherical/by/gis/{gisId<[\w_]+>}', name: 'app_spherical_by_gis')]
|
||||
public function byGis(
|
||||
string $gisId,
|
||||
EntityManagerInterface $em
|
||||
): JsonResponse
|
||||
{
|
||||
$repo = $em->getRepository(SphericalPhoto::class);
|
||||
$photos = $repo->findBySiteGis($gisId);
|
||||
|
||||
foreach ($photos as $key => $photo) {
|
||||
$coords = $repo->coordinates($photo->getId());
|
||||
$photo->setLat($coords['lat']);
|
||||
$photo->setLng($coords['lng']);
|
||||
$photos[$key] = $photo;
|
||||
}
|
||||
|
||||
return $this->json($photos);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user