Search in sources :

Example 21 with RotatedTileBox

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

the class PlanRouteFragment method showRouteOnMap.

private void showRouteOnMap(List<WptPt> points) {
    MapActivity mapActivity = getMapActivity();
    if (points.size() > 0 && mapActivity != null) {
        OsmandMapTileView mapView = mapActivity.getMapView();
        double left = 0, right = 0;
        double top = 0, bottom = 0;
        Location myLocation = mapActivity.getMyApplication().getLocationProvider().getLastStaleKnownLocation();
        if (mapActivity.getMyApplication().getMapMarkersHelper().isStartFromMyLocation() && myLocation != null) {
            left = myLocation.getLongitude();
            right = myLocation.getLongitude();
            top = myLocation.getLatitude();
            bottom = myLocation.getLatitude();
        }
        for (WptPt pt : points) {
            if (left == 0) {
                left = pt.getLongitude();
                right = pt.getLongitude();
                top = pt.getLatitude();
                bottom = pt.getLatitude();
            } else {
                left = Math.min(left, pt.getLongitude());
                right = Math.max(right, pt.getLongitude());
                top = Math.max(top, pt.getLatitude());
                bottom = Math.min(bottom, pt.getLatitude());
            }
        }
        RotatedTileBox tb = mapView.getCurrentRotatedTileBox().copy();
        int tileBoxWidthPx = 0;
        int tileBoxHeightPx = 0;
        if (portrait) {
            tileBoxHeightPx = 3 * (tb.getPixHeight() - toolbarHeight) / 4;
        } else {
            tileBoxWidthPx = tb.getPixWidth() - mapActivity.getResources().getDimensionPixelSize(R.dimen.dashboard_land_width);
        }
        mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, toolbarHeight * 3 / 2);
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) RotatedTileBox(net.osmand.data.RotatedTileBox) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) MapActivity(net.osmand.plus.activities.MapActivity) Location(net.osmand.Location)

Example 22 with RotatedTileBox

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

the class MeasurementToolLayer method getMovedPointToApply.

WptPt getMovedPointToApply() {
    RotatedTileBox tb = view.getCurrentRotatedTileBox();
    LatLon latLon = tb.getCenterLatLon();
    WptPt pt = new WptPt(editingCtx.getOriginalPointToMove());
    pt.lat = latLon.getLatitude();
    pt.lon = latLon.getLongitude();
    return pt;
}
Also used : LatLon(net.osmand.data.LatLon) WptPt(net.osmand.plus.GPXUtilities.WptPt) RotatedTileBox(net.osmand.data.RotatedTileBox)

Example 23 with RotatedTileBox

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

the class MeasurementToolLayer method selectPoint.

private void selectPoint(double x, double y, boolean singleTap) {
    RotatedTileBox tb = view.getCurrentRotatedTileBox();
    double lowestDistance = view.getResources().getDimension(R.dimen.measurement_tool_select_radius);
    for (int i = 0; i < editingCtx.getPointsCount(); i++) {
        WptPt pt = editingCtx.getPoints().get(i);
        if (tb.containsLatLon(pt.getLatitude(), pt.getLongitude())) {
            double xDiff = tb.getPixXFromLonNoRot(pt.getLongitude()) - x;
            double yDiff = tb.getPixYFromLatNoRot(pt.getLatitude()) - y;
            double distToPoint = Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));
            if (distToPoint < lowestDistance) {
                lowestDistance = distToPoint;
                editingCtx.setSelectedPointPosition(i);
            }
        }
    }
    if (singleTap && singleTapListener != null) {
        singleTapListener.onSelectPoint(editingCtx.getSelectedPointPosition());
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) RotatedTileBox(net.osmand.data.RotatedTileBox) Paint(android.graphics.Paint) QuadPoint(net.osmand.data.QuadPoint)

Example 24 with RotatedTileBox

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

the class OsmBugsLayer method initLayer.

@Override
public void initLayer(OsmandMapTileView view) {
    this.view = view;
    paintIcon = new Paint();
    resolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_resolved);
    unresolvedNote = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_unresolved);
    resolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_resolved_small);
    unresolvedNoteSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_osm_unresolved_small);
    data = new OsmandMapLayer.MapLayerData<List<OpenStreetNote>>() {

        {
            ZOOM_THRESHOLD = 1;
        }

        @Override
        protected List<OpenStreetNote> calculateResult(RotatedTileBox tileBox) {
            QuadRect bounds = tileBox.getLatLonBounds();
            return loadingBugs(bounds.top, bounds.left, bounds.bottom, bounds.right);
        }
    };
}
Also used : RotatedTileBox(net.osmand.data.RotatedTileBox) OsmandMapLayer(net.osmand.plus.views.OsmandMapLayer) ArrayList(java.util.ArrayList) List(java.util.List) Paint(android.graphics.Paint) QuadRect(net.osmand.data.QuadRect)

Example 25 with RotatedTileBox

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

the class MainActivity method getBox.

public RotatedTileBox getBox() {
    RotatedTileBox.RotatedTileBoxBuilder boxBuilder = new RotatedTileBox.RotatedTileBoxBuilder();
    LatLon screenCenter = getScreenCenter();
    boxBuilder.setLocation(screenCenter.getLatitude(), screenCenter.getLongitude());
    boxBuilder.setPixelDimensions(mapView.getWidth(), mapView.getHeight(), 0.5f, 0.5f);
    boxBuilder.setZoom((int) getZoom());
    boxBuilder.setRotate(mapView.getRotation());
    return boxBuilder.build();
}
Also used : LatLon(net.osmand.data.LatLon) RotatedTileBox(net.osmand.data.RotatedTileBox)

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