mirror of
https://gitlab.aliens-lyon.fr/encartes/web-interface.git
synced 2026-03-17 22:51:04 +01:00
resolution de l'unsafe reference ...
This commit is contained in:
parent
3807abc2ad
commit
b97903f5f8
57
src/Map.js
57
src/Map.js
@ -52,20 +52,26 @@ function polygonCenter(polygon)
|
|||||||
let minY = -1;
|
let minY = -1;
|
||||||
let maxX = -1;
|
let maxX = -1;
|
||||||
let maxY = -1;
|
let maxY = -1;
|
||||||
polygon.forEach((pt) => {
|
for (const ind in polygon)
|
||||||
if (minX === -1 || minX > pt[0]) {
|
{
|
||||||
|
const pt = polygon[ind];
|
||||||
|
if (minX === -1 || minX > pt[0])
|
||||||
|
{
|
||||||
minX = pt[0];
|
minX = pt[0];
|
||||||
}
|
}
|
||||||
if (minY === -1 || minY > pt[1]) {
|
if (minY === -1 || minY > pt[1])
|
||||||
|
{
|
||||||
minY = pt[1];
|
minY = pt[1];
|
||||||
}
|
}
|
||||||
if (maxY === -1 || maxY < pt[1]) {
|
if (maxY === -1 || maxY < pt[1])
|
||||||
|
{
|
||||||
maxY = pt[1];
|
maxY = pt[1];
|
||||||
}
|
}
|
||||||
if (maxX === -1 || maxX < pt[0]) {
|
if (maxX === -1 || maxX < pt[0])
|
||||||
|
{
|
||||||
maxX = pt[0];
|
maxX = pt[0];
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
return [(minX + maxX) / 2, (maxY + minY) / 2];
|
return [(minX + maxX) / 2, (maxY + minY) / 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,20 +85,26 @@ function logoSize(polygon)
|
|||||||
let maxY = -1;
|
let maxY = -1;
|
||||||
// We first calculate the maximal coordinates to then output
|
// We first calculate the maximal coordinates to then output
|
||||||
// 75% the size of the room
|
// 75% the size of the room
|
||||||
polygon.forEach((pt) => {
|
for (const ind in polygon)
|
||||||
if (minX === -1 || minX > pt[0]) {
|
{
|
||||||
|
const pt = polygon[ind];
|
||||||
|
if (minX === -1 || minX > pt[0])
|
||||||
|
{
|
||||||
minX = pt[0];
|
minX = pt[0];
|
||||||
}
|
}
|
||||||
if (minY === -1 || minY > pt[1]) {
|
if (minY === -1 || minY > pt[1])
|
||||||
|
{
|
||||||
minY = pt[1];
|
minY = pt[1];
|
||||||
}
|
}
|
||||||
if (maxY === -1 || maxY < pt[1]) {
|
if (maxY === -1 || maxY < pt[1])
|
||||||
|
{
|
||||||
maxY = pt[1];
|
maxY = pt[1];
|
||||||
}
|
}
|
||||||
if (maxX === -1 || maxX < pt[0]) {
|
if (maxX === -1 || maxX < pt[0])
|
||||||
|
{
|
||||||
maxX = pt[0];
|
maxX = pt[0];
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
// For some unknown reason we have to multiply by 10 otherwise
|
// For some unknown reason we have to multiply by 10 otherwise
|
||||||
// it's almost invisible
|
// it's almost invisible
|
||||||
const x = 30*(maxX - minX)/4;
|
const x = 30*(maxX - minX)/4;
|
||||||
@ -118,20 +130,26 @@ function min_max(request)
|
|||||||
{
|
{
|
||||||
const element = request[ind];
|
const element = request[ind];
|
||||||
// element can be a room, a lift, a staircase or toilets
|
// element can be a room, a lift, a staircase or toilets
|
||||||
(element["surface"]).forEach((pt) => {
|
for (const index in element["surface"])
|
||||||
if (minX === -1 || minX > pt["x"]) {
|
{
|
||||||
|
const pt = element["surface"][index];
|
||||||
|
if (minX === -1 || minX > pt["x"])
|
||||||
|
{
|
||||||
minX = pt["x"];
|
minX = pt["x"];
|
||||||
}
|
}
|
||||||
if (minY === -1 || minY > pt["y"]) {
|
if (minY === -1 || minY > pt["y"])
|
||||||
|
{
|
||||||
minY = pt["y"];
|
minY = pt["y"];
|
||||||
}
|
}
|
||||||
if (maxY === -1 || maxY < pt["y"]) {
|
if (maxY === -1 || maxY < pt["y"])
|
||||||
|
{
|
||||||
maxY = pt["y"];
|
maxY = pt["y"];
|
||||||
}
|
}
|
||||||
if (maxX === -1 || maxX < pt["x"]) {
|
if (maxX === -1 || maxX < pt["x"])
|
||||||
|
{
|
||||||
maxX = pt["x"];
|
maxX = pt["x"];
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
return [minX, maxX, minY, maxY];
|
return [minX, maxX, minY, maxY];
|
||||||
}
|
}
|
||||||
@ -213,7 +231,8 @@ function list_polygons(request, center, callbackRoomSelected, selectedRoom, call
|
|||||||
{
|
{
|
||||||
const element = request[ind];
|
const element = request[ind];
|
||||||
// element can be a room, a lift, a staircase or toilets
|
// 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
|
// This function rotates and recenters de the map (should not be necessary once the real data are gathered and
|
||||||
// only works for third floor)
|
// only works for third floor)
|
||||||
// It also changes the objects into lists of two coordinates to make it accepted by the "positions" attribute of
|
// It also changes the objects into lists of two coordinates to make it accepted by the "positions" attribute of
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user