Skip to content

Commit 24b48e9

Browse files
authored
Update BuildingShapeUtils.js
1 parent 3d131be commit 24b48e9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/extras/BuildingShapeUtils.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class BuildingShapeUtils extends ShapeUtils {
119119
const usedWays = new Set();
120120

121121
/**
122-
*
122+
* Use recursion to attempt to build a ring from ways.
123123
*
124124
* @param {[DOM.Element]} currentRingWays - array of OSM XML way elements.
125125
*/
@@ -133,6 +133,8 @@ class BuildingShapeUtils extends ShapeUtils {
133133

134134
const lastWay = currentRingWays[currentRingWays.length - 1];
135135
const lastNodeID = lastWay.querySelector('nd:last-of-type').getAttribute('ref');
136+
137+
// Check if any of the unused ways can complete a ring as the are.
136138
for (let way of wayBegins[lastNodeID] ?? []) {
137139
const wayID = way.getAttribute('id');
138140
// Add to check if wayID intersects with any of the other ways
@@ -150,6 +152,7 @@ class BuildingShapeUtils extends ShapeUtils {
150152
usedWays.delete(wayID);
151153
}
152154

155+
// Check if any of the unused ways can complete a ring if reversed.
153156
for (let way of wayEnds[lastNodeID] ?? []) {
154157
const wayID = way.getAttribute('id');
155158
if (usedWays.has(wayID)) {
@@ -167,7 +170,6 @@ class BuildingShapeUtils extends ShapeUtils {
167170
return [];
168171
}
169172

170-
171173
validWays.forEach(w => {
172174
const wayID = w.getAttribute('id');
173175
if (usedWays.has(wayID)){
@@ -184,6 +186,10 @@ class BuildingShapeUtils extends ShapeUtils {
184186
}
185187
});
186188

189+
// Notify the user if there are unused ways.
190+
// if (validWays.length !== usedWays.length) {
191+
// window.printError('Unused ways in relation')
192+
// }
187193
return closedWays;
188194
}
189195

0 commit comments

Comments
 (0)