From 135219b5dc4101c152c86556a3d117721b31193c Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Fri, 23 Jul 2021 19:12:13 +0200 Subject: [PATCH] Add point-only layer for nature reserves, mark point-only layer as old (so that geometries will show up) --- Logic/FeatureSource/FeaturePipeline.ts | 11 +++++++---- Logic/FeatureSource/GeoJsonSource.ts | 2 +- assets/themes/natuurpunt/natuurpunt.json | 21 ++++++++++++++++++++- scripts/generateCache.ts | 3 +++ 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index 3407105034..351ccdc3e2 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -16,7 +16,7 @@ import RegisteringFeatureSource from "./RegisteringFeatureSource"; export default class FeaturePipeline implements FeatureSource { - public features: UIEventSource<{ feature: any; freshness: Date }[]> ; + public features: UIEventSource<{ feature: any; freshness: Date }[]>; public readonly name = "FeaturePipeline" @@ -29,7 +29,7 @@ export default class FeaturePipeline implements FeatureSource { selectedElement: UIEventSource) { const allLoadedFeatures = new UIEventSource<{ feature: any; freshness: Date }[]>([]) - + // first we metatag, then we save to get the metatags into storage too // Note that we need to register before we do metatagging (as it expects the event sources) @@ -46,8 +46,11 @@ export default class FeaturePipeline implements FeatureSource { const geojsonSources: FeatureSource [] = GeoJsonSource .ConstructMultiSource(flayers.data, locationControl) .map(geojsonSource => { - let source = new RegisteringFeatureSource(new FeatureDuplicatorPerLayer(flayers, geojsonSource)); - if(!geojsonSource.isOsmCache){ + let source = new RegisteringFeatureSource( + new FeatureDuplicatorPerLayer(flayers, + geojsonSource + )); + if (!geojsonSource.isOsmCache) { source = new MetaTaggingFeatureSource(allLoadedFeatures, source, updater.features); } return source diff --git a/Logic/FeatureSource/GeoJsonSource.ts b/Logic/FeatureSource/GeoJsonSource.ts index b462c87da0..c684151c6f 100644 --- a/Logic/FeatureSource/GeoJsonSource.ts +++ b/Logic/FeatureSource/GeoJsonSource.ts @@ -175,7 +175,7 @@ export default class GeoJsonSource implements FeatureSource { let freshness: Date = time; if (feature.properties["_last_edit:timestamp"] !== undefined) { - freshness = new Date(feature["_last_edit:timestamp"]) + freshness = new Date(feature.properties["_last_edit:timestamp"]) } newFeatures.push({feature: feature, freshness: freshness}) diff --git a/assets/themes/natuurpunt/natuurpunt.json b/assets/themes/natuurpunt/natuurpunt.json index 0617b7cc47..4c8ebbf23c 100644 --- a/assets/themes/natuurpunt/natuurpunt.json +++ b/assets/themes/natuurpunt/natuurpunt.json @@ -27,6 +27,7 @@ "defaultBackgroundId": "CartoDB.Positron", "layers": [ { + "#": "Nature reserve with geometry, z>=13", "builtin": "nature_reserve", "override": { "source": { @@ -39,7 +40,25 @@ "geoJsonZoomLevel": 12, "isOsmCache": true }, - "minzoom": "10", + "minzoom": "13", + "icon": { + "render": "circle:#FE6F32;./assets/themes/natuurpunt/nature_reserve.svg" + } + } + }, + { + "#": "Nature reserve overview from cache, points only, z < 13", + "builtin": "nature_reserve", + "override": { + "source": { + "osmTags": { + "+and": [ + "operator~.*[nN]atuurpunt.*" + ] + }, + "geoJson": "https://pietervdvn.github.io/natuurpunt_cache/natuurpunt_nature_reserve_points.geojson" + }, + "minzoom": "0", "icon": { "render": "circle:#FE6F32;./assets/themes/natuurpunt/nature_reserve.svg" } diff --git a/scripts/generateCache.ts b/scripts/generateCache.ts index b961961a48..282c245a5f 100644 --- a/scripts/generateCache.ts +++ b/scripts/generateCache.ts @@ -274,6 +274,9 @@ async function createOverview(targetdir: string, r: TileRange, z: number, layern } const features = JSON.parse(fs.readFileSync(read_path, "UTF-8")).features const pointsOnly = features.map(f => { + + f.properties["_last_edit:timestamp"] = "1970-01-01" + if (f.geometry.type === "Point") { return f } else {