Setup activities
This commit is contained in:
parent
1e85c0234d
commit
8f96cdf1cd
13 changed files with 156 additions and 47 deletions
|
@ -2001,4 +2001,10 @@ public class BinaryMapIndexReader {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initRouteRegion(RouteRegion routeReg) throws IOException {
|
||||||
|
if(routeAdapter != null){
|
||||||
|
routeAdapter.initRouteRegion(routeReg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -31,6 +31,7 @@ import net.osmand.osm.MapUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import com.google.protobuf.CodedInputStreamRAF;
|
import com.google.protobuf.CodedInputStreamRAF;
|
||||||
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
import com.google.protobuf.WireFormat;
|
import com.google.protobuf.WireFormat;
|
||||||
|
|
||||||
public class BinaryMapRouteReaderAdapter {
|
public class BinaryMapRouteReaderAdapter {
|
||||||
|
@ -177,7 +178,7 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
return routeEncodingRules.get(id);
|
return routeEncodingRules.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initRouteEncodingRule(int id, String tags, String val) {
|
private void initRouteEncodingRule(int id, String tags, String val) {
|
||||||
while(routeEncodingRules.size() <= id) {
|
while(routeEncodingRules.size() <= id) {
|
||||||
routeEncodingRules.add(null);
|
routeEncodingRules.add(null);
|
||||||
}
|
}
|
||||||
|
@ -657,15 +658,19 @@ public class BinaryMapRouteReaderAdapter {
|
||||||
public void initRouteTypesIfNeeded(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
|
public void initRouteTypesIfNeeded(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
|
||||||
for (RouteSubregion rs : list) {
|
for (RouteSubregion rs : list) {
|
||||||
if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) {
|
if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) {
|
||||||
if (rs.routeReg.routeEncodingRules.isEmpty()) {
|
initRouteRegion(rs.routeReg);
|
||||||
codedIS.seek(rs.routeReg.filePointer);
|
}
|
||||||
int oldLimit = codedIS.pushLimit(rs.routeReg.length);
|
}
|
||||||
readRouteIndex(rs.routeReg);
|
}
|
||||||
|
|
||||||
|
public void initRouteRegion(RouteRegion routeReg) throws IOException, InvalidProtocolBufferException {
|
||||||
|
if (routeReg.routeEncodingRules.isEmpty()) {
|
||||||
|
codedIS.seek(routeReg.filePointer);
|
||||||
|
int oldLimit = codedIS.pushLimit(routeReg.length);
|
||||||
|
readRouteIndex(routeReg);
|
||||||
codedIS.popLimit(oldLimit);
|
codedIS.popLimit(oldLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<RouteDataObject> loadRouteRegionData(RouteSubregion rs) throws IOException {
|
public List<RouteDataObject> loadRouteRegionData(RouteSubregion rs) throws IOException {
|
||||||
|
|
|
@ -3636,7 +3636,7 @@ public final class OsmandIndex {
|
||||||
public boolean hasOffset() { return hasOffset; }
|
public boolean hasOffset() { return hasOffset; }
|
||||||
public long getOffset() { return offset_; }
|
public long getOffset() { return offset_; }
|
||||||
|
|
||||||
// required bool basemap = 3;
|
// optional bool basemap = 3;
|
||||||
public static final int BASEMAP_FIELD_NUMBER = 3;
|
public static final int BASEMAP_FIELD_NUMBER = 3;
|
||||||
private boolean hasBasemap;
|
private boolean hasBasemap;
|
||||||
private boolean basemap_ = false;
|
private boolean basemap_ = false;
|
||||||
|
@ -3684,7 +3684,6 @@ public final class OsmandIndex {
|
||||||
public final boolean isInitialized() {
|
public final boolean isInitialized() {
|
||||||
if (!hasSize) return false;
|
if (!hasSize) return false;
|
||||||
if (!hasOffset) return false;
|
if (!hasOffset) return false;
|
||||||
if (!hasBasemap) return false;
|
|
||||||
if (!hasLeft) return false;
|
if (!hasLeft) return false;
|
||||||
if (!hasRight) return false;
|
if (!hasRight) return false;
|
||||||
if (!hasTop) return false;
|
if (!hasTop) return false;
|
||||||
|
@ -4032,7 +4031,7 @@ public final class OsmandIndex {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required bool basemap = 3;
|
// optional bool basemap = 3;
|
||||||
public boolean hasBasemap() {
|
public boolean hasBasemap() {
|
||||||
return result.hasBasemap();
|
return result.hasBasemap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,16 +5,16 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
|
|
||||||
import net.osmand.LogUtil;
|
import net.osmand.LogUtil;
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter;
|
||||||
import net.osmand.binary.RouteDataObject;
|
|
||||||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion;
|
||||||
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.osm.LatLon;
|
import net.osmand.osm.LatLon;
|
||||||
import net.osmand.osm.MapUtils;
|
import net.osmand.osm.MapUtils;
|
||||||
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
public class RoutePlannerFrontEnd {
|
public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
private boolean useOldVersion;
|
private boolean useOldVersion;
|
||||||
|
@ -181,7 +181,7 @@ public class RoutePlannerFrontEnd {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, boolean leftSideNavigation) {
|
private List<RouteSegmentResult> runNativeRouting(final RoutingContext ctx, boolean leftSideNavigation) throws IOException {
|
||||||
refreshProgressDistance(ctx);
|
refreshProgressDistance(ctx);
|
||||||
RouteRegion[] regions = ctx.reverseMap.keySet().toArray(new BinaryMapRouteReaderAdapter.RouteRegion[ctx.reverseMap.size()]);
|
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,
|
RouteSegmentResult[] res = ctx.nativeLib.runNativeRouting(ctx.startX, ctx.startY, ctx.targetX, ctx.targetY,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.osmand.router;
|
package net.osmand.router;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -7,6 +8,7 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.binary.RouteDataObject;
|
import net.osmand.binary.RouteDataObject;
|
||||||
import net.osmand.osm.LatLon;
|
import net.osmand.osm.LatLon;
|
||||||
import net.osmand.osm.MapUtils;
|
import net.osmand.osm.MapUtils;
|
||||||
|
@ -20,13 +22,13 @@ public class RouteResultPreparation {
|
||||||
/**
|
/**
|
||||||
* Helper method to prepare final result
|
* Helper method to prepare final result
|
||||||
*/
|
*/
|
||||||
List<RouteSegmentResult> prepareResult(RoutingContext ctx, FinalRouteSegment finalSegment,boolean leftside) {
|
List<RouteSegmentResult> prepareResult(RoutingContext ctx, FinalRouteSegment finalSegment,boolean leftside) throws IOException {
|
||||||
List<RouteSegmentResult> result = convertFinalSegmentToResults(ctx, finalSegment);
|
List<RouteSegmentResult> result = convertFinalSegmentToResults(ctx, finalSegment);
|
||||||
prepareResult(ctx, leftside, result);
|
prepareResult(ctx, leftside, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<RouteSegmentResult> prepareResult(RoutingContext ctx, boolean leftside, List<RouteSegmentResult> result) {
|
List<RouteSegmentResult> prepareResult(RoutingContext ctx, boolean leftside, List<RouteSegmentResult> result) throws IOException {
|
||||||
validateAllPointsConnected(result);
|
validateAllPointsConnected(result);
|
||||||
// calculate time
|
// calculate time
|
||||||
calculateTimeSpeedAndAttachRoadSegments(ctx, result);
|
calculateTimeSpeedAndAttachRoadSegments(ctx, result);
|
||||||
|
@ -35,13 +37,17 @@ public class RouteResultPreparation {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateTimeSpeedAndAttachRoadSegments(RoutingContext ctx, List<RouteSegmentResult> result) {
|
private void calculateTimeSpeedAndAttachRoadSegments(RoutingContext ctx, List<RouteSegmentResult> result) throws IOException {
|
||||||
for (int i = 0; i < result.size(); i++) {
|
for (int i = 0; i < result.size(); i++) {
|
||||||
if(ctx.checkIfMemoryLimitCritical(ctx.config.memoryLimitation)) {
|
if(ctx.checkIfMemoryLimitCritical(ctx.config.memoryLimitation)) {
|
||||||
ctx.unloadUnusedTiles(ctx.config.memoryLimitation);
|
ctx.unloadUnusedTiles(ctx.config.memoryLimitation);
|
||||||
}
|
}
|
||||||
RouteSegmentResult rr = result.get(i);
|
RouteSegmentResult rr = result.get(i);
|
||||||
RouteDataObject road = rr.getObject();
|
RouteDataObject road = rr.getObject();
|
||||||
|
BinaryMapIndexReader reader = ctx.reverseMap.get(road.region);
|
||||||
|
if(reader != null) {
|
||||||
|
reader.initRouteRegion(road.region);
|
||||||
|
}
|
||||||
double distOnRoadToPass = 0;
|
double distOnRoadToPass = 0;
|
||||||
double speed = ctx.getRouter().defineSpeed(road);
|
double speed = ctx.getRouter().defineSpeed(road);
|
||||||
if (speed == 0) {
|
if (speed == 0) {
|
||||||
|
|
|
@ -75,7 +75,7 @@ message MapPart {
|
||||||
message RoutingSubregion {
|
message RoutingSubregion {
|
||||||
required int64 size = 1;
|
required int64 size = 1;
|
||||||
required int64 offset = 2;
|
required int64 offset = 2;
|
||||||
required bool basemap= 3;
|
optional bool basemap= 3;
|
||||||
|
|
||||||
required int32 left = 4;
|
required int32 left = 4;
|
||||||
required int32 right = 5;
|
required int32 right = 5;
|
||||||
|
|
|
@ -66,17 +66,22 @@ import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Gravity;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.animation.AccelerateInterpolator;
|
import android.view.animation.AccelerateInterpolator;
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.Transformation;
|
import android.view.animation.Transformation;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
@ -199,6 +204,7 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
savingTrackHelper = getMyApplication().getSavingTrackHelper();
|
savingTrackHelper = getMyApplication().getSavingTrackHelper();
|
||||||
liveMonitoringHelper = getMyApplication().getLiveMonitoringHelper();
|
liveMonitoringHelper = getMyApplication().getLiveMonitoringHelper();
|
||||||
routingHelper = getMyApplication().getRoutingHelper();
|
routingHelper = getMyApplication().getRoutingHelper();
|
||||||
|
createProgressBarForRouting();
|
||||||
// This situtation could be when navigation suddenly crashed and after restarting
|
// This situtation could be when navigation suddenly crashed and after restarting
|
||||||
// it tries to continue the last route
|
// it tries to continue the last route
|
||||||
if(settings.FOLLOW_THE_ROUTE.get() && !routingHelper.isRouteCalculated()){
|
if(settings.FOLLOW_THE_ROUTE.get() && !routingHelper.isRouteCalculated()){
|
||||||
|
@ -234,6 +240,22 @@ public class MapActivity extends AccessibleActivity implements IMapLocationListe
|
||||||
OsmandPlugin.onMapActivityCreate(this);
|
OsmandPlugin.onMapActivityCreate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createProgressBarForRouting() {
|
||||||
|
FrameLayout parent = (FrameLayout) mapView.getParent();
|
||||||
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||||
|
Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
||||||
|
DisplayMetrics dm = getResources().getDisplayMetrics();
|
||||||
|
params.topMargin = (int) (100 * dm.density);
|
||||||
|
ProgressBar pb = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
|
||||||
|
pb.setIndeterminate(false);
|
||||||
|
pb.setMax(100);
|
||||||
|
pb.setLayoutParams(params);
|
||||||
|
pb.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
parent.addView(pb);
|
||||||
|
routingHelper.setProgressBar(pb, new Handler());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
public Object getLastNonConfigurationInstanceByKey(String key) {
|
public Object getLastNonConfigurationInstanceByKey(String key) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import net.osmand.router.RouteCalculationProgress;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
|
|
||||||
public class RouteCalcuationParams {
|
public class RouteCalculationParams {
|
||||||
|
|
||||||
public Location start;
|
public Location start;
|
||||||
public LatLon end;
|
public LatLon end;
|
|
@ -145,7 +145,7 @@ public class RouteProvider {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public RouteCalculationResult calculateRouteImpl(RouteCalcuationParams params){
|
public RouteCalculationResult calculateRouteImpl(RouteCalculationParams params){
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
if (params.start != null && params.end != null) {
|
if (params.start != null && params.end != null) {
|
||||||
if(log.isInfoEnabled()){
|
if(log.isInfoEnabled()){
|
||||||
|
@ -181,7 +181,7 @@ public class RouteProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private RouteCalculationResult calculateGpxRoute(RouteCalcuationParams pars) {
|
private RouteCalculationResult calculateGpxRoute(RouteCalculationParams pars) {
|
||||||
RouteCalculationResult res;
|
RouteCalculationResult res;
|
||||||
// get the closest point to start and to end
|
// get the closest point to start and to end
|
||||||
float minDist = Integer.MAX_VALUE;
|
float minDist = Integer.MAX_VALUE;
|
||||||
|
@ -247,7 +247,7 @@ public class RouteProvider {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected RouteCalculationResult findYOURSRoute(RouteCalcuationParams params) throws MalformedURLException, IOException,
|
protected RouteCalculationResult findYOURSRoute(RouteCalculationParams params) throws MalformedURLException, IOException,
|
||||||
ParserConfigurationException, FactoryConfigurationError, SAXException {
|
ParserConfigurationException, FactoryConfigurationError, SAXException {
|
||||||
List<Location> res = new ArrayList<Location>();
|
List<Location> res = new ArrayList<Location>();
|
||||||
StringBuilder uri = new StringBuilder();
|
StringBuilder uri = new StringBuilder();
|
||||||
|
@ -306,7 +306,7 @@ public class RouteProvider {
|
||||||
params.ctx, params.leftSide, true);
|
params.ctx, params.leftSide, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RouteCalculationResult findVectorMapsRoute(RouteCalcuationParams params) throws IOException {
|
protected RouteCalculationResult findVectorMapsRoute(RouteCalculationParams params) throws IOException {
|
||||||
OsmandApplication app = (OsmandApplication) params.ctx.getApplicationContext();
|
OsmandApplication app = (OsmandApplication) params.ctx.getApplicationContext();
|
||||||
BinaryMapIndexReader[] files = app.getResourceManager().getRoutingMapFiles();
|
BinaryMapIndexReader[] files = app.getResourceManager().getRoutingMapFiles();
|
||||||
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(true);
|
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(true);
|
||||||
|
@ -411,7 +411,7 @@ public class RouteProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected RouteCalculationResult findCloudMadeRoute(RouteCalcuationParams params)
|
protected RouteCalculationResult findCloudMadeRoute(RouteCalculationParams params)
|
||||||
throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException {
|
throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError, SAXException {
|
||||||
List<Location> res = new ArrayList<Location>();
|
List<Location> res = new ArrayList<Location>();
|
||||||
List<RouteDirectionInfo> directions = null;
|
List<RouteDirectionInfo> directions = null;
|
||||||
|
@ -578,7 +578,7 @@ public class RouteProvider {
|
||||||
return directions;
|
return directions;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RouteCalculationResult findORSRoute(RouteCalcuationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError,
|
protected RouteCalculationResult findORSRoute(RouteCalculationParams params) throws MalformedURLException, IOException, ParserConfigurationException, FactoryConfigurationError,
|
||||||
SAXException {
|
SAXException {
|
||||||
List<Location> res = new ArrayList<Location>();
|
List<Location> res = new ArrayList<Location>();
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.location.Location;
|
import android.location.Location;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class RoutingHelper {
|
public class RoutingHelper {
|
||||||
|
@ -70,6 +72,9 @@ public class RoutingHelper {
|
||||||
private boolean makeUturnWhenPossible = false;
|
private boolean makeUturnWhenPossible = false;
|
||||||
private long makeUTwpDetected = 0;
|
private long makeUTwpDetected = 0;
|
||||||
|
|
||||||
|
private ProgressBar progress;
|
||||||
|
private Handler progressHandler;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public boolean makeUturnWhenPossible() {
|
public boolean makeUturnWhenPossible() {
|
||||||
|
@ -570,9 +575,9 @@ public class RoutingHelper {
|
||||||
private class RouteRecalculationThread extends Thread {
|
private class RouteRecalculationThread extends Thread {
|
||||||
|
|
||||||
private boolean interrupted = false;
|
private boolean interrupted = false;
|
||||||
private final RouteCalcuationParams params;
|
private final RouteCalculationParams params;
|
||||||
|
|
||||||
public RouteRecalculationThread(String name, RouteCalcuationParams params) {
|
public RouteRecalculationThread(String name, RouteCalculationParams params) {
|
||||||
super(name);
|
super(name);
|
||||||
this.params = params;
|
this.params = params;
|
||||||
if(params.calculationProgress == null) {
|
if(params.calculationProgress == null) {
|
||||||
|
@ -629,7 +634,7 @@ public class RoutingHelper {
|
||||||
if(currentRunningJob == null){
|
if(currentRunningJob == null){
|
||||||
// do not evaluate very often
|
// do not evaluate very often
|
||||||
if (System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
|
if (System.currentTimeMillis() - lastTimeEvaluatedRoute > evalWaitInterval) {
|
||||||
RouteCalcuationParams params = new RouteCalcuationParams();
|
RouteCalculationParams params = new RouteCalculationParams();
|
||||||
params.start = start;
|
params.start = start;
|
||||||
params.end = end;
|
params.end = end;
|
||||||
params.intermediates = intermediates;
|
params.intermediates = intermediates;
|
||||||
|
@ -641,6 +646,10 @@ public class RoutingHelper {
|
||||||
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
|
params.type = settings.ROUTER_SERVICE.getModeValue(mode);
|
||||||
params.mode = mode;
|
params.mode = mode;
|
||||||
params.ctx = app;
|
params.ctx = app;
|
||||||
|
if(previousRoute == null && params.type == RouteService.OSMAND) {
|
||||||
|
params.calculationProgress = new RouteCalculationProgress();
|
||||||
|
updateProgress(params.calculationProgress);
|
||||||
|
}
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
currentRunningJob = new RouteRecalculationThread("Calculating route", params); //$NON-NLS-1$
|
currentRunningJob = new RouteRecalculationThread("Calculating route", params); //$NON-NLS-1$
|
||||||
currentRunningJob.start();
|
currentRunningJob.start();
|
||||||
|
@ -650,6 +659,29 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateProgress(final RouteCalculationProgress calculationProgress) {
|
||||||
|
if(progress != null) {
|
||||||
|
progressHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (isRouteBeingCalculated()) {
|
||||||
|
progress.setVisibility(View.VISIBLE);
|
||||||
|
float p = calculationProgress.distanceFromBegin + calculationProgress.distanceFromEnd;
|
||||||
|
float all = calculationProgress.totalEstimatedDistance * 1.5f;
|
||||||
|
if (all > 0) {
|
||||||
|
int t = (int) Math.min(p * p / (all * all) * 100f, 99);
|
||||||
|
progress.setProgress(t);
|
||||||
|
updateProgress(calculationProgress);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
progress.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isRouteBeingCalculated(){
|
public boolean isRouteBeingCalculated(){
|
||||||
return currentRunningJob != null;
|
return currentRunningJob != null;
|
||||||
}
|
}
|
||||||
|
@ -682,4 +714,12 @@ public class RoutingHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setProgressBar(ProgressBar pb, Handler handler) {
|
||||||
|
progress = pb;
|
||||||
|
progressHandler = handler;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1007,7 +1007,6 @@ void searchRouteSubregions(SearchQuery* q, std::vector<RouteSubregion>& tempResu
|
||||||
void readRouteMapObjects(SearchQuery* q, BinaryMapFile* file, vector<RouteSubregion>& found,
|
void readRouteMapObjects(SearchQuery* q, BinaryMapFile* file, vector<RouteSubregion>& found,
|
||||||
RoutingIndex* routeIndex, std::vector<MapDataObject*>& tempResult, bool skipDuplicates,
|
RoutingIndex* routeIndex, std::vector<MapDataObject*>& tempResult, bool skipDuplicates,
|
||||||
IDS_SET& ids) {
|
IDS_SET& ids) {
|
||||||
osmand_log_print(LOG_INFO, "Search map %s %d", routeIndex->name.c_str(), found.size());
|
|
||||||
sort(found.begin(), found.end(), sortRouteRegions);
|
sort(found.begin(), found.end(), sortRouteRegions);
|
||||||
lseek(file->fd, 0, SEEK_SET);
|
lseek(file->fd, 0, SEEK_SET);
|
||||||
FileInputStream input(file->fd);
|
FileInputStream input(file->fd);
|
||||||
|
@ -1045,7 +1044,6 @@ void readRouteDataAsMapObjects(SearchQuery* q, BinaryMapFile* file, std::vector<
|
||||||
contains = true;
|
contains = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
osmand_log_print(LOG_INFO, "Search map %s %d", (*routeIndex)->name.c_str(), subs.size());
|
|
||||||
if (contains) {
|
if (contains) {
|
||||||
vector<RouteSubregion> found;
|
vector<RouteSubregion> found;
|
||||||
lseek(file->fd, 0, SEEK_SET);
|
lseek(file->fd, 0, SEEK_SET);
|
||||||
|
|
|
@ -2373,6 +2373,7 @@ void MapPart::Swap(MapPart* other) {
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
const int RoutingSubregion::kSizeFieldNumber;
|
const int RoutingSubregion::kSizeFieldNumber;
|
||||||
const int RoutingSubregion::kOffsetFieldNumber;
|
const int RoutingSubregion::kOffsetFieldNumber;
|
||||||
|
const int RoutingSubregion::kBasemapFieldNumber;
|
||||||
const int RoutingSubregion::kLeftFieldNumber;
|
const int RoutingSubregion::kLeftFieldNumber;
|
||||||
const int RoutingSubregion::kRightFieldNumber;
|
const int RoutingSubregion::kRightFieldNumber;
|
||||||
const int RoutingSubregion::kTopFieldNumber;
|
const int RoutingSubregion::kTopFieldNumber;
|
||||||
|
@ -2398,6 +2399,7 @@ void RoutingSubregion::SharedCtor() {
|
||||||
_cached_size_ = 0;
|
_cached_size_ = 0;
|
||||||
size_ = GOOGLE_LONGLONG(0);
|
size_ = GOOGLE_LONGLONG(0);
|
||||||
offset_ = GOOGLE_LONGLONG(0);
|
offset_ = GOOGLE_LONGLONG(0);
|
||||||
|
basemap_ = false;
|
||||||
left_ = 0;
|
left_ = 0;
|
||||||
right_ = 0;
|
right_ = 0;
|
||||||
top_ = 0;
|
top_ = 0;
|
||||||
|
@ -2434,6 +2436,7 @@ void RoutingSubregion::Clear() {
|
||||||
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
|
||||||
size_ = GOOGLE_LONGLONG(0);
|
size_ = GOOGLE_LONGLONG(0);
|
||||||
offset_ = GOOGLE_LONGLONG(0);
|
offset_ = GOOGLE_LONGLONG(0);
|
||||||
|
basemap_ = false;
|
||||||
left_ = 0;
|
left_ = 0;
|
||||||
right_ = 0;
|
right_ = 0;
|
||||||
top_ = 0;
|
top_ = 0;
|
||||||
|
@ -2476,6 +2479,22 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
if (input->ExpectTag(24)) goto parse_basemap;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// optional bool basemap = 3;
|
||||||
|
case 3: {
|
||||||
|
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||||
|
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||||
|
parse_basemap:
|
||||||
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
|
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
|
||||||
|
input, &basemap_)));
|
||||||
|
_set_bit(2);
|
||||||
|
} else {
|
||||||
|
goto handle_uninterpreted;
|
||||||
|
}
|
||||||
if (input->ExpectTag(32)) goto parse_left;
|
if (input->ExpectTag(32)) goto parse_left;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -2488,7 +2507,7 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||||
input, &left_)));
|
input, &left_)));
|
||||||
_set_bit(2);
|
_set_bit(3);
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
@ -2504,7 +2523,7 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||||
input, &right_)));
|
input, &right_)));
|
||||||
_set_bit(3);
|
_set_bit(4);
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
@ -2520,7 +2539,7 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||||
input, &top_)));
|
input, &top_)));
|
||||||
_set_bit(4);
|
_set_bit(5);
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
@ -2536,7 +2555,7 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
|
||||||
input, &bottom_)));
|
input, &bottom_)));
|
||||||
_set_bit(5);
|
_set_bit(6);
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
@ -2552,7 +2571,7 @@ bool RoutingSubregion::MergePartialFromCodedStream(
|
||||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||||
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
|
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
|
||||||
input, &shiftodata_)));
|
input, &shiftodata_)));
|
||||||
_set_bit(6);
|
_set_bit(7);
|
||||||
} else {
|
} else {
|
||||||
goto handle_uninterpreted;
|
goto handle_uninterpreted;
|
||||||
}
|
}
|
||||||
|
@ -2587,28 +2606,33 @@ void RoutingSubregion::SerializeWithCachedSizes(
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->offset(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt64(2, this->offset(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// required int32 left = 4;
|
// optional bool basemap = 3;
|
||||||
if (_has_bit(2)) {
|
if (_has_bit(2)) {
|
||||||
|
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->basemap(), output);
|
||||||
|
}
|
||||||
|
|
||||||
|
// required int32 left = 4;
|
||||||
|
if (_has_bit(3)) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->left(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt32(4, this->left(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// required int32 right = 5;
|
// required int32 right = 5;
|
||||||
if (_has_bit(3)) {
|
if (_has_bit(4)) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->right(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt32(5, this->right(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// required int32 top = 6;
|
// required int32 top = 6;
|
||||||
if (_has_bit(4)) {
|
if (_has_bit(5)) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->top(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt32(6, this->top(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// required int32 bottom = 7;
|
// required int32 bottom = 7;
|
||||||
if (_has_bit(5)) {
|
if (_has_bit(6)) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->bottom(), output);
|
::google::protobuf::internal::WireFormatLite::WriteInt32(7, this->bottom(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
// required uint32 shifToData = 8;
|
// required uint32 shifToData = 8;
|
||||||
if (_has_bit(6)) {
|
if (_has_bit(7)) {
|
||||||
::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->shiftodata(), output);
|
::google::protobuf::internal::WireFormatLite::WriteUInt32(8, this->shiftodata(), output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2632,6 +2656,11 @@ int RoutingSubregion::ByteSize() const {
|
||||||
this->offset());
|
this->offset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// optional bool basemap = 3;
|
||||||
|
if (has_basemap()) {
|
||||||
|
total_size += 1 + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// required int32 left = 4;
|
// required int32 left = 4;
|
||||||
if (has_left()) {
|
if (has_left()) {
|
||||||
total_size += 1 +
|
total_size += 1 +
|
||||||
|
@ -2689,18 +2718,21 @@ void RoutingSubregion::MergeFrom(const RoutingSubregion& from) {
|
||||||
set_offset(from.offset());
|
set_offset(from.offset());
|
||||||
}
|
}
|
||||||
if (from._has_bit(2)) {
|
if (from._has_bit(2)) {
|
||||||
set_left(from.left());
|
set_basemap(from.basemap());
|
||||||
}
|
}
|
||||||
if (from._has_bit(3)) {
|
if (from._has_bit(3)) {
|
||||||
set_right(from.right());
|
set_left(from.left());
|
||||||
}
|
}
|
||||||
if (from._has_bit(4)) {
|
if (from._has_bit(4)) {
|
||||||
set_top(from.top());
|
set_right(from.right());
|
||||||
}
|
}
|
||||||
if (from._has_bit(5)) {
|
if (from._has_bit(5)) {
|
||||||
set_bottom(from.bottom());
|
set_top(from.top());
|
||||||
}
|
}
|
||||||
if (from._has_bit(6)) {
|
if (from._has_bit(6)) {
|
||||||
|
set_bottom(from.bottom());
|
||||||
|
}
|
||||||
|
if (from._has_bit(7)) {
|
||||||
set_shiftodata(from.shiftodata());
|
set_shiftodata(from.shiftodata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2713,7 +2745,7 @@ void RoutingSubregion::CopyFrom(const RoutingSubregion& from) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RoutingSubregion::IsInitialized() const {
|
bool RoutingSubregion::IsInitialized() const {
|
||||||
if ((_has_bits_[0] & 0x0000007f) != 0x0000007f) return false;
|
if ((_has_bits_[0] & 0x000000fb) != 0x000000fb) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2722,6 +2754,7 @@ void RoutingSubregion::Swap(RoutingSubregion* other) {
|
||||||
if (other != this) {
|
if (other != this) {
|
||||||
std::swap(size_, other->size_);
|
std::swap(size_, other->size_);
|
||||||
std::swap(offset_, other->offset_);
|
std::swap(offset_, other->offset_);
|
||||||
|
std::swap(basemap_, other->basemap_);
|
||||||
std::swap(left_, other->left_);
|
std::swap(left_, other->left_);
|
||||||
std::swap(right_, other->right_);
|
std::swap(right_, other->right_);
|
||||||
std::swap(top_, other->top_);
|
std::swap(top_, other->top_);
|
||||||
|
|
|
@ -962,7 +962,7 @@ class RoutingSubregion : public ::google::protobuf::MessageLite {
|
||||||
inline ::google::protobuf::int64 offset() const;
|
inline ::google::protobuf::int64 offset() const;
|
||||||
inline void set_offset(::google::protobuf::int64 value);
|
inline void set_offset(::google::protobuf::int64 value);
|
||||||
|
|
||||||
// required bool basemap = 3;
|
// optional bool basemap = 3;
|
||||||
inline bool has_basemap() const;
|
inline bool has_basemap() const;
|
||||||
inline void clear_basemap();
|
inline void clear_basemap();
|
||||||
static const int kBasemapFieldNumber = 3;
|
static const int kBasemapFieldNumber = 3;
|
||||||
|
@ -2216,7 +2216,7 @@ inline void RoutingSubregion::set_offset(::google::protobuf::int64 value) {
|
||||||
offset_ = value;
|
offset_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// required bool basemap = 3;
|
// optional bool basemap = 3;
|
||||||
inline bool RoutingSubregion::has_basemap() const {
|
inline bool RoutingSubregion::has_basemap() const {
|
||||||
return _has_bit(2);
|
return _has_bit(2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue