use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class DownloadedRegionsLayer method getFilter.
public String getFilter(StringBuilder btnName) {
StringBuilder filter = new StringBuilder();
int zoom = view.getZoom();
RotatedTileBox queriedBox = data.getQueriedBox();
final List<BinaryMapDataObject> currentObjects = data.results;
if (osmandRegions.isInitialized() && queriedBox != null) {
if (zoom >= ZOOM_TO_SHOW_MAP_NAMES && Math.abs(queriedBox.getZoom() - zoom) <= ZOOM_THRESHOLD && currentObjects != null) {
btnName.setLength(0);
btnName.append(view.getResources().getString(R.string.shared_string_download));
filter.setLength(0);
Set<String> set = new TreeSet<String>();
int cx = view.getCurrentRotatedTileBox().getCenter31X();
int cy = view.getCurrentRotatedTileBox().getCenter31Y();
if ((currentObjects.size() > 0)) {
for (int i = 0; i < currentObjects.size(); i++) {
final BinaryMapDataObject o = currentObjects.get(i);
if (!osmandRegions.contain(o, cx, cy)) {
continue;
}
String fullName = osmandRegions.getFullName(o);
WorldRegion rd = osmandRegions.getRegionData(fullName);
if (rd != null && rd.isRegionMapDownload() && rd.getRegionDownloadName() != null) {
String name = rd.getLocaleName();
if (checkIfObjectDownloaded(rd.getRegionDownloadName())) {
return null;
}
if (!set.add(name)) {
continue;
}
if (set.size() > 1) {
btnName.append(" ").append(view.getResources().getString(R.string.shared_string_or)).append(" ");
filter.append(", ");
} else {
btnName.append(" ");
}
filter.append(name);
btnName.append(name);
}
}
}
}
}
if (filter.length() == 0) {
return null;
}
return filter.toString();
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class OsmandMapTileView method onGenericMotionEvent.
public boolean onGenericMotionEvent(MotionEvent event) {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0 && event.getAction() == MotionEvent.ACTION_SCROLL && event.getAxisValue(MotionEvent.AXIS_VSCROLL) != 0) {
final RotatedTileBox tb = getCurrentRotatedTileBox();
final double lat = tb.getLatFromPixel(event.getX(), event.getY());
final double lon = tb.getLonFromPixel(event.getX(), event.getY());
int zoomDir = event.getAxisValue(MotionEvent.AXIS_VSCROLL) < 0 ? -1 : 1;
getAnimatedDraggingThread().startMoving(lat, lon, getZoom() + zoomDir, true);
return true;
}
return false;
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class OsmandMapTileView method fitLocationToMap.
public void fitLocationToMap(double clat, double clon, int zoom, int tileBoxWidthPx, int tileBoxHeightPx, int marginTopPx, boolean animated) {
RotatedTileBox tb = currentViewport.copy();
int dy = 0;
int tbw = tb.getPixWidth();
int tbh = tb.getPixHeight();
if (tileBoxWidthPx > 0) {
tbw = tileBoxWidthPx;
} else if (tileBoxHeightPx > 0) {
tbh = tileBoxHeightPx;
dy = (tb.getPixHeight() - tileBoxHeightPx) / 2 - marginTopPx;
}
tb.setPixelDimensions(tbw, tbh);
tb.setLatLonCenter(clat, clon);
tb.setZoom(zoom);
if (dy != 0) {
clat = tb.getLatFromPixel(tb.getPixWidth() / 2, tb.getPixHeight() / 2 + dy);
clon = tb.getLonFromPixel(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
}
if (animated) {
animatedDraggingThread.startMoving(clat, clon, tb.getZoom(), true);
} else {
setLatLon(clat, clon);
}
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class OsmandMapTileView method drawBasemap.
private void drawBasemap(Canvas canvas) {
if (bufferImgLoc != null) {
float rot = -bufferImgLoc.getRotate();
canvas.rotate(rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
final RotatedTileBox calc = currentViewport.copy();
calc.setRotate(bufferImgLoc.getRotate());
int cz = getZoom();
QuadPointDouble lt = bufferImgLoc.getLeftTopTile(cz);
QuadPointDouble rb = bufferImgLoc.getRightBottomTile(cz);
final float x1 = calc.getPixXFromTile(lt.x, lt.y, cz);
final float x2 = calc.getPixXFromTile(rb.x, rb.y, cz);
final float y1 = calc.getPixYFromTile(lt.x, lt.y, cz);
final float y2 = calc.getPixYFromTile(rb.x, rb.y, cz);
// final float y2 = calc.getPixYFromLatLon(rb.getLatitude(), rb.getLongitude());
if (!bufferBitmap.isRecycled()) {
RectF rct = new RectF(x1, y1, x2, y2);
canvas.drawBitmap(bufferBitmap, null, rct, paintImg);
}
canvas.rotate(-rot, currentViewport.getCenterPixelX(), currentViewport.getCenterPixelY());
}
}
use of net.osmand.data.RotatedTileBox in project Osmand by osmandapp.
the class TransportStopRoute method calculateZoom.
public int calculateZoom(int startPosition, RotatedTileBox currentRotatedTileBox) {
RotatedTileBox cp = currentRotatedTileBox.copy();
boolean notContains = true;
while (cp.getZoom() > 12 && notContains) {
notContains = false;
List<TransportStop> sts = route.getForwardStops();
for (int i = startPosition; i < sts.size(); i++) {
TransportStop st = sts.get(startPosition);
if (!cp.containsLatLon(st.getLocation())) {
notContains = true;
break;
}
}
cp.setZoom(cp.getZoom() - 1);
}
return cp.getZoom();
}
Aggregations