Skip to content

Commit d97f22e

Browse files
authored
Update BuildingShapeUtils.js
1 parent e39e3fc commit d97f22e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/extras/BuildingShapeUtils.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,24 @@ class BuildingShapeUtils extends ShapeUtils {
1717
// Initialize objects
1818
const shape = new Shape();
1919
var ref;
20-
var node = [];
20+
const nodes = [];
2121

2222
// Get all the nodes in the way of interest
23+
/** {HTMLCollection} */
2324
const elements = way.getElementsByTagName('nd');
2425

2526
// Get the coordinates of all the nodes and add them to the shape outline.
26-
// If the first and last point are identical, remove the last copy.
27-
if (elements[0][0] === elements[elements.length - 1][0] && elements[0][1] === elements[elements.length - 1][1]) {
28-
elements.pop();
29-
}
30-
let first = true;
27+
3128
for (const element of elements) {
3229
ref = element.getAttribute('ref');
33-
node = nodelist[ref];
30+
nodes.push(nodelist[ref]);
31+
}
32+
// If the first and last point are identical, remove the last copy.
33+
if (nodes[0][0] === nodes[elements.length - 1][0] && nodes[0][1] === nodes[elements.length - 1][1]) {
34+
nodes.pop();
35+
}
36+
const first = true;
37+
for (const node of nodes) {
3438
// The first node requires a different function call.
3539
if (first) {
3640
first = false;

0 commit comments

Comments
 (0)