executor pla a route bug fix
This commit is contained in:
parent
b2c4412373
commit
8403fbf062
2 changed files with 10 additions and 2 deletions
|
@ -243,6 +243,9 @@ public class RoutePlannerFrontEnd {
|
||||||
start = gpxPoints.get(0);
|
start = gpxPoints.get(0);
|
||||||
}
|
}
|
||||||
while (start != null && !gctx.ctx.calculationProgress.isCancelled) {
|
while (start != null && !gctx.ctx.calculationProgress.isCancelled) {
|
||||||
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION;
|
double routeDist = gctx.MAXIMUM_STEP_APPROXIMATION;
|
||||||
GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist);
|
GpxPoint next = findNextGpxPointWithin(gctx, gpxPoints, start, routeDist);
|
||||||
boolean routeFound = false;
|
boolean routeFound = false;
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.commons.logging.Log;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -44,6 +45,7 @@ public class GpxApproximator {
|
||||||
|
|
||||||
private ThreadPoolExecutor singleThreadedExecutor;
|
private ThreadPoolExecutor singleThreadedExecutor;
|
||||||
private GpxApproximationProgressCallback approximationProgress;
|
private GpxApproximationProgressCallback approximationProgress;
|
||||||
|
private Future<?> currentApproximationTask;
|
||||||
|
|
||||||
public interface GpxApproximationProgressCallback {
|
public interface GpxApproximationProgressCallback {
|
||||||
|
|
||||||
|
@ -152,7 +154,10 @@ public class GpxApproximator {
|
||||||
this.gctx = gctx;
|
this.gctx = gctx;
|
||||||
startProgress();
|
startProgress();
|
||||||
updateProgress(gctx);
|
updateProgress(gctx);
|
||||||
singleThreadedExecutor.submit(new Runnable() {
|
if (currentApproximationTask != null) {
|
||||||
|
currentApproximationTask.cancel(true);
|
||||||
|
}
|
||||||
|
currentApproximationTask = singleThreadedExecutor.submit(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue