fix direct to

This commit is contained in:
MadWasp79 2020-02-18 18:59:17 +02:00
parent cc46858a50
commit 762f2840f3
2 changed files with 14 additions and 8 deletions

View file

@ -49,6 +49,11 @@ public class MapUtils {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '_', '~'
};
public static double getDistance(Location l1, Location l2) {
return getDistance(l1.getLatitude(), l1.getLongitude(), l2.getLatitude(), l2.getLongitude());
}
public static double getDistance(LatLon l, double latitude, double longitude) {
return getDistance(l.getLatitude(), l.getLongitude(), latitude, longitude);
}

View file

@ -35,6 +35,7 @@ import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu;
import net.osmand.plus.mapcontextmenu.other.TrackDetailsMenu.TrackChartPoints;
import net.osmand.plus.profiles.LocationIcon;
import net.osmand.plus.render.RenderingIcons;
import net.osmand.plus.routing.RouteCalculationResult;
import net.osmand.plus.routing.RouteDirectionInfo;
@ -319,7 +320,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
private void drawProjectionPoint(Canvas canvas, double[] projectionXY) {
if (projectionIcon == null) {
projectionIcon = (LayerDrawable) view.getResources().getDrawable(helper.getSettings().getApplicationMode().getLocationIcon().DEFAULT.getIconId());
helper.getSettings().getApplicationMode().getLocationIcon();
projectionIcon = (LayerDrawable) view.getResources().getDrawable(LocationIcon.DEFAULT.getIconId());
}
int locationX = (int) projectionXY[0];
int locationY = (int) projectionXY[1];
@ -1148,33 +1150,32 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
private double[] calculateProjectionOnRoutePoint(List<Location> routeNodes, RoutingHelper helper, RotatedTileBox box) {
double[] projectionXY;
boolean visible;
Location previousInRoute = null;
Location nextInRoute = null;
//need to change this code by fixing helper.route.getCurrentRoute() miscalculation
// TODO simplifiy all culation!
Location ll = helper.getLastFixedLocation();
Location previousInRoute = routeNodes.get(helper.getRoute().getCurrentRoute() > 0 ? helper.getRoute().getCurrentRoute() - 1 : 0);
if (helper.getRoute().getIntermediatePointsToPass() > 0) {
for (int i = 1; i < routeNodes.size(); i++) {
LatLon routePoint = new LatLon(routeNodes.get(i).getLatitude(), routeNodes.get(i).getLongitude());
if (routePoint.equals(helper.getIntermediatePoints().get(0))) {
previousInRoute = routeNodes.get(i - 1);
nextInRoute = routeNodes.get(i);
}
}
} else {
previousInRoute = routeNodes.get(routeNodes.size() - 2);
nextInRoute = routeNodes.get(routeNodes.size() - 1);
nextInRoute = routeNodes.get(routeNodes.size()-1);
}
if (nextInRoute != null && previousInRoute != null) {
final Location ll = view.getApplication().getLocationProvider().getLastKnownLocation();
// double Ri = MapUtils.getDistance(nextInRoute, ll);
//
final int aX = box.getPixXFromLonNoRot(ll.getLongitude());
final int aY = box.getPixYFromLatNoRot(ll.getLatitude());
final int centerX = box.getPixXFromLonNoRot(nextInRoute.getLongitude());
final int centerY = box.getPixYFromLatNoRot(nextInRoute.getLatitude());
final int bX = box.getPixXFromLonNoRot(previousInRoute.getLongitude());
final int bY = box.getPixYFromLatNoRot(previousInRoute.getLatitude());
double radius = MapUtils.getVectorMagnitude(centerX, centerY, aX, aY);
double angle2 = MapUtils.getAngleForRadiusVector(centerX, centerY, bX, bY);
projectionXY = MapUtils.getCoordinatesFromRadiusAndAngle(centerX, centerY, radius, angle2);