Compare commits
No commits in common. "e98cbc585b95d817da32b4e4f2494ce4b4b965d7" and "c0d5b38a893c284e5cbb34a2c3b6923cf70da828" have entirely different histories.
e98cbc585b
...
c0d5b38a89
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
use App\Entity\GeoImage;
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
|
||||||
|
|
||||||
class GeoImageController extends AbstractController
|
|
||||||
{
|
|
||||||
#[Route('/geoimage', name: 'app_geo_image')]
|
|
||||||
public function index(EntityManagerInterface $em): JsonResponse
|
|
||||||
{
|
|
||||||
$repo = $em->getRepository(GeoImage::class);
|
|
||||||
$geoImages = $repo->findAllWithGeometry();
|
|
||||||
|
|
||||||
return $this->json($geoImages);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Entity;
|
|
||||||
|
|
||||||
use App\Repository\GeoImageRepository;
|
|
||||||
use Doctrine\DBAL\Types\Types;
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
|
||||||
use JsonSerializable;
|
|
||||||
|
|
||||||
#[ORM\Entity(repositoryClass: GeoImageRepository::class)]
|
|
||||||
#[ORM\Table(name: 'geo_immagine_catasto')]
|
|
||||||
class GeoImage implements JsonSerializable
|
|
||||||
{
|
|
||||||
#[ORM\Id]
|
|
||||||
#[ORM\GeneratedValue]
|
|
||||||
#[ORM\Column]
|
|
||||||
private ?int $id = null;
|
|
||||||
|
|
||||||
#[ORM\Column(length: 255)]
|
|
||||||
private ?string $filename = null;
|
|
||||||
|
|
||||||
#[ORM\Column(type: Types::JSON, name: 'poligono')]
|
|
||||||
private ?string $polygon = null;
|
|
||||||
|
|
||||||
public function getId(): ?int
|
|
||||||
{
|
|
||||||
return $this->id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setId(string $id): static
|
|
||||||
{
|
|
||||||
$this->id = $id;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getFilename(): ?string
|
|
||||||
{
|
|
||||||
return $this->filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setFilename(string $filename): static
|
|
||||||
{
|
|
||||||
$this->filename = $filename;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPolygon(): ?string
|
|
||||||
{
|
|
||||||
return $this->polygon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPolygon(string $polygon): static
|
|
||||||
{
|
|
||||||
$this->polygon = $polygon;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function jsonSerialize(): mixed
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'filename' => $this->filename,
|
|
||||||
'polygon' => $this->polygon,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Repository;
|
|
||||||
|
|
||||||
use App\Entity\GeoImage;
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
||||||
use Doctrine\Persistence\ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @extends ServiceEntityRepository<GeoImage>
|
|
||||||
*/
|
|
||||||
class GeoImageRepository extends ServiceEntityRepository
|
|
||||||
{
|
|
||||||
public function __construct(ManagerRegistry $registry)
|
|
||||||
{
|
|
||||||
parent::__construct($registry, GeoImage::class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all geoimages with associated geometry (polygon)
|
|
||||||
* as GeoJSON
|
|
||||||
* @return GeoImage[]
|
|
||||||
*/
|
|
||||||
public function findAllWithGeometry()
|
|
||||||
{
|
|
||||||
$conn = $this->getEntityManager()->getConnection();
|
|
||||||
|
|
||||||
$sql = "SELECT
|
|
||||||
id,
|
|
||||||
filename,
|
|
||||||
ST_AsGeoJSON(poligono) as polygon
|
|
||||||
FROM geo_immagine_catasto
|
|
||||||
";
|
|
||||||
|
|
||||||
$results = $conn->executeQuery($sql)
|
|
||||||
->fetchAllAssociative();
|
|
||||||
|
|
||||||
$entities = [];
|
|
||||||
foreach ($results as $result) {
|
|
||||||
$geoimage = new GeoImage();
|
|
||||||
$geoimage->setId($result['id']);
|
|
||||||
$geoimage->setFilename($result['filename']);
|
|
||||||
$geoimage->setPolygon($result['polygon']);
|
|
||||||
$entities[] = $geoimage;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $entities;
|
|
||||||
}
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @return GeoImage[] Returns an array of GeoImage objects
|
|
||||||
// */
|
|
||||||
// public function findByExampleField($value): array
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('g')
|
|
||||||
// ->andWhere('g.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->orderBy('g.id', 'ASC')
|
|
||||||
// ->setMaxResults(10)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?GeoImage
|
|
||||||
// {
|
|
||||||
// return $this->createQueryBuilder('g')
|
|
||||||
// ->andWhere('g.exampleField = :val')
|
|
||||||
// ->setParameter('val', $value)
|
|
||||||
// ->getQuery()
|
|
||||||
// ->getOneOrNullResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user