From a3ef29696f6fc1bd7b110b3ab3822a7b1839fbad Mon Sep 17 00:00:00 2001 From: Hans-Joachim Zimmer Date: Tue, 14 Jul 2020 22:55:34 +0200 Subject: [PATCH 1/3] Changed GPX format: use only one line per TRKPT/WPT. This creates smaller files and facilitates scripted postprocessing or parsing --- .../net/osmtracker/gpx/ExportTrackTask.java | 94 +++++++++---------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java index b72fa621c..594c4a53e 100644 --- a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java +++ b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java @@ -342,54 +342,54 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil dialogUpdateThreshold++; } - fw.write("\t" + "" + "\n"); - fw.write("\t\t" + "" + CDATA_START + trackName + CDATA_END + "" + "\n"); + fw.write("" + "\n"); + fw.write("" + CDATA_START + trackName + CDATA_END + "" + "\n"); if (fillHDOP) { - fw.write("\t\t" + "" + fw.write("" + CDATA_START + context.getResources().getString(R.string.gpx_hdop_approximation_cmt) + CDATA_END + "" + "\n"); } - fw.write("\t\t" + "" + "\n"); + fw.write("" + "\n"); int i=0; for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(),i++) { StringBuffer out = new StringBuffer(); - out.append("\t\t\t" + "" + "\n"); + + "lon=\"" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_LONGITUDE)) + "\">"); if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) { - out.append("\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "" + "\n"); + out.append("" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + ""); } - out.append("\t\t\t\t" + "" + "\n"); + out.append(""); if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) { - out.append("\t\t\t\t" + "" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "" + "\n"); + 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("\t\t\t\t" + ""+CDATA_START+"compass: " + + out.append(""+CDATA_START+"compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))+ - "\n\t\t\t\t\tcompAccuracy: " + + " compAccuracy: " + c.getLong(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY))+ - CDATA_END+""+"\n"); + CDATA_END+""); } String buff = ""; if(! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED))) { - buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED)) + "" + "\n"; + 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 += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "" + "\n"; - buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "" + "\n"; + buff += "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + ""; + buff += "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + ""; } if(! buff.equals("")) { - out.append("\t\t\t\t" + "\n"); + out.append(""); out.append(buff); - out.append("\t\t\t\t" + "\n"); + out.append(""); } - out.append("\t\t\t" + "" + "\n"); + out.append("" + "\n"); fw.write(out.toString()); if (i % dialogUpdateThreshold == 0) { @@ -397,8 +397,8 @@ private void writeTrackPoints(String trackName, Writer fw, Cursor c, boolean fil } } - fw.write("\t\t" + "" + "\n"); - fw.write("\t" + "" + "\n"); + fw.write("" + "\n"); + fw.write("" + "\n"); } /** @@ -426,13 +426,13 @@ private void writeWayPoints(Writer fw, Cursor c, String accuracyInfo, boolean fi int i=0; for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(), i++) { StringBuffer out = new StringBuffer(); - out.append("\t" + "" + "\n"); + + "lon=\"" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_LONGITUDE)) + "\">"); if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) { - out.append("\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "" + "\n"); + out.append("" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + ""); } - out.append("\t\t" + "" + "\n"); + out.append(""); String name = c.getString(c.getColumnIndex(TrackContentProvider.Schema.COL_NAME)); @@ -440,67 +440,67 @@ private void writeWayPoints(Writer fw, Cursor c, String accuracyInfo, boolean fi // Outputs accuracy info for way point if (OSMTracker.Preferences.VAL_OUTPUT_ACCURACY_WPT_NAME.equals(accuracyInfo)) { // Output accuracy with name - out.append("\t\t" + "" + out.append("" + CDATA_START + name + " (" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + ")" + CDATA_END - + "" + "\n"); + + ""); if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { - out.append("\t\t"+ "" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + - "\n\t\t\tcompass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "\n"); + 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("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + 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("\t\t" + "" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + - "\n\t\t\t compass heading: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + - "deg\n\t\t\t compass accuracy: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) +CDATA_END + "" + "\n"); + 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("\t\t" + "" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + CDATA_END + "" + "\n"); + 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("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + out.append("" + CDATA_START + name + CDATA_END + ""); } } else { // No accuracy info requested, or available - out.append("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + 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("\t\t"+ "" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + - "\n\t\t\tcompass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "\n"); + 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("\t\t" + "" + "\n"); - out.append("\t\t\t" + "" + link +"\n"); - out.append("\t\t" + "" + "\n"); + out.append(""); + out.append("" + link +""); + out.append(""); } if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES))) { - out.append("\t\t" + "" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES)) + "" + "\n"); + out.append("" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES)) + ""); } if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) { - out.append("\t\t" + "" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "" + "\n"); + 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("\t\t\n"); - out.append("\t\t\t"+ "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "\n"); - out.append("\t\t\t" + "" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "" + "\n"); - out.append("\t\t\n"); + 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("\t" + "" + "\n"); + out.append("" + "\n"); fw.write(out.toString()); From 9d17835d003c5f88b2d8f69725c58ad6ab770ea0 Mon Sep 17 00:00:00 2001 From: Hans-Joachim Zimmer Date: Wed, 15 Jul 2020 11:23:33 +0200 Subject: [PATCH 2/3] Option to choose btw. long/short GPX format --- .../main/java/net/osmtracker/OSMTracker.java | 2 + .../osmtracker/gpx/ExportToStorageTask.java | 3 + .../net/osmtracker/gpx/ExportTrackTask.java | 204 +++++++++++++++++- .../main/res/values/strings-preferences.xml | 2 + app/src/main/res/xml/preferences.xml | 105 ++++----- 5 files changed, 260 insertions(+), 56 deletions(-) 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 594c4a53e..e99aac4fc 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,191 @@ 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. + * @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_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) { + dialogUpdateThreshold++; + } + + fw.write("\t" + "" + "\n"); + fw.write("\t\t" + "" + CDATA_START + trackName + CDATA_END + "" + "\n"); + if (fillHDOP) { + fw.write("\t\t" + "" + + CDATA_START + + context.getResources().getString(R.string.gpx_hdop_approximation_cmt) + + CDATA_END + + "" + "\n"); + } + fw.write("\t\t" + "" + "\n"); + + int i=0; + for(c.moveToFirst(); !c.isAfterLast(); c.moveToNext(),i++) { + StringBuffer out = new StringBuffer(); + out.append("\t\t\t" + "" + "\n"); + if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) { + out.append("\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "" + "\n"); + } + out.append("\t\t\t\t" + "" + "\n"); + + if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) { + out.append("\t\t\t\t" + "" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "" + "\n"); + } + if(OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && !c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + out.append("\t\t\t\t" + ""+CDATA_START+"compass: " + + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))+ + "\n\t\t\t\t\tcompAccuracy: " + + c.getLong(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY))+ + CDATA_END+""+"\n"); + } + + String buff = ""; + if(! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED))) { + buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_SPEED)) + "" + "\n"; + } + if(OSMTracker.Preferences.VAL_OUTPUT_COMPASS_EXTENSION.equals(compass) && !c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "" + "\n"; + buff += "\t\t\t\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "" + "\n"; + } + if(! buff.equals("")) { + out.append("\t\t\t\t" + "\n"); + out.append(buff); + out.append("\t\t\t\t" + "\n"); + } + + out.append("\t\t\t" + "" + "\n"); + fw.write(out.toString()); + + if (i % dialogUpdateThreshold == 0) { + publishProgress((long) dialogUpdateThreshold); + } + } + + fw.write("\t\t" + "" + "\n"); + fw.write("\t" + "" + "\n"); + } + + /** + * 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. + * @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_long(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("\t" + "" + "\n"); + if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION))) { + out.append("\t\t" + "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ELEVATION)) + "" + "\n"); + } + out.append("\t\t" + "" + "\n"); + + 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("\t\t" + "" + + CDATA_START + + name + + " (" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + ")" + + CDATA_END + + "" + "\n"); + if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && + ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + out.append("\t\t"+ "" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + + "\n\t\t\tcompass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "\n"); + } + } else if (OSMTracker.Preferences.VAL_OUTPUT_ACCURACY_WPT_CMT.equals(accuracyInfo)) { + // Output accuracy in separate tag + out.append("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && + ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + out.append("\t\t" + "" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + + "\n\t\t\t compass heading: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + + "deg\n\t\t\t compass accuracy: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) +CDATA_END + "" + "\n"); + } else { + out.append("\t\t" + "" + CDATA_START + accuracy + ": " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) + meterUnit + CDATA_END + "" + "\n"); + } + } 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("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + } + } else { + // No accuracy info requested, or available + out.append("\t\t" + "" + CDATA_START + name + CDATA_END + "" + "\n"); + if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_COMMENT.equals(compass) && + ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + out.append("\t\t"+ "" + CDATA_START + "compass: " + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + + "\n\t\t\tcompass accuracy: " + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + CDATA_END + "\n"); + } + } + + String link = c.getString(c.getColumnIndex(TrackContentProvider.Schema.COL_LINK)); + if (link != null) { + out.append("\t\t" + "" + "\n"); + out.append("\t\t\t" + "" + link +"\n"); + out.append("\t\t" + "" + "\n"); + } + + if (! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES))) { + out.append("\t\t" + "" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_NBSATELLITES)) + "" + "\n"); + } + + if(fillHDOP && ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY))) { + out.append("\t\t" + "" + (c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_ACCURACY)) / OSMTracker.HDOP_APPROXIMATION_FACTOR) + "" + "\n"); + } + + if (OSMTracker.Preferences.VAL_OUTPUT_COMPASS_EXTENSION.equals(compass) && + ! c.isNull(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS))) { + out.append("\t\t\n"); + out.append("\t\t\t"+ "" + c.getDouble(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS)) + "\n"); + out.append("\t\t\t" + "" + c.getInt(c.getColumnIndex(TrackContentProvider.Schema.COL_COMPASS_ACCURACY)) + "" + "\n"); + out.append("\t\t\n"); + } + + out.append("\t" + "" + "\n"); + + 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. @@ -335,7 +527,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_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) { @@ -402,7 +594,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. 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. @@ -410,7 +602,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_short(Writer fw, Cursor c, String accuracyInfo, boolean fillHDOP, String compass) throws IOException { // Update dialog every 1% int dialogUpdateThreshold = c.getCount() / 100; 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" /> From b1cc5407502f9978fe62cddba56496d37f0a9818 Mon Sep 17 00:00:00 2001 From: Hans-Joachim Zimmer Date: Sun, 19 Jul 2020 08:43:44 +0200 Subject: [PATCH 3/3] fix regression: Include tag for trackpoints in GPX --- app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java index e99aac4fc..5c0ac9f67 100644 --- a/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java +++ b/app/src/main/java/net/osmtracker/gpx/ExportTrackTask.java @@ -384,6 +384,7 @@ private void writeTrackPoints_long(String trackName, Writer fw, Cursor c, boolea } 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"; } @@ -568,6 +569,7 @@ private void writeTrackPoints_short(String trackName, Writer fw, Cursor c, boole } 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)) + ""; }