use of de.westnordost.osmapi.map.data.OsmLatLon 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.OsmLatLon 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())));
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class RoadNameSuggestionsDaoTest method testGetNoNames.
public void testGetNoNames() {
List<LatLon> positions = new ArrayList<>();
positions.add(new OsmLatLon(5, 5));
List<Map<String, String>> result = dao.getNames(positions, 0);
assertEquals(0, result.size());
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class RoadNameSuggestionsDaoTest method createPosOnRoad.
private static ArrayList<LatLon> createPosOnRoad() {
ArrayList<LatLon> roadPositions = new ArrayList<>();
roadPositions.add(new OsmLatLon(0, 0.00005));
return roadPositions;
}
use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.
the class SlippyMapMathTest method testForthAndBack.
public void testForthAndBack() {
LatLon p = new OsmLatLon(53.0, 9.0);
Point tile = SlippyMapMath.enclosingTile(p, 15);
BoundingBox bbox = SlippyMapMath.asBoundingBox(tile, 15);
assertTrue(bbox.getMinLatitude() <= p.getLatitude());
assertTrue(bbox.getMaxLatitude() >= p.getLatitude());
assertTrue(bbox.getMinLongitude() <= p.getLongitude());
assertTrue(bbox.getMaxLongitude() >= p.getLongitude());
Rect r = SlippyMapMath.enclosingTiles(bbox, 15);
BoundingBox bbox2 = SlippyMapMath.asBoundingBox(r, 15);
assertEquals(bbox, bbox2);
}
Aggregations