use of net.osmand.binary.BinaryMapIndexReader in project Osmand by osmandapp.
the class ResourceManager method setRepositories.
private void setRepositories() {
ArrayList<File> files = new ArrayList<>();
File appPath = app.getAppPath(null);
SampleUtils.collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
SampleUtils.collectFiles(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), IndexConstants.BINARY_MAP_INDEX_EXT, files);
for (File f : files) {
try {
RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r");
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f);
if (reader.containsPoiData()) {
amenityRepositories.put(f.getName(), new AmenityIndexRepositoryBinary(reader));
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of net.osmand.binary.BinaryMapIndexReader in project Osmand by osmandapp.
the class CurrentPositionHelper method setRepositories.
public void setRepositories() {
ArrayList<File> files = new ArrayList<File>();
File appPath = app.getAppPath(null);
SampleUtils.collectFiles(appPath, IndexConstants.BINARY_MAP_INDEX_EXT, files);
readers.clear();
for (File f : files) {
try {
RandomAccessFile mf = new RandomAccessFile(f.getPath(), "r");
BinaryMapIndexReader reader = new BinaryMapIndexReader(mf, f);
readers.add(reader);
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of net.osmand.binary.BinaryMapIndexReader in project Osmand by osmandapp.
the class CurrentPositionHelper method initCtx.
private void initCtx(SampleApplication app, List<BinaryMapIndexReader> checkReaders) {
BinaryMapIndexReader[] rs = checkReaders.toArray(new BinaryMapIndexReader[checkReaders.size()]);
if (rs.length > 0) {
RoutingConfiguration defCfg = RoutingConfiguration.getDefault().build("geocoding", 10, new HashMap<String, String>());
defCtx = new RoutePlannerFrontEnd(false).buildRoutingContext(defCfg, null, rs);
} else {
defCtx = null;
}
usedReaders = checkReaders;
}
use of net.osmand.binary.BinaryMapIndexReader in project Osmand by osmandapp.
the class MapRenderRepositories method containsLatLonMapData.
public boolean containsLatLonMapData(double lat, double lon, int zoom) {
int x = MapUtils.get31TileNumberX(lon);
int y = MapUtils.get31TileNumberY(lat);
for (BinaryMapIndexReader reader : files.values()) {
if (reader.containsMapData(x, y, zoom)) {
return true;
}
}
return false;
}
use of net.osmand.binary.BinaryMapIndexReader in project OsmAnd-tools by osmandapp.
the class DataExtractionSettings method getObfReaders.
public BinaryMapIndexReader[] getObfReaders() throws IOException {
List<BinaryMapIndexReader> files = new ArrayList<>();
File mapsFolder = new File(getBinaryFilesDir());
CachedOsmandIndexes cache = null;
File cacheFile = new File(mapsFolder, INDEXES_CACHE);
if (mapsFolder.exists() && obfFiles.isEmpty() && INDEXES_CACHE.length() > 0) {
cache = new CachedOsmandIndexes();
if (cacheFile.exists()) {
cache.readFromFile(cacheFile, 2);
}
}
for (File obf : Algorithms.getSortedFilesVersions(mapsFolder)) {
if (obf.getName().endsWith(".obf")) {
BinaryMapIndexReaderReference ref = obfFiles.get(obf.getAbsolutePath());
if (ref == null || ref.reader == null) {
ref = new BinaryMapIndexReaderReference();
ref.file = obf;
if (cache == null) {
// $NON-NLS-1$ //$NON-NLS-2$
RandomAccessFile raf = new RandomAccessFile(obf, "r");
ref.reader = new BinaryMapIndexReader(raf, obf);
} else {
ref.reader = cache.getReader(obf, true);
}
obfFiles.put(obf.getAbsolutePath(), ref);
}
files.add(ref.reader);
}
}
if (cache != null && !files.isEmpty()) {
cache.writeToFile(cacheFile);
}
return files.toArray(new BinaryMapIndexReader[files.size()]);
}
Aggregations