Search in sources :

Example 1 with QuadPoint

use of net.osmand.data.QuadPoint in project Osmand by osmandapp.

the class MapActivity method onTrackballEvent.

@Override
public boolean onTrackballEvent(MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()) {
        float x = event.getX();
        float y = event.getY();
        final RotatedTileBox tb = mapView.getCurrentRotatedTileBox();
        final QuadPoint cp = tb.getCenterPixelPoint();
        final LatLon l = tb.getLatLonFromPixel(cp.x + x * 15, cp.y + y * 15);
        setMapLocation(l.getLatitude(), l.getLongitude());
        return true;
    }
    return super.onTrackballEvent(event);
}
Also used : LatLon(net.osmand.data.LatLon) RotatedTileBox(net.osmand.data.RotatedTileBox) QuadPoint(net.osmand.data.QuadPoint)

Example 2 with QuadPoint

use of net.osmand.data.QuadPoint in project Osmand by osmandapp.

the class OsmandMapTileView method drawOverMap.

@SuppressLint("WrongCall")
public void drawOverMap(Canvas canvas, RotatedTileBox tileBox, DrawSettings drawSettings) {
    if (mapRenderer == null) {
        fillCanvas(canvas, drawSettings);
    }
    final QuadPoint c = tileBox.getCenterPixelPoint();
    synchronized (this) {
        if (bufferBitmap != null && !bufferBitmap.isRecycled() && mapRenderer == null) {
            canvas.save();
            canvas.rotate(tileBox.getRotate(), c.x, c.y);
            drawBasemap(canvas);
            canvas.restore();
        }
    }
    if (onDrawMapListener != null) {
        onDrawMapListener.onDrawOverMap();
    }
    for (int i = 0; i < layers.size(); i++) {
        try {
            OsmandMapLayer layer = layers.get(i);
            canvas.save();
            // rotate if needed
            if (!layer.drawInScreenPixels()) {
                canvas.rotate(tileBox.getRotate(), c.x, c.y);
            }
            if (mapRenderer != null) {
                layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
            }
            layer.onDraw(canvas, tileBox, drawSettings);
            canvas.restore();
        } catch (IndexOutOfBoundsException e) {
        // skip it
        }
    }
    if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
        drawMapPosition(canvas, c.x, c.y);
    } else if (multiTouchSupport.isInZoomMode()) {
        drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y);
    } else if (doubleTapScaleDetector.isInZoomMode()) {
        drawMapPosition(canvas, doubleTapScaleDetector.getCenterX(), doubleTapScaleDetector.getCenterY());
    }
}
Also used : QuadPoint(net.osmand.data.QuadPoint) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 3 with QuadPoint

use of net.osmand.data.QuadPoint in project Osmand by osmandapp.

the class OsmandMapTileView method moveTo.

public void moveTo(float dx, float dy) {
    final QuadPoint cp = currentViewport.getCenterPixelPoint();
    final LatLon latlon = currentViewport.getLatLonFromPixel(cp.x + dx, cp.y + dy);
    currentViewport.setLatLonCenter(latlon.getLatitude(), latlon.getLongitude());
    refreshMap();
// do not notify here listener
}
Also used : LatLon(net.osmand.data.LatLon) QuadPoint(net.osmand.data.QuadPoint)

Example 4 with QuadPoint

use of net.osmand.data.QuadPoint in project Osmand by osmandapp.

the class PrecalculatedRouteDirection method getDeviationDistance.

public float getDeviationDistance(int x31, int y31, int ind) {
    // BinaryRoutePlanner.squareRootDist(x31, y31, pointsX.get(ind), pointsY.get(ind));
    float distToPoint = 0;
    if (ind < pointsX.length - 1 && ind != 0) {
        double nx = BinaryRoutePlanner.squareRootDist(x31, y31, pointsX[ind + 1], pointsY[ind + 1]);
        double pr = BinaryRoutePlanner.squareRootDist(x31, y31, pointsX[ind - 1], pointsY[ind - 1]);
        int nind = nx > pr ? ind - 1 : ind + 1;
        QuadPoint proj = MapUtils.getProjectionPoint31(x31, y31, pointsX[ind], pointsY[ind], pointsX[nind], pointsX[nind]);
        distToPoint = (float) BinaryRoutePlanner.squareRootDist(x31, y31, (int) proj.x, (int) proj.y);
    }
    return distToPoint;
}
Also used : QuadPoint(net.osmand.data.QuadPoint) QuadPoint(net.osmand.data.QuadPoint)

Example 5 with QuadPoint

use of net.osmand.data.QuadPoint in project Osmand by osmandapp.

the class MapContextMenuFragment method getAdjustedMarkerLocation.

private LatLon getAdjustedMarkerLocation(int y, LatLon reqMarkerLocation, boolean center, int zoom) {
    double markerLat = reqMarkerLocation.getLatitude();
    double markerLon = reqMarkerLocation.getLongitude();
    RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
    box.setCenterLocation(0.5f, map.getMapPosition() == OsmandSettings.BOTTOM_CONSTANT ? 0.15f : 0.5f);
    box.setZoom(zoom);
    boolean hasMapCenter = mapCenter != null;
    int markerMapCenterX = 0;
    int markerMapCenterY = 0;
    if (hasMapCenter) {
        markerMapCenterX = (int) box.getPixXFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
        markerMapCenterY = (int) box.getPixYFromLatLon(mapCenter.getLatitude(), mapCenter.getLongitude());
    }
    float cpyOrig = box.getCenterPixelPoint().y;
    box.setCenterLocation(0.5f, 0.5f);
    int markerX = (int) box.getPixXFromLatLon(markerLat, markerLon);
    int markerY = (int) box.getPixYFromLatLon(markerLat, markerLon);
    QuadPoint cp = box.getCenterPixelPoint();
    float cpx = cp.x;
    float cpy = cp.y;
    float cpyDelta = menu.isLandscapeLayout() ? 0 : cpyOrig - cpy;
    markerY += cpyDelta;
    y += cpyDelta;
    float origMarkerY = this.origMarkerY + cpyDelta;
    LatLon latlon;
    if (center || !hasMapCenter) {
        latlon = reqMarkerLocation;
    } else {
        latlon = box.getLatLonFromPixel(markerMapCenterX, markerMapCenterY);
    }
    if (menu.isLandscapeLayout()) {
        int x = menu.getLandscapeWidthPx();
        if (markerX - markerPaddingXPx < x || markerX > origMarkerX) {
            int dx = (x + markerPaddingXPx) - markerX;
            int dy = 0;
            if (center) {
                dy = (int) cpy - markerY;
            } else {
                cpy = cpyOrig;
            }
            if (dx >= 0 || center) {
                latlon = box.getLatLonFromPixel(cpx - dx, cpy - dy);
            }
        }
    } else {
        if (markerY + markerPaddingPx > y || markerY < origMarkerY) {
            int dx = 0;
            int dy = markerY - (y - markerPaddingPx);
            if (markerY - dy <= origMarkerY) {
                if (center) {
                    dx = markerX - (int) cpx;
                }
                latlon = box.getLatLonFromPixel(cpx + dx, cpy + dy);
            }
        }
    }
    return latlon;
}
Also used : LatLon(net.osmand.data.LatLon) RotatedTileBox(net.osmand.data.RotatedTileBox) QuadPoint(net.osmand.data.QuadPoint) QuadPoint(net.osmand.data.QuadPoint)

Aggregations

QuadPoint (net.osmand.data.QuadPoint)14 Paint (android.graphics.Paint)5 LatLon (net.osmand.data.LatLon)5 RouteDataObject (net.osmand.binary.RouteDataObject)3 RotatedTileBox (net.osmand.data.RotatedTileBox)3 SuppressLint (android.annotation.SuppressLint)2 Bitmap (android.graphics.Bitmap)2 PointF (android.graphics.PointF)2 RouteSegmentPoint (net.osmand.router.BinaryRoutePlanner.RouteSegmentPoint)2 Canvas (android.graphics.Canvas)1 Handler (android.os.Handler)1 Message (android.os.Message)1 ArrayList (java.util.ArrayList)1 Location (net.osmand.Location)1 MapMarkersHelper (net.osmand.plus.MapMarkersHelper)1 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)1 OsmandSettings (net.osmand.plus.OsmandSettings)1 RulerMode (net.osmand.plus.OsmandSettings.RulerMode)1 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)1 GeoParsedPoint (net.osmand.util.GeoPointParserUtil.GeoParsedPoint)1