Skip to content

Commit cb7cd57

Browse files
authored
Update BuildingShapeUtils.js
1 parent 5e865fc commit cb7cd57

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/extras/BuildingShapeUtils.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,23 @@ class BuildingShapeUtils extends ShapeUtils {
8181
* @return {[DOM.Element]} array of closed ways.
8282
*/
8383
static combineWays(ways) {
84+
cnst validWays = [];
85+
86+
for (const way of ways) {
87+
if (BuildingShapeUtils.isSelfIntersecting(w)) {
88+
const id = w.getAttribute();
89+
const msg = 'Way ' + id + ' is self-intersecting';
90+
window.printError(msg)
91+
} else {
92+
validWays.push(way);
93+
}
94+
}
95+
8496
const closedWays = [];
8597
const wayBegins = {};
8698
const wayEnds = {};
8799

88-
ways.forEach(w => {
100+
validWays.forEach(w => {
89101
const firstNodeID = w.querySelector('nd').getAttribute('ref');
90102
if (wayBegins[firstNodeID]) {
91103
wayBegins[firstNodeID].push(w);
@@ -142,7 +154,7 @@ class BuildingShapeUtils extends ShapeUtils {
142154
return [];
143155
}
144156

145-
ways.forEach(w => {
157+
valisWays.forEach(w => {
146158
const wayID = w.getAttribute('id');
147159
if (usedWays.has(wayID)){
148160
return;

0 commit comments

Comments
 (0)