Merge pull request #8708 from k-yle/keep-oldest-feature-in-merge

keep the oldest Way when merging
This commit is contained in:
Milos Brzakovic
2021-10-13 12:10:29 +02:00
committed by GitHub
2 changed files with 32 additions and 7 deletions
+9 -7
View File
@@ -27,7 +27,6 @@ export function actionJoin(ids) {
var action = function(graph) {
var ways = ids.map(graph.entity, graph);
var survivorID = ways[0].id;
// if any of the ways are sided (e.g. coastline, cliff, kerb)
// sort them first so they establish the overall order - #6033
@@ -40,12 +39,15 @@ export function actionJoin(ids) {
});
// Prefer to keep an existing way.
for (var i = 0; i < ways.length; i++) {
if (!ways[i].isNew()) {
survivorID = ways[i].id;
break;
}
}
// if there are mulitple existing ways, keep the oldest one
// the oldest way is determined by the ID of the way
const survivorID = (
ways
.filter((way) => !way.isNew())
.sort((a, b) => +a.osmId() - +b.osmId())[0] || ways[0]
).id;
var sequences = osmJoinWays(ways, graph);
var joined = sequences[0];