Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-05-31 23:35:11 +02:00
commit 042f1af736
2 changed files with 43 additions and 15 deletions

View file

@ -258,21 +258,7 @@ public class MapRenderRepositories {
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
// check that everything is initialized // check that everything is initialized
for (String mapName : files.keySet()) { checkInitialized(zoom, library, leftX, rightX, bottomY, topY);
BinaryMapIndexReader fr = files.get(mapName);
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
if (!nativeFiles.contains(mapName)) {
long time = System.currentTimeMillis();
nativeFiles.add(mapName);
if (!library.initMapFile(mapName)) {
continue;
}
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
NativeSearchResult resultHandler = library.searchObjectsForRendering(leftX, rightX, topY, bottomY, zoom, renderingReq, NativeSearchResult resultHandler = library.searchObjectsForRendering(leftX, rightX, topY, bottomY, zoom, renderingReq,
checkForDuplicateObjectIds, this, ""); checkForDuplicateObjectIds, this, "");
if (checkWhetherInterrupted()) { if (checkWhetherInterrupted()) {
@ -291,6 +277,27 @@ public class MapRenderRepositories {
return true; return true;
} }
public void checkInitialized(final int zoom, NativeOsmandLibrary library, int leftX, int rightX, int bottomY,
int topY) {
if(library == null) {
return;
}
for (String mapName : files.keySet()) {
BinaryMapIndexReader fr = files.get(mapName);
if (fr != null && (fr.containsMapData(leftX, topY, rightX, bottomY, zoom) ||
fr.containsRouteData(leftX, topY, rightX, bottomY, zoom))) {
if (!nativeFiles.contains(mapName)) {
long time = System.currentTimeMillis();
nativeFiles.add(mapName);
if (!library.initMapFile(mapName)) {
continue;
}
log.debug("Native resource " + mapName + " initialized " + (System.currentTimeMillis() - time) + " ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
}
private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c, private void readRouteDataAsMapObjects(SearchRequest<BinaryMapDataObject> sr, BinaryMapIndexReader c,
final ArrayList<BinaryMapDataObject> tempResult, final TLongSet ids) { final ArrayList<BinaryMapDataObject> tempResult, final TLongSet ids) {
final boolean basemap = c.isBasemap(); final boolean basemap = c.isBasemap();

View file

@ -657,6 +657,27 @@ public class RouteProvider {
} }
// BUILD context // BUILD context
NativeOsmandLibrary lib = settings.SAFE_MODE.get() ? null : NativeOsmandLibrary.getLoadedLibrary(); NativeOsmandLibrary lib = settings.SAFE_MODE.get() ? null : NativeOsmandLibrary.getLoadedLibrary();
// check loaded files
int leftX = MapUtils.get31TileNumberX(params.start.getLongitude());
int rightX = leftX;
int bottomY = MapUtils.get31TileNumberY(params.start.getLatitude());
int topY = bottomY;
if (params.intermediates != null) {
for (LatLon l : params.intermediates) {
leftX = Math.min(MapUtils.get31TileNumberX(l.getLongitude()), leftX);
rightX = Math.max(MapUtils.get31TileNumberX(l.getLongitude()), rightX);
bottomY = Math.max(MapUtils.get31TileNumberY(l.getLatitude()), bottomY);
topY = Math.min(MapUtils.get31TileNumberY(l.getLatitude()), topY);
}
}
LatLon l = params.end;
leftX = Math.min(MapUtils.get31TileNumberX(l.getLongitude()), leftX);
rightX = Math.max(MapUtils.get31TileNumberX(l.getLongitude()), rightX);
bottomY = Math.max(MapUtils.get31TileNumberY(l.getLatitude()), bottomY);
topY = Math.min(MapUtils.get31TileNumberY(l.getLatitude()), topY);
params.ctx.getResourceManager().getRenderer().checkInitialized(15, lib, leftX, rightX, bottomY, topY);
RoutingContext ctx = router.buildRoutingContext(cf, RoutingContext ctx = router.buildRoutingContext(cf,
lib, files, lib, files,
RouteCalculationMode.NORMAL); RouteCalculationMode.NORMAL);