mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 21:48:20 +02:00
Fix bug causing improper calc of from/via/to metadata after trimming
This is the part of the algorithm where trivial sections get trimmed from the vgraph. Removing a vertex from `vertexIds` means "stop checking this one". But there were some situations where it could get removed twice, so we now just verify that `vertexId` is actually in the array before calling `splice`.
This commit is contained in:
@@ -263,14 +263,18 @@ export function osmIntersection(graph, startVertexId) {
|
||||
vertex = vgraph.hasEntity(vertexId);
|
||||
|
||||
if (!vertex) {
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
if (vertexIds.indexOf(vertexId) !== -1) {
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
}
|
||||
removeVertexIds.push(vertexId);
|
||||
continue;
|
||||
}
|
||||
|
||||
parents = vgraph.parentWays(vertex);
|
||||
if (parents.length < 3) {
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
if (vertexIds.indexOf(vertexId) !== -1) {
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
}
|
||||
}
|
||||
|
||||
if (parents.length === 2) { // vertex with 2 parents is trivial
|
||||
@@ -299,7 +303,9 @@ export function osmIntersection(graph, startVertexId) {
|
||||
parents = vgraph.parentWays(vertex);
|
||||
|
||||
if (parents.length < 2) { // vertex is no longer a key vertex
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
if (vertexIds.indexOf(vertexId) !== -1) {
|
||||
vertexIds.splice(vertexIds.indexOf(vertexId), 1); // stop checking this one
|
||||
}
|
||||
removeVertexIds.push(vertexId);
|
||||
keepGoing = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user