More work on the theme generator

This commit is contained in:
Pieter Vander Vennet 2020-08-23 01:49:19 +02:00
parent cd37d8db98
commit 0f433d026a
13 changed files with 340 additions and 87 deletions

View file

@ -30,6 +30,9 @@ export class Changes {
addTag(elementId: string, tagsFilter : TagsFilter){
if(tagsFilter instanceof Tag){
const tag = tagsFilter as Tag;
if(typeof tag.value !== "string"){
throw "Invalid value"
}
this.addChange(elementId, tag.key, tag.value);
return;
}
@ -114,6 +117,9 @@ export class Changes {
// The tags are not yet written into the OsmObject, but this is applied onto a
for (const kv of basicTags) {
properties[kv.key] = kv.value;
if(typeof kv.value !== "string"){
throw "Invalid value"
}
this._pendingChanges.push({elementId: id, key: kv.key, value: kv.value});
}
this.pendingChangesES.setData(this._pendingChanges.length);

View file

@ -62,7 +62,7 @@ export class Regex extends TagsFilter {
export class Tag extends TagsFilter {
public key: string
public value: string
public value: string | RegExp
public invertValue: boolean
constructor(key: string | RegExp, value: string | RegExp, invertValue = false) {
@ -156,7 +156,15 @@ export class Tag extends TagsFilter {
`=` +
`<a href='https://wiki.openstreetmap.org/wiki/Tag:${this.key}%3D${this.value}' target='_blank'>${this.value}</a>`
}
return this.key + "=" + this.value;
console.log("Humanizing", this)
if (typeof (this.value) === "string") {
return this.key + (this.invertValue ? "!=": "=") + this.value;
}else{
// value is a regex
return this.key + "~=" + this.value.source;
}
}
}