From d6b61f6df6f842faa2492c6475431b5b0852a237 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Mon, 22 Nov 2021 03:49:17 +0100 Subject: [PATCH] More GRB improvements --- Logic/FeatureSource/FeaturePipeline.ts | 11 +- UI/BigComponents/ImportButton.ts | 18 +- assets/themes/grb_import/grb.json | 330 ++++++++++++------------- langs/en.json | 1 + langs/themes/en.json | 2 +- langs/themes/nl.json | 12 +- 6 files changed, 170 insertions(+), 204 deletions(-) diff --git a/Logic/FeatureSource/FeaturePipeline.ts b/Logic/FeatureSource/FeaturePipeline.ts index d3ae11ac80..1f49228c39 100644 --- a/Logic/FeatureSource/FeaturePipeline.ts +++ b/Logic/FeatureSource/FeaturePipeline.ts @@ -75,7 +75,7 @@ export default class FeaturePipeline { .map(ch => ch.changes) .filter(coor => coor["lat"] !== undefined && coor["lon"] !== undefined) .forEach(coor => { - state.layoutToUse.layers.forEach(l => self.localStorageSavers.get(l.id).poison(coor["lon"], coor["lat"])) + state.layoutToUse.layers.forEach(l => self.localStorageSavers.get(l.id)?.poison(coor["lon"], coor["lat"])) }) }) @@ -227,10 +227,9 @@ export default class FeaturePipeline { if (layer.maxAgeOfCache > 0) { const saver = self.localStorageSavers.get(layer.id) if(saver === undefined){ - console.warn("No local storage saver found for ", layer.id) + console.error("No local storage saver found for ", layer.id) }else{ - - saver.MarkVisited(tileId, new Date()) + saver.MarkVisited(tileId, new Date()) } } self.freshnesses.get(layer.id).addTileLoad(tileId, new Date()) @@ -264,7 +263,7 @@ export default class FeaturePipeline { maxZoomLevel: state.layoutToUse.clustering.maxZoom, registerTile: (tile) => { // We save the tile data for the given layer to local storage - data sourced from overpass - self.localStorageSavers.get(tile.layer.layerDef.id).addTile(tile) + self.localStorageSavers.get(tile.layer.layerDef.id)?.addTile(tile) perLayerHierarchy.get(source.layer.layerDef.id).registerTile(new RememberingSource(tile)) tile.features.addCallbackAndRunD(_ => self.newDataLoadedSignal.setData(tile)) @@ -426,7 +425,7 @@ export default class FeaturePipeline { const tileIndex = Tiles.tile_index(paddedToZoomLevel, x, y) downloadedLayers.forEach(layer => { self.freshnesses.get(layer.id).addTileLoad(tileIndex, date) - self.localStorageSavers.get(layer.id).MarkVisited(tileIndex, date) + self.localStorageSavers.get(layer.id)?.MarkVisited(tileIndex, date) }) }) diff --git a/UI/BigComponents/ImportButton.ts b/UI/BigComponents/ImportButton.ts index d03bfc45d2..f42d0f88b0 100644 --- a/UI/BigComponents/ImportButton.ts +++ b/UI/BigComponents/ImportButton.ts @@ -302,11 +302,10 @@ export default class ImportButton extends Toggle { let action: OsmChangeAction & { getPreview(): Promise } - const theme = o.state.layoutToUse.id const changes = o.state.changes let confirm: () => Promise if (o.conflationSettings !== undefined) { - + // Conflate the way action = new ReplaceGeometryAction( o.state, o.feature, @@ -323,6 +322,7 @@ export default class ImportButton extends Toggle { } } else { + // Upload the way to OSM const geom = o.feature.geometry let coordinates: [number, number][] if (geom.type === "LineString") { @@ -331,7 +331,6 @@ export default class ImportButton extends Toggle { coordinates = geom.coordinates[0] } - action = new CreateWayWithPointReuseAction( o.newTags.data, coordinates, @@ -341,7 +340,6 @@ export default class ImportButton extends Toggle { withinRangeOfM: 1, ifMatches: new Tag("_is_part_of_building", "true"), mode: "move_osm_point" - }] ) @@ -364,7 +362,13 @@ export default class ImportButton extends Toggle { }) }) - const confirmButton = new SubtleButton(o.image(), o.message) + const tagsExplanation = new VariableUiElement(o.newTags.map(tagsToApply => { + const tagsStr = tagsToApply.map(t => t.asHumanString(false, true)).join("&"); + return Translations.t.general.add.importTags.Subs({tags: tagsStr}); + } + )).SetClass("subtle") + + const confirmButton = new SubtleButton(o.image(), new Combine([o.message, tagsExplanation]).SetClass("flex flex-col")) confirmButton.onClick(async () => { { if (isImported.data) { @@ -380,9 +384,7 @@ export default class ImportButton extends Toggle { } }) - const cancel = new SubtleButton(Svg.close_ui(), Translations.t.general.cancel).onClick(() => { - importClicked.setData(false) - }) + const cancel = new SubtleButton(Svg.close_ui(), Translations.t.general.cancel).onClick(() => importClicked.setData(false)) return new Combine([confirmationMap, confirmButton, cancel]).SetClass("flex flex-col") diff --git a/assets/themes/grb_import/grb.json b/assets/themes/grb_import/grb.json index 444d0b1953..cccd577162 100644 --- a/assets/themes/grb_import/grb.json +++ b/assets/themes/grb_import/grb.json @@ -31,44 +31,150 @@ "enableGeolocation": false, "layers": [ { - "id": "osm-fixmes", - "name": { - "nl": "Fixmes op gebouwen" + "builtin": "type_node", + "isShown": { + "render": "no" }, - "passAllFeatures": true, + "override": { + "calculatedTags": [ + "_is_part_of_building=feat.get('parent_ways')?.some(p => p.building !== undefined && p.building !== '') ?? false", + "_is_part_of_building_passage=feat.get('parent_ways')?.some(p => p.tunnel === 'building_passage') ?? false", + "_is_part_of_highway=!feat.get('is_part_of_building_passage') && (feat.get('parent_ways')?.some(p => p.highway !== undefined && p.highway !== '') ?? false)", + "_is_part_of_landuse=feat.get('parent_ways')?.some(p => (p.landuse !== undefined && p.landuse !== '') || (p.natural !== undefined && p.natural !== '')) ?? false" + ], + "mapRendering": [ + { + "icon": "square:#00f", + "iconSize": "5,5,center", + "location": "point" + } + ] + } + }, + { + "id": "OSM-buildings", + "name": "All OSM-buildings", "source": { - "maxCacheAge": 0, - "osmTags": { - "and": [ - "fixme~*", - "building~*" - ] - } + "osmTags": "building~*", + "maxCacheAge": 0 }, "calculatedTags": [ "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]" ], - "title": { - "render": { - "nl": "{addr:street} {addr:housenumber}" - }, - "mappings": [ - { - "if": { - "and": [ - "fixme~*" - ] - }, - "then": { - "nl": "{fixme}" - } + "mapRendering": [ + { + "width": { + "render": "2", + "mappings": [ + { + "if": "fixme~*", + "then": "5" + } + ] + }, + "color": { + "render": "#00c", + "mappings": [ + { + "if": "fixme~*", + "then": "#ff00ff" + }, + { + "if": "building=house", + "then": "#a00" + }, + { + "if": "building=shed", + "then": "#563e02" + }, + { + "if": { + "or": [ + "building=garage", + "building=garages" + ] + }, + "then": "#f9bfbb" + }, + { + "if": "building=yes", + "then": "#0774f2" + } + ] } - ] - }, - "description": { - "nl": "Dit gebouw heeft een foutmelding" - }, + }, + { + "location": [ + "point", + "centroid" + ], + "label": { + "mappings": [ + { + "if": "addr:housenumber~*", + "then": "
{addr:housenumber}
" + } + ] + }, + "iconSize": { + "render": "40,40,center" + } + } + ], + "title": "OSM-gebouw", "tagRenderings": [ + { + "id": "building type", + "freeform": { + "key": "building" + }, + "render": "The building type is {building}", + "question": { + "en": "What kind of building is this?" + }, + "mappings": [ + { + "if": "building=house", + "then": "A normal house" + }, + { + "if": "building=detached", + "then": "A house detached from other building" + }, + { + "if": "building=semidetached_house", + "then": "A house sharing only one wall with another house" + }, + { + "if": "building=apartments", + "then": "An apartment building - highrise for living" + }, + { + "if": "building=office", + "then": "An office building - highrise for work" + }, + { + "if": "building=apartments", + "then": "An apartment building" + }, + { + "if": "building=shed", + "then": "A small shed, e.g. in a garden" + }, + { + "if": "building=garage", + "then": "A single garage to park a car" + }, + { + "if": "building=garages", + "then": "A building containing only garages; typically they are all identical" + }, + { + "if": "building=yes", + "then": "A building - no specification" + } + ] + }, { "id": "grb-housenumber", "render": { @@ -185,153 +291,19 @@ "key": "building:min_level", "type": "pnat" } - } - ], - "mapRendering": [ - { - "location": [ - "point", - "centroid" - ], - "label": { - "mappings": [ - { - "if": "addr:housenumber~*", - "then": "
{addr:housenumber}
" - } - ] - }, - "iconSize": { - "render": "40,40,center" - } - }, - { - "dashArray": "2 2", - "color": { - "render": "#00f" - }, - "width": { - "render": "2" - } - } - ] - }, - { - "builtin": "type_node", - "isShown": { - "render": "no" - }, - "override": { - "calculatedTags": [ - "_is_part_of_building=feat.get('parent_ways')?.some(p => p.building !== undefined && p.building !== '') ?? false", - "_is_part_of_building_passage=feat.get('parent_ways')?.some(p => p.tunnel === 'building_passage') ?? false", - "_is_part_of_highway=!feat.get('is_part_of_building_passage') && (feat.get('parent_ways')?.some(p => p.highway !== undefined && p.highway !== '') ?? false)", - "_is_part_of_landuse=feat.get('parent_ways')?.some(p => (p.landuse !== undefined && p.landuse !== '') || (p.natural !== undefined && p.natural !== '')) ?? false" - ], - "mapRendering": [ - { - "icon": "square:#00f", - "iconSize": "5,5,center", - "location": "point" - } - ] - } - }, - { - "id": "OSM-buildings", - "name": "All OSM-buildings", - "source": { - "osmTags": "building~*", - "maxCacheAge": 0 - }, - "mapRendering": [ - { - "width": { - "render": "2" - }, - "color": { - "render": "#00c", - "mappings": [ - { - "if": "building=house", - "then": "#a00" - }, - { - "if": "building=shed", - "then": "#563e02" - }, - { - "if": { - "or": [ - "building=garage", - "building=garages" - ] - }, - "then": "#f9bfbb" - }, - { - "if": "building=yes", - "then": "#0774f2" - } - ] - } - } - ], - "title": "OSM-gebouw", - "tagRenderings": [ - { - "id": "building type", - "freeform": { - "key": "building" - }, - "render": "The building type is {building}", - "question": { - "en": "What kind of building is this?" - }, - "mappings": [ - { - "if": "building=house", - "then": "A normal house" - }, - { - "if": "building=detached", - "then": "A house detached from other building" - }, - { - "if": "building=semidetached_house", - "then": "A house sharing only one wall with another house" - }, - { - "if": "building=apartments", - "then": "An apartment building - highrise for living" - }, - { - "if": "building=office", - "then": "An office building - highrise for work" - }, - { - "if": "building=apartments", - "then": "An apartment building" - }, - { - "if": "building=shed", - "then": "A small shed, e.g. in a garden" - }, - { - "if": "building=garage", - "then": "A single garage to park a car" - }, - { - "if": "building=garages", - "then": "A building containing only garages; typically they are all identical" - }, - { - "if": "building=yes", - "then": "A building - no specification" - } - ] }, "all_tags" + ], + "filter": [ + { + "id": "has-fixme", + "options": [ + { + "osmTags": "fixme~*", + "question": "Heeft een FIXME" + } + ] + } ] }, { @@ -399,8 +371,10 @@ "point", "centroid" ], - "icon": "circle:#bb3322", - "iconSize": "15,15,center" + "iconSize": "15,15,center", + "label": { + "render": "
{HNRLABEL}
" + } } ], "calculatedTags": [ @@ -507,7 +481,7 @@ }, { "id": "Import-button", - "render": "{import_button(OSM-buildings,building=$building; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref, Upload this building to OpenStreetMap)}", + "render": "{import_button(OSM-buildings,building=$building; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber, Upload this building to OpenStreetMap)}", "mappings": [ { "if": "_overlaps_with!=null", diff --git a/langs/en.json b/langs/en.json index 59be9ebaaa..c26f2cc07f 100644 --- a/langs/en.json +++ b/langs/en.json @@ -109,6 +109,7 @@ "openLayerControl": "Open the layer control box", "layerNotEnabled": "The layer {layer} is not enabled. Enable this layer to add a point", "hasBeenImported": "This point has already been imported", + "importTags": "The element will receive {tags}", "zoomInMore": "Zoom in more to import this feature", "wrongType": "This element is not a point or a way and can not be imported" }, diff --git a/langs/themes/en.json b/langs/themes/en.json index 60d838d9cb..66355eefcd 100644 --- a/langs/themes/en.json +++ b/langs/themes/en.json @@ -834,7 +834,7 @@ "grb": { "description": "This theme is an attempt to help automating the GRB import.
Note that this is very hacky and 'steals' the GRB data from an external site; in order to do this, you need to install and activate this firefox extension for it to work.", "layers": { - "2": { + "1": { "tagRenderings": { "building type": { "question": "What kind of building is this?" diff --git a/langs/themes/nl.json b/langs/themes/nl.json index 31bbe76f04..d69c60b79b 100644 --- a/langs/themes/nl.json +++ b/langs/themes/nl.json @@ -753,9 +753,7 @@ "grb": { "description": "GRB Fixup", "layers": { - "0": { - "description": "Dit gebouw heeft een foutmelding", - "name": "Fixmes op gebouwen", + "1": { "tagRenderings": { "grb-fixme": { "mappings": { @@ -786,14 +784,6 @@ "grb-unit": { "render": "De wooneenheid-aanduiding is {addr:unit} " } - }, - "title": { - "mappings": { - "0": { - "then": "{fixme}" - } - }, - "render": "{addr:street} {addr:housenumber}" } } },