forked from MapComplete/MapComplete
		
	Fix questions: applicable mappings are now calculated dynamically; charging station theme now only shows applicable plugs based on the allowed vehicle types
This commit is contained in:
		
							parent
							
								
									bedc576313
								
							
						
					
					
						commit
						df34239256
					
				
					 14 changed files with 3677 additions and 3359 deletions
				
			
		|  | @ -141,18 +141,25 @@ export default class FeaturePipeline { | |||
| 
 | ||||
|             if (source.geojsonZoomLevel === undefined) { | ||||
|                 // This is a 'load everything at once' geojson layer
 | ||||
|                 // We split them up into tiles anyway
 | ||||
|                 const src = new GeoJsonSource(filteredLayer) | ||||
|                 TiledFeatureSource.createHierarchy(src, { | ||||
|                     layer: src.layer, | ||||
|                     minZoomLevel: 14, | ||||
|                     dontEnforceMinZoom: true, | ||||
|                     registerTile: (tile) => { | ||||
|                         new RegisteringAllFromFeatureSourceActor(tile) | ||||
|                         perLayerHierarchy.get(id).registerTile(tile) | ||||
|                         tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile)) | ||||
|                     } | ||||
|                 }) | ||||
| 
 | ||||
|                 if (source.isOsmCacheLayer) { | ||||
|                     // We split them up into tiles anyway as it is an OSM source
 | ||||
|                     TiledFeatureSource.createHierarchy(src, { | ||||
|                         layer: src.layer, | ||||
|                         minZoomLevel: 14, | ||||
|                         dontEnforceMinZoom: true, | ||||
|                         registerTile: (tile) => { | ||||
|                             new RegisteringAllFromFeatureSourceActor(tile) | ||||
|                             perLayerHierarchy.get(id).registerTile(tile) | ||||
|                             tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile)) | ||||
|                         } | ||||
|                     }) | ||||
|                 }else{ | ||||
|                     new RegisteringAllFromFeatureSourceActor(src) | ||||
|                     perLayerHierarchy.get(id).registerTile(src) | ||||
|                     src.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(src)) | ||||
|                 } | ||||
|             } else { | ||||
|                 new DynamicGeoJsonTileSource( | ||||
|                     filteredLayer, | ||||
|  | @ -312,9 +319,9 @@ export default class FeaturePipeline { | |||
|             if (zoom < 8) { | ||||
|                 zoom = zoom + 2 | ||||
|             } | ||||
|              | ||||
| 
 | ||||
|             const range = bbox.containingTileRange(zoom) | ||||
|             if(range.total > 100){ | ||||
|             if (range.total > 100) { | ||||
|                 return false | ||||
|             } | ||||
|             const self = this; | ||||
|  |  | |||
|  | @ -68,6 +68,50 @@ export class UIEventSource<T> { | |||
|         return src | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Given a UIEVentSource with a list, returns a new UIEventSource which is only updated if the _contents_ of the list are different. | ||||
|      * E.g. | ||||
|      * const src = new UIEventSource([1,2,3]) | ||||
|      * const stable = UIEventSource.ListStabilized(src) | ||||
|      * src.addCallback(_ => console.log("src pinged")) | ||||
|      * stable.addCallback(_ => console.log("stable pinged)) | ||||
|      * src.setDate([...src.data]) | ||||
|      *  | ||||
|      * This will only trigger 'src pinged' | ||||
|      *  | ||||
|      * @param src | ||||
|      * @constructor | ||||
|      */ | ||||
|     public static ListStabilized<T>(src: UIEventSource<T[]>) : UIEventSource<T[]>{ | ||||
|          | ||||
|         const stable = new UIEventSource<T[]>(src.data) | ||||
|         src.addCallback(list => { | ||||
|             if(list === undefined){ | ||||
|                 stable.setData(undefined) | ||||
|                 return; | ||||
|             } | ||||
|             const oldList = stable.data | ||||
|             if(oldList === list){ | ||||
|                 return; | ||||
|             } | ||||
|             if(oldList.length !== list.length){ | ||||
|                 stable.setData(list); | ||||
|                 return; | ||||
|             } | ||||
| 
 | ||||
|             for (let i = 0; i < list.length; i++) { | ||||
|                 if(oldList[i] !== list[i]){ | ||||
|                     stable.setData(list); | ||||
|                     return; | ||||
|                 } | ||||
|             } | ||||
|              | ||||
|             // No actual changes, so we don't do anything
 | ||||
|             return; | ||||
|         }) | ||||
|         return stable | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Adds a callback | ||||
|      * | ||||
|  | @ -88,7 +132,7 @@ export class UIEventSource<T> { | |||
| 
 | ||||
|     public addCallbackAndRun(callback: ((latestData: T) => (boolean | void | any))): UIEventSource<T> { | ||||
|         const doDeleteCallback = callback(this.data); | ||||
|         if (!doDeleteCallback) { | ||||
|         if (doDeleteCallback !== true) { | ||||
|             this.addCallback(callback); | ||||
|         } | ||||
|         return this; | ||||
|  |  | |||
							
								
								
									
										0
									
								
								Logic/Web/Wikipedia.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								Logic/Web/Wikipedia.ts
									
										
									
									
									
										Normal file
									
								
							
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue