This issue occurs because both the calculated navigation route and the planned route are being displayed simultaneously on the map, leading to visual confusion. To fix this, the OsmAnd-iOS app needs to clearly differentiate between the two routes or ensure that only one is displayed at a time, depending on the user's current activity.
Based on the available files, here's a breakdown of the potential areas to address and how they might be fixed:
1. Route Display Logic:
-
OARouteLayer.h: This class is responsible for drawing the route lines on the map. The fix likely involves modifying this class to handle different route types (navigation vs. planned) and display them accordingly. For example, different colors or line styles could be used. It's crucial to ensure that the refreshRoute method updates the display to reflect the current active route and hide or visually distinguish the inactive one. Setting preview route line info setPreviewRouteLineInfo should affect planned route, while refreshRoute should affect navigation route
-
OAMapViewController.h: This class manages the map view and its layers. The fix might involve changes in how the OARouteLayer is managed or updated when the user switches between navigation and route planning modes. Specifically, consider these points:
- The
kNotificationMapGestureAction and kNotificationLayersConfigurationChanged notifications might trigger updates that cause both routes to appear. Investigate these notifications.
- The methods related to showing temporary GPX tracks (
showTempGpxTrack, hideTempGpxTrack, showTempGpxTrackFromGpxFile) may be interfering with the display of the navigation route. Ensure that these methods properly manage the OARouteLayer to avoid conflicts.
- The
refreshMap method should be checked to ensure it correctly updates the route display based on the current mode.
2. Route Calculation and Management:
-
OARoutingHelper.h: This class manages the route calculation and provides access to the current route. The fix could involve changes to the setRoute method, ensuring that it properly clears or updates the OARouteLayer when a new route is calculated. Also, the clearCurrentRoute method needs review.
- The
isRoutePlanningMode and isFollowingMode flags should be used to determine which route should be displayed.
- The
newRouteCalculated method should ensure proper UI update of OARouteLayer
-
OARouteCalculationResult.h: This class holds the result of a route calculation. There's nothing to directly change here, but it's important that the route information is correctly passed from this object to the OARouteLayer for display.
-
OARouteProvider.h: This class performs the actual route calculation. No changes are likely needed here unless the issue involves how the route data is structured or passed to the OARoutingHelper.
3. Route Planning UI:
OARoutePlanningHudViewController.h: This class manages the UI for route planning. The fix may require modifying this class to communicate with the OARoutingHelper to ensure that the navigation route is hidden or visually distinguished when the route planning UI is active. The cancelModes method might be relevant here for clearing the planning route when navigation starts.
Specific Steps to Investigate and Implement:
-
Identify the Active Route: The code needs a clear way to determine whether the user is currently following a calculated navigation route or planning a new route. The isFollowingMode and isRoutePlanningMode flags in OARoutingHelper are crucial for this.
-
Modify OARouteLayer:
- Add properties to distinguish between navigation and planned routes (e.g., an enum or boolean flag).
- Modify the
refreshRoute method to check the active route type and display the route accordingly. Use different colors, line styles, or visibility settings.
-
Update OARoutingHelper:
- In the
setRoute method, when a new navigation route is calculated, ensure that the OARouteLayer is updated to display the new route and hide or visually distinguish any existing planned route.
- In
clearCurrentRoute, make sure the map is updated correctly
-
Update OARoutePlanningHudViewController:
- When the route planning UI is opened, signal the
OARoutingHelper to update the OARouteLayer to display the planned route (if any) and hide or visually distinguish the navigation route.
- When the route planning UI is closed (e.g., when navigation is started), signal the
OARoutingHelper to revert the OARouteLayer to display the navigation route.
-
Code Example (Illustrative - may require adjustments):
4. Testing:
- Thoroughly test the fix by calculating a navigation route, then opening the route planning UI and creating a planned route. Ensure that only the planned route is displayed.
- Start navigation along the calculated route, and ensure that the planned route is hidden and the navigation route is displayed.
By carefully analyzing the interaction between the OARouteLayer, OARoutingHelper, and OARoutePlanningHudViewController, and by implementing the necessary changes to manage the route display based on the active mode, the "calculated route is mixed with the planned route" issue can be resolved. Remember to use different visual cues for the planned and calculated routes.