forked from upstream-mirrors/OpenTracks
EGM2008 offset lookup for negative longitudes was wrong.
This commit is contained in:
@@ -142,7 +142,7 @@ public class EGM2008UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void data_Berlin() throws IOException {
|
||||
public void data_Berlin_Germany_() throws IOException {
|
||||
// given
|
||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(0));
|
||||
trackPoint.setLatitude(52.530644);
|
||||
@@ -157,7 +157,7 @@ public class EGM2008UtilsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void data_Berlin_Caching() throws IOException {
|
||||
public void data_Berlin_Germany_Caching() throws IOException {
|
||||
// given
|
||||
TrackPoint trackPoint1 = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(0));
|
||||
trackPoint1.setLatitude(52.530644);
|
||||
@@ -176,6 +176,22 @@ public class EGM2008UtilsTest {
|
||||
assertNotEquals(altitude_egm2008.correctAltitude(trackPoint1.getLocation()), altitude_egm2008.correctAltitude(trackPoint2.getLocation()), 0.0001);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void data_Seattle_USA() throws IOException {
|
||||
// given
|
||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(0));
|
||||
|
||||
trackPoint.setLatitude(47.63153);
|
||||
trackPoint.setLongitude(-122.30938);
|
||||
trackPoint.setAltitude(0);
|
||||
|
||||
// when
|
||||
EGM2008Utils.EGM2008Correction altitude_egm2008 = EGM2008Utils.createCorrection(context, trackPoint.getLocation());
|
||||
|
||||
// then
|
||||
assertEquals(22.99, altitude_egm2008.correctAltitude(trackPoint.getLocation()), MAX_BILINEAR_ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void data_MaxUndulation() throws IOException {
|
||||
// given
|
||||
@@ -191,6 +207,7 @@ public class EGM2008UtilsTest {
|
||||
assertEquals(-85.824, altitude_egm2008.correctAltitude(trackPoint.getLocation()), MAX_BILINEAR_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getIndices() {
|
||||
TrackPoint trackPoint = new TrackPoint(TrackPoint.Type.TRACKPOINT, Instant.ofEpochMilli(0));
|
||||
@@ -208,7 +225,7 @@ public class EGM2008UtilsTest {
|
||||
|
||||
trackPoint.setLatitude(-90);
|
||||
trackPoint.setLongitude(-180);
|
||||
assertEquals(new EGM2008Utils.Indices(2160, 0), EGM2008Utils.getIndices(trackPoint.getLocation()));
|
||||
assertEquals(new EGM2008Utils.Indices(2160, 2160), EGM2008Utils.getIndices(trackPoint.getLocation()));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -65,7 +65,7 @@ public class EGM2008Utils {
|
||||
if (location.getLongitude() >= 0) {
|
||||
longitude = location.getLongitude();
|
||||
} else {
|
||||
longitude = 180 + Math.abs(location.getLongitude());
|
||||
longitude = 360 + location.getLongitude();
|
||||
}
|
||||
int longitudeIndex = (int) (longitude * RESOLUTION_IN_MINUTES);
|
||||
|
||||
@@ -172,5 +172,13 @@ public class EGM2008Utils {
|
||||
public int hashCode() {
|
||||
return Objects.hash(latitudeIndex, longitudeIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Indices{" +
|
||||
"latitudeIndex=" + latitudeIndex +
|
||||
", longitudeIndex=" + longitudeIndex +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user