Merge pull request #4501 from osmandapp/gpx_current_track

Fix #4328
This commit is contained in:
vshcherb 2017-10-01 23:35:44 +02:00 committed by GitHub
commit 87e1942ed4

View file

@ -465,15 +465,29 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox, private void drawSelectedFilesSegments(Canvas canvas, RotatedTileBox tileBox,
List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) { List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
SelectedGpxFile currentTrack = null;
for (SelectedGpxFile g : selectedGPXFiles) { for (SelectedGpxFile g : selectedGPXFiles) {
GpxDataItem gpxDataItem = null; if (g.isShowCurrentTrack()) {
if (!g.isShowCurrentTrack()) { currentTrack = g;
gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path)); } else {
drawSelectedFileSegments(g, false, canvas, tileBox, settings);
} }
List<TrkSegment> segments = g.getPointsToDisplay(); }
if (currentTrack != null) {
drawSelectedFileSegments(currentTrack, true, canvas, tileBox, settings);
}
}
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas,
RotatedTileBox tileBox, DrawSettings settings) {
GpxDataItem gpxDataItem = null;
if (!currentTrack) {
gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path));
}
List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
for (TrkSegment ts : segments) { for (TrkSegment ts : segments) {
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0; int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
if (g.isShowCurrentTrack()) { if (currentTrack) {
color = currentTrackColor; color = currentTrackColor;
} }
if (color == 0) { if (color == 0) {
@ -481,17 +495,16 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
} }
if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD) if (ts.renders.isEmpty() // only do once (CODE HERE NEEDS TO BE UI INSTEAD)
&& !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how? && !ts.points.isEmpty()) { // hmmm. 0-point tracks happen, but.... how?
if (g.isShowCurrentTrack()) { if (currentTrack) {
ts.renders.add(new Renderable.CurrentTrack(ts.points)); ts.renders.add(new Renderable.CurrentTrack(ts.points));
} else { } else {
ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2)); ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
} }
} }
updatePaints(color, g.isRoutePoints(), g.isShowCurrentTrack(), settings, tileBox); updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
ts.drawRenderers(view.getZoom(), paint, canvas, tileBox); ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
} }
} }
}
private boolean isPointVisited(WptPt o) { private boolean isPointVisited(WptPt o) {
boolean visit = false; boolean visit = false;