KMZ/KML: Export/Import SENSORPOINTs.

Part of #500.
This commit is contained in:
Dennis Guse
2021-12-03 23:44:23 +01:00
parent ba66c45005
commit f8cc257895
10 changed files with 145 additions and 55 deletions
@@ -151,6 +151,9 @@ public class GPXTrackExporter implements TrackExporter {
wroteSegment = true;
writeTrackPoint(trackPoint);
break;
case SENSORPOINT:
//TODO We need somehow to compute the sensor data (mainly sensorDistance if present) and add it to the TRACKPOINT (if no segment followed in between)?
break;
case TRACKPOINT:
if (!wroteSegment) {
// Might happen for older data (pre v3.15.0)
@@ -159,6 +162,8 @@ public class GPXTrackExporter implements TrackExporter {
}
writeTrackPoint(trackPoint);
break;
default:
throw new RuntimeException("Exporting this TrackPoint type is not implemented: " + trackPoint.getType());
}
}
@@ -181,6 +181,7 @@ public class KMLTrackExporter implements TrackExporter {
writeCloseSegment();
wroteSegment = false;
break;
case SENSORPOINT:
case TRACKPOINT:
if (!wroteSegment) {
// Might happen for older data (pre v3.15.0)
@@ -189,6 +190,8 @@ public class KMLTrackExporter implements TrackExporter {
}
writeTrackPoint(trackPoint);
break;
default:
throw new RuntimeException("Exporting this TrackPoint type is not implemented: " + trackPoint.getType());
}
}
@@ -243,7 +243,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
private void onTrackSegmentEnd() {
if (currentSegment.isEmpty()) {
Log.w(TAG, "No locations in current segment.");
Log.w(TAG, "No TrackPoints in current segment.");
return;
}
@@ -256,7 +256,7 @@ public class GpxTrackImporter extends DefaultHandler implements XMLImporter.Trac
private TrackPoint createTrackPoint() throws ParsingException {
Instant parsedTime = null;
Instant parsedTime;
try {
parsedTime = StringUtils.parseTime(time);
} catch (Exception e) {
@@ -295,15 +295,21 @@ public class KmlTrackImporter extends DefaultHandler implements XMLImporter.Trac
TrackPoint trackPoint;
if (i == 0) {
//first
if (location == null) {
trackPoint = TrackPoint.createSegmentStartManualWithTime(time);
} else {
trackPoint = new TrackPoint(TrackPoint.Type.SEGMENT_START_AUTOMATIC, location, time);
}
} else if (i == locationList.size() - 1 && location == null) {
//last
trackPoint = TrackPoint.createSegmentEndWithTime(time);
} else {
trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, location, time);
if (location == null) {
trackPoint = new TrackPoint(TrackPoint.Type.SENSORPOINT, time);
} else {
trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, location, time);
}
}
if (i < sensorSpeedList.size() && sensorSpeedList.get(i) != null) {