Merge branch 'develop' into feature/conflation-fix

This commit is contained in:
Pieter Vander Vennet 2022-01-05 18:14:15 +01:00
commit 7f99e76b0c
6 changed files with 56 additions and 16 deletions

View file

@ -59,7 +59,7 @@ export class And extends TagsFilter {
} }
asHumanString(linkToWiki: boolean, shorten: boolean, properties) { asHumanString(linkToWiki: boolean, shorten: boolean, properties) {
return this.and.map(t => t.asHumanString(linkToWiki, shorten, properties)).join("&"); return this.and.map(t => t.asHumanString(linkToWiki, shorten, properties)).filter(x => x !== "").join("&");
} }
isUsableAsAnswer(): boolean { isUsableAsAnswer(): boolean {

View file

@ -48,7 +48,7 @@ export class Tag extends TagsFilter {
} }
if(v === "" || v === undefined){ if(v === "" || v === undefined){
// This tag will be removed if in the properties, so we indicate this with special rendering // This tag will be removed if in the properties, so we indicate this with special rendering
if(currentProperties !== undefined && (currentProperties[this.key] ?? "") !== ""){ if(currentProperties !== undefined && (currentProperties[this.key] ?? "") === ""){
// This tag is not present in the current properties, so this tag doesn't change anything // This tag is not present in the current properties, so this tag doesn't change anything
return "" return ""
} }

View file

@ -281,10 +281,12 @@ export class UIEventSource<T> {
* @param f: The transforming function * @param f: The transforming function
* @param extraSources: also trigger the update if one of these sources change * @param extraSources: also trigger the update if one of these sources change
* @param g: a 'backfunction to let the sync run in two directions. (data of the new UIEVEntSource, currentData) => newData * @param g: a 'backfunction to let the sync run in two directions. (data of the new UIEVEntSource, currentData) => newData
* @param allowUnregister: if set, the update will be halted if no listeners are registered
*/ */
public map<J>(f: ((t: T) => J), public map<J>(f: ((t: T) => J),
extraSources: UIEventSource<any>[] = [], extraSources: UIEventSource<any>[] = [],
g: ((j: J, t: T) => T) = undefined): UIEventSource<J> { g: ((j: J, t: T) => T) = undefined,
allowUnregister = false): UIEventSource<J> {
const self = this; const self = this;
const stack = new Error().stack.split("\n"); const stack = new Error().stack.split("\n");
@ -297,6 +299,7 @@ export class UIEventSource<T> {
const update = function () { const update = function () {
newSource.setData(f(self.data)); newSource.setData(f(self.data));
return allowUnregister && newSource._callbacks.length === 0
} }
this.addCallback(update); this.addCallback(update);

View file

@ -406,9 +406,17 @@ export default class ValidatedTextField {
if (str === undefined) { if (str === undefined) {
return false; return false;
} }
if(str.startsWith("tel:")){
str = str.substring("tel:".length)
}
return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any)?.isValid() ?? false return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any)?.isValid() ?? false
}, },
(str, country: () => string) => parsePhoneNumberFromString(str, (country())?.toUpperCase() as any).formatInternational(), (str, country: () => string) => {
if(str.startsWith("tel:")){
str = str.substring("tel:".length)
}
return parsePhoneNumberFromString(str, (country())?.toUpperCase() as any).formatInternational();
},
undefined, undefined,
"tel" "tel"
), ),

View file

@ -145,7 +145,8 @@ export default class ShowDataLayer {
pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng), pointToLayer: (feature, latLng) => self.pointToLayer(feature, latLng),
onEachFeature: (feature, leafletLayer) => self.postProcessFeature(feature, leafletLayer) onEachFeature: (feature, leafletLayer) => self.postProcessFeature(feature, leafletLayer)
}); });
const selfLayer = this.geoLayer;
const allFeats = this._features.features.data; const allFeats = this._features.features.data;
for (const feat of allFeats) { for (const feat of allFeats) {
if (feat === undefined) { if (feat === undefined) {
@ -153,12 +154,11 @@ export default class ShowDataLayer {
} }
try { try {
if (feat.geometry.type === "LineString") { if (feat.geometry.type === "LineString") {
const self = this;
const coords = L.GeoJSON.coordsToLatLngs(feat.geometry.coordinates) const coords = L.GeoJSON.coordsToLatLngs(feat.geometry.coordinates)
const tagsSource = this.allElements?.addOrGetElement(feat) ?? new UIEventSource<any>(feat.properties); const tagsSource = this.allElements?.addOrGetElement(feat) ?? new UIEventSource<any>(feat.properties);
let offsettedLine; let offsettedLine;
tagsSource tagsSource
.map(tags => this._layerToShow.lineRendering[feat.lineRenderingIndex].GenerateLeafletStyle(tags)) .map(tags => this._layerToShow.lineRendering[feat.lineRenderingIndex].GenerateLeafletStyle(tags), [], undefined, true)
.withEqualityStabilized((a, b) => { .withEqualityStabilized((a, b) => {
if (a === b) { if (a === b) {
return true return true
@ -176,6 +176,9 @@ export default class ShowDataLayer {
offsettedLine = L.polyline(coords, lineStyle); offsettedLine = L.polyline(coords, lineStyle);
this.postProcessFeature(feat, offsettedLine) this.postProcessFeature(feat, offsettedLine)
offsettedLine.addTo(this.geoLayer) offsettedLine.addTo(this.geoLayer)
// If 'self.geoLayer' is not the same as the layer the feature is added to, we can safely remove this callback
return self.geoLayer !== selfLayer
}) })
} else { } else {
this.geoLayer.addData(feat); this.geoLayer.addData(feat);
@ -186,11 +189,13 @@ export default class ShowDataLayer {
} }
if (options.zoomToFeatures ?? false) { if (options.zoomToFeatures ?? false) {
try { if(this.geoLayer.getLayers().length > 0){
const bounds = this.geoLayer.getBounds() try {
mp.fitBounds(bounds, {animate: false}) const bounds = this.geoLayer.getBounds()
} catch (e) { mp.fitBounds(bounds, {animate: false})
console.debug("Invalid bounds", e) } catch (e) {
console.debug("Invalid bounds", e)
}
} }
} }

View file

@ -71,9 +71,17 @@
"ca": "Quin és el telèfon de {name}?" "ca": "Quin és el telèfon de {name}?"
}, },
"render": "<a href='tel:{phone}'>{phone}</a>", "render": "<a href='tel:{phone}'>{phone}</a>",
"mappings": [
{
"if": "contact:phone~*",
"then": "<a href='tel:{contact:phone}'>{contact:phone}</a>",
"hideInAnswer": true
}
],
"freeform": { "freeform": {
"key": "phone", "key": "phone",
"type": "phone" "type": "phone",
"addExtraTags": ["contact:phone="]
} }
}, },
"osmlink": { "osmlink": {
@ -140,9 +148,17 @@
"hu": "Mi a(z) {name} e-mail címe?", "hu": "Mi a(z) {name} e-mail címe?",
"ca": "Quina és l'adreça de correu electrònic de {name}?" "ca": "Quina és l'adreça de correu electrònic de {name}?"
}, },
"mappings": [
{
"if": "contact:email~*",
"then": "<a href='mailto:{contact:email}' target='_blank'>{contact:email}</a>",
"hideInAnswer": true
}
],
"freeform": { "freeform": {
"key": "email", "key": "email",
"type": "email" "type": "email",
"addExtraTags": ["contact:email="]
} }
}, },
"website": { "website": {
@ -168,8 +184,16 @@
"render": "<a href='{website}' target='_blank'>{website}</a>", "render": "<a href='{website}' target='_blank'>{website}</a>",
"freeform": { "freeform": {
"key": "website", "key": "website",
"type": "url" "type": "url",
} "addExtraTags": ["contact:website="]
},
"mappings": [
{
"if": "contact:website~*",
"then": "<a href='{contact:website}' target='_blank'>{contact:website}</a>",
"hideInAnswer": true
}
]
}, },
"wheelchair-access": { "wheelchair-access": {
"question": { "question": {