Search in sources :

Example 11 with OsmLatLon

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

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())));
}
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)

Example 13 with OsmLatLon

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());
}
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) Map(java.util.Map) HashMap(java.util.HashMap)

Example 14 with OsmLatLon

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

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