Fix routing issue
This commit is contained in:
parent
f949218eae
commit
42e9e10fa8
4 changed files with 66 additions and 24 deletions
|
@ -1959,12 +1959,17 @@ public class BinaryMapIndexReader {
|
|||
}));
|
||||
}
|
||||
|
||||
public void initRouteRegionsIfNeeded(SearchRequest<RouteDataObject> req) throws IOException {
|
||||
routeAdapter.initRouteTypesIfNeeded(req);
|
||||
}
|
||||
|
||||
public void searchRouteIndex(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
|
||||
req.numberOfVisitedObjects = 0;
|
||||
req.numberOfAcceptedObjects = 0;
|
||||
req.numberOfAcceptedSubtrees = 0;
|
||||
req.numberOfReadSubtrees = 0;
|
||||
if(routeAdapter != null){
|
||||
initRouteRegionsIfNeeded(req);
|
||||
routeAdapter.searchRouteRegion(req, list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -154,10 +154,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
}
|
||||
|
||||
public static class RouteRegion extends BinaryIndexPart {
|
||||
double leftLongitude;
|
||||
double rightLongitude;
|
||||
double topLatitude;
|
||||
double bottomLatitude;
|
||||
int regionsRead;
|
||||
|
||||
List<RouteSubregion> subregions = new ArrayList<RouteSubregion>();
|
||||
|
@ -165,22 +161,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
int nameTypeRule = -1;
|
||||
int refTypeRule = -1;
|
||||
|
||||
public double getLeftLongitude() {
|
||||
return leftLongitude;
|
||||
}
|
||||
|
||||
public double getRightLongitude() {
|
||||
return rightLongitude;
|
||||
}
|
||||
|
||||
public double getTopLatitude() {
|
||||
return topLatitude;
|
||||
}
|
||||
|
||||
public double getBottomLatitude() {
|
||||
return bottomLatitude;
|
||||
}
|
||||
|
||||
public RouteTypeRule quickGetEncodingRule(int id) {
|
||||
return routeEncodingRules.get(id);
|
||||
}
|
||||
|
@ -200,6 +180,38 @@ public class BinaryMapRouteReaderAdapter {
|
|||
public List<RouteSubregion> getSubregions(){
|
||||
return subregions;
|
||||
}
|
||||
|
||||
public double getLeftLongitude() {
|
||||
double l = 180;
|
||||
for(RouteSubregion s : subregions) {
|
||||
l = Math.min(l, MapUtils.get31LongitudeX(s.left));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getRightLongitude() {
|
||||
double l = -180;
|
||||
for(RouteSubregion s : subregions) {
|
||||
l = Math.max(l, MapUtils.get31LongitudeX(s.right));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getBottomLatitude() {
|
||||
double l = 90;
|
||||
for(RouteSubregion s : subregions) {
|
||||
l = Math.min(l, MapUtils.get31LatitudeY(s.bottom));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public double getTopLatitude() {
|
||||
double l = -90;
|
||||
for(RouteSubregion s : subregions) {
|
||||
l = Math.max(l, MapUtils.get31LatitudeY(s.top));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
public static class RouteSubregion {
|
||||
|
@ -285,10 +297,6 @@ public class BinaryMapRouteReaderAdapter {
|
|||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
codedIS.popLimit(oldLimit);
|
||||
|
||||
region.bottomLatitude = MapUtils.get31LatitudeY(subregion.bottom);
|
||||
region.topLatitude = MapUtils.get31LatitudeY(subregion.top);
|
||||
region.rightLongitude = MapUtils.get31LongitudeX(subregion.right);
|
||||
region.leftLongitude = MapUtils.get31LongitudeX(subregion.left);
|
||||
// Finish reading file!
|
||||
codedIS.skipRawBytes(codedIS.getBytesUntilLimit());
|
||||
} break;
|
||||
|
@ -591,6 +599,27 @@ public class BinaryMapRouteReaderAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public void initRouteTypesIfNeeded(SearchRequest<RouteDataObject> req) throws IOException{
|
||||
for(RouteRegion r: map.getRoutingIndexes() ) {
|
||||
if (r.routeEncodingRules.isEmpty()) {
|
||||
boolean intersect = false;
|
||||
for (RouteSubregion rs : r.subregions) {
|
||||
if (req.intersects(rs.left, rs.top, rs.right, rs.bottom)) {
|
||||
intersect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(intersect) {
|
||||
codedIS.seek(r.filePointer);
|
||||
int oldLimit = codedIS.pushLimit(r.length);
|
||||
readRouteIndex(r);
|
||||
codedIS.popLimit(oldLimit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void searchRouteRegion(SearchRequest<RouteDataObject> req, List<RouteSubregion> list) throws IOException {
|
||||
List<RouteSubregion> toLoad = new ArrayList<BinaryMapRouteReaderAdapter.RouteSubregion>();
|
||||
searchRouteRegion(req, list, toLoad);
|
||||
|
|
|
@ -259,6 +259,11 @@ public class RoutingContext {
|
|||
(tileX + 1) << zoomToLoad, tileY << zoomToLoad, (tileY + 1) << zoomToLoad, matcher);
|
||||
for (Entry<BinaryMapIndexReader, List<RouteSubregion>> r : map.entrySet()) {
|
||||
if(nativeLib != null) {
|
||||
try {
|
||||
r.getKey().initRouteRegionsIfNeeded(request);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Loading data exception", e);
|
||||
}
|
||||
for(RouteRegion reg : r.getKey().getRoutingIndexes()) {
|
||||
NativeRouteSearchResult rs = nativeLoadRegion(request, reg, nativeLib, loadData);
|
||||
if(rs != null) {
|
||||
|
|
|
@ -412,6 +412,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||
buttons[ApplicationMode.PEDESTRIAN.ordinal()] = (ToggleButton) view.findViewById(R.id.PedestrianButton);
|
||||
ApplicationMode appMode = settings.getApplicationMode();
|
||||
if(appMode == ApplicationMode.DEFAULT) {
|
||||
appMode = ApplicationMode.CAR;
|
||||
}
|
||||
for (int i = 0; i < buttons.length; i++) {
|
||||
if (buttons[i] != null) {
|
||||
final int ind = i;
|
||||
|
|
Loading…
Reference in a new issue