diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 69c159bed0..10a8c2ae84 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -30,7 +30,7 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.track.GpxSplitType; import net.osmand.util.Algorithms; @@ -928,7 +928,7 @@ public class GpxSelectionHelper { } public boolean isFollowTrack(OsmandApplication app) { - RouteProvider.GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute(); if (routeParams != null) { return gpxFile.path.equals(routeParams.getFile().path); } diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java index 0b2683fcc6..1ecda23e78 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationSimulation.java @@ -18,7 +18,7 @@ import net.osmand.GPXUtilities; import net.osmand.Location; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.helpers.GpxUiHelper; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import java.util.ArrayList; diff --git a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java index 472899862b..bd77ebf33b 100644 --- a/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java +++ b/OsmAnd/src/net/osmand/plus/TargetPointsHelper.java @@ -10,7 +10,7 @@ import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; import net.osmand.data.PointDescription; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.settings.backend.ApplicationMode; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 2bb6f5caec..e2bec6f7b5 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -69,7 +69,7 @@ import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.WaypointsFragment; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java index 46708ce5ae..26fe55e1e8 100644 --- a/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java +++ b/OsmAnd/src/net/osmand/plus/base/FailSafeFuntions.java @@ -18,7 +18,7 @@ import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.activities.MapActivity; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java index 005433cbe2..897de79b6c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/other/RoutePreferencesMenu.java @@ -36,7 +36,7 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingPar import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.VoiceGuidanceRoutingParameter; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; @@ -373,13 +373,13 @@ public class RoutePreferencesMenu { } private void updateSpinnerItems(final TextView gpxSpinner) { - RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); gpxSpinner.setText(rp == null ? mapActivity.getString(R.string.shared_string_none) : new File(rp.getFile().path).getName()); } private void showOptionsMenu(final TextView gpxSpinner) { - RouteProvider.GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder rp = mapActivity.getRoutingHelper().getCurrentGPXRoute(); final PopupMenu optionsMenu = new PopupMenu(gpxSpinner.getContext(), gpxSpinner); MenuItem item = optionsMenu.getMenu().add( mapActivity.getString(R.string.shared_string_none)); diff --git a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java index bf6ee212dc..e654dc33b2 100644 --- a/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java +++ b/OsmAnd/src/net/osmand/plus/measurementtool/MeasurementToolFragment.java @@ -2073,7 +2073,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route private void startTrackNavigation() { MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { - if (editingCtx.hasRoute()) { + if (editingCtx.hasRoute() || editingCtx.hasChanges()) { String trackName = getSuggestedFileName(); GPXFile gpx = editingCtx.exportGpx(trackName); if (gpx != null) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java index 89afe180e2..e75efb2c25 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/ChooseRouteFragment.java @@ -58,7 +58,7 @@ import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.CumulativeInfo; import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.RouteDetailsFragmentListener; import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard; import net.osmand.plus.routing.RouteDirectionInfo; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java index 93b26b82a4..b5abb80b65 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/FollowTrackFragment.java @@ -58,8 +58,8 @@ import net.osmand.plus.routepreparationmenu.cards.SelectTrackCard; import net.osmand.plus.routepreparationmenu.cards.TrackEditCard; import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard; import net.osmand.plus.routing.IRouteInformationListener; -import net.osmand.plus.routing.RouteProvider; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.track.TrackSelectSegmentBottomSheet; @@ -224,7 +224,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca RoutingHelper routingHelper = app.getRoutingHelper(); GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute(); - boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = mode.getRouteService() == RouteService.OSMAND; if (rparams != null && osmandRouter) { cardsContainer.addView(buildDividerView(cardsContainer, false)); diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java index f88f499125..2475d70f34 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/MapRouteInfoMenu.java @@ -100,7 +100,7 @@ import net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard; import net.osmand.plus.routepreparationmenu.cards.TracksCard; import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.RouteCalculationResult; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.routing.TransportRoutingHelper; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java index 8ba86dfe35..4275be99a6 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RouteOptionsBottomSheet.java @@ -46,7 +46,8 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRo import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; @@ -501,7 +502,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { } private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) { - RouteProvider.GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute(); String description = null; int descriptionColorId; if (routeParamsBuilder == null) { @@ -661,11 +662,11 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment { private List getRoutingParameters(ApplicationMode applicationMode) { List routingParameters; - boolean osmandRouter = applicationMode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = applicationMode.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { - if (applicationMode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + if (applicationMode.getRouteService() == RouteService.STRAIGHT) { routingParameters = AppModeOptions.STRAIGHT.routingParameters; - } else if (applicationMode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { + } else if (applicationMode.getRouteService() == RouteService.DIRECT_TO) { routingParameters = AppModeOptions.DIRECT_TO.routingParameters; } else { routingParameters = AppModeOptions.OTHER.routingParameters; diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java index 72e985c353..d03973a796 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/RoutingOptionsHelper.java @@ -37,9 +37,8 @@ import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.routing.RouteProvider; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.voice.JSMediaCommandPlayerImpl; @@ -243,24 +242,25 @@ public class RoutingOptionsHelper { TargetPointsHelper tg = app.getTargetPointsHelper(); List ps = rp.getPoints(app); if (ps.size() > 0) { + TargetPoint pointToStart = tg.getPointToStart(); + TargetPoint pointToNavigate = tg.getPointToNavigate(); if (rp.getFile().hasRoute()) { tg.clearStartPoint(false); Location finishLoc = ps.get(ps.size() - 1); - TargetPoint pn = tg.getPointToNavigate(); - tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1, pn != null ? pn.getOriginalPointDescription() : null); + tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), + false, -1, pointToNavigate != null ? pointToNavigate.getOriginalPointDescription() : null); tg.updateRouteAndRefresh(true); } else { Location first = ps.get(0); Location end = ps.get(ps.size() - 1); - TargetPoint pn = tg.getPointToNavigate(); boolean update = false; - if (pn == null - || MapUtils.getDistance(pn.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) { + if (pointToNavigate == null + || MapUtils.getDistance(pointToNavigate.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) { tg.navigateToPoint(new LatLon(end.getLatitude(), end.getLongitude()), false, -1); update = true; } - if (tg.getPointToStart() == null - || MapUtils.getDistance(tg.getPointToStart().point, + if (pointToStart == null + || MapUtils.getDistance(pointToStart.point, new LatLon(end.getLatitude(), end.getLongitude())) < 10) { tg.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), false, null); update = true; @@ -490,7 +490,7 @@ public class RoutingOptionsHelper { } public List getRoutingParametersInner(ApplicationMode am) { - boolean osmandRouter = am.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = am.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { return getOsmandRouterParameters(am); } @@ -1061,7 +1061,7 @@ public class RoutingOptionsHelper { private List getRoutingParametersForProfileType(ApplicationMode appMode) { if (appMode != null) { - boolean osmandRouter = appMode.getRouteService() == RouteProvider.RouteService.OSMAND; + boolean osmandRouter = appMode.getRouteService() == RouteService.OSMAND; if (!osmandRouter) { return PermanentAppModeOptions.OTHER.routingParameters; } else if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) { diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java index 646e2da386..e924b46aba 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/TrackEditCard.java @@ -20,7 +20,7 @@ import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.TrackSelectSegmentAdapter; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.util.Algorithms; import java.io.File; diff --git a/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java b/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java new file mode 100644 index 0000000000..f62c686d3c --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/GPXRouteParams.java @@ -0,0 +1,221 @@ +package net.osmand.plus.routing; + +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.Route; +import net.osmand.GPXUtilities.TrkSegment; +import net.osmand.GPXUtilities.WptPt; +import net.osmand.Location; +import net.osmand.PlatformUtil; +import net.osmand.data.LatLon; +import net.osmand.data.LocationPoint; +import net.osmand.data.WptLocationPoint; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.R; +import net.osmand.plus.settings.backend.OsmandSettings; +import net.osmand.router.RouteSegmentResult; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import static net.osmand.router.RouteExporter.OSMAND_ROUTER_V2; + +public class GPXRouteParams { + + private static final String OSMAND_ROUTER = "OsmAndRouter"; + + protected List wpt; + protected List route; + protected List directions; + protected List points = new ArrayList<>(); + protected List routePoints = new ArrayList<>(); + protected boolean reverse; + protected boolean passWholeRoute; + protected boolean calculateOsmAndRoute; + protected boolean useIntermediatePointsRTE; + protected boolean calculateOsmAndRouteParts; + + boolean addMissingTurns = true; + + public List getPoints() { + return points; + } + + public List getWpt() { + return wpt; + } + + public Location getStartPointForRoute() { + if (!points.isEmpty()) { + return points.get(0); + } + return null; + } + + public Location getEndPointForRoute() { + if (!points.isEmpty()) { + return points.get(points.size()); + } + return null; + } + + public LatLon getLastPoint() { + if (!points.isEmpty()) { + Location l = points.get(points.size() - 1); + return new LatLon(l.getLatitude(), l.getLongitude()); + } + return null; + } + + public GPXRouteParams prepareGPXFile(GPXRouteParamsBuilder builder) { + GPXFile file = builder.file; + reverse = builder.reverse; + passWholeRoute = builder.passWholeRoute; + calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts; + useIntermediatePointsRTE = builder.isUseIntermediatePointsRTE(); + builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute; + if (!file.isPointsEmpty()) { + wpt = new ArrayList(file.getPoints().size()); + for (WptPt w : file.getPoints()) { + wpt.add(new WptLocationPoint(w)); + } + } + int selectedSegment = builder.getSelectedSegment(); + if (OSMAND_ROUTER_V2.equals(file.author)) { + route = RouteProvider.parseOsmAndGPXRoute(points, file, selectedSegment); + if (selectedSegment == -1) { + routePoints = file.getRoutePoints(); + } else { + routePoints = file.getRoutePoints(selectedSegment); + } + if (reverse) { + Collections.reverse(points); + Collections.reverse(routePoints); + } + addMissingTurns = route != null && route.isEmpty(); + } else if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) { + directions = RouteProvider.parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10, selectedSegment); + if (OSMAND_ROUTER.equals(file.author) && file.hasRtePt()) { + // For files generated by OSMAND_ROUTER use directions contained unaltered + addMissingTurns = false; + } + if (reverse) { + // clear directions all turns should be recalculated + directions = null; + Collections.reverse(points); + addMissingTurns = true; + } + } else { + // first of all check tracks + if (!useIntermediatePointsRTE) { + List segments = file.getNonEmptyTrkSegments(false); + if (selectedSegment != -1 && segments.size() > selectedSegment) { + TrkSegment segment = segments.get(selectedSegment); + for (WptPt p : segment.points) { + points.add(RouteProvider.createLocation(p)); + } + } else { + for (TrkSegment tkSeg : segments) { + for (WptPt p : tkSeg.points) { + points.add(RouteProvider.createLocation(p)); + } + } + } + } + if (points.isEmpty()) { + for (Route rte : file.routes) { + for (WptPt pt : rte.points) { + points.add(RouteProvider.createLocation(pt)); + } + } + } + if (reverse) { + Collections.reverse(points); + } + } + return this; + } + + public static class GPXRouteParamsBuilder { + + private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(GPXRouteParamsBuilder.class); + + boolean calculateOsmAndRoute = false; + // parameters + private final GPXFile file; + private boolean reverse; + private boolean leftSide; + private boolean passWholeRoute; + private boolean calculateOsmAndRouteParts; + private int selectedSegment = -1; + + public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings) { + leftSide = settings.DRIVING_REGION.get().leftHandDriving; + this.file = file; + } + + public boolean isReverse() { + return reverse; + } + + public boolean isCalculateOsmAndRouteParts() { + return calculateOsmAndRouteParts; + } + + public void setCalculateOsmAndRouteParts(boolean calculateOsmAndRouteParts) { + this.calculateOsmAndRouteParts = calculateOsmAndRouteParts; + } + + public boolean isUseIntermediatePointsRTE() { + return file.hasRtePt() && !file.hasTrkPt(); + } + + public boolean isCalculateOsmAndRoute() { + return calculateOsmAndRoute; + } + + public void setCalculateOsmAndRoute(boolean calculateOsmAndRoute) { + this.calculateOsmAndRoute = calculateOsmAndRoute; + } + + public int getSelectedSegment() { + return selectedSegment; + } + + public void setSelectedSegment(int selectedSegment) { + this.selectedSegment = selectedSegment; + } + + public void setPassWholeRoute(boolean passWholeRoute) { + this.passWholeRoute = passWholeRoute; + } + + public boolean isPassWholeRoute() { + return passWholeRoute; + } + + public GPXRouteParams build(OsmandApplication app) { + GPXRouteParams res = new GPXRouteParams(); + try { + res.prepareGPXFile(this); + } catch (RuntimeException e) { + log.error(e.getMessage(), e); + app.showShortToastMessage(app.getString(R.string.gpx_parse_error) + " " + e.getMessage()); + } + return res; + } + + public void setReverse(boolean reverse) { + this.reverse = reverse; + } + + public GPXFile getFile() { + return file; + } + + public List getPoints(OsmandApplication app) { + GPXRouteParams copy = build(app); + return copy.getPoints(); + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java b/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java index 65e683a734..ca10de2812 100644 --- a/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java +++ b/OsmAnd/src/net/osmand/plus/routing/GpxApproximator.java @@ -7,7 +7,6 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.routing.RouteProvider.RoutingEnvironment; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RoutePlannerFrontEnd.GpxPoint; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java index 7b38b5c91a..0c4f2a4cb6 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationParams.java @@ -4,7 +4,6 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.OsmandApplication; -import net.osmand.plus.routing.RouteProvider.GPXRouteParams; import net.osmand.router.RouteCalculationProgress; import java.util.List; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java index e6efcc321f..a174c1550c 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteCalculationResult.java @@ -15,7 +15,6 @@ import net.osmand.data.QuadRect; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; -import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.router.ExitInfo; import net.osmand.router.RouteSegmentResult; diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java index 3f0a30c99f..042db089bb 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteProvider.java @@ -1,7 +1,6 @@ package net.osmand.plus.routing; -import android.content.Context; import android.os.Bundle; import android.util.Base64; @@ -16,8 +15,6 @@ import net.osmand.PlatformUtil; import net.osmand.ResultMatcher; import net.osmand.binary.BinaryMapIndexReader; import net.osmand.data.LatLon; -import net.osmand.data.LocationPoint; -import net.osmand.data.WptLocationPoint; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.TargetPointsHelper; @@ -70,279 +67,14 @@ import javax.xml.parsers.ParserConfigurationException; import btools.routingapp.IBRouterService; -import static net.osmand.router.RouteExporter.OSMAND_ROUTER_V2; - public class RouteProvider { + private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(RouteProvider.class); - private static final String OSMAND_ROUTER = "OsmAndRouter"; private static final int MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT = 60; private static final int ADDITIONAL_DISTANCE_FOR_START_POINT = 300; private static final int MIN_STRAIGHT_DIST = 50000; - public enum RouteService { - OSMAND("OsmAnd (offline)"), - BROUTER("BRouter (offline)"), - STRAIGHT("Straight line"), - DIRECT_TO("Direct To"), - ONLINE("Online engine"); - - private final String name; - - RouteService(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public boolean isOnline() { - return this != OSMAND && this != BROUTER; - } - - boolean isAvailable(OsmandApplication ctx) { - if (this == BROUTER) { - return ctx.getBRouterService() != null; - } - return true; - } - - public static RouteService[] getAvailableRouters(OsmandApplication ctx) { - List list = new ArrayList<>(); - for (RouteService r : values()) { - if (r.isAvailable(ctx)) { - list.add(r); - } - } - return list.toArray(new RouteService[0]); - } - } - - public static class RoutingEnvironment { - private RoutePlannerFrontEnd router; - private RoutingContext ctx; - private RoutingContext complexCtx; - private PrecalculatedRouteDirection precalculated; - - public RoutingEnvironment(RoutePlannerFrontEnd router, RoutingContext ctx, RoutingContext complexCtx, PrecalculatedRouteDirection precalculated) { - this.router = router; - this.ctx = ctx; - this.complexCtx = complexCtx; - this.precalculated = precalculated; - } - - public RoutePlannerFrontEnd getRouter() { - return router; - } - - public RoutingContext getCtx() { - return ctx; - } - - public RoutingContext getComplexCtx() { - return complexCtx; - } - - public PrecalculatedRouteDirection getPrecalculated() { - return precalculated; - } - } - - public RouteProvider() { - } - - public static class GPXRouteParamsBuilder { - boolean calculateOsmAndRoute = false; - // parameters - private final GPXFile file; - private boolean reverse; - private boolean leftSide; - private boolean passWholeRoute; - private boolean calculateOsmAndRouteParts; - private int selectedSegment = -1; - - public GPXRouteParamsBuilder(GPXFile file, OsmandSettings settings) { - leftSide = settings.DRIVING_REGION.get().leftHandDriving; - this.file = file; - } - - public boolean isReverse() { - return reverse; - } - - public boolean isCalculateOsmAndRouteParts() { - return calculateOsmAndRouteParts; - } - - public void setCalculateOsmAndRouteParts(boolean calculateOsmAndRouteParts) { - this.calculateOsmAndRouteParts = calculateOsmAndRouteParts; - } - - public boolean isUseIntermediatePointsRTE() { - return file.hasRtePt() && !file.hasTrkPt(); - } - - public boolean isCalculateOsmAndRoute() { - return calculateOsmAndRoute; - } - - public void setCalculateOsmAndRoute(boolean calculateOsmAndRoute) { - this.calculateOsmAndRoute = calculateOsmAndRoute; - } - - public int getSelectedSegment() { - return selectedSegment; - } - - public void setSelectedSegment(int selectedSegment) { - this.selectedSegment = selectedSegment; - } - - public void setPassWholeRoute(boolean passWholeRoute) { - this.passWholeRoute = passWholeRoute; - } - - public boolean isPassWholeRoute() { - return passWholeRoute; - } - - public GPXRouteParams build(OsmandApplication app) { - GPXRouteParams res = new GPXRouteParams(); - try { - res.prepareGPXFile(this); - } catch (RuntimeException e) { - log.error(e.getMessage(), e); - app.showShortToastMessage(app.getString(R.string.gpx_parse_error) + " " + e.getMessage()); - } - return res; - } - - public void setReverse(boolean reverse) { - this.reverse = reverse; - } - - public GPXFile getFile() { - return file; - } - - public List getPoints(OsmandApplication app) { - GPXRouteParams copy = build(app); - return copy.getPoints(); - } - } - - public static class GPXRouteParams { - List points = new ArrayList<>(); - List directions; - List route; - List routePoints = new ArrayList<>(); - boolean reverse; - boolean calculateOsmAndRoute; - boolean passWholeRoute; - boolean calculateOsmAndRouteParts; - boolean useIntermediatePointsRTE; - private List wpt; - - boolean addMissingTurns = true; - - public List getPoints() { - return points; - } - - public Location getStartPointForRoute(){ - if(!points.isEmpty()){ - return points.get(0); - } - return null; - } - - public Location getEndPointForRoute(){ - if(!points.isEmpty()){ - return points.get(points.size()); - } - return null; - } - - public LatLon getLastPoint() { - if(!points.isEmpty()){ - Location l = points.get(points.size() - 1); - LatLon point = new LatLon(l.getLatitude(), l.getLongitude()); - return point; - } - return null; - } - - public GPXRouteParams prepareGPXFile(GPXRouteParamsBuilder builder) { - GPXFile file = builder.file; - reverse = builder.reverse; - passWholeRoute = builder.passWholeRoute; - calculateOsmAndRouteParts = builder.calculateOsmAndRouteParts; - useIntermediatePointsRTE = builder.isUseIntermediatePointsRTE(); - builder.calculateOsmAndRoute = false; // Disabled temporary builder.calculateOsmAndRoute; - if (!file.isPointsEmpty()) { - wpt = new ArrayList(file.getPoints().size()); - for(WptPt w : file.getPoints()) { - wpt.add(new WptLocationPoint(w)); - } - } - int selectedSegment = builder.getSelectedSegment(); - if (OSMAND_ROUTER_V2.equals(file.author)) { - route = parseOsmAndGPXRoute(points, file, selectedSegment); - if (selectedSegment == -1) { - routePoints = file.getRoutePoints(); - } else { - routePoints = file.getRoutePoints(selectedSegment); - } - if (reverse) { - Collections.reverse(points); - Collections.reverse(routePoints); - } - addMissingTurns = route != null && route.isEmpty(); - } else if (file.isCloudmadeRouteFile() || OSMAND_ROUTER.equals(file.author)) { - directions = parseOsmAndGPXRoute(points, file, OSMAND_ROUTER.equals(file.author), builder.leftSide, 10, selectedSegment); - if (OSMAND_ROUTER.equals(file.author) && file.hasRtePt()) { - // For files generated by OSMAND_ROUTER use directions contained unaltered - addMissingTurns = false; - } - if (reverse) { - // clear directions all turns should be recalculated - directions = null; - Collections.reverse(points); - addMissingTurns = true; - } - } else { - // first of all check tracks - if (!useIntermediatePointsRTE) { - List segments = file.getNonEmptyTrkSegments(false); - if (selectedSegment != -1 && segments.size() > selectedSegment) { - TrkSegment segment = segments.get(selectedSegment); - for (WptPt p : segment.points) { - points.add(createLocation(p)); - } - } else { - for (TrkSegment tkSeg : segments) { - for (WptPt p : tkSeg.points) { - points.add(createLocation(p)); - } - } - } - } - if (points.isEmpty()) { - for (Route rte : file.routes) { - for (WptPt pt : rte.points) { - points.add(createLocation(pt)); - } - } - } - if (reverse) { - Collections.reverse(points); - } - } - return this; - } - } - public static Location createLocation(WptPt pt){ Location loc = new Location("OsmandRouteProvider"); loc.setLatitude(pt.lat); @@ -771,13 +503,6 @@ public class RouteProvider { return nearestPointIndex; } - protected String getString(Context ctx, int resId){ - if(ctx == null){ - return ""; //$NON-NLS-1$ - } - return ctx.getString(resId); - } - public RoutingEnvironment getRoutingEnvironment(OsmandApplication ctx, ApplicationMode mode, LatLon start, LatLon end) throws IOException { RouteCalculationParams params = new RouteCalculationParams(); params.ctx = ctx; @@ -788,11 +513,11 @@ public class RouteProvider { } public List generateGpxPoints(RoutingEnvironment env, GpxRouteApproximation gctx, LocationsHolder locationsHolder) { - return env.router.generateGpxPoints(gctx, locationsHolder); + return env.getRouter().generateGpxPoints(gctx, locationsHolder); } public GpxRouteApproximation calculateGpxPointsApproximation(RoutingEnvironment env, GpxRouteApproximation gctx, List points, ResultMatcher resultMatcher) throws IOException, InterruptedException { - return env.router.searchGpxRoute(gctx, points, resultMatcher); + return env.getRouter().searchGpxRoute(gctx, points, resultMatcher); } protected RoutingEnvironment calculateRoutingEnvironment(RouteCalculationParams params, boolean calcGPXRoute, boolean skipComplex) throws IOException { @@ -885,7 +610,7 @@ public class RouteProvider { if (params.intermediates != null) { inters = new ArrayList(params.intermediates); } - return calcOfflineRouteImpl(params, env.router, env.ctx, env.complexCtx, st, en, inters, env.precalculated); + return calcOfflineRouteImpl(params, env.getRouter(), env.getCtx(), env.getComplexCtx(), st, en, inters, env.getPrecalculated()); } private RoutingConfiguration initOsmAndRoutingConfig(Builder config, final RouteCalculationParams params, OsmandSettings settings, @@ -1012,7 +737,7 @@ public class RouteProvider { return new RouteCalculationResult("Empty result"); } - private static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, int selectedSegment) { + protected static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, int selectedSegment) { List segments = gpxFile.getNonEmptyTrkSegments(false); if (selectedSegment != -1 && segments.size() > selectedSegment) { TrkSegment segment = segments.get(selectedSegment); @@ -1032,8 +757,8 @@ public class RouteProvider { } } - private static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, boolean osmandRouter, - boolean leftSide, float defSpeed, int selectedSegment) { + protected static List parseOsmAndGPXRoute(List points, GPXFile gpxFile, boolean osmandRouter, + boolean leftSide, float defSpeed, int selectedSegment) { List directions = null; if (!osmandRouter) { for (WptPt pt : gpxFile.getPoints()) { @@ -1378,6 +1103,4 @@ public class RouteProvider { } return new RouteCalculationResult(segments, computeDirections, params, null, false); } - - -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java index 175003fe18..8fb8201dea 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RouteRecalculationHelper.java @@ -6,6 +6,7 @@ import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.router.RouteCalculationProgress; @@ -179,7 +180,7 @@ class RouteRecalculationHelper { } public void recalculateRouteInBackground(final Location start, final LatLon end, final List intermediates, - final RouteProvider.GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged) { + final GPXRouteParamsBuilder gpxRoute, final RouteCalculationResult previousRoute, boolean paramsChanged, boolean onlyStartPointChanged) { if (start == null || end == null) { return; } @@ -207,7 +208,7 @@ class RouteRecalculationHelper { params.mode = mode; params.ctx = app; boolean updateProgress = false; - if (params.mode.getRouteService() == RouteProvider.RouteService.OSMAND) { + if (params.mode.getRouteService() == RouteService.OSMAND) { params.calculationProgress = new RouteCalculationProgress(); updateProgress = true; } else { diff --git a/OsmAnd/src/net/osmand/plus/routing/RouteService.java b/OsmAnd/src/net/osmand/plus/routing/RouteService.java new file mode 100644 index 0000000000..6565b09106 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RouteService.java @@ -0,0 +1,45 @@ +package net.osmand.plus.routing; + +import net.osmand.plus.OsmandApplication; + +import java.util.ArrayList; +import java.util.List; + +public enum RouteService { + OSMAND("OsmAnd (offline)"), + BROUTER("BRouter (offline)"), + STRAIGHT("Straight line"), + DIRECT_TO("Direct To"), + ONLINE("Online engine"); + + private final String name; + + RouteService(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public boolean isOnline() { + return this != OSMAND && this != BROUTER; + } + + boolean isAvailable(OsmandApplication ctx) { + if (this == BROUTER) { + return ctx.getBRouterService() != null; + } + return true; + } + + public static RouteService[] getAvailableRouters(OsmandApplication ctx) { + List list = new ArrayList<>(); + for (RouteService r : values()) { + if (r.isAvailable(ctx)) { + list.add(r); + } + } + return list.toArray(new RouteService[0]); + } +} diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java b/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java new file mode 100644 index 0000000000..15b484cc67 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingEnvironment.java @@ -0,0 +1,36 @@ +package net.osmand.plus.routing; + +import net.osmand.router.PrecalculatedRouteDirection; +import net.osmand.router.RoutePlannerFrontEnd; +import net.osmand.router.RoutingContext; + +public class RoutingEnvironment { + + private RoutingContext ctx; + private RoutingContext complexCtx; + private RoutePlannerFrontEnd router; + private PrecalculatedRouteDirection precalculated; + + public RoutingEnvironment(RoutePlannerFrontEnd router, RoutingContext ctx, RoutingContext complexCtx, PrecalculatedRouteDirection precalculated) { + this.router = router; + this.ctx = ctx; + this.complexCtx = complexCtx; + this.precalculated = precalculated; + } + + public RoutePlannerFrontEnd getRouter() { + return router; + } + + public RoutingContext getCtx() { + return ctx; + } + + public RoutingContext getComplexCtx() { + return complexCtx; + } + + public PrecalculatedRouteDirection getPrecalculated() { + return precalculated; + } +} diff --git a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java index 1addb2f50a..8ab9405ee1 100644 --- a/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/RoutingHelper.java @@ -20,9 +20,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; -import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; -import net.osmand.plus.routing.RouteProvider.RouteService; -import net.osmand.plus.routing.RouteProvider.RoutingEnvironment; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.settings.backend.OsmandSettings; @@ -670,9 +668,9 @@ public class RoutingHelper { private static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode, float posTolerance) { if (settings.DISABLE_OFFROUTE_RECALC.getModeValue(mode)) { return -1.0f; - } else if (mode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { + } else if (mode.getRouteService() == RouteService.DIRECT_TO) { return -1.0f; - } else if (mode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + } else if (mode.getRouteService() == RouteService.STRAIGHT) { MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode); if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) { return 500.f; diff --git a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java index 08da774f27..637e3078e7 100644 --- a/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java +++ b/OsmAnd/src/net/osmand/plus/routing/TransportRoutingHelper.java @@ -18,7 +18,6 @@ import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.routing.RouteCalculationParams.RouteCalculationResultListener; -import net.osmand.plus.routing.RouteProvider.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.OsmandSettings; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java index 29a50aae4b..8a27935c06 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/ApplicationMode.java @@ -12,7 +12,7 @@ import net.osmand.plus.R; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.util.Algorithms; import org.apache.commons.lang3.StringUtils; diff --git a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java index 44831fa52c..1667c05264 100644 --- a/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/settings/backend/OsmandSettings.java @@ -48,7 +48,7 @@ import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.render.RendererRegistry; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.srtmplugin.TerrainMode; import net.osmand.plus.views.layers.RadiusRulerControlLayer.RadiusRulerMode; import net.osmand.plus.voice.CommandPlayer; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java index 8c45d89def..2e86899ee8 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/NavigationFragment.java @@ -14,14 +14,13 @@ import net.osmand.plus.profiles.ProfileDataObject; import net.osmand.plus.profiles.ProfileDataUtils; import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet; import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; -import net.osmand.plus.routing.RouteProvider.RouteService; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; import net.osmand.plus.profiles.SelectProfileBottomSheet; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; -import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.util.Algorithms; @@ -151,17 +150,17 @@ public class NavigationFragment extends BaseSettingsFragment implements OnSelect navigationType.setIcon(getActiveIcon(selectedRoutingProfileDataObject.getIconRes())); ApplicationMode appMode = getSelectedAppMode(); - RouteProvider.RouteService routeService; + RouteService routeService; if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) { - routeService = RouteProvider.RouteService.STRAIGHT; + routeService = RouteService.STRAIGHT; } else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())) { - routeService = RouteProvider.RouteService.DIRECT_TO; + routeService = RouteService.DIRECT_TO; } else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) { - routeService = RouteProvider.RouteService.BROUTER; + routeService = RouteService.BROUTER; } else if (profileKey.startsWith(ONLINE_ROUTING_ENGINE_PREFIX)) { routeService = RouteService.ONLINE; } else { - routeService = RouteProvider.RouteService.OSMAND; + routeService = RouteService.OSMAND; } appMode.setRouteService(routeService); appMode.setRoutingProfile(profileKey); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java index 7e1277ca18..011ceb9287 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/ProfileAppearanceFragment.java @@ -41,6 +41,7 @@ import net.osmand.AndroidUtils; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.R; import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; @@ -54,7 +55,6 @@ import net.osmand.plus.profiles.ProfileIcons; import net.osmand.plus.profiles.SelectProfileBottomSheet; import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; -import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.widgets.FlowLayout; import net.osmand.plus.widgets.OsmandTextFieldBoxes; import net.osmand.util.Algorithms; @@ -965,7 +965,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O ProfileIconColors color; int iconRes; String routingProfile; - RouteProvider.RouteService routeService; + RouteService routeService; NavigationIcon navigationIcon; LocationIcon locationIcon; diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java index 4ec93b68ef..5321670187 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/RouteParametersFragment.java @@ -31,6 +31,7 @@ import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.RoutingHelper; @@ -229,7 +230,7 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP fastRoute.setSummaryOn(R.string.shared_string_on); fastRoute.setSummaryOff(R.string.shared_string_off); - if (am.getRouteService() == RouteProvider.RouteService.OSMAND) { + if (am.getRouteService() == RouteService.OSMAND) { GeneralRouter router = app.getRouter(am); clearParameters(); if (router != null) { @@ -308,10 +309,10 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP } } setupTimeConditionalRoutingPref(); - } else if (am.getRouteService() == RouteProvider.RouteService.BROUTER) { + } else if (am.getRouteService() == RouteService.BROUTER) { screen.addPreference(fastRoute); setupTimeConditionalRoutingPref(); - } else if (am.getRouteService() == RouteProvider.RouteService.STRAIGHT) { + } else if (am.getRouteService() == RouteService.STRAIGHT) { Preference straightAngle = new Preference(app.getApplicationContext()); straightAngle.setPersistent(false); straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId()); diff --git a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java index 7885a6700b..1aa061a363 100644 --- a/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java +++ b/OsmAnd/src/net/osmand/plus/settings/fragments/VehicleParametersFragment.java @@ -25,8 +25,7 @@ import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; import net.osmand.plus.helpers.enums.SpeedConstants; -import net.osmand.plus.routing.RouteProvider.RouteService; -import net.osmand.plus.routing.RoutingHelper; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.StringPreference; import net.osmand.plus.settings.bottomsheets.VehicleParametersBottomSheet; diff --git a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java index b72d4803fe..c674ea82ab 100644 --- a/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/track/TrackMenuFragment.java @@ -81,7 +81,7 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter; import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; @@ -1156,7 +1156,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card MapActivity mapActivity = getMapActivity(); if (mapActivity != null) { startNavigationForGPX(gpxFile, mapActivity.getMapActions()); - RouteProvider.GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); + GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); if (paramsBuilder != null) { paramsBuilder.setSelectedSegment(selectedSegment); app.getRoutingHelper().onSettingsChanged(true); diff --git a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java index f966b7d897..083d94f4ff 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/RouteLayer.java @@ -32,7 +32,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment; import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteDirectionInfo; -import net.osmand.plus.routing.RouteProvider; +import net.osmand.plus.routing.RouteService; import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.views.OsmandMapLayer; @@ -360,8 +360,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont } } else { RouteCalculationResult route = helper.getRoute(); - boolean directTo = route.getRouteService() == RouteProvider.RouteService.DIRECT_TO; - boolean straight = route.getRouteService() == RouteProvider.RouteService.STRAIGHT; + boolean directTo = route.getRouteService() == RouteService.DIRECT_TO; + boolean straight = route.getRouteService() == RouteService.STRAIGHT; publicTransportRouteGeometry.clearRoute(); routeGeometry.updateRoute(tb, route); if (directTo) {