mirror of
https://gitlab.aliens-lyon.fr/encartes/backend.git
synced 2026-03-17 22:51:04 +01:00
Add FloorAltitude & maj API > basefunction except edit are fine, representation take only cylinder and polySurface
This commit is contained in:
parent
250e186017
commit
0cb138d7d6
@ -22,29 +22,20 @@ class MapApiController extends AbstractController
|
||||
}
|
||||
|
||||
#[Route('/map/api/get_floor')]
|
||||
public function get_floor(FloorRepository $rep, int $id): JsonResponse
|
||||
public function get_floor(FloorRepository $rep, int $id, string $representation): JsonResponse
|
||||
{
|
||||
$floor = $rep->findFloorById($id);
|
||||
$corridors = $floor->getCorridors();
|
||||
$rooms = array();
|
||||
foreach ($corridors as $cor){
|
||||
foreach ($cor->getConnectedPlaces() as $place) {
|
||||
if (($place instanceof Room) and !($rooms->contains($place))) {
|
||||
$rooms[] = $place;
|
||||
}
|
||||
}
|
||||
}
|
||||
$jsonCorridors = array();
|
||||
$jsonRooms = array();
|
||||
foreach ($corridors as $cor){
|
||||
$jsonCorridors[] = $this->json([
|
||||
'id' => $cor->getId(),
|
||||
'name' => $cor->getName(),
|
||||
'type' => $cor->getType()
|
||||
//'polygon' => $cor->getPolyhedronRepresentation()
|
||||
$places = $floor->getPlace();
|
||||
$jsonPlaces = new ArrayCollection();
|
||||
foreach ($places as $place){
|
||||
$jsonPlaces[] = $this->json([
|
||||
'id' => $place->getId(),
|
||||
'name' => $place->getName(),
|
||||
'type' => $place->getType(),
|
||||
'surface' => $place->getTwoDRepresentation($representation, $floor->getAltitude())
|
||||
]);
|
||||
}
|
||||
return array($jsonCorridors, $jsonRooms);
|
||||
return $jsonPlaces;
|
||||
}
|
||||
|
||||
#[Route('/map/api/find_room_by_name')]
|
||||
|
||||
@ -15,6 +15,10 @@ class Floor
|
||||
#[ORM\Column(type: "integer")]
|
||||
private $id;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: "integer")]
|
||||
private $altitude;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Building::class, inversedBy: "floors")]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
private $building;
|
||||
@ -42,6 +46,17 @@ class Floor
|
||||
$this->building = $building;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAltitude(): ?int
|
||||
{
|
||||
return $this->altitude;
|
||||
}
|
||||
|
||||
public function setAltitude(int $altitude): self
|
||||
{
|
||||
$this->altitude = $altitude;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Place>
|
||||
|
||||
@ -26,7 +26,6 @@ class Place
|
||||
|
||||
#[ORM\OneToMany(targetEntity: PlaceName::class, mappedBy: "place")]
|
||||
private $names;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: RoomUserName::class, mappedBy: "place")]
|
||||
private $users;
|
||||
|
||||
@ -35,10 +34,19 @@ class Place
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Place::class, inversedBy: "connectedPlaces")]
|
||||
private $connection;
|
||||
|
||||
#[ORM\ManyToMany(targetEntity: Place::class, mappedBy: "connection")]
|
||||
private $connectedPlaces;
|
||||
|
||||
#[ORM\OneToMany(targetEntity: ThreeDObjectFile::class, mappedBy: "place")]
|
||||
private $ComplexRepresentation;
|
||||
#[ORM\OneToMany(targetEntity: Polyhedron::class, mappedBy: "place")]
|
||||
private $PolyhedronRepresentation;
|
||||
#[ORM\OneToMany(targetEntity: Cylinder::class, mappedBy: "place")]
|
||||
private $CylinderRepresentation;
|
||||
#[ORM\OneToMany(targetEntity: PolySurface::class, mappedBy: "place")]
|
||||
private $PolySurfaceRepresentation;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->connection = new ArrayCollection();
|
||||
@ -46,6 +54,9 @@ class Place
|
||||
$this->names = new ArrayCollection();
|
||||
$this->users = new ArrayCollection();
|
||||
$this->floors = new ArrayCollection();
|
||||
$this->ComplexRepresentation = new ArrayCollection();
|
||||
$this->PolyhedronRepresentation = new ArrayCollection();
|
||||
$this->CylinderRepresentation = new ArrayCollection();
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
@ -178,4 +189,162 @@ class Place
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, ThreeDObjectFile>
|
||||
*/
|
||||
public function getComplexRepresentation(): Collection
|
||||
{
|
||||
return $this->ComplexRepresentation;
|
||||
}
|
||||
|
||||
public function addComplexRepresentation(ThreeDObjectFile $complexRepresentation): self
|
||||
{
|
||||
if (!$this->ComplexRepresentation->contains($complexRepresentation)) {
|
||||
$this->ComplexRepresentation[] = $complexRepresentation;
|
||||
$complexRepresentation->setRoom($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeComplexRepresentation(ThreeDObjectFile $complexRepresentation): self
|
||||
{
|
||||
if ($this->ComplexRepresentation->removeElement($complexRepresentation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($complexRepresentation->getRoom() === $this) {
|
||||
$complexRepresentation->setRoom(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Polyhedron>
|
||||
*/
|
||||
public function getPolyhedronRepresentation(): Collection
|
||||
{
|
||||
return $this->PolyhedronRepresentation;
|
||||
}
|
||||
|
||||
public function addPolyhedronRepresentation(Polyhedron $polyhedronRepresentation): self
|
||||
{
|
||||
if (!$this->PolyhedronRepresentation->contains($polyhedronRepresentation)) {
|
||||
$this->PolyhedronRepresentation[] = $polyhedronRepresentation;
|
||||
$polyhedronRepresentation->setRoom($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePolyhedronRepresentation(Polyhedron $polyhedronRepresentation): self
|
||||
{
|
||||
if ($this->PolyhedronRepresentation->removeElement($polyhedronRepresentation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($polyhedronRepresentation->getRoom() === $this) {
|
||||
$polyhedronRepresentation->setRoom(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, Cylinder>
|
||||
*/
|
||||
public function getCylinderRepresentation(): Collection
|
||||
{
|
||||
return $this->CylinderRepresentation;
|
||||
}
|
||||
|
||||
public function addCylinderRepresentation(Cylinder $cylinderRepresentation): self
|
||||
{
|
||||
if (!$this->CylinderRepresentation->contains($cylinderRepresentation)) {
|
||||
$this->CylinderRepresentation[] = $cylinderRepresentation;
|
||||
$cylinderRepresentation->setRoom($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeCylinderRepresentation(Cylinder $cylinderRepresentation): self
|
||||
{
|
||||
if ($this->CylinderRepresentation->removeElement($cylinderRepresentation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($cylinderRepresentation->getRoom() === $this) {
|
||||
$cylinderRepresentation->setRoom(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return Collection<int, PolySurface>
|
||||
*/
|
||||
public function getPolySurfaceRepresentation(): Collection
|
||||
{
|
||||
return $this->PolySurfaceRepresentation;
|
||||
}
|
||||
|
||||
public function addPolySurfaceRepresentation(PolySurface $polySurfaceRepresentation): self
|
||||
{
|
||||
if (!$this->PolySurfaceRepresentation->contains($polySurfaceRepresentation)) {
|
||||
$this->PolySurfaceRepresentation[] = $polySurfaceRepresentation;
|
||||
$polySurfaceRepresentation->setRoom($this);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removePolySurfaceRepresentation(PolySurface $polySurfaceRepresentation): self
|
||||
{
|
||||
if ($this->PolySurfaceRepresentation->removeElement($polySurfaceRepresentation)) {
|
||||
// set the owning side to null (unless already changed)
|
||||
if ($polySurfaceRepresentation->getRoom() === $this) {
|
||||
$polySurfaceRepresentation->setRoom(null);
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getTwoDRepresentation(string $representation, int $alt) : array
|
||||
{
|
||||
if ($representation=='Cylinder') {
|
||||
$rep = $this->getCylinderRepresentation();
|
||||
if ($rep != null){
|
||||
$repPoints = $rep->getCylinderbase()->getPolygonpoint(); //Points in repository format
|
||||
$Points = new ArrayCollection();
|
||||
foreach ($repPoints as $p) {
|
||||
$xy=array([$p->getX(), $p->getY()]);
|
||||
if (!$Points->contains($xy)){
|
||||
$Points[] = $xy;
|
||||
}
|
||||
}
|
||||
return $Points;
|
||||
}
|
||||
}
|
||||
elseif ($representation=='PolySurface') {
|
||||
$rep = $this->getPolySurfaceRepresentation();
|
||||
if ($rep != null){
|
||||
$repPoints = $rep->getPolysurfaceComponent()->getPolygonpoint(); //Points in repository format
|
||||
$Points = new ArrayCollection();
|
||||
foreach ($repPoints as $p) {
|
||||
$xy=array([$p->getX(), $p->getY()]);
|
||||
if (!$Points->contains($xy)){
|
||||
$Points[] = $xy;
|
||||
}
|
||||
}
|
||||
return $Points;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ class PolySurface
|
||||
#[ORM\OneToMany(targetEntity: PlaneSurface::class, mappedBy: "polySurface")]
|
||||
private $polysurfaceComponent;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Place::class)]
|
||||
#[ORM\ManyToOne(targetEntity: Place::class, inversedBy: "PolySurfaceRepresentation")]
|
||||
private $place;
|
||||
|
||||
public function __construct()
|
||||
@ -71,5 +71,5 @@ class PolySurface
|
||||
$this->place = $place;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Corridor;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Corridor>
|
||||
*
|
||||
* @method Corridor|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Corridor|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Corridor[] findAll()
|
||||
* @method Corridor[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class CorridorRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Corridor::class);
|
||||
}
|
||||
|
||||
public function add(Corridor $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function remove(Corridor $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->remove($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Corridor[] Returns an array of Corridor objects
|
||||
// */
|
||||
// public function findByExampleField($value): array
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->orderBy('c.id', 'ASC')
|
||||
// ->setMaxResults(10)
|
||||
// ->getQuery()
|
||||
// ->getResult()
|
||||
// ;
|
||||
// }
|
||||
|
||||
// public function findOneBySomeField($value): ?Corridor
|
||||
// {
|
||||
// return $this->createQueryBuilder('c')
|
||||
// ->andWhere('c.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
@ -40,18 +40,31 @@ class PlaceRepository extends ServiceEntityRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Place[] Returns an array of Place objects having connection with Corrido
|
||||
* @return Place[] Returns an array of Place objects
|
||||
*/
|
||||
public function findPlaceConnectedTo($value): array
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.connectedPlace = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('p.id', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
public function findPlaceByName(string $name): array
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('LOWER(p.name) = :val')
|
||||
->setParameter('val', strtolower($name))
|
||||
->orderBy('p.id', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
/**
|
||||
* @return Place[] Returns an array of Place objects
|
||||
*/
|
||||
public function findPlaceById(int $id): array
|
||||
{
|
||||
return $this->createQueryBuilder('p')
|
||||
->andWhere('p.id = :val')
|
||||
->setParameter('val', $id)
|
||||
->orderBy('p.id', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,77 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Room;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Room>
|
||||
*
|
||||
* @method Room|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method Room|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method Room[] findAll()
|
||||
* @method Room[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class RoomRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Room::class);
|
||||
}
|
||||
|
||||
public function add(Room $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->persist($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
public function remove(Room $entity, bool $flush = false): void
|
||||
{
|
||||
$this->getEntityManager()->remove($entity);
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Room[] Returns an array of Room objects
|
||||
*/
|
||||
public function findRoomByName(string $name): array
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->andWhere('r.name.lower() = :val')
|
||||
->setParameter('val', $name.lower())
|
||||
->orderBy('r.id', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
/**
|
||||
* @return Room[] Returns an array of Room objects
|
||||
*/
|
||||
public function findRoomById(int $id): array
|
||||
{
|
||||
return $this->createQueryBuilder('r')
|
||||
->andWhere('r.id = :val')
|
||||
->setParameter('val', $id)
|
||||
->orderBy('r.id', 'ASC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
// public function findOneBySomeField($value): ?Room
|
||||
// {
|
||||
// return $this->createQueryBuilder('r')
|
||||
// ->andWhere('r.exampleField = :val')
|
||||
// ->setParameter('val', $value)
|
||||
// ->getQuery()
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user