forked from MapComplete/MapComplete
Various bug fixes and updates
This commit is contained in:
parent
97ec893479
commit
e069b31e4e
29 changed files with 482 additions and 148 deletions
|
@ -216,21 +216,26 @@ export class FilteredLayer {
|
|||
pointToLayer: function (feature, latLng) {
|
||||
const style = self._style(feature.properties);
|
||||
let marker;
|
||||
if (style.icon === undefined) {
|
||||
marker = L.circle(latLng, {
|
||||
radius: 25,
|
||||
color: style.color
|
||||
});
|
||||
if (style.icon === undefined) {
|
||||
marker = L.circle(latLng, {
|
||||
radius: 25,
|
||||
color: style.color
|
||||
});
|
||||
|
||||
} else {
|
||||
if(style.icon.iconSize === undefined){
|
||||
style.icon.iconSize = [50,50]
|
||||
}
|
||||
|
||||
marker = L.marker(latLng, {
|
||||
icon: new L.icon(style.icon),
|
||||
});
|
||||
}
|
||||
} else if (style.icon.iconUrl.startsWith("$circle ")) {
|
||||
marker = L.circle(latLng, {
|
||||
radius: 25,
|
||||
color: style.color
|
||||
});
|
||||
} else {
|
||||
if (style.icon.iconSize === undefined) {
|
||||
style.icon.iconSize = [50, 50]
|
||||
}
|
||||
|
||||
marker = L.marker(latLng, {
|
||||
icon: new L.icon(style.icon),
|
||||
});
|
||||
}
|
||||
let eventSource = State.state.allElements.addOrGetElement(feature);
|
||||
const uiElement = self._showOnPopup(eventSource, feature);
|
||||
const popup = L.popup({}, marker).setContent(uiElement.Render());
|
||||
|
@ -253,11 +258,7 @@ export class FilteredLayer {
|
|||
}
|
||||
} else {
|
||||
self._geolayer.setStyle(function (featureX) {
|
||||
const style = self._style(featureX.properties);
|
||||
if (featureX === feature) {
|
||||
console.log("Selected element is", featureX.properties.id)
|
||||
}
|
||||
return style;
|
||||
return self._style(featureX.properties);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,9 @@ export abstract class TagsFilter {
|
|||
abstract matches(tags: { k: string, v: string }[]): boolean
|
||||
abstract asOverpass(): string[]
|
||||
abstract substituteValues(tags: any) : TagsFilter;
|
||||
abstract isUsableAsAnswer() : boolean;
|
||||
abstract isUsableAsAnswer(): boolean;
|
||||
|
||||
abstract isEquivalent(other: TagsFilter): boolean;
|
||||
|
||||
matchesProperties(properties: Map<string, string>): boolean {
|
||||
return this.matches(TagUtils.proprtiesToKV(properties));
|
||||
|
@ -58,16 +60,26 @@ export class RegexTag extends TagsFilter {
|
|||
return this.invert;
|
||||
}
|
||||
|
||||
substituteValues(tags: any) : TagsFilter{
|
||||
substituteValues(tags: any): TagsFilter {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
asHumanString() {
|
||||
if (typeof this.key === "string") {
|
||||
return `${this.key}${this.invert ? "!" : ""}~${RegexTag.source(this.value)}`;
|
||||
}
|
||||
return `~${this.key.source}${this.invert ? "!" : ""}~${RegexTag.source(this.value)}`
|
||||
}
|
||||
|
||||
isEquivalent(other: TagsFilter): boolean {
|
||||
if (other instanceof RegexTag) {
|
||||
return other.asHumanString() == this.asHumanString();
|
||||
}
|
||||
if(other instanceof Tag){
|
||||
return RegexTag.doesMatch(other.key, this.key) && RegexTag.doesMatch(other.value, this.value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,6 +152,16 @@ export class Tag extends TagsFilter {
|
|||
isUsableAsAnswer(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
isEquivalent(other: TagsFilter): boolean {
|
||||
if(other instanceof Tag){
|
||||
return this.key === other.key && this.value === other.value;
|
||||
}
|
||||
if(other instanceof RegexTag){
|
||||
other.isEquivalent(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +209,24 @@ export class Or extends TagsFilter {
|
|||
isUsableAsAnswer(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
isEquivalent(other: TagsFilter): boolean {
|
||||
if(other instanceof Or){
|
||||
|
||||
for (const selfTag of this.or) {
|
||||
let matchFound = false;
|
||||
for (let i = 0; i < other.or.length && !matchFound; i++){
|
||||
let otherTag = other.or[i];
|
||||
matchFound = selfTag.isEquivalent(otherTag);
|
||||
}
|
||||
if(!matchFound){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -256,6 +296,24 @@ export class And extends TagsFilter {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
isEquivalent(other: TagsFilter): boolean {
|
||||
if(other instanceof And){
|
||||
|
||||
for (const selfTag of this.and) {
|
||||
let matchFound = false;
|
||||
for (let i = 0; i < other.and.length && !matchFound; i++){
|
||||
let otherTag = other.and[i];
|
||||
matchFound = selfTag.isEquivalent(otherTag);
|
||||
}
|
||||
if(!matchFound){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue