forked from MapComplete/MapComplete
		
	Robustify code
This commit is contained in:
		
							parent
							
								
									1dbe167e4e
								
							
						
					
					
						commit
						15a1ab19cd
					
				
					 2 changed files with 19 additions and 20 deletions
				
			
		|  | @ -54,12 +54,14 @@ export default class RenderingMultiPlexerFeatureSource { | |||
|                             }) | ||||
|                         } | ||||
|                     } else { | ||||
|                         // This is a a line
 | ||||
|                         // This is a a line: add the centroids
 | ||||
|                         for (const rendering of centroidRenderings) { | ||||
|                             addAsPoint(feat, rendering, GeoOperations.centerpointCoordinates(feat)) | ||||
|                         } | ||||
| 
 | ||||
|                         if (feat.geometry.type === "LineString" || feat.geometry.type==="Polygon" || feat.geometry.type === "MultiPolygon") { | ||||
|                         if (feat.geometry.type === "LineString") { | ||||
|                              | ||||
|                             // Add start- and endpoints
 | ||||
|                             const coordinates = feat.geometry.coordinates | ||||
|                             for (const rendering of startRenderings) { | ||||
|                                 addAsPoint(feat, rendering, coordinates[0]) | ||||
|  | @ -68,29 +70,17 @@ export default class RenderingMultiPlexerFeatureSource { | |||
|                                 const coordinate = coordinates[coordinates.length - 1] | ||||
|                                 addAsPoint(feat, rendering, coordinate) | ||||
|                             } | ||||
|                             for (let i = 0; i < lineRenderObjects.length; i++) { | ||||
|                                 withIndex.push({ | ||||
|                                     ...feat, | ||||
|                                     lineRenderingIndex: i | ||||
|                                 }) | ||||
|                             } | ||||
|                             | ||||
|                         } | ||||
| 
 | ||||
| 
 | ||||
|                         if (feat.geometry.type === "MultiLineString") { | ||||
|                             // Multilinestrings get a special treatment: we split them into their subparts before rendering
 | ||||
|                             const lineList: [number, number][][] = feat.geometry.coordinates | ||||
|                              | ||||
|                             for (let i1 = 0; i1 < lineList.length; i1++) { | ||||
|                                 const coordinates = lineList[i1]; | ||||
| 
 | ||||
|                                 for (const rendering of startRenderings) { | ||||
|                                     const coordinate = coordinates[0] | ||||
|                                     addAsPoint(feat, rendering, coordinate) | ||||
|                                 } | ||||
|                                 for (const rendering of endRenderings) { | ||||
|                                     const coordinate = coordinates[coordinates.length - 1] | ||||
|                                     addAsPoint(feat, rendering, coordinate) | ||||
|                                 } | ||||
| 
 | ||||
| 
 | ||||
|                                 for (let i = 0; i < lineRenderObjects.length; i++) { | ||||
|                                     const orig = { | ||||
|                                         ...feat, | ||||
|  | @ -102,7 +92,18 @@ export default class RenderingMultiPlexerFeatureSource { | |||
|                                     withIndex.push(orig) | ||||
|                                 } | ||||
|                             } | ||||
|                              | ||||
|                         }else{ | ||||
|                              | ||||
|                             // AT last, add it 'as is' to what we should render 
 | ||||
|                             for (let i = 0; i < lineRenderObjects.length; i++) { | ||||
|                                 withIndex.push({ | ||||
|                                     ...feat, | ||||
|                                     lineRenderingIndex: i | ||||
|                                 }) | ||||
|                             } | ||||
|                         } | ||||
|                       | ||||
| 
 | ||||
|                     } | ||||
|                 } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue