From 34a235afe0eefe514057d06bfb140e19a6322c17 Mon Sep 17 00:00:00 2001 From: marecabo <23156476+marecabo@users.noreply.github.com> Date: Sat, 20 Apr 2024 13:06:43 +0200 Subject: [PATCH] Adjust NetworkTools.findClosestLinksSorted and deprecate it --- src/main/java/org/matsim/pt2matsim/tools/NetworkTools.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/matsim/pt2matsim/tools/NetworkTools.java b/src/main/java/org/matsim/pt2matsim/tools/NetworkTools.java index 362a9d2a..a4c1a7df 100644 --- a/src/main/java/org/matsim/pt2matsim/tools/NetworkTools.java +++ b/src/main/java/org/matsim/pt2matsim/tools/NetworkTools.java @@ -182,7 +182,10 @@ public static Map> findClosestLinks(Network network, Coord coo * For opposite links, the link which has the coordinate on its right side is sorted "closer" to the coordinate. * If more than two links have the exact same distance, links are sorted by distance to their respective closest node. * After that, behaviour is undefined. + * + * @deprecated See https://github.com/matsim-org/pt2matsim/issues/199 */ + @Deprecated(since = "23.10-SNAPSHOT") public static List findClosestLinksSorted(Network network, Coord coord, double nodeSearchRadius, Set allowedTransportModes) { List links = new ArrayList<>(); Map> sortedLinks = findClosestLinks(network, coord, nodeSearchRadius, allowedTransportModes); @@ -203,7 +206,7 @@ public static List findClosestLinksSorted(Network network, Coord coord, do Map tmp = new HashMap<>(); for(Link l : list) { double fromNodeDist = CoordUtils.calcEuclideanDistance(l.getFromNode().getCoord(), coord); - double toNodeDist = CoordUtils.calcEuclideanDistance(l.getFromNode().getCoord(), coord); + double toNodeDist = CoordUtils.calcEuclideanDistance(l.getToNode().getCoord(), coord); double nodeDist = fromNodeDist < toNodeDist ? fromNodeDist : toNodeDist; double d = nodeDist + (coordIsOnRightSideOfLink(coord, l) ? 1 : 100);