forked from MapComplete/MapComplete
		
	Small tweaks, stabilizing local source cache
This commit is contained in:
		
							parent
							
								
									f33fe081d0
								
							
						
					
					
						commit
						fa4fb71e06
					
				
					 8 changed files with 53 additions and 37 deletions
				
			
		|  | @ -10,38 +10,41 @@ import {UIEventSource} from "../UIEventSource"; | |||
| import LocalStorageSaver from "./LocalStorageSaver"; | ||||
| import LayerConfig from "../../Customizations/JSON/LayerConfig"; | ||||
| import LocalStorageSource from "./LocalStorageSource"; | ||||
| import LayoutConfig from "../../Customizations/JSON/LayoutConfig"; | ||||
| 
 | ||||
| export default class FeaturePipeline implements FeatureSource { | ||||
| 
 | ||||
|     public features: UIEventSource<{ feature: any; freshness: Date }[]>; | ||||
| 
 | ||||
|     constructor(flayers: { isDisplayed: UIEventSource<boolean>, layerDef: LayerConfig }[], updater: FeatureSource) { | ||||
| 
 | ||||
|         const overpassSource = new WayHandlingApplyingFeatureSource(flayers, | ||||
|             new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, updater)) | ||||
|         ); | ||||
|     constructor(flayers: { isDisplayed: UIEventSource<boolean>, layerDef: LayerConfig }[], | ||||
|                 updater: FeatureSource, | ||||
|                 layout: UIEventSource<LayoutConfig>) { | ||||
| 
 | ||||
|         const amendedOverpassSource = | ||||
|             new RememberingSource(new LocalStorageSaver( | ||||
|                 overpassSource | ||||
|             )); | ||||
|             new RememberingSource( | ||||
|                 new WayHandlingApplyingFeatureSource(flayers, | ||||
|                     new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, | ||||
|                         new LocalStorageSaver(updater, layout))) | ||||
|                 ) | ||||
|             ); | ||||
| 
 | ||||
|         const amendedLocalStorageSource = | ||||
|             new RememberingSource( | ||||
|                 new WayHandlingApplyingFeatureSource(flayers, | ||||
|                     new NoOverlapSource(flayers, new FeatureDuplicatorPerLayer(flayers, new LocalStorageSource(layout))) | ||||
|                 )); | ||||
| 
 | ||||
|         const merged = new FeatureSourceMerger([ | ||||
|             amendedOverpassSource, | ||||
|             new FeatureDuplicatorPerLayer(flayers, State.state.changes), | ||||
|             new LocalStorageSource() | ||||
|             amendedLocalStorageSource | ||||
|         ]); | ||||
|         merged.features.addCallbackAndRun(feats => console.log("Merged has",feats?.length)) | ||||
| 
 | ||||
|         const source = | ||||
|             new FilteringFeatureSource( | ||||
|                 flayers, | ||||
|                 State.state.locationControl, | ||||
|                 merged | ||||
|             ); | ||||
|         source.features.addCallbackAndRun(feats => console.log("Filtered has",feats?.length)) | ||||
| 
 | ||||
| 
 | ||||
|         this.features = source.features; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue