Various bug fixes and updates

This commit is contained in:
Pieter Vander Vennet 2020-09-09 18:42:13 +02:00
parent 97ec893479
commit e069b31e4e
29 changed files with 482 additions and 148 deletions

View file

@ -17,6 +17,7 @@ import * as viewpoint from "../../assets/layers/viewpoint/viewpoint.json"
import * as bike_parking from "../../assets/layers/bike_parking/bike_parking.json"
import * as bike_repair_station from "../../assets/layers/bike_repair_station/bike_repair_station.json"
import * as birdhides from "../../assets/layers/bird_hide/birdhides.json"
import * as nature_reserve from "../../assets/layers/nature_reserve/nature_reserve.json"
import {Utils} from "../../Utils";
@ -34,6 +35,7 @@ export class FromJSON {
FromJSON.Layer(bike_parking),
FromJSON.Layer(bike_repair_station),
FromJSON.Layer(birdhides),
FromJSON.Layer(nature_reserve),
];
for (const layer of sharedLayersList) {
@ -102,7 +104,6 @@ export class FromJSON {
public static TagRenderingWithDefault(json: TagRenderingConfigJson | string, propertyName, defaultValue: string): TagDependantUIElementConstructor {
if (json === undefined) {
if(defaultValue !== undefined){
console.log(`Using default value ${defaultValue} for ${propertyName}`)
return FromJSON.TagRendering(defaultValue, propertyName);
}
throw `Tagrendering ${propertyName} is undefined...`
@ -207,7 +208,7 @@ export class FromJSON {
return new Tag(tag[0], tag[1]);
}
public static Tag(json: AndOrTagConfigJson | string, context: string): TagsFilter {
public static Tag(json: AndOrTagConfigJson | string, context: string = ""): TagsFilter {
if(json === undefined){
throw "Error while parsing a tag: nothing defined. Make sure all the tags are defined and at least one tag is present in a complex expression"
}
@ -286,7 +287,6 @@ export class FromJSON {
private static LayerUncaught(json: LayerConfigJson): LayerDefinition {
console.log("Parsing layer", json)
const tr = FromJSON.Translation;
const overpassTags = FromJSON.Tag(json.overpassTags, "overpasstags for layer "+json.id);
const icon = FromJSON.TagRenderingWithDefault(json.icon, "icon", "./assets/bug.svg");
@ -381,6 +381,7 @@ export class FromJSON {
}
);
layer.maxAllowedOverlapPercentage = json.hideUnderlayingFeaturesMinPercentage;
return layer;
}

View file

@ -70,6 +70,14 @@ export interface LayerConfigJson {
*/
wayHandling?: number;
/**
* Consider that we want to show 'Nature Reserves' and 'Forests'. Now, ofter, there are pieces of forest mapped _in_ the nature reserve.
* Now, showing those pieces of forest overlapping with the nature reserve truly clutters the map and is very user-unfriendly.
*
* The features are placed layer by layer. If a feature below a feature on this layer overlaps for more then 'x'-percent, the underlying feature is hidden.
*/
hideUnderlayingFeaturesMinPercentage?:number;
/**
* Presets for this layer
*/

View file

@ -129,47 +129,5 @@ export class LayerDefinition {
this.style = options.style;
this.wayHandling = options.wayHandling ?? LayerDefinition.WAYHANDLING_DEFAULT;
}
/*
ToJson() {
function t(translation: string | Translation | UIElement) {
if (translation === undefined) {
return undefined;
}
if (typeof (translation) === "string") {
return translation;
}
if (translation instanceof Translation && translation.translations !== undefined) {
return translation.translations;
}
return translation.InnerRender();
}
function tr(tagRendering : TagRenderingOptions) : TagRenderingConfigJson{
const o = tagRendering.options;
return {
key: o.freeform.key,
render: o.freeform.renderTemplate,
type: o.freeform.template.
}
}
const layerConfig : LayerConfigJson = {
name: t(this.name),
description: t(this.description),
maxAllowedOverlapPercentage: this.maxAllowedOverlapPercentage,
presets: this.presets,
icon: this.icon,
minzoom: this.minzoom,
overpassFilter: this.overpassFilter,
title: this.title,
elementsToShow: this.elementsToShow,
style: this.style,
wayHandling: this.wayHandling,
};
return JSON.stringify(layerConfig)
}*/
}

View file

@ -35,7 +35,7 @@ export class Bos extends LayerDefinition {
this.minzoom = 13;
this.style = this.generateStyleFunction();
this.title = new NameInline("bos");
this.title = new NameInline("Bos");
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new NameQuestion(),

View file

@ -26,7 +26,7 @@ export class NatureReserves extends LayerDefinition {
}
];
this.minzoom = 13;
this.title = new NameInline("natuurreservaat");
this.title = new NameInline("Natuurreservaat");
this.style = this.generateStyleFunction();
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),

View file

@ -13,7 +13,7 @@ export class Park extends LayerDefinition {
question: "Is dit park publiek toegankelijk?",
mappings: [
{k: new Tag("access", "yes"), txt: "Publiek toegankelijk"},
{k: new Tag("access", ""), txt: "Publiek toegankelijk"},
{k: new Tag("access", ""), txt: "Publiek toegankelijk", hideInAnswer: true},
{k: new Tag("access", "no"), txt: "Niet publiek toegankelijk"},
{k: new Tag("access", "private"), txt: "Niet publiek toegankelijk, want privaat"},
{k: new Tag("access", "guided"), txt: "Enkel toegankelijk met een gids of op een activiteit"},
@ -59,7 +59,7 @@ export class Park extends LayerDefinition {
this.minzoom = 13;
this.style = this.generateStyleFunction();
this.title = new NameInline("park");
this.title = new NameInline("Park");
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
new NameQuestion(),

View file

@ -168,12 +168,12 @@ export class Widths extends LayerDefinition {
let dashArray = undefined;
if (props.onewayBike) {
dashArray = [20, 8]
dashArray = [5, 6]
}
return {
icon: null,
color: c,
weight: 9,
weight: 5,
dashArray: dashArray
}
}

View file

@ -1,7 +1,7 @@
import {NatureReserves} from "../Layers/NatureReserves";
import {Park} from "../Layers/Park";
import {Bos} from "../Layers/Bos";
import {Layout} from "../Layout";
import {NatureReserves} from "../Layers/NatureReserves";
export class Groen extends Layout {

View file

@ -41,7 +41,7 @@ export class OnlyShowIfConstructor implements TagDependantUIElementConstructor{
}
GetContent(tags: any): Translation {
if(this.IsKnown(tags)){
if(!this.IsKnown(tags)){
return undefined;
}
return this._embedded.GetContent(tags);

View file

@ -17,7 +17,7 @@ export class AccessTag extends TagRenderingOptions {
{k: new And([new Tag("access", "no"), new Tag("fee", "")]), txt: "Niet toegankelijk"},
{k: new And([new Tag("access", "private"), new Tag("fee", "")]), txt: "Niet toegankelijk, want privegebied"},
{k: new And([new Tag("access", "permissive"), new Tag("fee", "")]), txt: "Toegankelijk, maar het is privegebied"},
{k: new And([new Tag("access", "guided"), new Tag("fee", "")]), txt: "Enkel met gids of op activiteit"},
{k: new And([new Tag("access", "guided"), new Tag("fee", "")]), txt: "Enkel met een gids of tijdens een activiteit toegankelijk"},
{
k: new And([new Tag("access", "yes"),
new Tag("fee", "yes")]),

View file

@ -1,4 +1,4 @@
import {Tag} from "../../Logic/Tags";
import {RegexTag, Tag} from "../../Logic/Tags";
import Translations from "../../UI/i18n/Translations";
import {TagRenderingOptions} from "../TagRenderingOptions";
import Translation from "../../UI/i18n/Translation";
@ -8,18 +8,10 @@ export class NameInline extends TagRenderingOptions{
constructor(category: string | Translation ) {
super({
question: "",
freeform: {
renderTemplate: "{name}",
template: Translations.t.general.nameInlineQuestion.Subs({category: category}),
key: "name",
extraTags: new Tag("noname", "") // Remove 'noname=yes'
},
mappings: [
{k: new Tag("noname","yes"), txt: Translations.t.general.noNameCategory.Subs({category: category})},
{k: null, txt: category}
{k: new Tag("noname", "yes"), txt: Translations.t.general.noNameCategory.Subs({category: category})},
{k: new RegexTag("name", /.+/), txt: "{name}"},
{k:new Tag("name",""), txt: category}
]
});
}

View file

@ -3,31 +3,29 @@
* One is a big 'name-question', the other is the 'edit name' in the title.
* THis one is the big question
*/
import {Tag} from "../../Logic/Tags";
import {And, Tag} from "../../Logic/Tags";
import {TagRenderingOptions} from "../TagRenderingOptions";
export class NameQuestion extends TagRenderingOptions{
static options = {
priority: 10, // Move this last on the priority list, in order to prevent ppl to enter access restrictions and descriptions
question: "Wat is de <i>officiële</i> naam van dit gebied?<br><span class='question-subtext'>" +
"Zelf een naam bedenken wordt afgeraden.<br/>" +
"Een beschrijving van het gebied geven kan in een volgende stap.<br/>" +
"</span>",
freeform: {
key: "name",
template: "De naam is $$$",
renderTemplate: "", // We don't actually render it, only ask
placeholder: "",
extraTags: new Tag("noname","")
},
mappings: [
{k: new Tag("noname", "yes"), txt: "Dit gebied heeft geen naam"},
]
}
export class NameQuestion extends TagRenderingOptions {
constructor() {
super(NameQuestion.options);
super({
priority: 10, // Move this last on the priority list, in order to prevent ppl to enter access restrictions and descriptions
question: "Wat is de <i>officiële</i> naam van dit gebied?<br><span class='question-subtext'>" +
"Zelf een naam bedenken wordt afgeraden.<br/>" +
"Een beschrijving van het gebied geven kan in een volgende stap.<br/>" +
"</span>",
freeform: {
key: "name",
template: "De naam is $$$",
renderTemplate: "Dit gebied heet <i>{name}</i>",
placeholder: "",
extraTags: new Tag("noname", "")
},
mappings: [
{k: new And([new Tag("name", ""), new Tag("noname", "yes")]), txt: "Dit gebied heeft geen naam"},
]
});
}
}

View file

@ -1,5 +1,5 @@
import {Img} from "../../UI/Img";
import {Tag} from "../../Logic/Tags";
import {RegexTag, Tag} from "../../Logic/Tags";
import {TagRenderingOptions} from "../TagRenderingOptions";
@ -18,7 +18,7 @@ export class OsmLink extends TagRenderingOptions {
placeholder: "",
},
mappings: [
{k: new Tag("id", "node/-1"), txt: "<span class='alert'>Uploading</span>"}
{k: new RegexTag("id", /node\/-.+/), txt: "<span class='alert'>Uploading</span>"}
]
}

View file

@ -18,17 +18,16 @@ import Translation from "../UI/i18n/Translation";
import Combine from "../UI/Base/Combine";
export class
TagRendering extends UIElement implements TagDependantUIElement {
export class TagRendering extends UIElement implements TagDependantUIElement {
private readonly _priority: number;
private readonly _question: string | Translation;
private readonly _mapping: { k: TagsFilter, txt: string | UIElement, priority?: number }[];
private currentTags : UIEventSource<any> ;
private currentTags: UIEventSource<any>;
private readonly _freeform: {
key: string,
template: string | UIElement,
@ -110,7 +109,6 @@ TagRendering extends UIElement implements TagDependantUIElement {
for (const choice of options.mappings ?? []) {
let choiceSubbed = {
k: choice.k?.substituteValues(this.currentTags.data),
txt: choice.txt,
@ -225,7 +223,7 @@ TagRendering extends UIElement implements TagDependantUIElement {
}
previousTexts.push(this.ApplyTemplate(mapping.txt));
elements.push(this.InputElementForMapping(mapping));
elements.push(this.InputElementForMapping(mapping, mapping.substitute));
}
}
@ -247,14 +245,26 @@ TagRendering extends UIElement implements TagDependantUIElement {
}
private InputElementForMapping(mapping: { k: TagsFilter, txt: (string | Translation) }) {
return new FixedInputElement(this.ApplyTemplate(mapping.txt),
mapping.k.substituteValues(this.currentTags.data)
);
private InputElementForMapping(mapping: { k: TagsFilter, txt: (string | Translation) }, substituteValues: boolean) {
if (substituteValues) {
return new FixedInputElement(this.ApplyTemplate(mapping.txt),
mapping.k.substituteValues(this.currentTags.data),
(t0, t1) => t0.isEquivalent(t1)
);
}
return new FixedInputElement(this.ApplyTemplate(mapping.txt),mapping.k,
(t0, t1) => t0.isEquivalent(t1));
}
private InputForFreeForm(freeform): InputElement<TagsFilter> {
private InputForFreeForm(freeform : {
key: string,
template: string | Translation,
renderTemplate: string | Translation,
placeholder?: string | Translation,
extraTags?: TagsFilter,
}): InputElement<TagsFilter> {
if (freeform?.template === undefined) {
return undefined;
}
@ -283,7 +293,7 @@ TagRendering extends UIElement implements TagDependantUIElement {
const tag = new Tag(freeform.key, formatter(string, this._source.data._country));
if (tag.value.length > 255) {
return undefined; // Toolong
return undefined; // Too long
}
if (freeform.extraTags === undefined) {
@ -299,7 +309,13 @@ TagRendering extends UIElement implements TagDependantUIElement {
const toString =
(tag) => {
if (tag instanceof And) {
return toString(tag.and[0])
for (const subtag of tag.and) {
if(subtag instanceof Tag && subtag.key === freeform.key){
return subtag.value;
}
}
return undefined;
} else if (tag instanceof Tag) {
return tag.value
}