use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class RoutingOptionsHelper method getRoutingParametersInner.
public List<LocalRoutingParameter> getRoutingParametersInner(ApplicationMode am) {
boolean osmandRouter = am.getRouteService() == RouteService.OSMAND;
if (!osmandRouter) {
return getOsmandRouterParameters(am);
}
GPXRouteParamsBuilder rparams = app.getRoutingHelper().getCurrentGPXRoute();
List<LocalRoutingParameter> list = new ArrayList<LocalRoutingParameter>(getGpxRouterParameters(am));
GeneralRouter rm = app.getRouter(am);
if (rm == null || (rparams != null && !rparams.isCalculateOsmAndRoute()) && !rparams.getFile().hasRtePt()) {
return list;
}
for (GeneralRouter.RoutingParameter r : rm.getParameters().values()) {
if (r.getType() == GeneralRouter.RoutingParameterType.BOOLEAN) {
if ("relief_smoothness_factor".equals(r.getGroup())) {
continue;
}
if (!Algorithms.isEmpty(r.getGroup())) {
LocalRoutingParameterGroup rpg = getLocalRoutingParameterGroup(list, r.getGroup());
if (rpg == null) {
rpg = new LocalRoutingParameterGroup(am, r.getGroup());
list.add(rpg);
}
rpg.addRoutingParameter(r);
} else {
LocalRoutingParameter rp = new LocalRoutingParameter(am);
rp.routingParameter = r;
updateRoutingParameterIcons(rp);
list.add(rp);
}
}
}
return list;
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class TrackEditCard method updateContent.
@Override
protected void updateContent() {
String fileName = null;
File file = null;
if (!Algorithms.isEmpty(gpxFile.path)) {
file = new File(gpxFile.path);
fileName = gpxFile.path;
} else if (!Algorithms.isEmpty(gpxFile.tracks)) {
fileName = gpxFile.tracks.get(0).name;
}
if (Algorithms.isEmpty(fileName)) {
fileName = app.getString(R.string.shared_string_gpx_track);
}
GPXInfo gpxInfo = new GPXInfo(fileName, file != null ? file.lastModified() : 0, file != null ? file.length() : 0);
GPXTrackAnalysis analysis = null;
if (file != null) {
GpxDataItem dataItem = getDataItem(gpxInfo);
if (dataItem != null) {
analysis = dataItem.getAnalysis();
}
} else {
analysis = gpxFile.getAnalysis(0);
}
String title = GpxUiHelper.getGpxTitle(Algorithms.getFileWithoutDirs(fileName));
GPXRouteParamsBuilder routeParams = app.getRoutingHelper().getCurrentGPXRoute();
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1) {
int selectedSegmentCount = routeParams.getSelectedSegment() + 1;
int totalSegmentCount = routeParams.getFile().getNonEmptyTrkSegments(false).size();
title = app.getString(R.string.of, selectedSegmentCount, totalSegmentCount) + ", " + title;
}
GpxUiHelper.updateGpxInfoView(view, title, gpxInfo, analysis, app);
if (gpxFile.getNonEmptySegmentsCount() > 1 && routeParams != null && routeParams.getSelectedSegment() != -1 && gpxFile.getNonEmptySegmentsCount() > routeParams.getSelectedSegment()) {
TextView distanceView = view.findViewById(R.id.distance);
TextView timeView = view.findViewById(R.id.time);
ImageView timeIcon = view.findViewById(R.id.time_icon);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_icon), false);
AndroidUiHelper.updateVisibility(view.findViewById(R.id.points_count), false);
List<GPXUtilities.TrkSegment> segments = gpxFile.getNonEmptyTrkSegments(false);
GPXUtilities.TrkSegment segment = segments.get(routeParams.getSelectedSegment());
double distance = TrackSelectSegmentAdapter.getDistance(segment);
long time = TrackSelectSegmentAdapter.getSegmentTime(segment);
boolean timeAvailable = time != 1;
if (timeAvailable) {
timeView.setText(Algorithms.formatDuration((int) (time / 1000), app.accessibilityEnabled()));
}
AndroidUiHelper.updateVisibility(timeView, timeAvailable);
AndroidUiHelper.updateVisibility(timeIcon, timeAvailable);
distanceView.setText(OsmAndFormatter.getFormattedDistance((float) distance, app));
}
ImageButton editButton = view.findViewById(R.id.show_on_map);
editButton.setVisibility(View.VISIBLE);
editButton.setImageDrawable(getContentIcon(R.drawable.ic_action_edit_dark));
editButton.setOnClickListener(v -> notifyCardPressed());
int minCardHeight = getDimen(R.dimen.setting_list_item_large_height);
int listContentPadding = getDimen(R.dimen.list_content_padding);
LinearLayout container = view.findViewById(R.id.container);
container.setMinimumHeight(minCardHeight);
AndroidUtils.setPadding(container, listContentPadding, 0, 0, 0);
int activeColor = getActiveColor();
int bgColor = ColorUtilities.getColorWithAlpha(activeColor, 0.1f);
view.setBackgroundDrawable(new ColorDrawable(bgColor));
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class SelectedTrackToFollowCard method updateContent.
@Override
protected void updateContent() {
view.getViewTreeObserver().addOnScrollChangedListener(() -> {
boolean bottomScrollAvailable = view.canScrollVertically(1);
if (bottomScrollAvailable) {
target.showShadowButton();
} else {
target.hideShadowButton();
}
});
ViewGroup cardsContainer = ((ViewGroup) view.findViewById(R.id.cards_container));
cardsContainer.removeAllViews();
TrackEditCard importTrackCard = new TrackEditCard(mapActivity, gpxFile);
importTrackCard.setListener(target);
cardsContainer.addView(importTrackCard.build(mapActivity));
SelectTrackCard selectTrackCard = new SelectTrackCard(mapActivity);
selectTrackCard.setListener(target);
cardsContainer.addView(selectTrackCard.build(mapActivity));
ApplicationMode mode = app.getRoutingHelper().getAppMode();
RoutingHelper routingHelper = app.getRoutingHelper();
GPXRouteParamsBuilder rparams = routingHelper.getCurrentGPXRoute();
boolean osmandRouter = mode.getRouteService() == RouteService.OSMAND;
if (rparams != null && osmandRouter) {
cardsContainer.addView(buildDividerView(cardsContainer, false));
ReverseTrackCard reverseTrackCard = new ReverseTrackCard(mapActivity, rparams.isReverse());
reverseTrackCard.setListener(target);
cardsContainer.addView(reverseTrackCard.build(mapActivity));
if (!gpxFile.hasRtePt() && !gpxFile.hasRoute()) {
cardsContainer.addView(buildDividerView(cardsContainer, true));
AttachTrackToRoadsCard attachTrackCard = new AttachTrackToRoadsCard(mapActivity);
attachTrackCard.setListener(target);
cardsContainer.addView(attachTrackCard.build(mapActivity));
}
setupNavigateOptionsCard(cardsContainer, rparams);
}
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class MapActivityActions method createSaveDirections.
public static Dialog createSaveDirections(Activity activity, RoutingHelper routingHelper) {
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
final File fileDir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final Dialog dlg = new Dialog(activity);
dlg.setTitle(R.string.shared_string_save_as_gpx);
dlg.setContentView(R.layout.save_directions_dialog);
final EditText edit = (EditText) dlg.findViewById(R.id.FileNameEdit);
final GPXRouteParamsBuilder rp = routingHelper.getCurrentGPXRoute();
final String editText;
if (rp == null || rp.getFile() == null || rp.getFile().path == null) {
editText = "_" + MessageFormat.format("{0,date,yyyy-MM-dd}", new Date()) + "_";
} else {
editText = new File(rp.getFile().path).getName();
}
edit.setText(editText);
dlg.findViewById(R.id.Save).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String name = edit.getText().toString();
// noinspection ResultOfMethodCallIgnored
fileDir.mkdirs();
File toSave = fileDir;
if (name.length() > 0) {
if (!name.endsWith(GPX_FILE_EXT)) {
name += GPX_FILE_EXT;
}
toSave = new File(fileDir, name);
}
if (toSave.exists()) {
dlg.findViewById(R.id.DuplicateFileName).setVisibility(View.VISIBLE);
} else {
dlg.dismiss();
new SaveDirectionsAsyncTask(app, false).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, toSave);
}
}
});
dlg.findViewById(R.id.Cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dlg.dismiss();
}
});
return dlg;
}
use of net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder in project Osmand by osmandapp.
the class FollowTrackFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
app = requireMyApplication();
MapActivity mapActivity = requireMapActivity();
importHelper = new ImportHelper(mapActivity, getMyApplication());
GPXRouteParamsBuilder routeParamsBuilder = app.getRoutingHelper().getCurrentGPXRoute();
if (routeParamsBuilder != null) {
gpxFile = routeParamsBuilder.getFile();
}
if (savedInstanceState != null) {
selectingTrack = savedInstanceState.getBoolean(SELECTING_TRACK, gpxFile == null);
} else {
selectingTrack = gpxFile == null;
}
}
Aggregations