Search in sources :

Example 46 with BinaryMapIndexReader

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();
        }
    }
}
Also used : RandomAccessFile(java.io.RandomAccessFile) ArrayList(java.util.ArrayList) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) IOException(java.io.IOException) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File)

Example 47 with BinaryMapIndexReader

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;
}
Also used : RoutingConfiguration(net.osmand.router.RoutingConfiguration) BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader) RoutePlannerFrontEnd(net.osmand.router.RoutePlannerFrontEnd)

Example 48 with BinaryMapIndexReader

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;
}
Also used : BinaryMapIndexReader(net.osmand.binary.BinaryMapIndexReader)

Aggregations

BinaryMapIndexReader (net.osmand.binary.BinaryMapIndexReader)48 File (java.io.File)26 RandomAccessFile (java.io.RandomAccessFile)25 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)16 List (java.util.List)7 RoutePlannerFrontEnd (net.osmand.router.RoutePlannerFrontEnd)7 RoutingConfiguration (net.osmand.router.RoutingConfiguration)7 LinkedHashMap (java.util.LinkedHashMap)6 LatLon (net.osmand.data.LatLon)6 HashMap (java.util.HashMap)5 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)5 MapIndex (net.osmand.binary.BinaryMapIndexReader.MapIndex)5 RouteRegion (net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion)5 City (net.osmand.data.City)5 RoutingContext (net.osmand.router.RoutingContext)5 Point (java.awt.Point)4 FileOutputStream (java.io.FileOutputStream)4 GeocodingResult (net.osmand.binary.GeocodingUtilities.GeocodingResult)4 TLongHashSet (gnu.trove.set.hash.TLongHashSet)3