use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.
the class TangramConst method toLatLon.
public static List<List<LatLon>> toLatLon(List<List<LngLat>> positionLists) {
List<List<LatLon>> result = new ArrayList<>(positionLists.size());
for (List<LngLat> positions : positionLists) {
List<LatLon> resultPositions = new ArrayList<>(positions.size());
for (LngLat pos : positions) {
resultPositions.add(toLatLon(pos));
}
result.add(resultPositions);
}
return result;
}
use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.
the class MapFragment method updateAccuracy.
private void updateAccuracy() {
if (accuracyMarker != null && lastLocation != null && accuracyMarker.isVisible()) {
LngLat pos = new LngLat(lastLocation.getLongitude(), lastLocation.getLatitude());
float size = meters2Pixels(pos, lastLocation.getAccuracy());
accuracyMarker.setStylingFromString("{ style: 'points', color: 'white', size: [" + size + "px, " + size + "px], order: 2000, flat: true, collide: false }");
}
}
use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.
the class QuestsMapFragment method zoomAndMoveToContain.
private void zoomAndMoveToContain(ElementGeometry g) {
// never zoom back further than 17.5
previousZoom = Math.max(17.5f, controller.getZoom());
float targetZoom = getMaxZoomThatContains(g);
if (Float.isNaN(targetZoom) || targetZoom > MAX_QUEST_ZOOM) {
targetZoom = MAX_QUEST_ZOOM;
} else {
// zoom out a bit
targetZoom -= 0.4;
}
float currentZoom = controller.getZoom();
controller.setZoom(targetZoom);
LngLat pos = getCenterWithOffset(g);
controller.setZoom(currentZoom);
controller.setPositionEased(pos, 500);
controller.setZoomEased(targetZoom, 500);
updateView();
}
use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.
the class QuestsMapFragment method getCenterWithOffset.
private LngLat getCenterWithOffset(ElementGeometry geometry) {
int w = getView().getWidth();
int h = getView().getHeight();
LngLat normalCenter = controller.screenPositionToLngLat(new PointF(w / 2f, h / 2f));
LngLat offsetCenter = controller.screenPositionToLngLat(new PointF(questOffset.left + (w - questOffset.left - questOffset.right) / 2, questOffset.top + (h - questOffset.top - questOffset.bottom) / 2));
LngLat pos = TangramConst.toLngLat(geometry.center);
pos.latitude -= offsetCenter.latitude - normalCenter.latitude;
pos.longitude -= offsetCenter.longitude - normalCenter.longitude;
return pos;
}
use of com.mapzen.tangram.LngLat in project StreetComplete by westnordost.
the class QuestsMapFragment method updateView.
protected void updateView() {
super.updateView();
if (controller.getZoom() < TILES_ZOOM)
return;
// check if anything changed (needs to be extended when I reenable tilt and rotation)
LngLat positionNow = controller.getPosition();
if (lastPos != null && lastPos.equals(positionNow))
return;
lastPos = positionNow;
BoundingBox displayedArea = getDisplayedArea(new Rect());
if (displayedArea == null)
return;
Rect tilesRect = SlippyMapMath.enclosingTiles(displayedArea, TILES_ZOOM);
if (lastDisplayedRect != null && lastDisplayedRect.equals(tilesRect))
return;
lastDisplayedRect = tilesRect;
// area to big -> skip ( see https://github.com/tangrams/tangram-es/issues/1492 )
if (tilesRect.width() * tilesRect.height() > 4) {
return;
}
List<Point> tiles = SlippyMapMath.asTileList(tilesRect);
tiles.removeAll(retrievedTiles);
Rect minRect = SlippyMapMath.minRect(tiles);
if (minRect == null)
return;
BoundingBox bbox = SlippyMapMath.asBoundingBox(minRect, TILES_ZOOM);
listener.onFirstInView(bbox);
// debugging
/*List<LatLon> corners = new ArrayList<LatLon>(5);
corners.add(bbox.getMin());
corners.add(new OsmLatLon(bbox.getMinLatitude(), bbox.getMaxLongitude()));
corners.add(bbox.getMax());
corners.add(new OsmLatLon(bbox.getMaxLatitude(), bbox.getMinLongitude()));
corners.add(bbox.getMin());
ElementGeometry e = new ElementGeometry(null, Collections.singletonList(corners));
addQuestGeometry(e);*/
retrievedTiles.addAll(tiles);
}
Aggregations