Search in sources :

Example 1 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class SphericalEarthMath method enclosedArea.

/**
 * area enclosed in the given bbox in m²
 */
public static double enclosedArea(BoundingBox bbox) {
    LatLon min = bbox.getMin();
    LatLon max = bbox.getMax();
    LatLon minLatMaxLon = new OsmLatLon(min.getLatitude(), max.getLongitude());
    LatLon maxLatMinLon = new OsmLatLon(max.getLatitude(), min.getLongitude());
    return distance(min, minLatMaxLon) * distance(min, maxLatMinLon);
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 2 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class ElementGeometryTest method testFindCenterOfPolyline.

public void testFindCenterOfPolyline() {
    List<List<LatLon>> polylines = new ArrayList<>();
    List<LatLon> polyline = new ArrayList<>();
    LatLon start = new OsmLatLon(-10, -20);
    LatLon finish = new OsmLatLon(10, 20);
    polyline.add(start);
    polyline.add(finish);
    polylines.add(polyline);
    ElementGeometry geom = new ElementGeometry(polylines, null);
    double dist = SphericalEarthMath.distance(start, finish);
    double bearing = SphericalEarthMath.bearing(start, finish);
    LatLon expect = SphericalEarthMath.translate(start, dist / 2, bearing);
    assertEquals(expect, geom.center);
    assertEquals(new BoundingBox(start, finish), geom.getBounds());
}
Also used : LatLon(de.westnordost.osmapi.map.data.LatLon) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) BoundingBox(de.westnordost.osmapi.map.data.BoundingBox) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon)

Example 3 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon 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 4 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon in project StreetComplete by westnordost.

the class CreateNoteUploadTest method createNote.

private Note createNote(CreateNote fitsTo) {
    Note note = new Note();
    note.id = 2;
    note.status = Note.Status.OPEN;
    note.dateCreated = new Date();
    note.position = new OsmLatLon(1, 2);
    NoteComment comment = new NoteComment();
    comment.text = "bla bla";
    if (fitsTo != null) {
        comment.text += CreateNoteUpload.getAssociatedElementString(fitsTo);
    }
    comment.action = NoteComment.Action.OPENED;
    comment.date = new Date();
    note.comments.add(0, comment);
    return note;
}
Also used : NoteComment(de.westnordost.osmapi.notes.NoteComment) Note(de.westnordost.osmapi.notes.Note) OsmLatLon(de.westnordost.osmapi.map.data.OsmLatLon) Date(java.util.Date)

Example 5 with OsmLatLon

use of de.westnordost.osmapi.map.data.OsmLatLon 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)

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