First steps for a decent custom theme generator

This commit is contained in:
Pieter Vander Vennet 2020-08-31 02:59:47 +02:00
parent a57b7d93fa
commit 2052976909
82 changed files with 1880 additions and 1311 deletions

View file

@ -223,12 +223,8 @@ export class FilteredLayer {
} else {
if(style.icon.iconSize === undefined){
style.icon.iconSize = [50,50]
}if(style.icon.iconAnchor === undefined){
style.icon.iconAnchor = [style.icon.iconSize[0] / 2,style.icon.iconSize[1]]
}
if (style.icon.popupAnchor === undefined) {
style.icon.popupAnchor = [0, 8 - (style.icon.iconSize[1])]
}
marker = L.marker(latLng, {
icon: new L.icon(style.icon),
});

View file

@ -53,12 +53,11 @@ export class LayerUpdater {
console.log("Not loading layer ", layer.id, " as it needs at least ", layer.minzoom, "zoom")
continue;
}
// Check if data for this layer has already been loaded
let previouslyLoaded = false;
for (let z = layer.minzoom; z < 25 && !previouslyLoaded; z++) {
const previousLoadedBounds = this.previousBounds.get(z);
if (previousLoadedBounds == undefined) {
if (previousLoadedBounds === undefined) {
continue;
}
for (const previousLoadedBound of previousLoadedBounds) {
@ -89,7 +88,7 @@ export class LayerUpdater {
self.runningQuery.setData(false);
if (geojson.features.length > 0) {
console.log("Got some leftovers: ", geojson)
console.warn("Got some leftovers: ", geojson)
}
return;
}

View file

@ -18,15 +18,14 @@ export class RegexTag extends TagsFilter {
private readonly value: RegExp;
private readonly invert: boolean;
constructor(key: RegExp, value: RegExp, invert: boolean = false) {
constructor(key: string | RegExp, value: RegExp, invert: boolean = false) {
super();
this.key = key;
this.key = typeof (key) === "string" ? new RegExp(key) : key;
this.value = value;
this.invert = invert;
}
asOverpass(): string[] {
return [`['${this.key.source}'${this.invert ? "!" : ""}~'${this.value.source}']`];
}
@ -45,7 +44,7 @@ export class RegexTag extends TagsFilter {
}
asHumanString() {
return `${this.key}${this.invert ? "!" : ""}~${this.value}`;
return `${this.key.source}${this.invert ? "!" : ""}~${this.value.source}`;
}
}
@ -64,7 +63,7 @@ export class Tag extends TagsFilter {
if(value === undefined){
throw "Invalid value";
}
if(value === undefined || value === "*"){
if(value === "*"){
console.warn(`Got suspicious tag ${key}=* ; did you mean ${key}!~*`)
}
}

View file

@ -8,17 +8,18 @@ export class UIEventSource<T>{
}
public addCallback(callback: ((latestData : T) => void)) {
public addCallback(callback: ((latestData : T) => void)) : UIEventSource<T>{
this._callbacks.push(callback);
return this;
}
public setData(t: T): void {
public setData(t: T): UIEventSource<T> {
if (this.data === t) {
return;
}
this.data = t;
this.ping();
return this;
}
public ping(): void {
@ -55,7 +56,6 @@ export class UIEventSource<T>{
const update = function () {
newSource.setData(f(self.data));
newSource.ping();
}
this.addCallback(update);