Search in sources :

Example 41 with RotatedTileBox

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();
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) WorldRegion(net.osmand.map.WorldRegion) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) TreeSet(java.util.TreeSet) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint)

Example 42 with RotatedTileBox

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;
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 43 with RotatedTileBox

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);
    }
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint)

Example 44 with RotatedTileBox

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());
    }
}
Also used : RectF(android.graphics.RectF) RotatedTileBox(net.osmand.data.RotatedTileBox) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) QuadPointDouble(net.osmand.data.QuadPointDouble)

Example 45 with RotatedTileBox

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();
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) TransportStop(net.osmand.data.TransportStop)

Aggregations

RotatedTileBox (net.osmand.data.RotatedTileBox)48 LatLon (net.osmand.data.LatLon)20 QuadPoint (net.osmand.data.QuadPoint)15 Paint (android.graphics.Paint)11 QuadRect (net.osmand.data.QuadRect)8 SuppressLint (android.annotation.SuppressLint)7 View (android.view.View)6 ImageView (android.widget.ImageView)5 ArrayList (java.util.ArrayList)4 Location (net.osmand.Location)4 ITileSource (net.osmand.map.ITileSource)4 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)4 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)4 PointF (android.graphics.PointF)3 TextView (android.widget.TextView)3 List (java.util.List)3 QuadPointDouble (net.osmand.data.QuadPointDouble)3 WptPt (net.osmand.plus.GPXUtilities.WptPt)3 DialogInterface (android.content.DialogInterface)2 Bitmap (android.graphics.Bitmap)2