resolution de l'unsafe reference ...

This commit is contained in:
Gabriel Dehame 2023-03-03 23:39:01 +01:00
parent 3807abc2ad
commit b97903f5f8

View File

@ -52,20 +52,26 @@ function polygonCenter(polygon)
let minY = -1;
let maxX = -1;
let maxY = -1;
polygon.forEach((pt) => {
if (minX === -1 || minX > pt[0]) {
for (const ind in polygon)
{
const pt = polygon[ind];
if (minX === -1 || minX > pt[0])
{
minX = pt[0];
}
if (minY === -1 || minY > pt[1]) {
if (minY === -1 || minY > pt[1])
{
minY = pt[1];
}
if (maxY === -1 || maxY < pt[1]) {
if (maxY === -1 || maxY < pt[1])
{
maxY = pt[1];
}
if (maxX === -1 || maxX < pt[0]) {
if (maxX === -1 || maxX < pt[0])
{
maxX = pt[0];
}
})
}
return [(minX + maxX) / 2, (maxY + minY) / 2];
}
@ -79,20 +85,26 @@ function logoSize(polygon)
let maxY = -1;
// We first calculate the maximal coordinates to then output
// 75% the size of the room
polygon.forEach((pt) => {
if (minX === -1 || minX > pt[0]) {
for (const ind in polygon)
{
const pt = polygon[ind];
if (minX === -1 || minX > pt[0])
{
minX = pt[0];
}
if (minY === -1 || minY > pt[1]) {
if (minY === -1 || minY > pt[1])
{
minY = pt[1];
}
if (maxY === -1 || maxY < pt[1]) {
if (maxY === -1 || maxY < pt[1])
{
maxY = pt[1];
}
if (maxX === -1 || maxX < pt[0]) {
if (maxX === -1 || maxX < pt[0])
{
maxX = pt[0];
}
})
}
// For some unknown reason we have to multiply by 10 otherwise
// it's almost invisible
const x = 30*(maxX - minX)/4;
@ -118,20 +130,26 @@ function min_max(request)
{
const element = request[ind];
// element can be a room, a lift, a staircase or toilets
(element["surface"]).forEach((pt) => {
if (minX === -1 || minX > pt["x"]) {
for (const index in element["surface"])
{
const pt = element["surface"][index];
if (minX === -1 || minX > pt["x"])
{
minX = pt["x"];
}
if (minY === -1 || minY > pt["y"]) {
if (minY === -1 || minY > pt["y"])
{
minY = pt["y"];
}
if (maxY === -1 || maxY < pt["y"]) {
if (maxY === -1 || maxY < pt["y"])
{
maxY = pt["y"];
}
if (maxX === -1 || maxX < pt["x"]) {
if (maxX === -1 || maxX < pt["x"])
{
maxX = pt["x"];
}
})
}
}
return [minX, maxX, minY, maxY];
}
@ -213,7 +231,8 @@ function list_polygons(request, center, callbackRoomSelected, selectedRoom, call
{
const element = request[ind];
// element can be a room, a lift, a staircase or toilets
const positions = (element["surface"]).map((pt) => {
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)
// It also changes the objects into lists of two coordinates to make it accepted by the "positions" attribute of