More fixing, first complete version of UK-addresses-theme

This commit is contained in:
pietervdvn 2022-01-17 23:50:50 +01:00
parent c2806a1b4a
commit d4d7ab6f3a
13 changed files with 122 additions and 47 deletions

View file

@ -304,7 +304,10 @@ export default class FeaturePipeline {
}
}),
updater)
updater,
{handleLeftovers: (leftOvers) => {
console.warn("Overpass returned a few non-matched features:", leftOvers)
}})
// Also load points/lines that are newly added.
@ -323,7 +326,10 @@ export default class FeaturePipeline {
perLayer.features.addCallbackAndRunD(_ => self.onNewDataLoaded(perLayer))
},
newGeometry
newGeometry,
{handleLeftovers: (leftOvers) => {
console.warn("Got some leftovers from the filteredLayers: ", leftOvers)
}}
)

View file

@ -2,7 +2,7 @@ import {Utils} from "../Utils";
export default class Constants {
public static vNumber = "0.14.0-rc-1";
public static vNumber = "0.14.0-rc-2";
public static ImgurApiKey = '7070e7167f0a25a'
public static readonly mapillary_client_token_v4 = "MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85"

View file

@ -236,7 +236,7 @@ class ExpandTagRendering extends Conversion<string | TagRenderingConfigJson | {
}
for (const key of Object.keys(tr)) {
if (key === "builtin" || key === "override" || key === "id") {
if (key === "builtin" || key === "override" || key === "id" || key.startsWith("#")) {
continue
}
errors.push("At " + ctx + ": an object calling a builtin can only have keys `builtin` or `override`, but a key with name `" + key + "` was found. This won't be picked up! The full object is: " + JSON.stringify(tr))
@ -827,8 +827,8 @@ class AddDependencyLayersToTheme extends DesugaringStep<LayoutConfigJson> {
const knownTagRenderings: Map<string, TagRenderingConfigJson> = state.tagRenderings;
const errors = [];
const warnings = [];
const layers: LayerConfigJson[] = <LayerConfigJson[]>theme.layers; // Layers should be expanded at this point
const layers: LayerConfigJson[] = <LayerConfigJson[]> theme.layers; // Layers should be expanded at this point
knownTagRenderings.forEach((value, key) => {
value.id = key;
})
@ -954,11 +954,25 @@ class AddDefaultLayers extends DesugaringStep<LayoutConfigJson> {
convert(state: DesugaringContext, json: LayoutConfigJson, context: string): { result: LayoutConfigJson; errors: string[]; warnings: string[] } {
const errors = []
const warnings = []
json.layers = [...json.layers]
if (json.id === "personal") {
json.layers = []
for (const publicLayer of AllKnownLayouts.AllPublicLayers()) {
const id = publicLayer.id
const config = state.sharedLayers.get(id)
if(Constants.added_by_default.indexOf(id) >= 0){
continue;
}
if(config === undefined){
// This is a layer which is coded within a public theme, not as separate .json
continue
}
json.layers.push(config)
}
const publicIds = AllKnownLayouts.AllPublicLayers().map(l => l.id)
json.layers = publicIds.map(id => state.sharedLayers.get(id))
publicIds.map(id => state.sharedLayers.get(id))
}
for (const layerName of Constants.added_by_default) {
@ -968,10 +982,11 @@ class AddDefaultLayers extends DesugaringStep<LayoutConfigJson> {
}
json.layers.push(v)
}
return {
result: json,
errors,
warnings: []
warnings
};
}

View file

@ -373,6 +373,9 @@ export default class TagRenderingConfig {
return mapping.then;
}
if (mapping.if.matchesProperties(tags)) {
if(this.id === "uk_addresses_placename"){
console.log("Matched",mapping.if,"with ",tags["addr:place"])
}
return mapping.then;
}
}

View file

@ -4,7 +4,6 @@ import {UIEventSource} from "../../Logic/UIEventSource";
import Combine from "../Base/Combine";
import {VariableUiElement} from "../Base/VariableUIElement";
import Translations from "../i18n/Translations";
import Constants from "../../Models/Constants";
import Toggle from "../Input/Toggle";
import CreateNewNodeAction from "../../Logic/Osm/Actions/CreateNewNodeAction";
import Loading from "../Base/Loading";
@ -37,8 +36,12 @@ import TagApplyButton from "./TagApplyButton";
import LayerConfig from "../../Models/ThemeConfig/LayerConfig";
import * as conflation_json from "../../assets/layers/conflation/conflation.json";
import {GeoOperations} from "../../Logic/GeoOperations";
import {LoginToggle} from "./LoginButton";
/**
* A helper class for the various import-flows.
* An import-flow always starts with a 'Import this'-button. Upon click, a custom confirmation panel is provided
*/
abstract class AbstractImportButton implements SpecialVisualizations {
public readonly funcName: string
public readonly docs: string
@ -93,7 +96,6 @@ ${Utils.special_visualizations_importRequirementDocs}
constr(state, tagSource: UIEventSource<any>, argsRaw, guiState) {
const self = this;
/**
* Some generic import button pre-validation is implemented here:
* - Are we logged in?
@ -136,25 +138,11 @@ ${Utils.special_visualizations_importRequirementDocs}
// Explanation of the tags that will be applied onto the imported/conflated object
let tagSpec = args.tags;
if(tagSpec.indexOf(" ")< 0 && tagSpec.indexOf(";") < 0){
if(tagSpec.indexOf(" ")< 0 && tagSpec.indexOf(";") < 0 && tagSource.data[args.tags] !== undefined){
// This is probably a key
tagSpec = tagSource.data[args.tags]
console.warn("Using tagspec tagSource.data["+args.tags+"] which is ",tagSpec)
}
const newTags = TagApplyButton.generateTagsToApply(tagSpec, tagSource)
const appliedTags = new Toggle(
new VariableUiElement(
newTags.map(tgs => {
const filteredTags = tgs.filter(tg => self.showRemovedTags || (tg.value ?? "") !== "")
const asText = new And(filteredTags)
.asHumanString(true, true, {})
return t0.presetInfo.Subs({tags: asText}).SetClass("subtle");
})),
undefined,
state.osmConnection.userDetails.map(ud => ud.csCount >= Constants.userJourney.tagsVisibleAt)
)
const importClicked = new UIEventSource(false);
inviteToImportButton.onClick(() => {
@ -179,7 +167,7 @@ ${Utils.special_visualizations_importRequirementDocs}
const importFlow = new Toggle(
new Toggle(
new Loading(t0.stillLoading),
new Combine([importGuidingPanel, appliedTags]).SetClass("flex flex-col"),
importGuidingPanel,
state.featurePipeline.runningQuery
),
inviteToImportButton,
@ -187,7 +175,7 @@ ${Utils.special_visualizations_importRequirementDocs}
);
return new Toggle(
new Toggle(
new LoginToggle(
new Toggle(
new Toggle(
t.hasBeenImported,
@ -198,7 +186,7 @@ ${Utils.special_visualizations_importRequirementDocs}
state.locationControl.map(l => l.zoom >= 18)
),
pleaseLoginButton,
state.osmConnection.isLoggedIn
state
),
t.wrongType,
new UIEventSource(this.canBeImported(feature)))
@ -210,9 +198,10 @@ ${Utils.special_visualizations_importRequirementDocs}
if (originalFeatureTags !== undefined) {
const tags = baseArgs.tags
if(tags.indexOf(" ") < 0 && tags.indexOf(";") < 0){
// This might be a propertie to expand...
if(tags.indexOf(" ") < 0 && tags.indexOf(";") < 0 && originalFeatureTags.data[tags] !== undefined){
// This might be a property to expand...
const items : string = originalFeatureTags.data[tags]
console.warn("Using tagspec tagSource.data["+tags+"] which is ",items)
baseArgs["newTags"] = TagApplyButton.generateTagsToApply(items, originalFeatureTags)
}else{
baseArgs["newTags"] = TagApplyButton.generateTagsToApply(tags, originalFeatureTags)
@ -569,7 +558,6 @@ export class ImportPointButton extends AbstractImportButton {
const presetInfo = <PresetInfo>{
tags: args.newTags.data,
icon: () => new Img(args.icon),
description: Translations.WT(args.text),
layerToAddTo: state.filteredLayers.data.filter(l => l.layerDef.id === args.targetLayer)[0],
name: args.text,
title: Translations.WT(args.text),

View file

@ -12,8 +12,7 @@
"osmTags": {
"or": [
"addr:housenumber~*",
"addr:street~*",
"ref:inspireid~*"
"addr:street~*"
]
}
},

View file

@ -48,8 +48,12 @@
"version": "0",
"startLat": 0,
"startLon": 0,
"startZoom": 16,
"startZoom": 0,
"widenFactor": 1.2,
"overpassMaxZoom": 0,
"#note": "The 'overpassMaxZoom' should be exactly the same as or less then the overrideAll",
"overpassMaxZoom": 15,
"overrideAll": {
"minZoom": 16
},
"layers": []
}

View file

@ -77,5 +77,15 @@
"Pieter Vander Vennet"
],
"sources": []
},
{
"path": "stamp.jpg",
"license": "CC-BY 2.0",
"authors": [
"Mark Morgan"
],
"sources": [
"https://commons.wikimedia.org/wiki/File:Queen_Elizabeth_II_Virgin_Islands_stamp.jpg"
]
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View file

@ -66,7 +66,7 @@
"calculatedTags": [
"_has_address=feat.overlapWith('address').length > 0"
],
"#mapRendering": [
"mapRendering": [
{
"width": 2,
"color": {
@ -80,13 +80,18 @@
}
}
],
"mapRendering": null
"shownByDefault": false,
"name": {
"en": "Inspire polygons"
}
},
{
"id": "to_import",
"source": {
"geoJson": "https://osm-uk-addresses.russss.dev/addresses/{z}/{x}/{y}.json",
"osmTags": "inspireid~*",
"osmTags": {
"and": ["ref:GB:inspire~*","id!~node/.*"]
},
"geoJsonZoomLevel": 16,
"isOsmCache": false
},
@ -126,7 +131,7 @@
},
{
"id": "uk_addresses_import_button",
"render": "{import_button(address,ref:inspireid=$inspireid, Add this address, ./assets/themes/uk_addresses/housenumber_add.svg)}"
"render": "{import_button(address,ref:GB:inspire=$ref:GB:inspire;ref:GB:uprn=$ref:GB:uprn$, Add this address, ./assets/themes/uk_addresses/housenumber_add.svg)}"
}
],
"calculatedTags": [
@ -203,7 +208,7 @@
"or": [
"addr:housenumber~*",
"addr:street~*",
"ref:inspireid~*"
"ref:GB:inspire~*"
]
}
},
@ -285,6 +290,7 @@
"then": "This building has no housename"
},
{
"#": "By adding nohousenumber!=yes, this option will trigger when first added, but will be untriggered if a housenumber is added, resulting in the question poping up!",
"if": {
"and": [
"addr:housename=",
@ -298,7 +304,7 @@
},
{
"id": "uk_addresses_unit",
"render": "The sub-part of this address is {addr:unit}",
"render": "The sub-part of this address is <b>{addr:unit}</b>",
"question": {
"en": "What is the unit indication of this address? <div class='subtle'>This is the letter or number of the letterbox here, if multiple letterboxes share the same street and housenumber. If there are multiple at the same location, add them here with a <b>;</b> between them</div>"
},
@ -346,6 +352,26 @@
]
},
{
"id": "uk_addresses_placename",
"question": {
"en": "What is the place or locality?<div class='subtle'>This is additional information if the streetname alone isn't enough to find this address. Typical examples are 'Technology Park', 'XYZ Terrace', ...</div>"
},
"render": {
"en": "The placename is <b>{addr:place}</b>"
},
"freeform": {
"key": "addr:place"
},
"mappings": [
{
"if": "addr:place=",
"then": {
"en": "No extra placename is given or needed"
}
}
]
},
{
"id": "fixme",
"render": "<b>This address is complicated - therefore someone has given a description of what should be fixed:</b>{fixme}",
@ -358,7 +384,7 @@
"mappings": [
{
"if": "fixme=",
"then": "Is this address very complicated? - write something here to explain complicated cases"
"then": "Is this address complicated? Write something here to explain this case. An experienced mapper will have a look at it"
}
]
},
@ -368,6 +394,12 @@
"render": {
"en": "{image_carousel(image:address)}<br/>{image_upload(image:address, Add image of the address)}"
}
},
{
"id": "preview",
"render": {
"en": "To send a letter to this addres, you would write:<div style='background: #fcdf94; border: 2px solid black; border-radius: 1rem; padding: 1.5rem 0.5rem 2rem 8rem; margin: 1rem' class='flex flex-col'><img src='./assets/themes/uk_addresses/stamp.jpg' class='self-end w-16'/><div class='subtle'>Name of the inhabitant</div><div>{addr:housename}</div><div>{addr:unit} {addr:housenumber} {addr:street}</div><div>{addr:place}</div><div class='subtle'>Suburb</div><div class='subtle'>Town</div><div class='subtle'>Postal code</div></div>"
}
}
],
"mapRendering": [

View file

@ -841,7 +841,7 @@
},
"grb": {
"layers": {
"2": {
"1": {
"tagRenderings": {
"building type": {
"question": "Was ist das für ein Gebäude?"

View file

@ -839,7 +839,7 @@
"grb": {
"description": "This theme is an attempt to help automating the GRB import.",
"layers": {
"2": {
"1": {
"tagRenderings": {
"building type": {
"question": "What kind of building is this?"
@ -1271,6 +1271,9 @@
"uk_addresses": {
"description": "Contribute to OpenStreetMap by filling out address information",
"layers": {
"0": {
"name": "Inspire polygons"
},
"1": {
"tagRenderings": {
"uk_addresses_embedding_outline": {
@ -1301,6 +1304,9 @@
"fixme": {
"question": "What should be fixed here? Please explain what the address is"
},
"preview": {
"render": "To send a letter to this addres, you would write:<div style='background: #fcdf94; border: 2px solid black; border-radius: 1rem; padding: 1.5rem 0.5rem 2rem 8rem; margin: 1rem' class='flex flex-col'><img src='./assets/themes/uk_addresses/stamp.jpg' class='self-end w-16'/><div class='subtle'>Name of the inhabitant</div><div>{addr:housename}</div><div>{addr:unit} {addr:housenumber} {addr:street}</div><div>{addr:place}</div><div class='subtle'>Suburb</div><div class='subtle'>Town</div><div class='subtle'>Postal code</div></div>"
},
"uk_addresses_explanation_osm": {
"render": "This address is saved in OpenStreetMap"
},
@ -1313,9 +1319,21 @@
"question": "What is the number of this house?",
"render": "The housenumber is <b>{addr:housenumber}</b>"
},
"uk_addresses_placename": {
"mappings": {
"0": {
"then": "No extra placename is given or needed"
}
},
"question": "What is the place or locality?<div class='subtle'>This is additional information if the streetname alone isn't enough to find this address. Typical examples are 'Technology Park', 'XYZ Terrace', ...</div>",
"render": "The placename is <b>{addr:place}</b>"
},
"uk_addresses_street": {
"question": "What street is this address located in?",
"render": "This address is in street <b>{addr:street}</b>"
},
"uk_addresses_unit": {
"question": "What is the unit indication of this address? <div class='subtle'>This is the letter or number of the letterbox here, if multiple letterboxes share the same street and housenumber. If there are multiple at the same location, add them here with a <b>;</b> between them</div>"
}
},
"title": {

View file

@ -769,7 +769,7 @@
"grb": {
"description": "Dit thema helpt het GRB importeren.",
"layers": {
"2": {
"1": {
"tagRenderings": {
"grb-fixme": {
"mappings": {