refonte des commentaires et suppression du Tooltip pour les couloirs

This commit is contained in:
Gabriel Dehame 2023-03-05 14:36:34 +01:00
parent 0f97be0499
commit 28e4816e79

View File

@ -53,6 +53,7 @@ function polygonCenter(polygon)
let minY = -1;
let maxX = -1;
let maxY = -1;
// We get the extremal coordinates
for (const ind in polygon)
{
const pt = polygon[ind];
@ -73,6 +74,7 @@ function polygonCenter(polygon)
maxX = pt[0];
}
}
// Then return the average
return [(minX + maxX) / 2, (maxY + minY) / 2];
}
@ -130,7 +132,6 @@ function min_max(request)
for (const ind in request)
{
const element = request[ind];
// element can be a room, a lift, a staircase or toilets
for (const index in element["surface"])
{
const pt = element["surface"][index];
@ -159,6 +160,7 @@ function floorList(connectedFloors, callbackChangeFloor)
{
// Returns under html format a list of floors connected
// listed in connectedFloors
// Auxiliary function used when creating a Lift/Strairs component
let htmlFloorList = [];
for (const floor in connectedFloors)
{
@ -172,7 +174,11 @@ function floorList(connectedFloors, callbackChangeFloor)
function newPolygon(element, positions, selectedRoom, callbackRoomSelected, callbackChangeFloor)
{
// Auxiliary function to return the appropriate polygon depending
// on wether it is a room, a lift, a staircase or toilets
// on wether it is a room (R), a lift (L), a staircase (S), toilets (T) or corridor (C)
// For all except corridors we put a Tooltip with the name of the room
// as well as a callback to display the room informations when the user clicks on the room
// and for S or L, we add a Popup with the list of connected floors and possibility to load the
// map of a connected floor
const color = selectedRoom === element["id"] ? 'red' : 'grey';
if (element["type"] === "S")
{
@ -215,9 +221,7 @@ function newPolygon(element, positions, selectedRoom, callbackRoomSelected, call
else if (element["type"] === "C")
{
// In this case it is a corridor
return <Polygon positions={positions} key={element["id"] + color} color={"peru"}>
<Tooltip>{element["id"]}</Tooltip>
</Polygon>
return <Polygon positions={positions} key={element["id"] + color} color={"peru"}/>
}
}
@ -234,8 +238,7 @@ function list_polygons(request, center, callbackRoomSelected, selectedRoom, call
// element can be a room, a lift, a staircase or toilets
const positions = (element["surface"]).map((pt) =>
{
// This function rotates and recenters de the map (should not be necessary once the real data are gathered and
// only works for third floor)
// This function rotates and recenters de the map (should not be necessary once the real data are gathered.
// It also changes the objects into lists of two coordinates to make it accepted by the "positions" attribute of
// the "Polygon" react-leaflet component
return [-(pt["y"] - center[1]) / 6, (pt["x"] - center[0]) / 6];