Customize GPX export.
This commit is contained in:
parent
699c533789
commit
5d3b9a2dcb
|
|
@ -33,6 +33,8 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
|
|||
private final String TAG = MainActivity.class.getName();
|
||||
private Button exportButton;
|
||||
private WriteToFile writeToFile;
|
||||
private static boolean includeComments = false;
|
||||
private static Double accuracyThreshold = 2.0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
|
|
@ -93,7 +95,10 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
|
|||
new Thread(() -> {
|
||||
GPX gpx = GPX.builder().addTrack(track -> track.addSegment(segment -> {
|
||||
for(LocationEntity location : binder.allLocations()){
|
||||
segment.addPoint(locationToWayPoint(location));
|
||||
WayPoint wayPoint = locationToWayPoint(location);
|
||||
if(wayPoint != null) {
|
||||
segment.addPoint(wayPoint);
|
||||
}
|
||||
}
|
||||
})).build();
|
||||
Log.d(TAG, "Built GPX.");
|
||||
|
|
@ -111,6 +116,17 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
|
|||
}
|
||||
|
||||
private static WayPoint locationToWayPoint(LocationEntity location) {
|
||||
if(accuracyThreshold != null)
|
||||
{
|
||||
if(location.accuracy == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if(location.accuracy > accuracyThreshold) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
WayPoint.Builder builder = WayPoint.builder()
|
||||
.lat(location.latitude)
|
||||
.lon(location.longitude)
|
||||
|
|
@ -128,6 +144,7 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
|
|||
builder.ele(location.altitude);
|
||||
}
|
||||
|
||||
if(includeComments) {
|
||||
StringBuilder commentBuilder = new StringBuilder();
|
||||
|
||||
if (location.isMock) {
|
||||
|
|
@ -151,6 +168,7 @@ public class MainActivity extends AppCompatActivity implements LocationListener,
|
|||
}
|
||||
|
||||
builder.cmt(commentBuilder.toString());
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue