(MAX_POINTS_PER_UPLOAD);
progressIndicator.setProgressMessage(R.string.progress_message_reading_track);
Location lastLocation = null;
@@ -274,16 +282,16 @@ public class SendToFusionTables implements Runnable {
if (totalLocationsRead % 100 == 0) {
updateProgress();
}
-
+
Location loc = providerUtils.createLocation(locationsCursor);
locations.add(loc);
-
+
if (totalLocationsRead == 0) {
// Put a marker at the first point of the first valid segment:
- String name = track.getName() + " " + context.getString(R.string.start);
- createNewPoint(name, "", loc, "large_green");
+ String name = track.getName() + " " + context.getString(R.string.start);
+ createNewPoint(name, "", loc, MARKER_TYPE_START);
}
-
+
// Add to the elevation profile.
if (loc != null && MyTracksUtils.isValidLocation(loc)) {
// All points go into the smoothing buffer...
@@ -293,43 +301,41 @@ public class SendToFusionTables implements Runnable {
double dist = lastLocation.distanceTo(loc);
totalDistance += dist;
}
-
+
// ...but only a few points are really used to keep the url short.
if (totalLocationsRead % elevationSamplingFrequency == 0) {
distances.add(totalDistance);
elevations.add(elevationBuffer.getAverage());
}
}
-
+
// If the location was not valid, it's a segment split, so make sure the
// distance between the previous segment and the new one is not accounted
// for in the next iteration.
lastLocation = loc;
-
+
// Every now and then, upload the accumulated points
- if (totalLocationsRead % MAX_POINTS_PER_UPLOAD
- == MAX_POINTS_PER_UPLOAD - 1) {
+ if (totalLocationsRead % MAX_POINTS_PER_UPLOAD == MAX_POINTS_PER_UPLOAD - 1) {
if (!prepareAndUploadPoints(track, locations)) {
return false;
}
}
-
+
totalLocationsRead++;
} while (locationsCursor.moveToNext());
-
+
// Do a final upload with what's left
if (!prepareAndUploadPoints(track, locations)) {
return false;
}
-
+
// Put an end marker at the last point of the last valid segment:
if (lastLocation != null) {
track.setDescription("" + originalDescription + "
"
- + stringUtils.generateTrackDescription(
- track, distances, elevations)
+ + stringUtils.generateTrackDescription(track, distances, elevations)
+ "
");
- String name = track.getName() + " " + context.getString(R.string.end);
- return createNewPoint(name, track.getDescription(), lastLocation, "large_red");
+ String name = track.getName() + " " + context.getString(R.string.end);
+ return createNewPoint(name, track.getDescription(), lastLocation, MARKER_TYPE_END);
}
return true;
@@ -337,7 +343,7 @@ public class SendToFusionTables implements Runnable {
locationsCursor.close();
}
}
-
+
/**
* Appends the given location to the string in the format:
* longitude,latitude[,altitude]
@@ -346,14 +352,14 @@ public class SendToFusionTables implements Runnable {
* @param builder the string builder to use
*/
private void appendCoordinate(Location location, StringBuilder builder) {
- builder
- .append(location.getLongitude())
- .append(",")
- .append(location.getLatitude());
- if (location.hasAltitude()) {
- builder.append(",");
- builder.append(location.getAltitude());
- }
+ builder
+ .append(location.getLongitude())
+ .append(",")
+ .append(location.getLatitude());
+ if (location.hasAltitude()) {
+ builder.append(",");
+ builder.append(location.getAltitude());
+ }
}
/**
@@ -376,29 +382,29 @@ public class SendToFusionTables implements Runnable {
* @return the kml.
*/
private String getKmlLineString(Track track) {
- StringBuilder builder = new StringBuilder("");
- for (Location location : track.getLocations()) {
- appendCoordinate(location, builder);
- builder.append(' ');
- }
- builder.append("");
- return builder.toString();
+ StringBuilder builder = new StringBuilder("");
+ for (Location location : track.getLocations()) {
+ appendCoordinate(location, builder);
+ builder.append(' ');
+ }
+ builder.append("");
+ return builder.toString();
}
private boolean prepareAndUploadPoints(Track track, List locations) {
progressIndicator.setProgressMessage(R.string.progress_message_preparing_track);
updateProgress();
-
+
int numLocations = locations.size();
if (numLocations < 2) {
Log.d(MyTracksConstants.TAG, "Not preparing/uploading too few points");
totalLocationsUploaded += numLocations;
return true;
}
-
+
// Prepare/pre-process the points
ArrayList