add idSite and idBuilding to get_floor

This commit is contained in:
Kouril42 2023-02-19 12:34:40 +01:00
parent e3f16127af
commit c6222386a0
3 changed files with 21 additions and 10 deletions

19
API.md
View File

@ -11,17 +11,24 @@ Other participants for this project are Adrien Vannson & Gabriel Dehame & Maxime
## Functions
### /api/map/get_floor/ID/REPRESENTATION
> Return a list of place composing floor _ID_
> Return a json with siteId, buildingId and 'places': a list of place composing floor _ID_
> _REPRESENTATION_ is the representation' type to consider for every places in {'Cylinder', 'PolySurface'}. The default is 'Cylinder'
> Other representations should be added later, and it should become a priority order instead of a strict selection (actually if a place doesn't have Cylinder representation, it will return an empty list, even if the place has a PolySurface representation).
__Each place is a dict :__
__The dict looks like :__
```json
{
'id': int, //unique id
'names' : string[], //possibly empty,
'type': string, //in {'C'(orridor), 'S'(tairs), 'E'(levator), 'R'(oom)} ,
'surface' : list of [int, int] //list of every points composing the room, projected on the floor surface
'idSite' : int, //id of the Site
'idBuilding': int, //id of the Building
'places : [
{
'id': int, //unique id
'names' : string[], //Names of the place, possibly empty,
'type': string, //in {'C'(orridor), 'S'(tairs), 'E'(levator), 'R'(oom)} ,
'surface' : list of [int, int] //list of every points composing the room, projected on the floor surface
},
{...}
]
}
```
__Errors :__

View File

@ -91,7 +91,7 @@ class MapApiController extends AbstractController
elseif (sizeof($floors)>1) { throw new Exception('Internal Error: '.$id.' refers to more than one floorId ; the BDD is corrupted.'); }
$floor = $floors[0];
$places = $floor->getPlaces();
$jsonPlaces = new ArrayCollection();
$jsonPlaces = array();
if ($representation == 'Cylinder' || $representation == 'PolySurface'){
foreach ($places as $place){
$jsonPlaces[] = array(
@ -105,7 +105,11 @@ class MapApiController extends AbstractController
else {
return $this->json(["Error on represantation attribute"]);
}
return $this->json($jsonPlaces->toArray());
$building = $floor->getBuilding();
return $this->json(['idSite' => $building->getId(),
'idBuilding' => $building->getSite()->getId(),
'places' => $jsonPlaces
]);
}
#[Route('/api/map/get_all_floors/')]

View File

@ -88,11 +88,11 @@ class Place
public function getJoinedNames(): array
{
$names = new ArrayCollection();
$names = array();
foreach ($this->names as $plName) {
$names[] = $plName->getName();
}
return $names->toArray();
return $names;
}
public function addName(PlaceName $name): self