Filter duplicate ids from new ways, #564

This commit is contained in:
pietervdvn 2022-02-11 02:55:42 +01:00
parent 32ae6957e7
commit 31205f3430
2 changed files with 16 additions and 2 deletions

View file

@ -26,7 +26,22 @@ export default class CreateNewWayAction extends OsmCreateAction {
theme: string
}) {
super(null, true)
this.coordinates = coordinates;
this.coordinates = [];
for (const coordinate of coordinates) {
/* The 'PointReuseAction' is a bit buggy and might generate duplicate ids.
We filter those here, as the CreateWayWithPointReuseAction delegates the actual creation to here.
Filtering here also prevents similar bugs in other actions
*/
if(this.coordinates.length > 0 && this.coordinates[this.coordinates.length - 1].nodeId === coordinate.nodeId){
// This is a duplicate id
console.warn("Skipping a node in createWay to avoid a duplicate node:", coordinate,"\nThe previous coordinates are: ", this.coordinates)
continue
}
this.coordinates.push(coordinate)
}
this.tags = tags;
this._options = options;
}

View file

@ -210,7 +210,6 @@ export default class AutoApplyButton implements SpecialVisualization {
// Very ugly hack: read the value every 500ms
UIEventSource.Chronic(500, () => to_parse.data === undefined).addCallback(() => {
const applicable = tagSource.data[argument[1]]
console.log("Current applicable value is: ", applicable)
to_parse.setData(applicable)
})