Merge branch 'master' into follow_track_fixes
This commit is contained in:
commit
69e5293412
9 changed files with 146 additions and 97 deletions
|
@ -1283,7 +1283,7 @@
|
|||
<string name="mapillary_widget">Mapillary widget</string>
|
||||
<string name="mapillary_widget_descr">Allows quick contributions to Mapillary.</string>
|
||||
<string name="mapillary_descr">Online street-level photos for everyone. Discover places, collaborate, capture the world.</string>
|
||||
<string name="mapillary">Street-level imagery</string>
|
||||
<string name="mapillary">Mapillary</string>
|
||||
<string name="plugin_mapillary_descr">Street-level photos for everyone. Discover places, collaborate, capture the world.</string>
|
||||
<string name="private_access_routing_req">Your destination is located in an area with private access. Allow using private roads for this trip?</string>
|
||||
<string name="restart_search">Restart search</string>
|
||||
|
|
|
@ -10,6 +10,8 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.SQLiteTileSource;
|
||||
|
@ -128,7 +130,13 @@ public class FileUtils {
|
|||
dest.getParentFile().mkdirs();
|
||||
}
|
||||
if (source.renameTo(dest)) {
|
||||
GpxSelectionHelper helper = ctx.getSelectedGpxHelper();
|
||||
SelectedGpxFile selected = helper.getSelectedFileByPath(source.getAbsolutePath());
|
||||
ctx.getGpxDbHelper().rename(source, dest);
|
||||
if (selected != null && selected.getGpxFile() != null) {
|
||||
selected.getGpxFile().path = dest.getAbsolutePath();
|
||||
helper.updateSelectedGpxFile(selected);
|
||||
}
|
||||
if (callback != null) {
|
||||
callback.renamedTo(dest);
|
||||
}
|
||||
|
|
|
@ -318,7 +318,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, IRouteInfo
|
|||
} else if (visibleType == DashboardType.OVERLAY_MAP) {
|
||||
tv.setText(R.string.map_overlay);
|
||||
} else if (visibleType == DashboardType.MAPILLARY) {
|
||||
tv.setText(R.string.mapillary);
|
||||
tv.setText(R.string.street_level_imagery);
|
||||
} else if (visibleType == DashboardType.CONTOUR_LINES) {
|
||||
tv.setText(R.string.srtm_plugin_name);
|
||||
} else if (visibleType == DashboardType.OSM_NOTES) {
|
||||
|
|
|
@ -181,7 +181,7 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
}
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setId(MAPILLARY)
|
||||
.setTitleId(R.string.mapillary, mapActivity)
|
||||
.setTitleId(R.string.street_level_imagery, mapActivity)
|
||||
.setDescription("Mapillary")
|
||||
.setSelected(settings.SHOW_MAPILLARY.get())
|
||||
.setColor(settings.SHOW_MAPILLARY.get() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||
|
|
|
@ -596,10 +596,10 @@ public class MeasurementEditingContext {
|
|||
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
int pairs = calculatedPairs + pointsToCalculateSize;
|
||||
int pairs = pointsToCalculateSize;
|
||||
if (pairs != 0) {
|
||||
int pairProgress = 100 / pairs;
|
||||
progress = calculatedPairs * pairProgress + progress / pairs;
|
||||
float pairProgress = 100f / pairs;
|
||||
progress = (int)(calculatedPairs * pairProgress + (float) progress / pairs);
|
||||
}
|
||||
progressListener.updateProgress(progress);
|
||||
}
|
||||
|
@ -633,6 +633,7 @@ public class MeasurementEditingContext {
|
|||
pts.add(pt);
|
||||
}
|
||||
calculatedPairs++;
|
||||
params.calculationProgressCallback.updateProgress(0);
|
||||
List<RouteSegmentResult> originalRoute = route.getOriginalRoute();
|
||||
if (Algorithms.isEmpty(originalRoute)) {
|
||||
originalRoute = Collections.singletonList(routePlannerFrontEnd.generateStraightLineSegment(
|
||||
|
|
|
@ -472,13 +472,6 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
displaySegmentPoints();
|
||||
}
|
||||
}
|
||||
/*
|
||||
if (saved == null) {
|
||||
saved = gpxData != null
|
||||
&& (gpxData.getActionType() == ActionType.ADD_ROUTE_POINTS
|
||||
|| gpxData.getActionType() == ActionType.EDIT_SEGMENT);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1443,6 +1436,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
|
||||
private ProgressDialog progressDialog;
|
||||
private File toSave;
|
||||
private GPXFile savedGpxFile;
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
|
@ -1494,6 +1488,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
}
|
||||
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
|
||||
gpx.path = toSave.getAbsolutePath();
|
||||
savedGpxFile = gpx;
|
||||
if (showOnMap) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
}
|
||||
|
@ -1564,6 +1559,7 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
}
|
||||
}
|
||||
Exception res = GPXUtilities.writeGpxFile(toSave, gpx);
|
||||
savedGpxFile = gpx;
|
||||
if (showOnMap) {
|
||||
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, true, false);
|
||||
if (sf != null) {
|
||||
|
@ -1592,6 +1588,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
mapActivity.refreshMap();
|
||||
if (warning == null) {
|
||||
editingCtx.setChangesSaved();
|
||||
if (editingCtx.isNewData() && savedGpxFile != null) {
|
||||
QuadRect rect = savedGpxFile.getRect();
|
||||
TrkSegment segment = savedGpxFile.getNonEmptyTrkSegment();
|
||||
GpxData gpxData = new GpxData(savedGpxFile, rect, ActionType.EDIT_SEGMENT, segment);
|
||||
editingCtx.setGpxData(gpxData);
|
||||
updateToolbar();
|
||||
}
|
||||
if (isInEditMode()) {
|
||||
dismiss(mapActivity);
|
||||
} else {
|
||||
|
@ -1604,8 +1607,13 @@ public class MeasurementToolFragment extends BaseOsmAndFragment implements Route
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null && AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||
FileUtils.renameFile(mapActivity, toSave, null);
|
||||
if (AndroidUtils.isActivityNotDestroyed(mapActivity)) {
|
||||
FileUtils.renameFile(mapActivity, toSave, new FileUtils.RenameCallback() {
|
||||
@Override
|
||||
public void renamedTo(File file) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ import net.osmand.GPXUtilities.WptPt;
|
|||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.settings.backend.ApplicationMode;
|
||||
|
@ -178,6 +179,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
new Renderable.StandardTrack(new ArrayList<>(after.points), 17.2).
|
||||
drawSegment(view.getZoom(), lineAttrs.paint, canvas, tb);
|
||||
|
||||
drawPoints(canvas, tb);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,6 +187,7 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
|
||||
if (inMeasurementMode) {
|
||||
lineAttrs.updatePaints(view.getApplication(), settings, tb);
|
||||
drawBeforeAfterPath(canvas, tb);
|
||||
|
||||
if (editingCtx.getSelectedPointPosition() == -1) {
|
||||
drawCenterIcon(canvas, tb, settings.isNightMode());
|
||||
|
@ -203,90 +206,115 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
}
|
||||
}
|
||||
|
||||
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||
|
||||
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
|
||||
if (before.points.size() > 0 || after.points.size() > 0) {
|
||||
path.reset();
|
||||
tx.clear();
|
||||
ty.clear();
|
||||
|
||||
if (before.points.size() > 0) {
|
||||
WptPt pt = before.points.get(before.points.size() - 1);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
if (after.points.size() > 0) {
|
||||
if (before.points.size() == 0) {
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
WptPt pt = after.points.get(0);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
}
|
||||
|
||||
GeometryWay.calculatePath(tb, tx, ty, path);
|
||||
canvas.drawPath(path, lineAttrs.paint);
|
||||
List<WptPt> beforePoints = editingCtx.getBeforePoints();
|
||||
List<WptPt> afterPoints = editingCtx.getAfterPoints();
|
||||
if (beforePoints.size() > 0) {
|
||||
drawPointIcon(canvas, tb, beforePoints.get(beforePoints.size() - 1));
|
||||
}
|
||||
|
||||
List<WptPt> points = new ArrayList<>();
|
||||
points.addAll(editingCtx.getBeforePoints());
|
||||
points.addAll(editingCtx.getAfterPoints());
|
||||
overlapped = false;
|
||||
int drawn = 0;
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
WptPt pt = points.get(i);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||
drawn++;
|
||||
if (drawn > POINTS_TO_DRAW) {
|
||||
overlapped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (overlapped) {
|
||||
WptPt pt = points.get(0);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
pt = points.get(points.size() - 1);
|
||||
locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
WptPt pt = points.get(i);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (locX >= 0 && locX <= tb.getPixWidth() && locY >= 0 && locY <= tb.getPixHeight()) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
}
|
||||
if (afterPoints.size() > 0) {
|
||||
drawPointIcon(canvas, tb, afterPoints.get(0));
|
||||
}
|
||||
|
||||
if (editingCtx.getSelectedPointPosition() != -1) {
|
||||
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
int locX = tb.getCenterPixelX();
|
||||
int locY = tb.getCenterPixelY();
|
||||
canvas.drawBitmap(applyingPointIcon, locX - marginApplyingPointIconX, locY - marginApplyingPointIconY, bitmapPaint);
|
||||
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInTileBox(RotatedTileBox tb, WptPt point) {
|
||||
QuadRect latLonBounds = tb.getLatLonBounds();
|
||||
return point.getLatitude() >= latLonBounds.bottom && point.getLatitude() <= latLonBounds.top
|
||||
&& point.getLongitude() >= latLonBounds.left && point.getLongitude() <= latLonBounds.right;
|
||||
}
|
||||
|
||||
private void drawPoints(Canvas canvas, RotatedTileBox tb) {
|
||||
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
|
||||
WptPt lastBeforePoint = null;
|
||||
List<WptPt> points = new ArrayList<>(editingCtx.getBeforePoints());
|
||||
if (points.size() > 0) {
|
||||
lastBeforePoint = points.get(points.size() - 1);
|
||||
}
|
||||
WptPt firstAfterPoint = null;
|
||||
List<WptPt> afterPoints = editingCtx.getAfterPoints();
|
||||
if (afterPoints.size() > 0) {
|
||||
firstAfterPoint = afterPoints.get(0);
|
||||
}
|
||||
points.addAll(afterPoints);
|
||||
overlapped = false;
|
||||
int drawn = 0;
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
WptPt pt = points.get(i);
|
||||
if (tb.containsLatLon(pt.lat, pt.lon)) {
|
||||
drawn++;
|
||||
if (drawn > POINTS_TO_DRAW) {
|
||||
overlapped = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (overlapped) {
|
||||
WptPt pt = points.get(0);
|
||||
if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) {
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
pt = points.get(points.size() - 1);
|
||||
if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) {
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
WptPt pt = points.get(i);
|
||||
if (pt != lastBeforePoint && pt != firstAfterPoint && isInTileBox(tb, pt)) {
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
}
|
||||
|
||||
private void drawBeforeAfterPath(Canvas canvas, RotatedTileBox tb) {
|
||||
TrkSegment before = editingCtx.getBeforeTrkSegmentLine();
|
||||
TrkSegment after = editingCtx.getAfterTrkSegmentLine();
|
||||
if (before.points.size() > 0 || after.points.size() > 0) {
|
||||
path.reset();
|
||||
tx.clear();
|
||||
ty.clear();
|
||||
|
||||
if (before.points.size() > 0) {
|
||||
WptPt pt = before.points.get(before.points.size() - 1);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
if (after.points.size() > 0) {
|
||||
if (before.points.size() == 0) {
|
||||
tx.add((float) tb.getCenterPixelX());
|
||||
ty.add((float) tb.getCenterPixelY());
|
||||
}
|
||||
WptPt pt = after.points.get(0);
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
tx.add(locX);
|
||||
ty.add(locY);
|
||||
}
|
||||
|
||||
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
GeometryWay.calculatePath(tb, tx, ty, path);
|
||||
canvas.drawPath(path, lineAttrs.paint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,6 +326,16 @@ public class MeasurementToolLayer extends OsmandMapLayer implements ContextMenuL
|
|||
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
}
|
||||
|
||||
private void drawPointIcon(Canvas canvas, RotatedTileBox tb, WptPt pt) {
|
||||
canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
float locX = tb.getPixXFromLatLon(pt.lat, pt.lon);
|
||||
float locY = tb.getPixYFromLatLon(pt.lat, pt.lon);
|
||||
if (tb.containsPoint(locX, locY, 0)) {
|
||||
canvas.drawBitmap(pointIcon, locX - marginPointIconX, locY - marginPointIconY, bitmapPaint);
|
||||
}
|
||||
canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
|
||||
}
|
||||
|
||||
public WptPt addCenterPoint() {
|
||||
RotatedTileBox tb = view.getCurrentRotatedTileBox();
|
||||
LatLon l = tb.getCenterLatLon();
|
||||
|
|
|
@ -1500,16 +1500,11 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment implement
|
|||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByPath(gpxInfo.file.getPath());
|
||||
FileUtils.renameFile(getActivity(), gpxInfo.file, new RenameCallback() {
|
||||
@Override
|
||||
public void renamedTo(File file) {
|
||||
asyncLoader = new LoadGpxTask();
|
||||
asyncLoader.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, getActivity());
|
||||
if (selectedGpxFile != null && selectedGpxFile.getGpxFile() != null) {
|
||||
selectedGpxFile.getGpxFile().path = file.getPath();
|
||||
selectedGpxHelper.updateSelectedGpxFile(selectedGpxFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1263,13 +1263,12 @@ public class RoutingHelper {
|
|||
public void run() {
|
||||
RouteCalculationProgress calculationProgress = params.calculationProgress;
|
||||
if (isRouteBeingCalculated()) {
|
||||
float pr = calculationProgress.getLinearProgress();
|
||||
progressRoute.updateProgress((int) pr);
|
||||
Thread t = currentRunningJob;
|
||||
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {
|
||||
// different calculation started
|
||||
return;
|
||||
} else {
|
||||
progressRoute.updateProgress((int) calculationProgress.getLinearProgress());
|
||||
if (calculationProgress.requestPrivateAccessRouting) {
|
||||
progressRoute.requestPrivateAccessRouting();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue