forked from MapComplete/MapComplete
		
	Fix import flow, add typing
This commit is contained in:
		
							parent
							
								
									97334fc369
								
							
						
					
					
						commit
						4246221e8e
					
				
					 29 changed files with 396 additions and 309 deletions
				
			
		|  | @ -3,6 +3,7 @@ import {ImmutableStore, Store, UIEventSource} from "../../UIEventSource"; | |||
| import {stat} from "fs"; | ||||
| import FilteredLayer from "../../../Models/FilteredLayer"; | ||||
| import {BBox} from "../../BBox"; | ||||
| import {Feature} from "@turf/turf"; | ||||
| 
 | ||||
| /** | ||||
|  * A simple, read only feature store. | ||||
|  | @ -11,7 +12,7 @@ export default class StaticFeatureSource implements FeatureSource { | |||
|     public readonly features: Store<{ feature: any; freshness: Date }[]>; | ||||
|     public readonly name: string | ||||
| 
 | ||||
|     constructor(features: Store<{ feature: any, freshness: Date }[]>, name = "StaticFeatureSource") { | ||||
|     constructor(features: Store<{ feature: Feature, freshness: Date }[]>, name = "StaticFeatureSource") { | ||||
|         if (features === undefined) { | ||||
|             throw "Static feature source received undefined as source" | ||||
|         } | ||||
|  | @ -19,17 +20,23 @@ export default class StaticFeatureSource implements FeatureSource { | |||
|         this.features = features; | ||||
|     } | ||||
| 
 | ||||
|     public static fromGeojsonAndDate(features: { feature: any, freshness: Date }[], name = "StaticFeatureSourceFromGeojsonAndDate"): StaticFeatureSource { | ||||
|     public static fromGeojsonAndDate(features: { feature: Feature, freshness: Date }[], name = "StaticFeatureSourceFromGeojsonAndDate"): StaticFeatureSource { | ||||
|         return new StaticFeatureSource(new ImmutableStore(features), name); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     public static fromGeojson(geojson: any[], name = "StaticFeatureSourceFromGeojson"): StaticFeatureSource { | ||||
|     public static fromGeojson(geojson: Feature[], name = "StaticFeatureSourceFromGeojson"): StaticFeatureSource { | ||||
|         const now = new Date(); | ||||
|         return StaticFeatureSource.fromGeojsonAndDate(geojson.map(feature => ({feature, freshness: now})), name); | ||||
|     } | ||||
| 
 | ||||
|     static fromDateless(featureSource: Store<{ feature: any }[]>, name = "StaticFeatureSourceFromDateless") { | ||||
|     public static fromGeojsonStore(geojson: Store<Feature[]>, name = "StaticFeatureSourceFromGeojson"): StaticFeatureSource { | ||||
|         const now = new Date(); | ||||
|         const mapped : Store<{feature: Feature, freshness: Date}[]> = geojson.map(features => features.map(feature => ({feature, freshness: now}))) | ||||
|         return new StaticFeatureSource(mapped, name); | ||||
|     } | ||||
| 
 | ||||
|     static fromDateless(featureSource: Store<{ feature: Feature }[]>, name = "StaticFeatureSourceFromDateless") { | ||||
|         const now = new Date(); | ||||
|         return new StaticFeatureSource(featureSource.map(features => features.map(feature => ({ | ||||
|             feature: feature.feature, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue