use of de.westnordost.osmapi.map.data.LatLon 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.LatLon in project StreetComplete by westnordost.
the class ElementGeometryCreator method eliminateDuplicates.
private void eliminateDuplicates(List<LatLon> polyline) {
Iterator<LatLon> it = polyline.iterator();
LatLon previous = null;
while (it.hasNext()) {
LatLon line = it.next();
if (previous == null || line.getLatitude() != previous.getLatitude() || line.getLongitude() != previous.getLongitude()) {
previous = line;
} else {
it.remove();
}
}
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class ElementGeometryDao method createObjectFrom.
static ElementGeometry createObjectFrom(Serializer serializer, Cursor cursor) {
int colGeometryPolygons = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.GEOMETRY_POLYGONS), colGeometryPolylines = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.GEOMETRY_POLYLINES), colCenterLat = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.LATITUDE), colCenterLon = cursor.getColumnIndexOrThrow(ElementGeometryTable.Columns.LONGITUDE);
List<List<LatLon>> polygons = null, polylines = null;
if (!cursor.isNull(colGeometryPolygons)) {
polygons = serializer.toObject(cursor.getBlob(colGeometryPolygons), ArrayList.class);
}
if (!cursor.isNull(colGeometryPolylines)) {
polylines = serializer.toObject(cursor.getBlob(colGeometryPolylines), ArrayList.class);
}
LatLon center = new OsmLatLon(cursor.getDouble(colCenterLat), cursor.getDouble(colCenterLon));
return new ElementGeometry(polylines, polygons, center);
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class NodeDao method createObjectFrom.
@Override
protected Node createObjectFrom(Cursor cursor) {
int colId = cursor.getColumnIndexOrThrow(NodeTable.Columns.ID), colLat = cursor.getColumnIndexOrThrow(NodeTable.Columns.LATITUDE), colLon = cursor.getColumnIndexOrThrow(NodeTable.Columns.LONGITUDE), colVersion = cursor.getColumnIndexOrThrow(NodeTable.Columns.VERSION), colTags = cursor.getColumnIndexOrThrow(NodeTable.Columns.TAGS);
long id = cursor.getLong(colId);
int version = cursor.getInt(colVersion);
LatLon latLon = new OsmLatLon(cursor.getDouble(colLat), cursor.getDouble(colLon));
Map<String, String> tags = null;
if (!cursor.isNull(colTags)) {
tags = serializer.toObject(cursor.getBlob(colTags), HashMap.class);
}
return new OsmNode(id, version, latLon, tags);
}
use of de.westnordost.osmapi.map.data.LatLon in project StreetComplete by westnordost.
the class TangramConstTest method testConvertSingle.
public void testConvertSingle() {
double lng = 10;
double lat = 5;
OsmLatLon pos = new OsmLatLon(lat, lng);
LatLon pos2 = TangramConst.toLatLon(TangramConst.toLngLat(pos));
assertEquals(pos, pos2);
}
Aggregations