Search in sources :

Example 96 with Location

use of net.osmand.Location in project Osmand by osmandapp.

the class QuickSearchCoordinatesFragment method updateCompassVisibility.

private void updateCompassVisibility(View view, LatLon location, Float heading) {
    View compassView = view.findViewById(R.id.compass_layout);
    Location ll = getMyApplication().getLocationProvider().getLastKnownLocation();
    boolean showCompass = currentLatLon != null && location != null;
    if (ll != null && showCompass) {
        updateDistanceDirection(view, location, currentLatLon, heading);
        compassView.setVisibility(View.VISIBLE);
    } else {
        if (!showCompass) {
            compassView.setVisibility(View.GONE);
        } else {
            compassView.setVisibility(View.INVISIBLE);
        }
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) Location(net.osmand.Location)

Example 97 with Location

use of net.osmand.Location in project Osmand by osmandapp.

the class QuickSearchCoordinatesFragment method updateCompassValue.

@Override
public void updateCompassValue(final float value) {
    // 99 in next line used to one-time initialize arrows (with reference vs. fixed-north direction)
    // on non-compass devices
    float lastHeading = heading != null ? heading : 99;
    heading = value;
    if (Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
        final net.osmand.Location location = this.myLocation;
        getMyApplication().runInUIThread(new Runnable() {

            @Override
            public void run() {
                updateLocationUI(location, value);
            }
        });
    } else {
        heading = lastHeading;
    }
}
Also used : Location(net.osmand.Location)

Example 98 with Location

use of net.osmand.Location in project Osmand by osmandapp.

the class MapControlsLayer method updateMyLocation.

private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
    Location lastKnownLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
    boolean enabled = lastKnownLocation != null;
    boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
    if (!enabled) {
        backToLocationControl.setBg(R.drawable.btn_circle, R.drawable.btn_circle_night);
        backToLocationControl.setIconColorId(R.color.icon_color, 0);
        backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.unknown_location));
    } else if (tracked) {
        backToLocationControl.setBg(R.drawable.btn_circle, R.drawable.btn_circle_night);
        backToLocationControl.setIconColorId(R.color.color_myloc_distance);
        backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.access_map_linked_to_location));
    } else {
        backToLocationControl.setIconColorId(0);
        backToLocationControl.setBg(R.drawable.btn_circle_blue);
        backToLocationControl.iv.setContentDescription(mapActivity.getString(R.string.map_widget_back_to_loc));
    }
    boolean visible = !(tracked && rh.isFollowingMode());
    backToLocationControl.updateVisibility(visible && !dialogOpened && !isInPlanRouteMode());
    if (app.accessibilityEnabled()) {
        backToLocationControl.iv.setClickable(enabled && visible);
    }
}
Also used : Location(net.osmand.Location)

Example 99 with Location

use of net.osmand.Location in project Osmand by osmandapp.

the class RulerControlLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
    if (rulerModeOn()) {
        lineAttrs.updatePaints(view, settings, tb);
        lineFontAttrs.updatePaints(view, settings, tb);
        lineFontAttrs.paint.setStyle(Style.FILL);
        circleAttrs.updatePaints(view, settings, tb);
        circleAttrs.paint2.setStyle(Style.FILL);
        circleAttrsAlt.updatePaints(view, settings, tb);
        circleAttrsAlt.paint2.setStyle(Style.FILL);
        final QuadPoint center = tb.getCenterPixelPoint();
        final RulerMode mode = app.getSettings().RULER_MODE.get();
        final long currentTime = System.currentTimeMillis();
        if (cacheMultiTouchEndTime != view.getMultiTouchEndTime()) {
            cacheMultiTouchEndTime = view.getMultiTouchEndTime();
            refreshMapDelayed();
        }
        if (touched && view.isMultiTouch()) {
            touched = false;
            touchEndTime = currentTime;
        }
        if (tb.isZoomAnimated()) {
            wasZoom = true;
        }
        showTwoFingersDistance = !tb.isZoomAnimated() && !view.isWasZoomInMultiTouch() && currentTime - view.getMultiTouchStartTime() > DELAY_BEFORE_DRAW && (view.isMultiTouch() || currentTime - cacheMultiTouchEndTime < DRAW_TIME);
        showDistBetweenFingerAndLocation = !wasZoom && !showTwoFingersDistance && !view.isMultiTouch() && !touchOutside && touchStartTime - view.getMultiTouchStartTime() > DELAY_BEFORE_DRAW && currentTime - touchStartTime > DELAY_BEFORE_DRAW && (touched || currentTime - touchEndTime < DRAW_TIME);
        drawCenterIcon(canvas, tb, center, settings.isNightMode(), mode);
        Location currentLoc = app.getLocationProvider().getLastKnownLocation();
        if (showDistBetweenFingerAndLocation && currentLoc != null) {
            drawDistBetweenFingerAndLocation(canvas, tb, currentLoc, settings.isNightMode());
        } else if (showTwoFingersDistance) {
            drawTwoFingersDistance(canvas, tb, view.getFirstTouchPointLatLon(), view.getSecondTouchPointLatLon(), settings.isNightMode());
        }
        if (mode == RulerMode.FIRST || mode == RulerMode.SECOND) {
            updateData(tb, center);
            RenderingLineAttributes attrs = mode == RulerMode.FIRST ? circleAttrs : circleAttrsAlt;
            for (int i = 1; i <= cacheDistances.size(); i++) {
                drawCircle(canvas, tb, i, center, attrs);
            }
        }
    }
}
Also used : RulerMode(net.osmand.plus.OsmandSettings.RulerMode) QuadPoint(net.osmand.data.QuadPoint) QuadPoint(net.osmand.data.QuadPoint) Paint(android.graphics.Paint) Location(net.osmand.Location)

Example 100 with Location

use of net.osmand.Location in project Osmand by osmandapp.

the class RouteLayer method drawAction.

private void drawAction(RotatedTileBox tb, Canvas canvas, List<Location> actionPoints) {
    if (actionPoints.size() > 0) {
        canvas.rotate(-tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
        try {
            Path pth = new Path();
            Matrix matrix = new Matrix();
            boolean first = true;
            int x = 0, px = 0, py = 0, y = 0;
            for (int i = 0; i < actionPoints.size(); i++) {
                Location o = actionPoints.get(i);
                if (o == null) {
                    first = true;
                    canvas.drawPath(pth, attrs.paint3);
                    double angleRad = Math.atan2(y - py, x - px);
                    double angle = (angleRad * 180 / Math.PI) + 90f;
                    double distSegment = Math.sqrt((y - py) * (y - py) + (x - px) * (x - px));
                    if (distSegment == 0) {
                        continue;
                    }
                    // int len = (int) (distSegment / pxStep);
                    float pdx = x - px;
                    float pdy = y - py;
                    matrix.reset();
                    matrix.postTranslate(0, -actionArrow.getHeight() / 2);
                    matrix.postRotate((float) angle, actionArrow.getWidth() / 2, 0);
                    matrix.postTranslate(px + pdx - actionArrow.getWidth() / 2, py + pdy);
                    canvas.drawBitmap(actionArrow, matrix, paintIconAction);
                } else {
                    px = x;
                    py = y;
                    x = (int) tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
                    y = (int) tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
                    if (first) {
                        pth.reset();
                        pth.moveTo(x, y);
                        first = false;
                    } else {
                        pth.lineTo(x, y);
                    }
                }
            }
        } finally {
            canvas.rotate(tb.getRotate(), tb.getCenterPixelX(), tb.getCenterPixelY());
        }
    }
}
Also used : Path(android.graphics.Path) Matrix(android.graphics.Matrix) Paint(android.graphics.Paint) Location(net.osmand.Location)

Aggregations

Location (net.osmand.Location)105 LatLon (net.osmand.data.LatLon)37 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)29 ArrayList (java.util.ArrayList)21 LocationPoint (net.osmand.data.LocationPoint)21 View (android.view.View)13 OsmandApplication (net.osmand.plus.OsmandApplication)12 Paint (android.graphics.Paint)11 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)10 RouteDataObject (net.osmand.binary.RouteDataObject)9 WptPt (net.osmand.plus.GPXUtilities.WptPt)9 MapMarker (net.osmand.plus.MapMarkersHelper.MapMarker)8 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)7 PointDescription (net.osmand.data.PointDescription)6 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)6 TIntArrayList (gnu.trove.list.array.TIntArrayList)5 IOException (java.io.IOException)5 QuadPoint (net.osmand.data.QuadPoint)5 MapActivity (net.osmand.plus.activities.MapActivity)5