Move GPXRouteParams and RouteService to separate classes

This commit is contained in:
Vitaliy 2021-03-01 11:53:16 +02:00
parent 04e90d5284
commit 0bc9c0cb48
31 changed files with 370 additions and 350 deletions

View file

@ -30,7 +30,7 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXDataSetType;
import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.mapmarkers.MapMarkersGroup;
import net.osmand.plus.mapmarkers.MapMarkersHelper; 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.plus.track.GpxSplitType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -928,7 +928,7 @@ public class GpxSelectionHelper {
} }
public boolean isFollowTrack(OsmandApplication app) { public boolean isFollowTrack(OsmandApplication app) {
RouteProvider.GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute(); GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParams != null) { if (routeParams != null) {
return gpxFile.path.equals(routeParams.getFile().path); return gpxFile.path.equals(routeParams.getFile().path);
} }

View file

@ -18,7 +18,7 @@ import net.osmand.GPXUtilities;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper; 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 net.osmand.plus.settings.backend.ApplicationMode;
import java.util.ArrayList; import java.util.ArrayList;

View file

@ -10,7 +10,7 @@ import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; 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.RoutingHelper;
import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.routing.RoutingHelperUtils;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;

View file

@ -69,7 +69,7 @@ import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.ProfileDataUtils; import net.osmand.plus.profiles.ProfileDataUtils;
import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu; import net.osmand.plus.routepreparationmenu.MapRouteInfoMenu;
import net.osmand.plus.routepreparationmenu.WaypointsFragment; 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.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -18,7 +18,7 @@ import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.activities.MapActivity; 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.routing.RoutingHelper;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -36,7 +36,7 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.LocalRoutingPar
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.MuteSoundRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRoutingParameter;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.VoiceGuidanceRoutingParameter; 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.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
@ -373,13 +373,13 @@ public class RoutePreferencesMenu {
} }
private void updateSpinnerItems(final TextView gpxSpinner) { 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) : gpxSpinner.setText(rp == null ? mapActivity.getString(R.string.shared_string_none) :
new File(rp.getFile().path).getName()); new File(rp.getFile().path).getName());
} }
private void showOptionsMenu(final TextView gpxSpinner) { 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); final PopupMenu optionsMenu = new PopupMenu(gpxSpinner.getContext(), gpxSpinner);
MenuItem item = optionsMenu.getMenu().add( MenuItem item = optionsMenu.getMenu().add(
mapActivity.getString(R.string.shared_string_none)); mapActivity.getString(R.string.shared_string_none));

View file

@ -2073,7 +2073,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
private void startTrackNavigation() { private void startTrackNavigation() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
if (editingCtx.hasRoute()) { if (editingCtx.hasRoute() || editingCtx.hasChanges()) {
String trackName = getSuggestedFileName(); String trackName = getSuggestedFileName();
GPXFile gpx = editingCtx.exportGpx(trackName); GPXFile gpx = editingCtx.exportGpx(trackName);
if (gpx != null) { if (gpx != null) {

View file

@ -58,7 +58,7 @@ import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.CumulativeInfo;
import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.RouteDetailsFragmentListener; import net.osmand.plus.routepreparationmenu.RouteDetailsFragment.RouteDetailsFragmentListener;
import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard; import net.osmand.plus.routepreparationmenu.cards.PublicTransportCard;
import net.osmand.plus.routing.RouteDirectionInfo; 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.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -58,8 +58,8 @@ import net.osmand.plus.routepreparationmenu.cards.SelectTrackCard;
import net.osmand.plus.routepreparationmenu.cards.TrackEditCard; import net.osmand.plus.routepreparationmenu.cards.TrackEditCard;
import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard; import net.osmand.plus.routepreparationmenu.cards.TracksToFollowCard;
import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RouteService;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.track.TrackSelectSegmentBottomSheet; import net.osmand.plus.track.TrackSelectSegmentBottomSheet;
@ -224,7 +224,7 @@ public class FollowTrackFragment extends ContextMenuScrollFragment implements Ca
RoutingHelper routingHelper = app.getRoutingHelper(); RoutingHelper routingHelper = app.getRoutingHelper();
GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute(); GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute();
boolean osmandRouter = mode.getRouteService() == RouteProvider.RouteService.OSMAND; boolean osmandRouter = mode.getRouteService() == RouteService.OSMAND;
if (rparams != null && osmandRouter) { if (rparams != null && osmandRouter) {
cardsContainer.addView(buildDividerView(cardsContainer, false)); cardsContainer.addView(buildDividerView(cardsContainer, false));

View file

@ -100,7 +100,7 @@ import net.osmand.plus.routepreparationmenu.cards.SimpleRouteCard;
import net.osmand.plus.routepreparationmenu.cards.TracksCard; import net.osmand.plus.routepreparationmenu.cards.TracksCard;
import net.osmand.plus.routing.IRouteInformationListener; import net.osmand.plus.routing.IRouteInformationListener;
import net.osmand.plus.routing.RouteCalculationResult; 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.RoutingHelper;
import net.osmand.plus.routing.RoutingHelperUtils; import net.osmand.plus.routing.RoutingHelperUtils;
import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper;

View file

@ -46,7 +46,8 @@ import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.OtherSettingsRo
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.RouteSimulationItem;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem; import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.ShowAlongTheRouteItem;
import net.osmand.plus.routepreparationmenu.RoutingOptionsHelper.TimeConditionalRoutingItem; 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.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
@ -501,7 +502,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
} }
private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) { private BaseBottomSheetItem createGpxRoutingItem(final LocalRoutingParameter optionsItem) {
RouteProvider.GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute(); GPXRouteParamsBuilder routeParamsBuilder = mapActivity.getRoutingHelper().getCurrentGPXRoute();
String description = null; String description = null;
int descriptionColorId; int descriptionColorId;
if (routeParamsBuilder == null) { if (routeParamsBuilder == null) {
@ -661,11 +662,11 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private List<LocalRoutingParameter> getRoutingParameters(ApplicationMode applicationMode) { private List<LocalRoutingParameter> getRoutingParameters(ApplicationMode applicationMode) {
List<String> routingParameters; List<String> routingParameters;
boolean osmandRouter = applicationMode.getRouteService() == RouteProvider.RouteService.OSMAND; boolean osmandRouter = applicationMode.getRouteService() == RouteService.OSMAND;
if (!osmandRouter) { if (!osmandRouter) {
if (applicationMode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { if (applicationMode.getRouteService() == RouteService.STRAIGHT) {
routingParameters = AppModeOptions.STRAIGHT.routingParameters; routingParameters = AppModeOptions.STRAIGHT.routingParameters;
} else if (applicationMode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { } else if (applicationMode.getRouteService() == RouteService.DIRECT_TO) {
routingParameters = AppModeOptions.DIRECT_TO.routingParameters; routingParameters = AppModeOptions.DIRECT_TO.routingParameters;
} else { } else {
routingParameters = AppModeOptions.OTHER.routingParameters; routingParameters = AppModeOptions.OTHER.routingParameters;

View file

@ -37,9 +37,8 @@ import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadActivityType;
import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.helpers.FileNameTranslationHelper;
import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.RouteService;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.voice.JSMediaCommandPlayerImpl; import net.osmand.plus.voice.JSMediaCommandPlayerImpl;
@ -243,24 +242,25 @@ public class RoutingOptionsHelper {
TargetPointsHelper tg = app.getTargetPointsHelper(); TargetPointsHelper tg = app.getTargetPointsHelper();
List<Location> ps = rp.getPoints(app); List<Location> ps = rp.getPoints(app);
if (ps.size() > 0) { if (ps.size() > 0) {
TargetPoint pointToStart = tg.getPointToStart();
TargetPoint pointToNavigate = tg.getPointToNavigate();
if (rp.getFile().hasRoute()) { if (rp.getFile().hasRoute()) {
tg.clearStartPoint(false); tg.clearStartPoint(false);
Location finishLoc = ps.get(ps.size() - 1); Location finishLoc = ps.get(ps.size() - 1);
TargetPoint pn = tg.getPointToNavigate(); tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()),
tg.navigateToPoint(new LatLon(finishLoc.getLatitude(), finishLoc.getLongitude()), false, -1, pn != null ? pn.getOriginalPointDescription() : null); false, -1, pointToNavigate != null ? pointToNavigate.getOriginalPointDescription() : null);
tg.updateRouteAndRefresh(true); tg.updateRouteAndRefresh(true);
} else { } else {
Location first = ps.get(0); Location first = ps.get(0);
Location end = ps.get(ps.size() - 1); Location end = ps.get(ps.size() - 1);
TargetPoint pn = tg.getPointToNavigate();
boolean update = false; boolean update = false;
if (pn == null if (pointToNavigate == null
|| MapUtils.getDistance(pn.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) { || MapUtils.getDistance(pointToNavigate.point, new LatLon(first.getLatitude(), first.getLongitude())) < 10) {
tg.navigateToPoint(new LatLon(end.getLatitude(), end.getLongitude()), false, -1); tg.navigateToPoint(new LatLon(end.getLatitude(), end.getLongitude()), false, -1);
update = true; update = true;
} }
if (tg.getPointToStart() == null if (pointToStart == null
|| MapUtils.getDistance(tg.getPointToStart().point, || MapUtils.getDistance(pointToStart.point,
new LatLon(end.getLatitude(), end.getLongitude())) < 10) { new LatLon(end.getLatitude(), end.getLongitude())) < 10) {
tg.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), false, null); tg.setStartPoint(new LatLon(first.getLatitude(), first.getLongitude()), false, null);
update = true; update = true;
@ -490,7 +490,7 @@ public class RoutingOptionsHelper {
} }
public List<LocalRoutingParameter> getRoutingParametersInner(ApplicationMode am) { public List<LocalRoutingParameter> getRoutingParametersInner(ApplicationMode am) {
boolean osmandRouter = am.getRouteService() == RouteProvider.RouteService.OSMAND; boolean osmandRouter = am.getRouteService() == RouteService.OSMAND;
if (!osmandRouter) { if (!osmandRouter) {
return getOsmandRouterParameters(am); return getOsmandRouterParameters(am);
} }
@ -1061,7 +1061,7 @@ public class RoutingOptionsHelper {
private List<String> getRoutingParametersForProfileType(ApplicationMode appMode) { private List<String> getRoutingParametersForProfileType(ApplicationMode appMode) {
if (appMode != null) { if (appMode != null) {
boolean osmandRouter = appMode.getRouteService() == RouteProvider.RouteService.OSMAND; boolean osmandRouter = appMode.getRouteService() == RouteService.OSMAND;
if (!osmandRouter) { if (!osmandRouter) {
return PermanentAppModeOptions.OTHER.routingParameters; return PermanentAppModeOptions.OTHER.routingParameters;
} else if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) { } else if (appMode.isDerivedRoutingFrom(ApplicationMode.CAR)) {

View file

@ -20,7 +20,7 @@ import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.helpers.GpxUiHelper; import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.GpxUiHelper.GPXInfo;
import net.osmand.plus.helpers.TrackSelectSegmentAdapter; 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 net.osmand.util.Algorithms;
import java.io.File; import java.io.File;

View file

@ -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<LocationPoint> wpt;
protected List<RouteSegmentResult> route;
protected List<RouteDirectionInfo> directions;
protected List<Location> points = new ArrayList<>();
protected List<WptPt> routePoints = new ArrayList<>();
protected boolean reverse;
protected boolean passWholeRoute;
protected boolean calculateOsmAndRoute;
protected boolean useIntermediatePointsRTE;
protected boolean calculateOsmAndRouteParts;
boolean addMissingTurns = true;
public List<Location> getPoints() {
return points;
}
public List<LocationPoint> 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<LocationPoint>(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<TrkSegment> 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<Location> getPoints(OsmandApplication app) {
GPXRouteParams copy = build(app);
return copy.getPoints();
}
}
}

View file

@ -7,7 +7,6 @@ import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.routing.RouteProvider.RoutingEnvironment;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RouteCalculationProgress;
import net.osmand.router.RoutePlannerFrontEnd.GpxPoint; import net.osmand.router.RoutePlannerFrontEnd.GpxPoint;

View file

@ -4,7 +4,6 @@ import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.routing.RouteProvider.GPXRouteParams;
import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RouteCalculationProgress;
import java.util.List; import java.util.List;

View file

@ -15,7 +15,6 @@ import net.osmand.data.QuadRect;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.routing.AlarmInfo.AlarmInfoType; import net.osmand.plus.routing.AlarmInfo.AlarmInfoType;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.router.ExitInfo; import net.osmand.router.ExitInfo;
import net.osmand.router.RouteSegmentResult; import net.osmand.router.RouteSegmentResult;

View file

@ -1,7 +1,6 @@
package net.osmand.plus.routing; package net.osmand.plus.routing;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.util.Base64; import android.util.Base64;
@ -16,8 +15,6 @@ import net.osmand.PlatformUtil;
import net.osmand.ResultMatcher; import net.osmand.ResultMatcher;
import net.osmand.binary.BinaryMapIndexReader; import net.osmand.binary.BinaryMapIndexReader;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.WptLocationPoint;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
@ -70,279 +67,14 @@ import javax.xml.parsers.ParserConfigurationException;
import btools.routingapp.IBRouterService; import btools.routingapp.IBRouterService;
import static net.osmand.router.RouteExporter.OSMAND_ROUTER_V2;
public class RouteProvider { public class RouteProvider {
private static final org.apache.commons.logging.Log log = PlatformUtil.getLog(RouteProvider.class); 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 MIN_DISTANCE_FOR_INSERTING_ROUTE_SEGMENT = 60;
private static final int ADDITIONAL_DISTANCE_FOR_START_POINT = 300; private static final int ADDITIONAL_DISTANCE_FOR_START_POINT = 300;
private static final int MIN_STRAIGHT_DIST = 50000; 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<RouteService> 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<Location> getPoints(OsmandApplication app) {
GPXRouteParams copy = build(app);
return copy.getPoints();
}
}
public static class GPXRouteParams {
List<Location> points = new ArrayList<>();
List<RouteDirectionInfo> directions;
List<RouteSegmentResult> route;
List<WptPt> routePoints = new ArrayList<>();
boolean reverse;
boolean calculateOsmAndRoute;
boolean passWholeRoute;
boolean calculateOsmAndRouteParts;
boolean useIntermediatePointsRTE;
private List<LocationPoint> wpt;
boolean addMissingTurns = true;
public List<Location> 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<LocationPoint>(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<TrkSegment> 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){ public static Location createLocation(WptPt pt){
Location loc = new Location("OsmandRouteProvider"); Location loc = new Location("OsmandRouteProvider");
loc.setLatitude(pt.lat); loc.setLatitude(pt.lat);
@ -771,13 +503,6 @@ public class RouteProvider {
return nearestPointIndex; 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 { public RoutingEnvironment getRoutingEnvironment(OsmandApplication ctx, ApplicationMode mode, LatLon start, LatLon end) throws IOException {
RouteCalculationParams params = new RouteCalculationParams(); RouteCalculationParams params = new RouteCalculationParams();
params.ctx = ctx; params.ctx = ctx;
@ -788,11 +513,11 @@ public class RouteProvider {
} }
public List<GpxPoint> generateGpxPoints(RoutingEnvironment env, GpxRouteApproximation gctx, LocationsHolder locationsHolder) { public List<GpxPoint> 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<GpxPoint> points, ResultMatcher<GpxRouteApproximation> resultMatcher) throws IOException, InterruptedException { public GpxRouteApproximation calculateGpxPointsApproximation(RoutingEnvironment env, GpxRouteApproximation gctx, List<GpxPoint> points, ResultMatcher<GpxRouteApproximation> 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 { protected RoutingEnvironment calculateRoutingEnvironment(RouteCalculationParams params, boolean calcGPXRoute, boolean skipComplex) throws IOException {
@ -885,7 +610,7 @@ public class RouteProvider {
if (params.intermediates != null) { if (params.intermediates != null) {
inters = new ArrayList<LatLon>(params.intermediates); inters = new ArrayList<LatLon>(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, private RoutingConfiguration initOsmAndRoutingConfig(Builder config, final RouteCalculationParams params, OsmandSettings settings,
@ -1012,7 +737,7 @@ public class RouteProvider {
return new RouteCalculationResult("Empty result"); return new RouteCalculationResult("Empty result");
} }
private static List<RouteSegmentResult> parseOsmAndGPXRoute(List<Location> points, GPXFile gpxFile, int selectedSegment) { protected static List<RouteSegmentResult> parseOsmAndGPXRoute(List<Location> points, GPXFile gpxFile, int selectedSegment) {
List<TrkSegment> segments = gpxFile.getNonEmptyTrkSegments(false); List<TrkSegment> segments = gpxFile.getNonEmptyTrkSegments(false);
if (selectedSegment != -1 && segments.size() > selectedSegment) { if (selectedSegment != -1 && segments.size() > selectedSegment) {
TrkSegment segment = segments.get(selectedSegment); TrkSegment segment = segments.get(selectedSegment);
@ -1032,8 +757,8 @@ public class RouteProvider {
} }
} }
private static List<RouteDirectionInfo> parseOsmAndGPXRoute(List<Location> points, GPXFile gpxFile, boolean osmandRouter, protected static List<RouteDirectionInfo> parseOsmAndGPXRoute(List<Location> points, GPXFile gpxFile, boolean osmandRouter,
boolean leftSide, float defSpeed, int selectedSegment) { boolean leftSide, float defSpeed, int selectedSegment) {
List<RouteDirectionInfo> directions = null; List<RouteDirectionInfo> directions = null;
if (!osmandRouter) { if (!osmandRouter) {
for (WptPt pt : gpxFile.getPoints()) { for (WptPt pt : gpxFile.getPoints()) {
@ -1378,6 +1103,4 @@ public class RouteProvider {
} }
return new RouteCalculationResult(segments, computeDirections, params, null, false); return new RouteCalculationResult(segments, computeDirections, params, null, false);
} }
} }

View file

@ -6,6 +6,7 @@ import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; 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.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.router.RouteCalculationProgress; import net.osmand.router.RouteCalculationProgress;
@ -179,7 +180,7 @@ class RouteRecalculationHelper {
} }
public void recalculateRouteInBackground(final Location start, final LatLon end, final List<LatLon> intermediates, public void recalculateRouteInBackground(final Location start, final LatLon end, final List<LatLon> 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) { if (start == null || end == null) {
return; return;
} }
@ -207,7 +208,7 @@ class RouteRecalculationHelper {
params.mode = mode; params.mode = mode;
params.ctx = app; params.ctx = app;
boolean updateProgress = false; boolean updateProgress = false;
if (params.mode.getRouteService() == RouteProvider.RouteService.OSMAND) { if (params.mode.getRouteService() == RouteService.OSMAND) {
params.calculationProgress = new RouteCalculationProgress(); params.calculationProgress = new RouteCalculationProgress();
updateProgress = true; updateProgress = true;
} else { } else {

View file

@ -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<RouteService> list = new ArrayList<>();
for (RouteService r : values()) {
if (r.isAvailable(ctx)) {
list.add(r);
}
}
return list.toArray(new RouteService[0]);
}
}

View file

@ -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;
}
}

View file

@ -20,9 +20,7 @@ import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.helpers.enums.MetricsConstants;
import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.notifications.OsmandNotification.NotificationType;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder;
import net.osmand.plus.routing.RouteProvider.RouteService;
import net.osmand.plus.routing.RouteProvider.RoutingEnvironment;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener; import net.osmand.plus.settings.backend.OsmAndAppCustomization.OsmAndAppCustomizationListener;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;
@ -670,9 +668,9 @@ public class RoutingHelper {
private static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode, float posTolerance) { private static float getDefaultAllowedDeviation(OsmandSettings settings, ApplicationMode mode, float posTolerance) {
if (settings.DISABLE_OFFROUTE_RECALC.getModeValue(mode)) { if (settings.DISABLE_OFFROUTE_RECALC.getModeValue(mode)) {
return -1.0f; return -1.0f;
} else if (mode.getRouteService() == RouteProvider.RouteService.DIRECT_TO) { } else if (mode.getRouteService() == RouteService.DIRECT_TO) {
return -1.0f; return -1.0f;
} else if (mode.getRouteService() == RouteProvider.RouteService.STRAIGHT) { } else if (mode.getRouteService() == RouteService.STRAIGHT) {
MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode); MetricsConstants mc = settings.METRIC_SYSTEM.getModeValue(mode);
if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) { if (mc == MetricsConstants.KILOMETERS_AND_METERS || mc == MetricsConstants.MILES_AND_METERS) {
return 500.f; return 500.f;

View file

@ -18,7 +18,6 @@ import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.render.NativeOsmandLibrary; import net.osmand.plus.render.NativeOsmandLibrary;
import net.osmand.plus.routing.RouteCalculationParams.RouteCalculationResultListener; 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.ApplicationMode;
import net.osmand.plus.settings.backend.CommonPreference; import net.osmand.plus.settings.backend.CommonPreference;
import net.osmand.plus.settings.backend.OsmandSettings; import net.osmand.plus.settings.backend.OsmandSettings;

View file

@ -12,7 +12,7 @@ import net.osmand.plus.R;
import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.LocationIcon;
import net.osmand.plus.profiles.NavigationIcon; import net.osmand.plus.profiles.NavigationIcon;
import net.osmand.plus.profiles.ProfileIconColors; 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 net.osmand.util.Algorithms;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;

View file

@ -48,7 +48,7 @@ import net.osmand.plus.profiles.NavigationIcon;
import net.osmand.plus.profiles.ProfileIconColors; import net.osmand.plus.profiles.ProfileIconColors;
import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode; import net.osmand.plus.rastermaps.LayerTransparencySeekbarMode;
import net.osmand.plus.render.RendererRegistry; 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.srtmplugin.TerrainMode;
import net.osmand.plus.views.layers.RadiusRulerControlLayer.RadiusRulerMode; import net.osmand.plus.views.layers.RadiusRulerControlLayer.RadiusRulerMode;
import net.osmand.plus.voice.CommandPlayer; import net.osmand.plus.voice.CommandPlayer;

View file

@ -14,14 +14,13 @@ import net.osmand.plus.profiles.ProfileDataObject;
import net.osmand.plus.profiles.ProfileDataUtils; import net.osmand.plus.profiles.ProfileDataUtils;
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet; import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet;
import net.osmand.plus.routepreparationmenu.RouteOptionsBottomSheet.DialogMode; 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.settings.backend.ApplicationMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources; import net.osmand.plus.profiles.RoutingProfileDataObject.RoutingProfilesResources;
import net.osmand.plus.profiles.SelectProfileBottomSheet; import net.osmand.plus.profiles.SelectProfileBottomSheet;
import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -151,17 +150,17 @@ public class NavigationFragment extends BaseSettingsFragment implements OnSelect
navigationType.setIcon(getActiveIcon(selectedRoutingProfileDataObject.getIconRes())); navigationType.setIcon(getActiveIcon(selectedRoutingProfileDataObject.getIconRes()));
ApplicationMode appMode = getSelectedAppMode(); ApplicationMode appMode = getSelectedAppMode();
RouteProvider.RouteService routeService; RouteService routeService;
if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) { if (profileKey.equals(RoutingProfilesResources.STRAIGHT_LINE_MODE.name())) {
routeService = RouteProvider.RouteService.STRAIGHT; routeService = RouteService.STRAIGHT;
} else if (profileKey.equals(RoutingProfilesResources.DIRECT_TO_MODE.name())) { } 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())) { } else if (profileKey.equals(RoutingProfilesResources.BROUTER_MODE.name())) {
routeService = RouteProvider.RouteService.BROUTER; routeService = RouteService.BROUTER;
} else if (profileKey.startsWith(ONLINE_ROUTING_ENGINE_PREFIX)) { } else if (profileKey.startsWith(ONLINE_ROUTING_ENGINE_PREFIX)) {
routeService = RouteService.ONLINE; routeService = RouteService.ONLINE;
} else { } else {
routeService = RouteProvider.RouteService.OSMAND; routeService = RouteService.OSMAND;
} }
appMode.setRouteService(routeService); appMode.setRouteService(routeService);
appMode.setRoutingProfile(profileKey); appMode.setRoutingProfile(profileKey);

View file

@ -41,6 +41,7 @@ import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.routing.RouteService;
import net.osmand.plus.settings.backend.ApplicationMode; import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.settings.backend.backup.ProfileSettingsItem; 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;
import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode; import net.osmand.plus.profiles.SelectProfileBottomSheet.DialogMode;
import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback; import net.osmand.plus.profiles.SelectProfileBottomSheet.OnSelectProfileCallback;
import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.widgets.FlowLayout; import net.osmand.plus.widgets.FlowLayout;
import net.osmand.plus.widgets.OsmandTextFieldBoxes; import net.osmand.plus.widgets.OsmandTextFieldBoxes;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
@ -965,7 +965,7 @@ public class ProfileAppearanceFragment extends BaseSettingsFragment implements O
ProfileIconColors color; ProfileIconColors color;
int iconRes; int iconRes;
String routingProfile; String routingProfile;
RouteProvider.RouteService routeService; RouteService routeService;
NavigationIcon navigationIcon; NavigationIcon navigationIcon;
LocationIcon locationIcon; LocationIcon locationIcon;

View file

@ -31,6 +31,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.routing.RouteService;
import net.osmand.plus.development.OsmandDevelopmentPlugin; import net.osmand.plus.development.OsmandDevelopmentPlugin;
import net.osmand.plus.routing.RouteProvider; import net.osmand.plus.routing.RouteProvider;
import net.osmand.plus.routing.RoutingHelper; 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.setSummaryOn(R.string.shared_string_on);
fastRoute.setSummaryOff(R.string.shared_string_off); fastRoute.setSummaryOff(R.string.shared_string_off);
if (am.getRouteService() == RouteProvider.RouteService.OSMAND) { if (am.getRouteService() == RouteService.OSMAND) {
GeneralRouter router = app.getRouter(am); GeneralRouter router = app.getRouter(am);
clearParameters(); clearParameters();
if (router != null) { if (router != null) {
@ -308,10 +309,10 @@ public class RouteParametersFragment extends BaseSettingsFragment implements OnP
} }
} }
setupTimeConditionalRoutingPref(); setupTimeConditionalRoutingPref();
} else if (am.getRouteService() == RouteProvider.RouteService.BROUTER) { } else if (am.getRouteService() == RouteService.BROUTER) {
screen.addPreference(fastRoute); screen.addPreference(fastRoute);
setupTimeConditionalRoutingPref(); setupTimeConditionalRoutingPref();
} else if (am.getRouteService() == RouteProvider.RouteService.STRAIGHT) { } else if (am.getRouteService() == RouteService.STRAIGHT) {
Preference straightAngle = new Preference(app.getApplicationContext()); Preference straightAngle = new Preference(app.getApplicationContext());
straightAngle.setPersistent(false); straightAngle.setPersistent(false);
straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId()); straightAngle.setKey(settings.ROUTE_STRAIGHT_ANGLE.getId());

View file

@ -25,8 +25,7 @@ import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities; import net.osmand.plus.UiUtilities;
import net.osmand.plus.helpers.enums.SpeedConstants; import net.osmand.plus.helpers.enums.SpeedConstants;
import net.osmand.plus.routing.RouteProvider.RouteService; 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.ApplicationMode;
import net.osmand.plus.settings.backend.StringPreference; import net.osmand.plus.settings.backend.StringPreference;
import net.osmand.plus.settings.bottomsheets.VehicleParametersBottomSheet; import net.osmand.plus.settings.bottomsheets.VehicleParametersBottomSheet;

View file

@ -81,7 +81,7 @@ import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.routepreparationmenu.cards.BaseCard; import net.osmand.plus.routepreparationmenu.cards.BaseCard;
import net.osmand.plus.routepreparationmenu.cards.BaseCard.CardListener; 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.SaveGpxAsyncTask.SaveGpxListener;
import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener; import net.osmand.plus.track.TrackSelectSegmentBottomSheet.OnSegmentSelectedListener;
import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint; import net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint;
@ -1156,7 +1156,7 @@ public class TrackMenuFragment extends ContextMenuScrollFragment implements Card
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) { if (mapActivity != null) {
startNavigationForGPX(gpxFile, mapActivity.getMapActions()); startNavigationForGPX(gpxFile, mapActivity.getMapActions());
RouteProvider.GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute(); GPXRouteParamsBuilder paramsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (paramsBuilder != null) { if (paramsBuilder != null) {
paramsBuilder.setSelectedSegment(selectedSegment); paramsBuilder.setSelectedSegment(selectedSegment);
app.getRoutingHelper().onSettingsChanged(true); app.getRoutingHelper().onSettingsChanged(true);

View file

@ -32,7 +32,7 @@ import net.osmand.plus.measurementtool.MeasurementToolFragment;
import net.osmand.plus.profiles.LocationIcon; import net.osmand.plus.profiles.LocationIcon;
import net.osmand.plus.routing.RouteCalculationResult; import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.RouteDirectionInfo; 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.RoutingHelper;
import net.osmand.plus.routing.TransportRoutingHelper; import net.osmand.plus.routing.TransportRoutingHelper;
import net.osmand.plus.views.OsmandMapLayer; import net.osmand.plus.views.OsmandMapLayer;
@ -360,8 +360,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
} }
} else { } else {
RouteCalculationResult route = helper.getRoute(); RouteCalculationResult route = helper.getRoute();
boolean directTo = route.getRouteService() == RouteProvider.RouteService.DIRECT_TO; boolean directTo = route.getRouteService() == RouteService.DIRECT_TO;
boolean straight = route.getRouteService() == RouteProvider.RouteService.STRAIGHT; boolean straight = route.getRouteService() == RouteService.STRAIGHT;
publicTransportRouteGeometry.clearRoute(); publicTransportRouteGeometry.clearRoute();
routeGeometry.updateRoute(tb, route); routeGeometry.updateRoute(tb, route);
if (directTo) { if (directTo) {