use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.
the class ElementGeometry method getBounds.
public BoundingBox getBounds() {
List<List<LatLon>> points;
if (polygons != null)
points = polygons;
else if (polylines != null)
points = polylines;
else
return new BoundingBox(center.getLatitude(), center.getLongitude(), center.getLatitude(), center.getLongitude());
Double latMin = null, lonMin = null, latMax = null, lonMax = null;
for (List<LatLon> ps : points) {
for (LatLon p : ps) {
double lat = p.getLatitude();
double lon = p.getLongitude();
if (latMin == null || latMin > lat)
latMin = lat;
if (latMax == null || latMax < lat)
latMax = lat;
if (lonMin == null || lonMin > lon)
lonMin = lon;
if (lonMax == null || lonMax < lon)
lonMax = lon;
}
}
return new BoundingBox(latMin, lonMin, latMax, lonMax);
}
use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.
the class CreateNoteUpload method findAlreadyExistingNoteWithSameAssociatedElement.
private Note findAlreadyExistingNoteWithSameAssociatedElement(final CreateNote newNote) {
SingleElementHandler<Note> handler = new SingleElementHandler<Note>() {
@Override
public void handle(Note oldNote) {
if (newNote.hasAssociatedElement()) {
String firstCommentText = oldNote.comments.get(0).text;
String newNoteRegex = getAssociatedElementRegex(newNote);
if (firstCommentText.matches(newNoteRegex)) {
super.handle(oldNote);
}
}
}
};
final int hideClosedNoteAfter = 7;
osmDao.getAll(new BoundingBox(newNote.position.getLatitude(), newNote.position.getLongitude(), newNote.position.getLatitude(), newNote.position.getLongitude()), handler, 10, hideClosedNoteAfter);
return handler.get();
}
use of de.westnordost.osmapi.map.data.BoundingBox in project StreetComplete by westnordost.
the class SphericalEarthMathTest method testEnclosingBoundingBoxLine.
public void testEnclosingBoundingBoxLine() {
List<LatLon> positions = new ArrayList<>();
positions.add(new OsmLatLon(-4, 0));
positions.add(new OsmLatLon(12, 3));
positions.add(new OsmLatLon(1, 16));
positions.add(new OsmLatLon(0, -6));
BoundingBox bbox = SphericalEarthMath.enclosingBoundingBox(positions);
assertEquals(-4.0, bbox.getMinLatitude());
assertEquals(12.0, bbox.getMaxLatitude());
assertEquals(16.0, bbox.getMaxLongitude());
assertEquals(-6.0, bbox.getMinLongitude());
}
Aggregations