diff --git a/UI/ImportFlow/ConflationChecker.ts b/UI/ImportFlow/ConflationChecker.ts index 91b78fb24..3ae2103f8 100644 --- a/UI/ImportFlow/ConflationChecker.ts +++ b/UI/ImportFlow/ConflationChecker.ts @@ -47,6 +47,27 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea const toImport: {features: any[]} = params; let overpassStatus = new UIEventSource<{ error: string } | "running" | "success" | "idle" | "cached">("idle") const cacheAge = new UIEventSource(undefined); + + + function loadDataFromOverpass(){ + // Load the data! + const url = Constants.defaultOverpassUrls[1] + const relationTracker = new RelationsTracker() + const overpass = new Overpass(params.layer.source.osmTags, [], url, new UIEventSource(180), relationTracker, true) + console.log("Loading from overpass!") + overpassStatus.setData("running") + overpass.queryGeoJson(bbox).then( + ([data, date]) => { + console.log("Received overpass-data: ", data.features.length, "features are loaded at ", date); + overpassStatus.setData("success") + fromLocalStorage.setData([data, date]) + }, + (error) => { + overpassStatus.setData({error}) + }) + } + + const fromLocalStorage = IdbLocalStorage.Get<[any, Date]>("importer-overpass-cache-" + layer.id, { whenLoaded: (v) => { @@ -63,22 +84,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea } cacheAge.setData(-1) } - // Load the data! - const url = Constants.defaultOverpassUrls[1] - const relationTracker = new RelationsTracker() - const overpass = new Overpass(params.layer.source.osmTags, [], url, new UIEventSource(180), relationTracker, true) - console.log("Loading from overpass!") - overpassStatus.setData("running") - overpass.queryGeoJson(bbox).then( - ([data, date]) => { - console.log("Received overpass-data: ", data.features.length, "features are loaded at ", date); - overpassStatus.setData("success") - fromLocalStorage.setData([data, date]) - }, - (error) => { - overpassStatus.setData({error}) - }) - + loadDataFromOverpass() } }); @@ -166,7 +172,7 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea return osmData.features.filter(f => toImport.features.some(imp => maxDist >= GeoOperations.distanceBetween(imp.geometry.coordinates, GeoOperations.centerpointCoordinates(f)))) - }, [nearbyCutoff.GetValue()]), false); + }, [nearbyCutoff.GetValue().stabilized(500)]), false); const paritionedImport = ImportUtils.partitionFeaturesIfNearby(toImport, geojson, nearbyCutoff.GetValue().map(Number)); // Featuresource showing OSM-features which are nearby a toImport-feature @@ -211,7 +217,11 @@ export default class ConflationChecker extends Combine implements FlowStep<{ fea if (age < 0) { return t.cacheExpired } - return t.loadedDataAge.Subs({age: Utils.toHumanTime(age)}) + return new Combine([t.loadedDataAge.Subs({age: Utils.toHumanTime(age)}), + new SubtleButton(Svg.reload_svg().SetClass("h-8"), t.reloadTheCache) + .onClick(loadDataFromOverpass) + .SetClass("h-12") + ]) })), new Title(t.titleLive), diff --git a/langs/en.json b/langs/en.json index c7ab07ad6..6c22f0cef 100644 --- a/langs/en.json +++ b/langs/en.json @@ -321,6 +321,7 @@ "nearbyWarn": "The {count} red elements on the following map will not be imported!", "nothingLoaded": "No elements are loaded from OpenStreetMap which match the current layer {name}", "osmLoaded": "{count} elements are loaded from OpenStreetMap which match the layer {name}.", + "reloadTheCache": "Clear the cache and query overpass again", "setRangeToZero": "Set the range to 0 or 1 if you want to import them all", "states": { "error": "Could not load latest data from overpass due to {error}", diff --git a/scripts/filter.ts b/scripts/filter.ts index 62e068cf6..1a9713658 100644 --- a/scripts/filter.ts +++ b/scripts/filter.ts @@ -1,6 +1,7 @@ import * as fs from "fs"; import {TagUtils} from "../Logic/Tags/TagUtils"; import {writeFileSync} from "fs"; +import {TagsFilter} from "../Logic/Tags/TagsFilter"; function main(args) { if (args.length < 2) { @@ -13,7 +14,13 @@ function main(args) { const output = args[2] const data = JSON.parse(fs.readFileSync(path, "UTF8")) - const filter = TagUtils.Tag(JSON.parse(spec)) + let filter : TagsFilter ; + try{ + filter = TagUtils.Tag(JSON.parse(spec)) + + }catch(e){ + filter = TagUtils.Tag(spec) + } const features = data.features.filter(f => filter.matchesProperties(f.properties)) if(features.length === 0){