Clean up formatting of numbers in gpx export.

Addresses issue #299 and ensures Latitude and Longitude are formatted
correctly as well.
This commit is contained in:
Jared Casper
2011-02-09 10:25:28 -08:00
parent ddafdcf392
commit 58e3c0604d
3 changed files with 22 additions and 11 deletions
@@ -75,12 +75,17 @@ public class GpxTrackWriterTest extends TrackFormatWriterTest {
* Asserts that the given tag describes the given location.
*/
private void assertTagMatchesLocation(Element tag, Location loc) {
assertEquals(Double.toString(loc.getLatitude()), tag.getAttribute("lat"));
assertEquals(Double.toString(loc.getLongitude()), tag.getAttribute("lon"));
assertEquals(
Location.convert(loc.getLatitude(), GpxTrackWriter.LATLONG_FORMAT),
tag.getAttribute("lat"));
assertEquals(
Location.convert(loc.getLongitude(), GpxTrackWriter.LATLONG_FORMAT),
tag.getAttribute("lon"));
assertEquals(
GpxTrackWriter.TIMESTAMP_FORMAT.format(new Date(loc.getTime())),
getChildTextValue(tag, "time"));
assertEquals(Double.toString(loc.getAltitude()),
assertEquals(
GpxTrackWriter.ELEVATION_FORMAT.format(loc.getAltitude()),
getChildTextValue(tag, "ele"));
}
}
@@ -81,7 +81,7 @@ public abstract class TrackFormatWriterTest extends AndroidTestCase {
protected void populateLocations(MyTracksLocation... locs) {
for (int i = 0; i < locs.length; i++) {
MyTracksLocation loc = locs[i];
loc.setAltitude(i * 1000);
loc.setAltitude(i * 5000000);
loc.setLatitude(i);
loc.setLongitude(-i);
loc.setTime(10000000 + i * 1000);