Fixed issue where polygon coords were not a list
This commit is contained in:
+13
-8
@@ -13,16 +13,21 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
// console.log(rows);
|
// console.log(rows);
|
||||||
let polygons = []
|
let polygons = []
|
||||||
|
let polygonDict = {};
|
||||||
rows[0].map((point) => {
|
rows[0].map((point) => {
|
||||||
let polygon = {};
|
if (!(point.polygonID in polygonDict)) {
|
||||||
polygon.coords = [];
|
polygonDict[point.polygonID] = {};
|
||||||
polygon.polygonID = point.polygonID;
|
polygonDict[point.polygonID].coords = [];
|
||||||
polygon.coords.push({lat: point.lat, lng: point.lng});
|
polygonDict[point.polygonID].gameID = point.gameID;
|
||||||
polygon.gameID = point.gameID;
|
polygonDict[point.polygonID].userID = point.userID;
|
||||||
polygon.userID = point.userID;
|
polygonDict[point.polygonID].colour = point.colour;
|
||||||
polygon.colour = point.colour;
|
polygonDict[point.polygonID].polygonID = point.polygonID;
|
||||||
polygons.push(polygon);
|
}
|
||||||
|
polygonDict[point.polygonID].coords.push({lat: point.lat, lng: point.lng});
|
||||||
});
|
});
|
||||||
|
for (let [polygon, polygonData] of Object.entries(polygonDict)){
|
||||||
|
polygons.push(polygonDict[polygon]);
|
||||||
|
}
|
||||||
res.send(polygons);
|
res.send(polygons);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user