From 6a3a0251d060ee69cc070ca1fa12ae01d2969c60 Mon Sep 17 00:00:00 2001 From: J Guthrie Date: Tue, 22 Jan 2019 14:29:45 +0000 Subject: [PATCH] Fix bug where end nodes being on top of each other gave false positive --- modules/actions/join.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/actions/join.js b/modules/actions/join.js index ec7da47cd..e48f10b4c 100644 --- a/modules/actions/join.js +++ b/modules/actions/join.js @@ -1,9 +1,10 @@ import _extend from 'lodash-es/extend'; import _groupBy from 'lodash-es/groupBy'; +import _intersection from 'lodash-es/intersection'; import { actionDeleteWay } from './delete_way'; import { osmIsInterestingTag, osmJoinWays } from '../osm'; -import { geoPathHasIntersections } from '../geo'; +import { geoPathIntersections } from '../geo'; // Join ways at the end node they share. @@ -81,7 +82,14 @@ export function actionJoin(ids) { var path2 = graph.childNodes(graph.entity(ids[1])).map(function(e) { return e.loc; }); - if (geoPathHasIntersections(path1, path2)) return 'paths_intersect'; + var intersections = geoPathIntersections(path1, path2); + + // Check if intersections are just nodes lying on top of each other/the line, + // as opposed to crossing it + if (_intersection( + joined[0].nodes.map(function(n) { return n.loc.toString(); }), + intersections.map(function(n) { return n.toString(); }) + ).length != intersections.length) return 'paths_intersect'; } }