forked from MapComplete/MapComplete
		
	Enable copyright if welcome message is hidden, add overlap detection on GRB theme
This commit is contained in:
		
							parent
							
								
									7e46e25943
								
							
						
					
					
						commit
						7dfbe5f4b4
					
				
					 2 changed files with 45 additions and 46 deletions
				
			
		| 
						 | 
					@ -20,10 +20,12 @@ import Lazy from "../Base/Lazy";
 | 
				
			||||||
import {VariableUiElement} from "../Base/VariableUIElement";
 | 
					import {VariableUiElement} from "../Base/VariableUIElement";
 | 
				
			||||||
import FeatureInfoBox from "../Popup/FeatureInfoBox";
 | 
					import FeatureInfoBox from "../Popup/FeatureInfoBox";
 | 
				
			||||||
import {ElementStorage} from "../../Logic/ElementStorage";
 | 
					import {ElementStorage} from "../../Logic/ElementStorage";
 | 
				
			||||||
 | 
					import FeatureSwitchState from "../../Logic/State/FeatureSwitchState";
 | 
				
			||||||
 | 
					import CopyrightPanel from "./CopyrightPanel";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default class LeftControls extends Combine {
 | 
					export default class LeftControls extends Combine {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    constructor(state: {
 | 
					    constructor(state: FeatureSwitchState & {
 | 
				
			||||||
                    allElements: ElementStorage;
 | 
					                    allElements: ElementStorage;
 | 
				
			||||||
                    currentView: FeatureSourceForLayer;
 | 
					                    currentView: FeatureSourceForLayer;
 | 
				
			||||||
                    featureSwitchBackgroundSelection: UIEventSource<boolean>;
 | 
					                    featureSwitchBackgroundSelection: UIEventSource<boolean>;
 | 
				
			||||||
| 
						 | 
					@ -50,7 +52,7 @@ export default class LeftControls extends Combine {
 | 
				
			||||||
        const currentViewFL = state.currentView?.layer
 | 
					        const currentViewFL = state.currentView?.layer
 | 
				
			||||||
        const currentViewAction = new Toggle(
 | 
					        const currentViewAction = new Toggle(
 | 
				
			||||||
            new Lazy(() => {
 | 
					            new Lazy(() => {
 | 
				
			||||||
               const feature : UIEventSource<any> = state.currentView.features.map(ffs => ffs[0]?.feature)
 | 
					                const feature: UIEventSource<any> = state.currentView.features.map(ffs => ffs[0]?.feature)
 | 
				
			||||||
                const icon = new VariableUiElement(feature.map(feature => {
 | 
					                const icon = new VariableUiElement(feature.map(feature => {
 | 
				
			||||||
                    const defaultIcon = Svg.checkbox_empty_svg()
 | 
					                    const defaultIcon = Svg.checkbox_empty_svg()
 | 
				
			||||||
                    if (feature === undefined) {
 | 
					                    if (feature === undefined) {
 | 
				
			||||||
| 
						 | 
					@ -61,16 +63,18 @@ export default class LeftControls extends Combine {
 | 
				
			||||||
                        noSize: true
 | 
					                        noSize: true
 | 
				
			||||||
                    })?.html
 | 
					                    })?.html
 | 
				
			||||||
                    console.log("Elem is ", elem, "for", tags)
 | 
					                    console.log("Elem is ", elem, "for", tags)
 | 
				
			||||||
                    if(elem === undefined){
 | 
					                    if (elem === undefined) {
 | 
				
			||||||
                        return defaultIcon
 | 
					                        return defaultIcon
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    return elem
 | 
					                    return elem
 | 
				
			||||||
                })).SetClass("inline-block w-full h-full")
 | 
					                })).SetClass("inline-block w-full h-full")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const featureBox = new VariableUiElement(feature.map(feature => {
 | 
					                const featureBox = new VariableUiElement(feature.map(feature => {
 | 
				
			||||||
                    if(feature === undefined){return undefined}
 | 
					                    if (feature === undefined) {
 | 
				
			||||||
 | 
					                        return undefined
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                    return new Lazy(() => {
 | 
					                    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)
 | 
					                        return new FeatureInfoBox(tagsSource, currentViewFL.layerDef, "currentview", guiState.currentViewControlIsOpened)
 | 
				
			||||||
                            .SetClass("md:floating-element-width")
 | 
					                            .SetClass("md:floating-element-width")
 | 
				
			||||||
                    })
 | 
					                    })
 | 
				
			||||||
| 
						 | 
					@ -135,10 +139,29 @@ export default class LeftControls extends Combine {
 | 
				
			||||||
            state.featureSwitchBackgroundSelection
 | 
					            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([
 | 
					        super([
 | 
				
			||||||
            currentViewAction,
 | 
					            currentViewAction,
 | 
				
			||||||
            filterButton,
 | 
					            filterButton,
 | 
				
			||||||
            downloadButtonn,
 | 
					            downloadButtonn,
 | 
				
			||||||
 | 
					            copyright,
 | 
				
			||||||
            mapSwitch
 | 
					            mapSwitch
 | 
				
			||||||
        ])
 | 
					        ])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -100,7 +100,6 @@
 | 
				
			||||||
        "maxCacheAge": 0
 | 
					        "maxCacheAge": 0
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "calculatedTags": [
 | 
					      "calculatedTags": [
 | 
				
			||||||
        "_grbNumber=(feat.properties.fixme?.match(/GRB thinks that this has number ([^;]+)/ ) ?? ['','none']) [1]"
 | 
					 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
      "mapRendering": [
 | 
					      "mapRendering": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
| 
						 | 
					@ -221,33 +220,6 @@
 | 
				
			||||||
              "then": {
 | 
					              "then": {
 | 
				
			||||||
                "nl": "Geen huisnummer"
 | 
					                "nl": "Geen huisnummer"
 | 
				
			||||||
              }
 | 
					              }
 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
              "if": {
 | 
					 | 
				
			||||||
                "and": [
 | 
					 | 
				
			||||||
                  "addr:housenumber:={_grbNumber}",
 | 
					 | 
				
			||||||
                  "fixme="
 | 
					 | 
				
			||||||
                ]
 | 
					 | 
				
			||||||
              },
 | 
					 | 
				
			||||||
              "then": "Het huisnummer is <b>{_grbNumber}</b>, 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",
 | 
					      "name": "All OSM Objects",
 | 
				
			||||||
      "source": {
 | 
					      "source": {
 | 
				
			||||||
        "osmTags": {
 | 
					        "osmTags": {
 | 
				
			||||||
          "and": [
 | 
					          "and": [
 | 
				
			||||||
            "id~*",
 | 
					            "id~*",
 | 
				
			||||||
            "landuse=",
 | 
					 | 
				
			||||||
            "place=",
 | 
					            "place=",
 | 
				
			||||||
            "disused:power=",
 | 
					            "disused:power=",
 | 
				
			||||||
            "power=",
 | 
					            "power=",
 | 
				
			||||||
| 
						 | 
					@ -365,16 +333,17 @@
 | 
				
			||||||
      "mapRendering": [
 | 
					      "mapRendering": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "color": {
 | 
					          "color": {
 | 
				
			||||||
            "render": "#00c"
 | 
					            "render": "#ccc"
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          "width": {
 | 
					          "width": {
 | 
				
			||||||
            "render": "1"
 | 
					            "render": "1"
 | 
				
			||||||
          }
 | 
					          },
 | 
				
			||||||
 | 
					          "fill": "no"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
      "title": {
 | 
					      "title": {
 | 
				
			||||||
        "render": {
 | 
					        "render": {
 | 
				
			||||||
          "*": "OSM-Object"
 | 
					          "*": "Other OSM-Object"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
      "tagRenderings": [
 | 
					      "tagRenderings": [
 | 
				
			||||||
| 
						 | 
					@ -494,7 +463,8 @@
 | 
				
			||||||
      "name": "GRB geometries",
 | 
					      "name": "GRB geometries",
 | 
				
			||||||
      "title": "GRB outline",
 | 
					      "title": "GRB outline",
 | 
				
			||||||
      "calculatedTags": [
 | 
					      "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_absolute=feat.get('_overlaps_with')?.overlap",
 | 
				
			||||||
        "_overlap_percentage=Math.round(100 * feat.get('_overlap_absolute') / feat.get('_surface')) ",
 | 
					        "_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']",
 | 
					        "_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,'-')",
 | 
					        "_grb_date=feat.properties['source:geometry:date'].replace(/\\//g,'-')",
 | 
				
			||||||
        "_imported_osm_still_fresh= feat.properties['_osm_obj:source:date'] == feat.properties._grb_date",
 | 
					        "_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)",
 | 
					        "_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 => \"<a href='https://osm.org/\"+f.feat.properties.id+\"' target='_blank'>\" + f.feat.properties.id + \"</a>\").join(', ')"
 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
      "tagRenderings": [
 | 
					      "tagRenderings": [
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
          "id": "Import-button",
 | 
					          "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)}",
 | 
					          "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": [
 | 
					          "mappings": [
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					              "if": "_overlaps_with_other_features~*",
 | 
				
			||||||
 | 
					              "then": "This GRB building overlaps with the following features: {_overlaps_with_other_features}.<br/>Fix the overlap and try again"
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
              "if": {
 | 
					              "if": {
 | 
				
			||||||
                "and": [
 | 
					                "and": [
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue