forked from MapComplete/MapComplete
Further work on GRB, bugfixes
This commit is contained in:
parent
4e4e64ce13
commit
89004af7f9
16 changed files with 456 additions and 102 deletions
|
@ -58,6 +58,7 @@ export default class FeaturePipeline {
|
|||
private readonly osmSourceZoomLevel
|
||||
|
||||
private readonly localStorageSavers = new Map<string, SaveTileToLocalStorageActor>()
|
||||
private readonly metataggingRecalculated = new UIEventSource<void>(undefined)
|
||||
|
||||
constructor(
|
||||
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
||||
|
@ -95,11 +96,13 @@ export default class FeaturePipeline {
|
|||
const perLayerHierarchy = new Map<string, TileHierarchyMerger>()
|
||||
this.perLayerHierarchy = perLayerHierarchy
|
||||
|
||||
// Given a tile, wraps it and passes it on to render (handled by 'handleFeatureSource'
|
||||
function patchedHandleFeatureSource (src: FeatureSourceForLayer & IndexedFeatureSource & Tiled) {
|
||||
// This will already contain the merged features for this tile. In other words, this will only be triggered once for every tile
|
||||
const srcFiltered =
|
||||
new FilteringFeatureSource(state, src.tileIndex,
|
||||
new ChangeGeometryApplicator(src, state.changes)
|
||||
new ChangeGeometryApplicator(src, state.changes),
|
||||
self.metataggingRecalculated
|
||||
)
|
||||
|
||||
handleFeatureSource(srcFiltered)
|
||||
|
@ -472,6 +475,7 @@ export default class FeaturePipeline {
|
|||
self.applyMetaTags(tile)
|
||||
})
|
||||
})
|
||||
self.metataggingRecalculated.ping()
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,8 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti
|
|||
allElements: ElementStorage
|
||||
},
|
||||
tileIndex,
|
||||
upstream: FeatureSourceForLayer
|
||||
upstream: FeatureSourceForLayer,
|
||||
metataggingUpdated: UIEventSource<any>
|
||||
) {
|
||||
this.name = "FilteringFeatureSource(" + upstream.name + ")"
|
||||
this.tileIndex = tileIndex
|
||||
|
@ -53,11 +54,15 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti
|
|||
self.update()
|
||||
}
|
||||
})
|
||||
|
||||
metataggingUpdated.addCallback(_ => {
|
||||
self._is_dirty.setData(true)
|
||||
})
|
||||
|
||||
this.update();
|
||||
}
|
||||
|
||||
public update() {
|
||||
private update() {
|
||||
const self = this;
|
||||
const layer = this.upstream.layer;
|
||||
const features: { feature: any; freshness: Date }[] = this.upstream.features.data;
|
||||
|
@ -106,13 +111,11 @@ export default class FilteringFeatureSource implements FeatureSourceForLayer, Ti
|
|||
return
|
||||
}
|
||||
this._alreadyRegistered.add(src)
|
||||
if (layer.isShown !== undefined) {
|
||||
|
||||
const self = this;
|
||||
src.map(tags => layer.isShown?.GetRenderValue(tags, "yes").txt).addCallbackAndRunD(isShown => {
|
||||
src.addCallbackAndRunD(isShown => {
|
||||
self._is_dirty.setData(true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ export class GeoOperations {
|
|||
continue;
|
||||
}
|
||||
|
||||
const intersection = this.calculateInstersection(feature, otherFeature, featureBBox)
|
||||
const intersection = GeoOperations.calculateInstersection(feature, otherFeature, featureBBox)
|
||||
if (intersection === null) {
|
||||
continue
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ export class GeoOperations {
|
|||
* Returns 0 if both are linestrings
|
||||
* Returns null if the features are not intersecting
|
||||
*/
|
||||
private static calculateInstersection(feature, otherFeature, featureBBox: BBox, otherFeatureBBox?: BBox): number {
|
||||
static calculateInstersection(feature, otherFeature, featureBBox: BBox, otherFeatureBBox?: BBox): number {
|
||||
try {
|
||||
if (feature.geometry.type === "LineString") {
|
||||
|
||||
|
@ -433,7 +433,7 @@ export class GeoOperations {
|
|||
}
|
||||
|
||||
} catch (exception) {
|
||||
console.warn("EXCEPTION CAUGHT WHILE INTERSECTING: ", exception);
|
||||
console.warn("EXCEPTION CAUGHT WHILE INTERSECTING: ", exception,"\nThe considered objects are",feature, otherFeature);
|
||||
return undefined
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
@ -291,6 +291,10 @@ export default class CreateWayWithPointReuseAction extends OsmChangeAction {
|
|||
if (other.closebyNodes === undefined || other.closebyNodes[0] === undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
if(coorInfo.closebyNodes[0] === undefined){
|
||||
continue
|
||||
}
|
||||
|
||||
if (other.closebyNodes[0].node === coorInfo.closebyNodes[0].node) {
|
||||
conflictFree = false
|
||||
|
|
|
@ -12,13 +12,14 @@ import {TagsFilter} from "./TagsFilter";
|
|||
export default class SubstitutingTag implements TagsFilter {
|
||||
private readonly _key: string;
|
||||
private readonly _value: string;
|
||||
|
||||
constructor(key: string, value: string) {
|
||||
private readonly _invert: boolean
|
||||
constructor(key: string, value: string, invert = false) {
|
||||
this._key = key;
|
||||
this._value = value;
|
||||
this._invert = invert
|
||||
}
|
||||
|
||||
public static substituteString(template: string, dict: any): string {
|
||||
private static substituteString(template: string, dict: any): string {
|
||||
for (const k in dict) {
|
||||
template = template.replace(new RegExp("\\{" + k + "\\}", 'g'), dict[k])
|
||||
}
|
||||
|
@ -26,7 +27,7 @@ export default class SubstitutingTag implements TagsFilter {
|
|||
}
|
||||
|
||||
asHumanString(linkToWiki: boolean, shorten: boolean, properties) {
|
||||
return this._key + "=" + SubstitutingTag.substituteString(this._value, properties);
|
||||
return this._key + (this._invert ? '!' : '') + "=" + SubstitutingTag.substituteString(this._value, properties);
|
||||
}
|
||||
|
||||
asOverpass(): string[] {
|
||||
|
@ -37,11 +38,11 @@ export default class SubstitutingTag implements TagsFilter {
|
|||
if (!(other instanceof SubstitutingTag)) {
|
||||
return false;
|
||||
}
|
||||
return other._key === this._key && other._value === this._value;
|
||||
return other._key === this._key && other._value === this._value && other._invert === this._invert;
|
||||
}
|
||||
|
||||
isUsableAsAnswer(): boolean {
|
||||
return true;
|
||||
return !this._invert;
|
||||
}
|
||||
|
||||
matchesProperties(properties: any): boolean {
|
||||
|
@ -50,7 +51,7 @@ export default class SubstitutingTag implements TagsFilter {
|
|||
return false;
|
||||
}
|
||||
const expectedValue = SubstitutingTag.substituteString(this._value, properties);
|
||||
return value === expectedValue;
|
||||
return (value === expectedValue) !== this._invert;
|
||||
}
|
||||
|
||||
usedKeys(): string[] {
|
||||
|
@ -58,6 +59,7 @@ export default class SubstitutingTag implements TagsFilter {
|
|||
}
|
||||
|
||||
asChange(properties: any): { k: string; v: string }[] {
|
||||
if(this._invert){throw "An inverted substituting tag can not be used to create a change"}
|
||||
const v = SubstitutingTag.substituteString(this._value, properties);
|
||||
if (v.match(/{.*}/) !== null) {
|
||||
throw "Could not calculate all the substitutions: still have " + v
|
||||
|
|
|
@ -226,6 +226,10 @@ export class TagUtils {
|
|||
new RegExp("^" + split[1] + "$")
|
||||
);
|
||||
}
|
||||
if (tag.indexOf("!:=") >= 0) {
|
||||
const split = Utils.SplitFirst(tag, "!:=");
|
||||
return new SubstitutingTag(split[0], split[1], true);
|
||||
}
|
||||
if (tag.indexOf(":=") >= 0) {
|
||||
const split = Utils.SplitFirst(tag, ":=");
|
||||
return new SubstitutingTag(split[0], split[1]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue