File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,6 @@ class BuildingShapeUtils extends ShapeUtils {
8888 } else if ( way1 [ 0 ] . getAttribute ( 'ref' ) === way2 [ 0 ] . getAttribute ( 'ref' ) ) {
8989 const tempway = BuildingShapeUtils . reverseWay ( ways [ i ] )
9090 const result = BuildingShapeUtils . joinWays ( tempway , ways [ i + 1 ] ) ;
91- }
9291 } else if ( way1 [ way1 . length - 1 ] . getAttribute ( 'ref' ) === way2 [ way2 . length - 1 ] . getAttribute ( 'ref' ) ) {
9392 const tempway = BuildingShapeUtils . reverseWay ( ways [ i + 1 ] )
9493 const result = BuildingShapeUtils . joinWays ( ways [ i ] , tempway ) ;
@@ -126,6 +125,23 @@ class BuildingShapeUtils extends ShapeUtils {
126125 return way1 ;
127126 }
128127
128+ /**
129+ * Reverse the order of nodes in a way.
130+ *
131+ * @param {DOM.Element } way - a way
132+ *
133+ * @return {DOM.Element } way
134+ */
135+ static reverseWay ( way ) {
136+ const elements = way . getElementsByTagName ( 'nd' ) ;
137+ const newWay = way . cloneNode ( true ) ;
138+ for ( let i = 0 ; i < elements . length ; i ++ ) {
139+ let elem = elements [ elements . length - 1 + i ] . cloneNode ( ) ;
140+ newWay . replaceChild ( elements [ i ] , elem ) ;
141+ }
142+ return newWay ;
143+ }
144+
129145 /**
130146 * Find the center of a closed way
131147 *
You can’t perform that action at this time.
0 commit comments