From 32dff8b9e202cff936745135df84cc44345f01b2 Mon Sep 17 00:00:00 2001 From: Dima-1 Date: Thu, 22 Apr 2021 13:02:16 +0300 Subject: [PATCH] Fix #11362 name of underground station --- .../controllers/TransportStopController.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java index 2337031400..5a7ac0d665 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/controllers/TransportStopController.java @@ -189,7 +189,24 @@ public class TransportStopController extends MenuController { } } - private static void sortTransportStops(@NonNull LatLon latLon, List transportStops) { + private static void sortTransportStopsExits(@NonNull LatLon latLon, @NonNull List transportStops) { + for (TransportStop transportStop : transportStops) { + for (TransportStopExit exit : transportStop.getExits()) { + int distance = (int) MapUtils.getDistance(latLon, exit.getLocation()); + if (transportStop.distance > distance) { + transportStop.distance = distance; + } + } + } + Collections.sort(transportStops, new Comparator() { + @Override + public int compare(TransportStop s1, TransportStop s2) { + return Algorithms.compare(s1.distance, s2.distance); + } + }); + } + + private static void sortTransportStops(@NonNull LatLon latLon, @NonNull List transportStops) { for (TransportStop transportStop : transportStops) { transportStop.distance = (int) MapUtils.getDistance(latLon, transportStop.getLocation()); } @@ -227,6 +244,8 @@ public class TransportStopController extends MenuController { if (isSubwayEntrance) { stopAggregated = processTransportStopsForAmenity(transportStops, amenity); + sortTransportStopsExits(loc, stopAggregated.getLocalTransportStops()); + sortTransportStopsExits(loc, stopAggregated.getNearbyTransportStops()); } else { stopAggregated = new TransportStopAggregated(); stopAggregated.setAmenity(amenity);