Search in sources :

Example 6 with OsmLatLon

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

Example 7 with OsmLatLon

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));
}
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 8 with OsmLatLon

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);
}
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 9 with OsmLatLon

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));
}
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 10 with OsmLatLon

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

Aggregations

OsmLatLon (de.westnordost.osmapi.map.data.OsmLatLon)61 LatLon (de.westnordost.osmapi.map.data.LatLon)33 ArrayList (java.util.ArrayList)24 BoundingBox (de.westnordost.osmapi.map.data.BoundingBox)9 ElementGeometry (de.westnordost.streetcomplete.data.osm.ElementGeometry)9 Date (java.util.Date)8 List (java.util.List)8 OsmQuest (de.westnordost.streetcomplete.data.osm.OsmQuest)7 Note (de.westnordost.osmapi.notes.Note)6 OsmNode (de.westnordost.osmapi.map.data.OsmNode)5 TestQuestType (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType)5 Element (de.westnordost.osmapi.map.data.Element)4 TestQuestType2 (de.westnordost.streetcomplete.data.osm.persist.test.TestQuestType2)4 Node (de.westnordost.osmapi.map.data.Node)3 NoteComment (de.westnordost.osmapi.notes.NoteComment)3 HashMap (java.util.HashMap)3 Point (android.graphics.Point)2 Rect (android.graphics.Rect)2 LongSparseArray (android.util.LongSparseArray)2 QuestGroup (de.westnordost.streetcomplete.data.QuestGroup)2