use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class ElementCreatorTestGeometry method testCreateForSimpleNonAreaWay.
public void testCreateForSimpleNonAreaWay() {
ElementGeometry geom = createCreator().create(W0);
assertNotNull(geom.polylines);
assertEquals(1, geom.polylines.size());
assertEquals(W0.getNodeIds().size(), geom.polylines.get(0).size());
List<LatLon> polyline = geom.polylines.get(0);
for (int i = 0; i < W0.getNodeIds().size(); ++i) {
LatLon shouldBe = nodes.get(W0.getNodeIds().get(i).intValue()).getPosition();
assertEquals(shouldBe, polyline.get(i));
}
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class OsmQuestDownloadTest method testIgnoreBlacklistedPositionsAndInvalidGeometry.
public void testIgnoreBlacklistedPositionsAndInvalidGeometry() {
LatLon blacklistPos = new OsmLatLon(3.0, 4.0);
ElementWithGeometry blacklistElement = new ElementWithGeometry();
blacklistElement.element = new OsmNode(0, 0, blacklistPos, null);
blacklistElement.geometry = new ElementGeometry(blacklistPos);
ElementWithGeometry invalidGeometryElement = new ElementWithGeometry();
invalidGeometryElement.element = new OsmNode(0, 0, new OsmLatLon(1.0, 1.0), null);
invalidGeometryElement.geometry = null;
OsmElementQuestType questType = new ListBackedQuestType(Arrays.asList(blacklistElement, invalidGeometryElement));
setUpOsmQuestDaoMockWithNoPreviousElements();
OsmQuestDownload dl = new OsmQuestDownload(geometryDb, elementDb, osmQuestDao, countryBoundariesFuture);
VisibleQuestListener listener = mock(VisibleQuestListener.class);
dl.setQuestListener(listener);
dl.download(questType, new BoundingBox(0, 0, 1, 1), Collections.singleton(blacklistPos));
verify(listener, times(0)).onQuestsCreated(any(Collection.class), any(QuestGroup.class));
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testCenterLineOfLineIsLine.
public void testCenterLineOfLineIsLine() {
List<LatLon> positions = new ArrayList<>();
LatLon p0 = new OsmLatLon(0, 0);
LatLon p1 = new OsmLatLon(1, 1);
positions.addAll(Arrays.asList(p0, p1));
assertThat(SphericalEarthMath.centerLineOf(positions)).containsExactly(p0, p1);
}
use of de.westnordost.osmapi.map.data.LatLon 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.LatLon in project StreetComplete by westnordost.
the class SphericalEarthMathTest method checkTranslate.
private void checkTranslate(LatLon one, int distance, int angle) {
LatLon two = SphericalEarthMath.translate(one, distance, angle);
assertEquals(distance, Math.round(SphericalEarthMath.distance(one, two)));
assertEquals(angle, Math.round(SphericalEarthMath.bearing(one, two)));
}
Aggregations