File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -17,16 +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- let first = true ;
27+
2728 for ( const element of elements ) {
2829 ref = element . getAttribute ( 'ref' ) ;
29- 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 . length > 1 && nodes [ 0 ] [ 0 ] === nodes [ elements . length - 1 ] [ 0 ] && nodes [ 0 ] [ 1 ] === nodes [ elements . length - 1 ] [ 1 ] ) {
34+ nodes . pop ( ) ;
35+ }
36+ let first = true ;
37+ for ( const node of nodes ) {
3038 // The first node requires a different function call.
3139 if ( first ) {
3240 first = false ;
@@ -37,7 +45,6 @@ class BuildingShapeUtils extends ShapeUtils {
3745 }
3846 return shape ;
3947 }
40-
4148 /**
4249 * Check if a way is a closed shape.
4350 *
You can’t perform that action at this time.
0 commit comments