@@ -51,14 +51,14 @@ class Exporter extends Thread {
51
51
52
52
private final Track track ;
53
53
private final ExportingTask exportingTask ;
54
- private boolean exportKML = true ;
55
- private boolean exportGPX = true ;
56
- private boolean exportTXT = true ;
57
- private String saveIntoFolder = "/" ;
58
- private double altitudeManualCorrection = 0 ;
59
- private boolean egmAltitudeCorrection = false ;
60
- private int getPrefKMLAltitudeMode = 0 ;
61
- private int getPrefGPXVersion = 0 ;
54
+ private final boolean exportKML ;
55
+ private final boolean exportGPX ;
56
+ private final boolean exportTXT ;
57
+ private final String saveIntoFolder ;
58
+ private final double altitudeManualCorrection ;
59
+ private final boolean egmAltitudeCorrection ;
60
+ private final int getPrefKMLAltitudeMode ;
61
+ private final int getPrefGPXVersion ;
62
62
private boolean txtFirstTrackpointFlag = true ;
63
63
64
64
private DocumentFile kmlFile ;
@@ -152,20 +152,6 @@ private boolean tryToInitFiles(String fName) {
152
152
exportingTask .setStatus (ExportingTask .STATUS_ENDED_FAILED );
153
153
return false ;
154
154
}
155
-
156
- // Check if all the files are writable:
157
- // try {
158
- // if ((exportGPX && !(gpxFile.createNewFile())) || (exportKML && !(kmlFile.createNewFile())) || (exportTXT && !(txtFile.createNewFile()))) {
159
- // Log.w("myApp", "[#] Exporter.java - Unable to write the file " + fName);
160
- // return false;
161
- // }
162
- // } catch (SecurityException e) {
163
- // Log.w("myApp", "[#] Exporter.java - Unable to write the file: SecurityException");
164
- // return false;
165
- // } catch (IOException e) {
166
- // Log.w("myApp", "[#] Exporter.java - Unable to write the file: IOException");
167
- // return false;
168
- // }
169
155
return true ;
170
156
}
171
157
@@ -228,15 +214,6 @@ public void run() {
228
214
elements_total = track .getNumberOfLocations () + track .getNumberOfPlacemarks ();
229
215
long startTime = System .currentTimeMillis ();
230
216
231
- // ------------------------------------------------- Create the Directory tree if not exist
232
-
233
- // if (!sd.exists()) {
234
- // if (!sd.mkdir()) {
235
- // Log.w("myApp", "[#] Exporter.java - UNABLE TO CREATE THE FOLDER");
236
- // exportingTask.setStatus(ExportingTask.STATUS_ENDED_FAILED);
237
- // return;
238
- // }
239
- // }
240
217
// ----------------------------------------------------------------------------------------
241
218
242
219
if (track == null ) {
@@ -276,19 +253,6 @@ public void run() {
276
253
//final String newLine = System.getProperty("line.separator"); //\n\r
277
254
final String newLine = "\r \n " ;
278
255
279
- // Verify if Folder exists
280
- // sd = new File(saveIntoFolder);
281
- // boolean success = true;
282
- // if (!sd.exists()) {
283
- // success = sd.mkdir();
284
- // }
285
- // if (!success) {
286
- // Log.w("myApp", "[#] Exporter.java - Unable to sd.mkdir");
287
- // exportingTask.setStatus(ExportingTask.STATUS_ENDED_FAILED);
288
- // //EventBus.getDefault().post(new EventBusMSGNormal(EventBusMSG.TOAST_UNABLE_TO_WRITE_THE_FILE, track.getId()));
289
- // return;
290
- // }
291
-
292
256
// If the file is not writable abort exportation:
293
257
boolean fileWritable = tryToInitFiles (gpsApp .getFileName (track )); // Try to use the name with the description
294
258
//if (!fileWritable) fileWritable = tryToInitFiles(track.getName()); // else try to use the name without description
@@ -404,6 +368,9 @@ public void run() {
404
368
gpxBW .write ("<!-- Avg Speed = " + phdSpeedAvg .value + " | " + phdSpeedAvgMoving .value + " " + phdSpeedAvg .um + " -->" + newLine );
405
369
if (!phdOverallDirection .value .isEmpty ())
406
370
gpxBW .write ("<!-- Direction = " + phdOverallDirection .value + phdOverallDirection .um + " -->" + newLine );
371
+ if (track .getEstimatedTrackType () != NOT_AVAILABLE )
372
+ gpxBW .write ("<!-- Activity = " + Track .ACTIVITY_DESCRIPTION [track .getEstimatedTrackType ()] + " -->" + newLine );
373
+
407
374
gpxBW .write (newLine );
408
375
}
409
376
@@ -415,8 +382,20 @@ public void run() {
415
382
+ " xsi:schemaLocation=\" http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd\" >" + newLine );
416
383
gpxBW .write ("<name>GPS Logger " + track .getName () + "</name>" + newLine );
417
384
if (!track .getDescription ().isEmpty ()) gpxBW .write ("<desc>" + stringToXML (track .getDescription ()) + "</desc>" + newLine );
418
- gpxBW .write ("<time>" + dfdtGPX_NoMillis .format (creationTime ) + "</time>" + newLine + newLine );
385
+ gpxBW .write ("<time>" + dfdtGPX_NoMillis .format (creationTime ) + "</time>" + newLine );
386
+ if (track .getEstimatedTrackType () != NOT_AVAILABLE ) gpxBW .write ("<keywords>" + Track .ACTIVITY_DESCRIPTION [track .getEstimatedTrackType ()] + "</keywords>" + newLine );
387
+ if ((track .getValidMap () != 0 )
388
+ && (track .getLatitudeMin () != NOT_AVAILABLE ) && (track .getLongitudeMin () != NOT_AVAILABLE )
389
+ && (track .getLatitudeMax () != NOT_AVAILABLE ) && (track .getLongitudeMax () != NOT_AVAILABLE )) {
390
+ gpxBW .write ("<bounds minlat=\" " + String .format (Locale .US , "%.8f" , track .getLatitudeMin ())
391
+ + "\" minlon=\" " + String .format (Locale .US , "%.8f" , track .getLongitudeMin ())
392
+ + "\" maxlat=\" " + String .format (Locale .US , "%.8f" , track .getLatitudeMax ())
393
+ + "\" maxlon=\" " + String .format (Locale .US , "%.8f" , track .getLongitudeMax ())
394
+ + "\" />" + newLine );
395
+ }
396
+ gpxBW .write (newLine );
419
397
}
398
+
420
399
if (getPrefGPXVersion == GPX1_1 ) { // GPX 1.1
421
400
gpxBW .write ("<gpx version=\" 1.1\" " + newLine
422
401
+ " creator=\" BasicAirData GPS Logger " + versionName + "\" " + newLine
@@ -430,6 +409,16 @@ public void run() {
430
409
gpxBW .write (" <name>GPS Logger " + track .getName () + "</name>" + newLine );
431
410
if (!track .getDescription ().isEmpty ()) gpxBW .write (" <desc>" + stringToXML (track .getDescription ()) + "</desc>" + newLine );
432
411
gpxBW .write (" <time>" + dfdtGPX_NoMillis .format (creationTime ) + "</time>" + newLine );
412
+ if (track .getEstimatedTrackType () != NOT_AVAILABLE ) gpxBW .write (" <keywords>" + Track .ACTIVITY_DESCRIPTION [track .getEstimatedTrackType ()] + "</keywords>" + newLine );
413
+ if ((track .getValidMap () != 0 )
414
+ && (track .getLatitudeMin () != NOT_AVAILABLE ) && (track .getLongitudeMin () != NOT_AVAILABLE )
415
+ && (track .getLatitudeMax () != NOT_AVAILABLE ) && (track .getLongitudeMax () != NOT_AVAILABLE )) {
416
+ gpxBW .write (" <bounds minlat=\" " + String .format (Locale .US , "%.8f" , track .getLatitudeMin ())
417
+ + "\" minlon=\" " + String .format (Locale .US , "%.8f" , track .getLongitudeMin ())
418
+ + "\" maxlat=\" " + String .format (Locale .US , "%.8f" , track .getLatitudeMax ())
419
+ + "\" maxlon=\" " + String .format (Locale .US , "%.8f" , track .getLongitudeMax ())
420
+ + "\" />" + newLine );
421
+ }
433
422
gpxBW .write ("</metadata>" + newLine + newLine );
434
423
}
435
424
}
0 commit comments