Search in sources :

Example 11 with LatLon

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));
    }
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry)

Example 12 with LatLon

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));
}
Also used : VisibleQuestListener(de.westnordost.streetcomplete.data.VisibleQuestListener) LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) OsmNode(de.westnordost.osmapi.map.data.OsmNode) OsmElementQuestType(de.westnordost.streetcomplete.data.osm.OsmElementQuestType) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) ElementGeometry(de.westnordost.streetcomplete.data.osm.ElementGeometry) Collection(java.util.Collection) QuestGroup(de.westnordost.streetcomplete.data.QuestGroup) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 13 with LatLon

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);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 14 with LatLon

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)));
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 15 with LatLon

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)));
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Aggregations

LatLon (de.westnordost.osmapi.map.data.LatLon)63 OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)45 ArrayList (java.util.ArrayList)29 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)13 List (java.util.List)12 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)8 OsmNode (de.westnordost.osmapi.map.data.OsmNode)5 HashMap (java.util.HashMap)5 Point (android.graphics.Point)3 PointF (android.graphics.PointF)3 Node (de.westnordost.osmapi.map.data.Node)3 OsmElementQuestType (de.westnordost.streetcomplete.data.osm.OsmElementQuestType)3 LngLat (com.mapzen.tangram.LngLat)2 Point (com.vividsolutions.jts.geom.Point)2 Element (de.westnordost.osmapi.map.data.Element)2 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)2 VisibleQuestListener (de.westnordost.streetcomplete.data.VisibleQuestListener)2 OsmNoteQuestType (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestType)2 Collection (java.util.Collection)2 Map (java.util.Map)2