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