From 7dfbe5f4b476367698ec2598553372c3b5102f25 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Tue, 14 Dec 2021 03:12:10 +0100 Subject: [PATCH] Enable copyright if welcome message is hidden, add overlap detection on GRB theme --- UI/BigComponents/LeftControls.ts | 37 +++++++++++++++++---- assets/themes/grb_import/grb.json | 54 +++++++++---------------------- 2 files changed, 45 insertions(+), 46 deletions(-) diff --git a/UI/BigComponents/LeftControls.ts b/UI/BigComponents/LeftControls.ts index 4b0f56aa9..6fe0a317b 100644 --- a/UI/BigComponents/LeftControls.ts +++ b/UI/BigComponents/LeftControls.ts @@ -20,10 +20,12 @@ import Lazy from "../Base/Lazy"; import {VariableUiElement} from "../Base/VariableUIElement"; import FeatureInfoBox from "../Popup/FeatureInfoBox"; import {ElementStorage} from "../../Logic/ElementStorage"; +import FeatureSwitchState from "../../Logic/State/FeatureSwitchState"; +import CopyrightPanel from "./CopyrightPanel"; export default class LeftControls extends Combine { - constructor(state: { + constructor(state: FeatureSwitchState & { allElements: ElementStorage; currentView: FeatureSourceForLayer; featureSwitchBackgroundSelection: UIEventSource; @@ -50,7 +52,7 @@ export default class LeftControls extends Combine { const currentViewFL = state.currentView?.layer const currentViewAction = new Toggle( new Lazy(() => { - const feature : UIEventSource = state.currentView.features.map(ffs => ffs[0]?.feature) + const feature: UIEventSource = state.currentView.features.map(ffs => ffs[0]?.feature) const icon = new VariableUiElement(feature.map(feature => { const defaultIcon = Svg.checkbox_empty_svg() if (feature === undefined) { @@ -61,21 +63,23 @@ export default class LeftControls extends Combine { noSize: true })?.html console.log("Elem is ", elem, "for", tags) - if(elem === undefined){ + if (elem === undefined) { return defaultIcon } return elem })).SetClass("inline-block w-full h-full") - + const featureBox = new VariableUiElement(feature.map(feature => { - if(feature === undefined){return undefined} + if (feature === undefined) { + return undefined + } return new Lazy(() => { - const tagsSource= state.allElements.getEventSourceById(feature.properties.id) + const tagsSource = state.allElements.getEventSourceById(feature.properties.id) return new FeatureInfoBox(tagsSource, currentViewFL.layerDef, "currentview", guiState.currentViewControlIsOpened) .SetClass("md:floating-element-width") }) })) - + return new Toggle( featureBox, @@ -135,10 +139,29 @@ export default class LeftControls extends Combine { state.featureSwitchBackgroundSelection ) + // If the welcomeMessage is disabled, the copyright is hidden (as that is where the copyright is located + const copyright = new Toggle( + undefined, + new Lazy(() => + new Toggle( + new ScrollableFullScreen( + () => Translations.t.general.attribution.attributionTitle, + () => new CopyrightPanel(state), + "copyright", + guiState.copyrightViewIsOpened + ), + new MapControlButton(Svg.copyright_svg()).onClick(() => guiState.copyrightViewIsOpened.setData(true)), + guiState.copyrightViewIsOpened + ) + ), + state.featureSwitchWelcomeMessage + ) + super([ currentViewAction, filterButton, downloadButtonn, + copyright, mapSwitch ]) diff --git a/assets/themes/grb_import/grb.json b/assets/themes/grb_import/grb.json index f4b2d80d3..2a11d0fc8 100644 --- a/assets/themes/grb_import/grb.json +++ b/assets/themes/grb_import/grb.json @@ -100,7 +100,6 @@ "maxCacheAge": 0 }, "calculatedTags": [ - "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]" ], "mapRendering": [ { @@ -221,33 +220,6 @@ "then": { "nl": "Geen huisnummer" } - }, - { - "if": { - "and": [ - "addr:housenumber:={_grbNumber}", - "fixme=" - ] - }, - "then": "Het huisnummer is {_grbNumber}, wat overeenkomt met het GRB", - "hideInAnswer": { - "or": [ - "_grbNumber=", - "_grbNumber=none", - "_grbNumber=no number" - ] - } - }, - { - "if": { - "and": [ - "addr:housenumber=", - "not:addr:housenumber=yes", - "fixme=" - ] - }, - "then": "Dit gebouw heeft geen nummer, net zoals in het GRB", - "hideInAnswer": "_grbNumber!=no number" } ] }, @@ -328,19 +300,15 @@ } ] } - ], - "#": "Pass all the features in order to render the address in the layer below", - "passAllFeatures": true + ] }, - "address", { - "id": "All OSM objects", + "id": "generic_osm_object", "name": "All OSM Objects", "source": { "osmTags": { "and": [ "id~*", - "landuse=", "place=", "disused:power=", "power=", @@ -365,16 +333,17 @@ "mapRendering": [ { "color": { - "render": "#00c" + "render": "#ccc" }, "width": { "render": "1" - } + }, + "fill": "no" } ], "title": { "render": { - "*": "OSM-Object" + "*": "Other OSM-Object" } }, "tagRenderings": [ @@ -494,7 +463,8 @@ "name": "GRB geometries", "title": "GRB outline", "calculatedTags": [ - "_overlaps_with=feat.overlapWith('OSM-buildings').filter(f => f.overlap > 1 && (feat.get('_surface') < 20 || f.overlap / feat.get('_surface')) > 0.5)[0] ?? ''", + "_overlaps_with_buildings=feat.overlapWith('OSM-buildings')", + "_overlap_with=feat.get('_overlaps_with_buildings').filter(f => f.overlap > 1 && (feat.get('_surface') < 20 || f.overlap / feat.get('_surface')) > 0.5)[0] ?? ''", "_overlap_absolute=feat.get('_overlaps_with')?.overlap", "_overlap_percentage=Math.round(100 * feat.get('_overlap_absolute') / feat.get('_surface')) ", "_osm_obj:source:ref=feat.get('_overlaps_with')?.feat?.properties['source:geometry:ref']", @@ -508,13 +478,19 @@ "_grb_date=feat.properties['source:geometry:date'].replace(/\\//g,'-')", "_imported_osm_still_fresh= feat.properties['_osm_obj:source:date'] == feat.properties._grb_date", "_target_building_type=feat.properties['_osm_obj:building'] === 'yes' ? feat.properties.building : (feat.properties['_osm_obj:building'] ?? feat.properties.building)", - "_building:min_level= feat.properties['fixme']?.startsWith('verdieping, correct the building tag, add building:level and building:min_level before upload in JOSM!') ? '1' : ''" + "_building:min_level= feat.properties['fixme']?.startsWith('verdieping, correct the building tag, add building:level and building:min_level before upload in JOSM!') ? '1' : ''", + "_overlaps_with_other_features=feat.overlapWith('generic_osm_object').map(f => \"\" + f.feat.properties.id + \"\").join(', ')" ], "tagRenderings": [ { "id": "Import-button", "render": "{import_way_button(OSM-buildings,building=$building;man_made=$man_made; source:geometry:date=$_grb_date; source:geometry:ref=$_grb_ref; addr:street=$addr:street; addr:housenumber=$addr:housenumber; building:min_level=$_building:min_level, Upload this building to OpenStreetMap,,_is_part_of_building=true,1,_moveable=true)}", "mappings": [ + { + "if": "_overlaps_with_other_features~*", + "then": "This GRB building overlaps with the following features: {_overlaps_with_other_features}.
Fix the overlap and try again" + }, + { "if": { "and": [