Optimisation. Line culler slightly quicker.

This commit is contained in:
Andrew Davie 2016-04-02 20:30:59 +11:00
parent 6371dd2da4
commit ff29a1a744

View file

@ -209,17 +209,19 @@ public abstract class AsynchronousResampler extends AsyncTask<String,Integer,Str
double dmax = Double.NEGATIVE_INFINITY; double dmax = Double.NEGATIVE_INFINITY;
int index = -1; int index = -1;
WptPt startPt = rs.points.get(start);
WptPt endPt = rs.points.get(end);
for (int i = start + 1; i < end && !isCancelled(); i++) { for (int i = start + 1; i < end && !isCancelled(); i++) {
double d = MapUtils.getOrthogonalDistance( WptPt pt = rs.points.get(i);
rs.points.get(i).getLatitude(), rs.points.get(i).getLongitude(), double d = MapUtils.getOrthogonalDistance(pt.lat, pt.lon, startPt.lat, startPt.lon, endPt.lat, endPt.lon);
rs.points.get(start).getLatitude(), rs.points.get(start).getLongitude(),
rs.points.get(end).getLatitude(), rs.points.get(end).getLongitude());
if (d > dmax) { if (d > dmax) {
dmax = d; dmax = d;
index = i; index = i;
} }
} }
if (dmax >= epsilon) { if (dmax > epsilon) {
cullRamerDouglasPeucer(survivor, start, index); cullRamerDouglasPeucer(survivor, start, index);
cullRamerDouglasPeucer(survivor, index, end); cullRamerDouglasPeucer(survivor, index, end);
} else { } else {