Compare commits

...

2 Commits

Author SHA1 Message Date
Victor Shcherb
6de4d996da Revert changes and fix exception 2024-03-14 12:54:55 +02:00
Victor Shcherb
46edf48e3f Fix gpx approximation 2024-03-14 00:59:29 +02:00

View File

@ -425,8 +425,8 @@ public class RoutePlannerFrontEnd {
while (st != end) {
LatLon point = r.getPoint(st);
boolean pointIsClosed = false;
int delta = 0, startInd = Math.max(0, start.ind - delta),
nextInd = Math.min(gpxPoints.size(), next.ind + delta);
int delta = 3, startInd = Math.max(0, start.ind - delta),
nextInd = Math.min(gpxPoints.size() - 1, next.ind + delta);
for (int k = startInd; !pointIsClosed && k < nextInd; k++) {
pointIsClosed = pointCloseEnough(minPointApproximation, point, gpxPoints.get(k),
gpxPoints.get(k + 1));
@ -773,11 +773,14 @@ public class RoutePlannerFrontEnd {
private boolean pointCloseEnough(float minPointApproximation, LatLon point, GpxPoint gpxPoint,
GpxPoint gpxPointNext) {
// LatLon gpxPointLL = gpxPoint.loc; // more correct version
// LatLon gpxPointNextLL = gpxPointNext.loc;
LatLon gpxPointLL = gpxPoint.pnt != null ? gpxPoint.pnt.getPreciseLatLon() : gpxPoint.loc;
LatLon gpxPointNextLL = gpxPointNext.pnt != null ? gpxPointNext.pnt.getPreciseLatLon() : gpxPointNext.loc;
double orthogonalDistance = MapUtils.getOrthogonalDistance(point.getLatitude(), point.getLongitude(),
gpxPointLL.getLatitude(), gpxPointLL.getLongitude(), gpxPointNextLL.getLatitude(),
gpxPointNextLL.getLongitude());
// System.out.printf("%.1f %s ( ntNext.ind, gpxPointLL, gpxPointNextLL);
return orthogonalDistance <= minPointApproximation;
}