File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -178,10 +178,7 @@ class BuildingShapeUtils extends ShapeUtils {
178178 usedWays . add ( wayID ) ;
179179 const result = tryMakeRing ( [ w ] ) ;
180180 if ( result . length ) {
181- let ring = result [ 0 ] ;
182- result . slice ( 1 ) . forEach ( w => {
183- ring = this . joinWays ( ring , w ) ;
184- } ) ;
181+ ring = this . joinAllWays ( result )
185182 closedWays . push ( ring ) ;
186183 }
187184 } ) ;
@@ -203,11 +200,28 @@ class BuildingShapeUtils extends ShapeUtils {
203200 */
204201 static joinWays ( way1 , way2 ) {
205202 const elements = way2 . getElementsByTagName ( 'nd' ) ;
203+ const newWay = way1 . cloneNode ( true ) ;
206204 for ( let i = 1 ; i < elements . length ; i ++ ) {
207205 let elem = elements [ i ] . cloneNode ( ) ;
208- way1 . appendChild ( elem ) ;
206+ newWay . appendChild ( elem ) ;
209207 }
210- return way1 ;
208+ return newWay ;
209+ }
210+
211+ /**
212+ * Append the nodes from one way into another.
213+ *
214+ * @param {DOM.Element } way1 - an open, non self-intersecring way
215+ * @param {DOM.Element } way2
216+ *
217+ * @return {DOM.Element } way
218+ */
219+ static joinAllWays ( ways ) {
220+ let way = ways [ 0 ] ;
221+ ways . slice ( 1 ) . forEach ( w => {
222+ way = this . joinWays ( way , w ) ;
223+ } ) ;
224+ return way ;
211225 }
212226
213227 /**
You can’t perform that action at this time.
0 commit comments