diff --git a/app/src/main/java/net/osmtracker/OSMTracker.java b/app/src/main/java/net/osmtracker/OSMTracker.java
index 14d54b1ea..568811876 100644
--- a/app/src/main/java/net/osmtracker/OSMTracker.java
+++ b/app/src/main/java/net/osmtracker/OSMTracker.java
@@ -29,6 +29,7 @@ public static final class Preferences {
public final static String KEY_OUTPUT_GPX_HDOP_APPROXIMATION = "gpx.hdop.approximation";
public final static String KEY_OUTPUT_DIR_PER_TRACK = "gpx.directory_per_track";
public final static String KEY_OUTPUT_COMPASS = "gpx.compass_heading";
+ public final static String KEY_GPX_FORMAT_SHORT = "gpx.gpx_format_short";
public final static String KEY_UI_PICTURE_SOURCE = "ui.picture.source";
public final static String KEY_UI_BUTTONS_LAYOUT = "ui.buttons.layout";
@@ -75,6 +76,7 @@ public static final class Preferences {
public final static boolean VAL_OUTPUT_GPX_HDOP_APPROXIMATION = false;
public final static boolean VAL_OUTPUT_GPX_OUTPUT_DIR_PER_TRACK = true;
+ public final static boolean VAL_GPX_FORMAT_SHORT = false;
public final static String VAL_UI_PICTURE_SOURCE_CAMERA = "camera";
public final static String VAL_UI_PICTURE_SOURCE_GALLERY = "gallery";
diff --git a/app/src/main/java/net/osmtracker/gpx/ExportToStorageTask.java b/app/src/main/java/net/osmtracker/gpx/ExportToStorageTask.java
index daf13d632..00fd48d5e 100644
--- a/app/src/main/java/net/osmtracker/gpx/ExportToStorageTask.java
+++ b/app/src/main/java/net/osmtracker/gpx/ExportToStorageTask.java
@@ -39,6 +39,9 @@ protected File getExportDirectory(Date startDate) throws ExportTrackException {
boolean directoryPerTrack = prefs.getBoolean(OSMTracker.Preferences.KEY_OUTPUT_DIR_PER_TRACK,
OSMTracker.Preferences.VAL_OUTPUT_GPX_OUTPUT_DIR_PER_TRACK);
+
+ boolean gpxFormatShort = prefs.getBoolean(OSMTracker.Preferences.KEY_GPX_FORMAT_SHORT,
+ OSMTracker.Preferences.VAL_GPX_FORMAT_SHORT);
// Create the path to the directory to which we will be writing
// Trim the directory name, as additional spaces at the end will
diff --git a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java
index b72fa621c..5c0ac9f67 100644
--- a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java
+++ b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java
@@ -290,6 +290,9 @@ private void writeGpxFile(String trackName, String tags, String track_descriptio
String compassOutput = PreferenceManager.getDefaultSharedPreferences(context).getString(
OSMTracker.Preferences.KEY_OUTPUT_COMPASS,
OSMTracker.Preferences.VAL_OUTPUT_COMPASS);
+ boolean gpxFormatShort = PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
+ OSMTracker.Preferences.KEY_GPX_FORMAT_SHORT,
+ OSMTracker.Preferences.VAL_GPX_FORMAT_SHORT);
Log.v(TAG, "write preferences: compass:" + compassOutput);
@@ -315,8 +318,13 @@ private void writeGpxFile(String trackName, String tags, String track_descriptio
writer.write("\t\n");
- writeWayPoints(writer, cWayPoints, accuracyOutput, fillHDOP, compassOutput);
- writeTrackPoints(context.getResources().getString(R.string.gpx_track_name), writer, cTrackPoints, fillHDOP, compassOutput);
+ if (gpxFormatShort) {
+ writeWayPoints_short(writer, cWayPoints, accuracyOutput, fillHDOP, compassOutput);
+ writeTrackPoints_short(context.getResources().getString(R.string.gpx_track_name), writer, cTrackPoints, fillHDOP, compassOutput);
+ } else {
+ writeWayPoints_long(writer, cWayPoints, accuracyOutput, fillHDOP, compassOutput);
+ writeTrackPoints_long(context.getResources().getString(R.string.gpx_track_name), writer, cTrackPoints, fillHDOP, compassOutput);
+ }
writer.write("");
} finally {
@@ -327,7 +335,7 @@ private void writeGpxFile(String trackName, String tags, String track_descriptio
}
/**
- * Iterates on track points and write them.
+ * Iterates on track points and write them. Long version, multiple lines per point.
* @param trackName Name of the track (metadata).
* @param fw Writer to the target file.
* @param c Cursor to track points.
@@ -335,7 +343,7 @@ private void writeGpxFile(String trackName, String tags, String track_descriptio
* @param compass Indicates if and how to write compass heading to the GPX ('none', 'comment', 'extension')
* @throws IOException
*/
- private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fillHDOP, String compass) throws IOException {
+ private void writeTrackPoints_long(String trackName, Writer fw, Cursor c, boolean fillHDOP, String compass) throws IOException {
// Update dialog every 1%
int dialogUpdateThreshold = c.getCount() / 100;
if (dialogUpdateThreshold == 0) {
@@ -376,6 +384,7 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil
}
String buff = "";
+ buff += "\t\t\t\t\t" + String.valueOf(c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) + "\n";
if(! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED))) {
buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED)) + "" + "\n";
}
@@ -402,7 +411,7 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil
}
/**
- * Iterates on way points and write them.
+ * Iterates on way points and write them. Long version, multiple lines per point.
* @param fw Writer to the target file.
* @param c Cursor to way points.
* @param accuracyInfo Constant describing how to include (or not) accuracy info for way points.
@@ -410,7 +419,7 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil
* @param compass Indicates if and how to write compass heading to the GPX ('none', 'comment', 'extension')
* @throws IOException
*/
- private void writeWayPoints(Writer fw, Cursor c, String accuracyInfo, boolean fillHDOP, String compass) throws IOException {
+ private void writeWayPoints_long(Writer fw, Cursor c, String accuracyInfo, boolean fillHDOP, String compass) throws IOException {
// Update dialog every 1%
int dialogUpdateThreshold = c.getCount() / 100;
@@ -504,6 +513,191 @@ private void writeWayPoints(Writer fw, Cursor c, String accuracyInfo, boolean fi
fw.write(out.toString());
+ if (i % dialogUpdateThreshold == 0) {
+ publishProgress((long) dialogUpdateThreshold);
+ }
+ }
+ }
+
+ /**
+ * Iterates on track points and write them. Short version, one line per point.
+ * @param trackName Name of the track (metadata).
+ * @param fw Writer to the target file.
+ * @param c Cursor to track points.
+ * @param fillHDOP Indicates whether fill tag with approximation from location accuracy.
+ * @param compass Indicates if and how to write compass heading to the GPX ('none', 'comment', 'extension')
+ * @throws IOException
+ */
+ private void writeTrackPoints_short(String trackName, Writer fw, Cursor c, boolean fillHDOP, String compass) throws IOException {
+ // Update dialog every 1%
+ int dialogUpdateThreshold = c.getCount() / 100;
+ if (dialogUpdateThreshold == 0) {
+ dialogUpdateThreshold++;
+ }
+
+ fw.write("" + "\n");
+ fw.write("" + CDATA_START + trackName + CDATA_END + "" + "\n");
+ if (fillHDOP) {
+ fw.write(""
+ + CDATA_START
+ + context.getResources().getString(R.string.gpx_hdop_approximation_cmt)
+ + CDATA_END
+ + "" + "\n");
+ }
+ fw.write("" + "\n");
+
+ int i=0;
+ for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(),i++) {
+ StringBuffer out = new StringBuffer();
+ out.append("");
+ if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) {
+ out.append("" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "");
+ }
+ out.append("");
+
+ if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) {
+ out.append("" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "");
+ }
+ if(OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && !c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ out.append(""+CDATA_START+"compass: " +
+ c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))+
+ " compAccuracy: " +
+ c.getLong(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY))+
+ CDATA_END+"");
+ }
+
+ String buff = "";
+ buff += "" + String.valueOf(c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) + "";
+ if(! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED))) {
+ buff += "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED)) + "";
+ }
+ if(OSMTracker.Preferences.VAL_OUTPUT_COMPASS_EXTENSION.equals(compass) && !c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ buff += "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "";
+ buff += "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "";
+ }
+ if(! buff.equals("")) {
+ out.append("");
+ out.append(buff);
+ out.append("");
+ }
+
+ out.append("" + "\n");
+ fw.write(out.toString());
+
+ if (i % dialogUpdateThreshold == 0) {
+ publishProgress((long) dialogUpdateThreshold);
+ }
+ }
+
+ fw.write("" + "\n");
+ fw.write("" + "\n");
+ }
+
+ /**
+ * Iterates on way points and write them. Short version, one line per point.
+ * @param fw Writer to the target file.
+ * @param c Cursor to way points.
+ * @param accuracyInfo Constant describing how to include (or not) accuracy info for way points.
+ * @param fillHDOP Indicates whether fill tag with approximation from location accuracy.
+ * @param compass Indicates if and how to write compass heading to the GPX ('none', 'comment', 'extension')
+ * @throws IOException
+ */
+ private void writeWayPoints_short(Writer fw, Cursor c, String accuracyInfo, boolean fillHDOP, String compass) throws IOException {
+
+ // Update dialog every 1%
+ int dialogUpdateThreshold = c.getCount() / 100;
+ if (dialogUpdateThreshold == 0) {
+ dialogUpdateThreshold++;
+ }
+
+ // Label for meter unit
+ String meterUnit = context.getResources().getString(R.string.various_unit_meters);
+ // Word "accuracy"
+ String accuracy = context.getResources().getString(R.string.various_accuracy);
+
+ int i=0;
+ for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(), i++) {
+ StringBuffer out = new StringBuffer();
+ out.append("");
+ if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) {
+ out.append("" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "");
+ }
+ out.append("");
+
+ String name = c.getString(c.getColumnIndex(TrackContentProvider.Schema.COL_NAME));
+
+ if (! OSMTracker.Preferences.VAL_OUTPUT_ACCURACY_NONE.equals(accuracyInfo) && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) {
+ // Outputs accuracy info for way point
+ if (OSMTracker.Preferences.VAL_OUTPUT_ACCURACY_WPT_NAME.equals(accuracyInfo)) {
+ // Output accuracy with name
+ out.append(""
+ + CDATA_START
+ + name
+ + " (" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + ")"
+ + CDATA_END
+ + "");
+ if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) &&
+ ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ out.append("" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) +
+ " compass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "");
+ }
+ } else if (OSMTracker.Preferences.VAL_OUTPUT_ACCURACY_WPT_CMT.equals(accuracyInfo)) {
+ // Output accuracy in separate tag
+ out.append("" + CDATA_START + name + CDATA_END + "");
+ if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) &&
+ ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ out.append("" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit +
+ " compass heading: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) +
+ "deg compass accuracy: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) +CDATA_END + "");
+ } else {
+ out.append("" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + CDATA_END + "");
+ }
+ } else {
+ // Unknown value for accuracy info, shouldn't occur but who knows ?
+ // See issue #68. Output at least the name just in case.
+ out.append("" + CDATA_START + name + CDATA_END + "");
+ }
+ } else {
+ // No accuracy info requested, or available
+ out.append("" + CDATA_START + name + CDATA_END + "");
+ if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) &&
+ ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ out.append("" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) +
+ " compass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "");
+ }
+ }
+
+ String link = c.getString(c.getColumnIndex(TrackContentProvider.Schema.COL_LINK));
+ if (link != null) {
+ out.append("");
+ out.append("" + link +"");
+ out.append("");
+ }
+
+ if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES))) {
+ out.append("" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES)) + "");
+ }
+
+ if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) {
+ out.append("" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "");
+ }
+
+ if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_EXTENSION.equals(compass) &&
+ ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) {
+ out.append("");
+ out.append("" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "");
+ out.append("" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "");
+ out.append("");
+ }
+
+ out.append("" + "\n");
+
+ fw.write(out.toString());
+
if (i % dialogUpdateThreshold == 0) {
publishProgress((long) dialogUpdateThreshold);
}
diff --git a/app/src/main/res/values/strings-preferences.xml b/app/src/main/res/values/strings-preferences.xml
index de851929a..842240fa7 100644
--- a/app/src/main/res/values/strings-preferences.xml
+++ b/app/src/main/res/values/strings-preferences.xml
@@ -77,6 +77,8 @@
Effective for the next track (not the current one)
One directory per track
Save each track and associated files to its own directory
+ Short format
+ One line per track- or waypoint
Filename for named tracks
Pattern for filename if the track has a name
diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml
index 13c1ec7a9..c1ad0da2f 100644
--- a/app/src/main/res/xml/preferences.xml
+++ b/app/src/main/res/xml/preferences.xml
@@ -1,108 +1,113 @@
+ android:entries="@array/prefs_voicerec_durations"
+ android:entryValues="@array/prefs_voicerec_durations"
+ android:key="voicerec.duration"
+ android:title="@string/prefs_voicerec_duration" />
+ android:title="@string/prefs_sound_enabled" />
-
+ android:title="@string/prefs_use_barometer" />
+
+ android:title="@string/prefs_gps_os_settings" />
+ android:title="@string/prefs_check_gps_startup" />
+ android:title="@string/prefs_gps_ignore_clock" />
+ android:title="@string/prefs_gps_logging_interval" />
+ android:title="@string/prefs_gps_logging_min_distance" />
-
+
-
+ android:title="@string/prefs_output_one_dir_per_track" />
+
+
+ android:key="gpx.accuracy"
+ android:summary="@string/prefs_output_accuracy_summary"
+ android:title="@string/prefs_output_accuracy" />
-
+ android:title="@string/prefs_output_gpx_hdop_approximation" />
+
+ android:title="@string/prefs_ui_picture_source" />
+ android:title="@string/prefs_display_always_on" />
-
+ android:title="@string/prefs_theme" />
+
+ android:title="@string/prefs_displaytrack_osm" />
+ android:title="@string/prefs_ui_orientation" />