mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-25 15:23:52 +00:00
[routing] Make 'auto reordering of intermediate stops' optional
Signed-off-by: Gonzalo Pesquero <gpesquero@yahoo.es>
This commit is contained in:
committed by
Konstantin Pastbin
parent
8b096035df
commit
5bb2569e76
@@ -230,15 +230,21 @@ public class Framework
|
||||
public static native void nativeShowCountry(String countryId, boolean zoomToDownloadButton);
|
||||
|
||||
public static void addRoutePoint(RouteMarkData point)
|
||||
{
|
||||
addRoutePoint(point, true);
|
||||
}
|
||||
|
||||
public static void addRoutePoint(RouteMarkData point, boolean reorderIntermediatePoints)
|
||||
{
|
||||
Framework.nativeAddRoutePoint(point.mTitle, point.mSubtitle, point.mPointType,
|
||||
point.mIntermediateIndex, point.mIsMyPosition,
|
||||
point.mLat, point.mLon);
|
||||
point.mLat, point.mLon, reorderIntermediatePoints);
|
||||
}
|
||||
|
||||
public static native void nativeAddRoutePoint(String title, String subtitle, @NonNull RouteMarkType markType,
|
||||
int intermediateIndex, boolean isMyPosition,
|
||||
double lat, double lon);
|
||||
double lat, double lon,
|
||||
boolean reorderIntermediatePoints);
|
||||
|
||||
public static native void nativeRemoveRoutePoints();
|
||||
|
||||
|
||||
@@ -141,42 +141,9 @@ public class ManageRouteBottomSheet extends BottomSheetDialogFragment
|
||||
// Secondly, add the starting point.
|
||||
Framework.addRoutePoint(newRoutePoints.get(0));
|
||||
|
||||
// And then, add all intermediate points.
|
||||
// And then, add all intermediate points (with no reordering).
|
||||
for (int pos = 1; pos < newRoutePoints.size() - 1; pos++)
|
||||
Framework.addRoutePoint(newRoutePoints.get(pos));
|
||||
|
||||
// Intermediate route points are added sorted by distance.
|
||||
// We have to make sure that they follow the requested order.
|
||||
RouteMarkData[] finalRoutePoints = Framework.nativeGetRoutePoints();
|
||||
|
||||
for (int first = 1; first < newRoutePoints.size() - 1; first++)
|
||||
{
|
||||
int secondIndex = -1;
|
||||
|
||||
for (int second = first; second < newRoutePoints.size() - 1; second++)
|
||||
{
|
||||
if (finalRoutePoints[first].equals(newRoutePoints.get(second)))
|
||||
{
|
||||
secondIndex = second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (secondIndex < 0)
|
||||
{
|
||||
// Something went bad. Intermediate point not found in the route points.
|
||||
break;
|
||||
}
|
||||
|
||||
if (first != secondIndex)
|
||||
{
|
||||
// Intermediate point needs to be moved.
|
||||
Framework.nativeMoveRoutePoint(secondIndex, first);
|
||||
|
||||
// Refresh final route points.
|
||||
finalRoutePoints = Framework.nativeGetRoutePoints();
|
||||
}
|
||||
}
|
||||
Framework.addRoutePoint(newRoutePoints.get(pos), false);
|
||||
|
||||
// Launch route planning.
|
||||
RoutingController.get().launchPlanning();
|
||||
|
||||
@@ -778,7 +778,8 @@ public class RoutingController
|
||||
Framework.nativeAddRoutePoint(description.first /* title */, description.second /* subtitle */,
|
||||
type, 0 /* intermediateIndex */,
|
||||
point.isMyPosition(),
|
||||
point.getLat(), point.getLon());
|
||||
point.getLat(), point.getLon(),
|
||||
true /* reorderIntermediatePoints */);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
Reference in New Issue
Block a user