use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method checkHamburgTo.
private void checkHamburgTo(double lat, double lon, int dist, int angle, Integer angle2) {
LatLon t = new OsmLatLon(lat, lon);
assertEquals(dist, Math.round(SphericalEarthMath.distance(HH, t) / 1000));
assertEquals(dist, Math.round(SphericalEarthMath.distance(t, HH) / 1000));
assertEquals(angle, Math.round(SphericalEarthMath.bearing(HH, t)));
if (angle2 != null)
assertEquals((int) angle2, Math.round(SphericalEarthMath.finalBearing(HH, t)));
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testNoCenterLineForPoint.
public void testNoCenterLineForPoint() {
List<LatLon> positions = new ArrayList<>();
positions.add(new OsmLatLon(0, 0));
assertEquals(null, SphericalEarthMath.centerLineOf(positions));
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testCenterLineIsTheMiddleOne.
public void testCenterLineIsTheMiddleOne() {
List<LatLon> positions = new ArrayList<>();
LatLon p0 = new OsmLatLon(0, 0);
LatLon p1 = new OsmLatLon(1, 1);
LatLon p2 = new OsmLatLon(2, 2);
LatLon p3 = new OsmLatLon(3, 3);
positions.addAll(Arrays.asList(p0, p1, p2, p3));
assertThat(SphericalEarthMath.centerLineOf(positions)).containsExactly(p1, p2);
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testDistanceOfPolylineForThreePositions.
public void testDistanceOfPolylineForThreePositions() {
List<LatLon> positions = new ArrayList<>();
LatLon p0 = new OsmLatLon(0, 0);
LatLon p1 = new OsmLatLon(1, 1);
LatLon p2 = new OsmLatLon(2, 2);
positions.addAll(Arrays.asList(p0, p1, p2));
assertEquals(SphericalEarthMath.distance(p0, p1) + SphericalEarthMath.distance(p1, p2), SphericalEarthMath.distance(positions));
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testTranslateOverBoundaries.
public void testTranslateOverBoundaries() {
// cross 180th meridian both ways
checkTranslate(new OsmLatLon(0, 179.9999999), 1000, 90);
checkTranslate(new OsmLatLon(0, -179.9999999), 1000, 270);
// cross north pole and come out on the other side
// should come out at 45,-90
int quarterOfEarth = (int) (Math.PI / 2 * SphericalEarthMath.EARTH_RADIUS);
checkTranslate(new OsmLatLon(+45, 90), quarterOfEarth, 0);
// should come out at -45,-90
checkTranslate(new OsmLatLon(-45, 90), quarterOfEarth, 180);
}
Aggregations