Change interface

This commit is contained in:
vshcherb 2014-01-22 23:41:43 +01:00
parent 6d785e7bba
commit 2ce1385ae5
3 changed files with 13 additions and 11 deletions

View file

@ -22,6 +22,7 @@ import net.osmand.binary.RouteDataObject;
import net.osmand.render.RenderingRuleSearchRequest;
import net.osmand.render.RenderingRulesStorage;
import net.osmand.router.GeneralRouter;
import net.osmand.router.PrecalculatedRouteDirection;
import net.osmand.router.RouteCalculationProgress;
import net.osmand.router.RouteSegmentResult;
import net.osmand.router.RoutingConfiguration;
@ -129,7 +130,8 @@ public class NativeLibrary {
}
public RouteSegmentResult[] runNativeRouting(int sx31, int sy31, int ex31, int ey31, RoutingConfiguration config,
RouteRegion[] regions, RouteCalculationProgress progress) {
RouteRegion[] regions, RouteCalculationProgress progress, PrecalculatedRouteDirection precalculatedRouteDirection,
boolean basemap) {
TIntArrayList state = new TIntArrayList();
List<String> keys = new ArrayList<String>();
List<String> values = new ArrayList<String>();
@ -145,7 +147,7 @@ public class NativeLibrary {
return nativeRouting(new int[] { sx31, sy31, ex31, ey31 }, state.toArray(), keys.toArray(new String[keys.size()]),
values.toArray(new String[values.size()]), config.initialDirection == null ? -360 : config.initialDirection.floatValue(),
regions, progress);
regions, progress, precalculatedRouteDirection, basemap);
}
public <T> void fillObjects(TIntArrayList state, List<String> keys, List<String> values, int s, Map<String, T> map) {
@ -175,7 +177,7 @@ public class NativeLibrary {
protected static native RouteDataObject[] getRouteDataObjects(RouteRegion reg, long rs, int x31, int y31);
protected static native RouteSegmentResult[] nativeRouting(int[] coordinates, int[] state, String[] keyConfig, String[] valueConfig,
float initDirection, RouteRegion[] regions, RouteCalculationProgress progress);
float initDirection, RouteRegion[] regions, RouteCalculationProgress progress, PrecalculatedRouteDirection precalculatedRouteDirection, boolean basemap);
protected static native void deleteSearchResult(long searchResultHandle);

View file

@ -14,7 +14,7 @@ public class PrecalculatedRouteDirection {
private TIntArrayList pointsX = new TIntArrayList();
private TIntArrayList pointsY = new TIntArrayList();
private float avgSpeed;
private float speed;
private float[] tms;
private static final int SHIFT = (1 << (31 - 18));
private static final int[] SHIFTS = new int[]{1 << (31 - 17), 1 << (31 - 15), 1 << (31 - 13), 1 << (31 - 12),
@ -28,12 +28,12 @@ public class PrecalculatedRouteDirection {
private DataTileManager<Integer> indexedPoints = new DataTileManager<Integer>(17);
private PrecalculatedRouteDirection(List<RouteSegmentResult> ls, float avgSpeed) {
this.avgSpeed = avgSpeed;
this.speed = avgSpeed;
init(ls);
}
private PrecalculatedRouteDirection(PrecalculatedRouteDirection parent, int s1, int s2) {
this.avgSpeed = parent.avgSpeed;
this.speed = parent.speed;
tms = new float[s2 - s1 + 1];
for (int i = s1; i <= s2; i++) {
pointsX.add(parent.pointsX.get(i));
@ -138,7 +138,7 @@ public class PrecalculatedRouteDirection {
}
double ds = BinaryRoutePlanner.squareRootDist(x31, y31, pointsX.get(ind), pointsY.get(ind));
ct[0] = tms[ind];
ct[1] = (float) (ds / avgSpeed);
ct[1] = (float) (ds / speed);
return ind;
}

View file

@ -92,6 +92,7 @@ public class RoutePlannerFrontEnd {
boolean intermediatesEmpty = intermediates == null || intermediates.isEmpty();
// TODO native, empty route...
// + intermediates, + progress, +complex,
// TODO remove fast recalculation
PrecalculatedRouteDirection routeDirection = null;
if(ctx.calculationMode == RouteCalculationMode.COMPLEX) {
RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE);
@ -100,8 +101,7 @@ public class RoutePlannerFrontEnd {
routeDirection = PrecalculatedRouteDirection.build(ls,
5000, ctx.getRouter().getMaxDefaultSpeed() );
}
// remove fast recalculation
if(intermediatesEmpty && useOldVersion && ctx.nativeLib != null) {
if(intermediatesEmpty && ctx.nativeLib != null) {
ctx.startX = MapUtils.get31TileNumberX(start.getLongitude());
ctx.startY = MapUtils.get31TileNumberY(start.getLatitude());
ctx.targetX = MapUtils.get31TileNumberX(end.getLongitude());
@ -159,7 +159,7 @@ public class RoutePlannerFrontEnd {
if(routeDirection != null) {
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
}
if (ctx.nativeLib != null && useOldVersion) {
if (ctx.nativeLib != null) {
return runNativeRouting(ctx);
} else {
refreshProgressDistance(ctx);
@ -191,7 +191,7 @@ public class RoutePlannerFrontEnd {
refreshProgressDistance(ctx);
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY,
ctx.config, regions, ctx.calculationProgress);
ctx.config, regions, ctx.calculationProgress, ctx.precalculatedRouteDirection, ctx.calculationMode == RouteCalculationMode.BASE);
ArrayList<RouteSegmentResult> result = new ArrayList<RouteSegmentResult>(Arrays.asList(res));
ctx.routingTime = ctx.calculationProgress.routingCalculatedTime;
ctx.visitedSegments = ctx.calculationProgress.visitedSegments;