use of de.westnordost.osmapi.map.data.LatLon 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.LatLon 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.LatLon 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.LatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testCenterLineIsNotMiddleOneBeauseItIsSoLong.
public void testCenterLineIsNotMiddleOneBeauseItIsSoLong() {
List<LatLon> positions = new ArrayList<>();
LatLon p0 = new OsmLatLon(0, 0);
LatLon p1 = new OsmLatLon(10, 10);
LatLon p2 = new OsmLatLon(11, 11);
LatLon p3 = new OsmLatLon(12, 12);
positions.addAll(Arrays.asList(p0, p1, p2, p3));
assertThat(SphericalEarthMath.centerLineOf(positions)).containsExactly(p0, p1);
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testEnclosingBoundingBox.
public void testEnclosingBoundingBox() {
LatLon pos = new OsmLatLon(0, 0);
BoundingBox bbox = SphericalEarthMath.enclosingBoundingBox(pos, 5000);
int dist = (int) (Math.sqrt(2) * 5000);
// all four corners of the bbox should be 'radius' away
assertEquals(dist, Math.round(SphericalEarthMath.distance(pos, bbox.getMin())));
assertEquals(dist, Math.round(SphericalEarthMath.distance(pos, bbox.getMax())));
assertEquals(dist, Math.round(SphericalEarthMath.distance(pos, new OsmLatLon(bbox.getMinLatitude(), bbox.getMaxLongitude()))));
assertEquals(dist, Math.round(SphericalEarthMath.distance(pos, new OsmLatLon(bbox.getMaxLatitude(), bbox.getMinLongitude()))));
assertEquals(225, Math.round(SphericalEarthMath.bearing(pos, bbox.getMin())));
assertEquals(45, Math.round(SphericalEarthMath.bearing(pos, bbox.getMax())));
}
Aggregations