Add route points to track
This commit is contained in:
parent
bc3683923a
commit
7f03ce321b
2 changed files with 36 additions and 16 deletions
|
@ -935,6 +935,19 @@ public class GPXUtilities {
|
|||
return false;
|
||||
}
|
||||
|
||||
public void addRoutePoints(List<WptPt> points) {
|
||||
if (routes.size() == 0) {
|
||||
Route route = new Route();
|
||||
routes.add(route);
|
||||
}
|
||||
|
||||
Route lastRoute = routes.get(routes.size() - 1);
|
||||
|
||||
lastRoute.points.addAll(points);
|
||||
|
||||
modifiedTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void replaceRoutePoints(List<WptPt> points) {
|
||||
routes.clear();
|
||||
routes.add(new Route());
|
||||
|
|
|
@ -533,7 +533,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
public void addToTheTrackOnClick() {
|
||||
if (mapActivity != null && measurementLayer != null) {
|
||||
if (measurementLayer.getPointsCount() > 0) {
|
||||
// showAddSegmentDialog(mapActivity);
|
||||
showAddSegmentDialog(mapActivity);
|
||||
} else {
|
||||
Toast.makeText(mapActivity, getString(R.string.none_point_error), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
@ -789,6 +789,9 @@ public class MeasurementToolFragment extends Fragment {
|
|||
GPXFile gpxFile;
|
||||
if (result != null && result.length > 0) {
|
||||
gpxFile = result[0];
|
||||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
|
||||
boolean showOnMap = selectedGpxFile != null;
|
||||
saveExistingGpx(gpxFile, showOnMap, null, false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1059,7 +1062,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpx.path);
|
||||
boolean showOnMap = selectedGpxFile != null;
|
||||
LineType lineType = newGpxLine.getLineType();
|
||||
saveExistingGpx(gpx, showOnMap, lineType);
|
||||
saveExistingGpx(gpx, showOnMap, lineType, true);
|
||||
}
|
||||
|
||||
private void saveAsGpx(final SaveType saveType) {
|
||||
|
@ -1135,8 +1138,8 @@ public class MeasurementToolFragment extends Fragment {
|
|||
saveGpx(dir, fileName, checked, null, false, null, saveType);
|
||||
}
|
||||
|
||||
private void saveExistingGpx(GPXFile gpx, boolean showOnMap, LineType lineType) {
|
||||
saveGpx(null, null, showOnMap, gpx, true, lineType, null);
|
||||
private void saveExistingGpx(GPXFile gpx, boolean showOnMap, LineType lineType, boolean openTrackActivity) {
|
||||
saveGpx(null, null, showOnMap, gpx, openTrackActivity, lineType, null);
|
||||
}
|
||||
|
||||
private void saveGpx(final File dir,
|
||||
|
@ -1195,6 +1198,7 @@ public class MeasurementToolFragment extends Fragment {
|
|||
toSave = new File(gpx.path);
|
||||
if (measurementLayer != null) {
|
||||
List<WptPt> points = measurementLayer.getMeasurementPoints();
|
||||
if (lineType != null) {
|
||||
switch (lineType) {
|
||||
case ADD_SEGMENT:
|
||||
gpx.addTrkSegment(points);
|
||||
|
@ -1208,6 +1212,9 @@ public class MeasurementToolFragment extends Fragment {
|
|||
gpx.replaceSegment(newGpxLine.getTrkSegment(), segment);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
gpx.addRoutePoints(points);
|
||||
}
|
||||
}
|
||||
if (activity != null) {
|
||||
String res = GPXUtilities.writeGpxFile(toSave, gpx, activity.getMyApplication());
|
||||
|
|
Loading…
Reference in a new issue