diff --git a/API.md b/API.md index 654bad9..92480fb 100644 --- a/API.md +++ b/API.md @@ -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 :__ diff --git a/src/Controller/MapApiController.php b/src/Controller/MapApiController.php index 42fc873..f4f4e75 100644 --- a/src/Controller/MapApiController.php +++ b/src/Controller/MapApiController.php @@ -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/')] diff --git a/src/Entity/Place.php b/src/Entity/Place.php index 43ae3f1..ec2ff5a 100644 --- a/src/Entity/Place.php +++ b/src/Entity/Place.php @@ -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