Search in sources :

Example 16 with LatLon

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));
}
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 17 with LatLon

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);
}
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 18 with LatLon

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));
}
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 19 with LatLon

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);
}
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 20 with LatLon

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