Search in sources :

Example 6 with MapZoomPair

use of net.osmand.binary.MapZooms.MapZoomPair in project OsmAnd-tools by osmandapp.

the class ObfRegionSplitter method splitRegionMapData.

private Map<String, Map<MapZoomPair, TLongObjectHashMap<BinaryMapDataObject>>> splitRegionMapData(ObfFileInMemory allMapObjects, OsmandRegions osmandRegions) throws IOException {
    Map<String, Map<MapZoomPair, TLongObjectHashMap<BinaryMapDataObject>>> result = new HashMap<>();
    for (MapZoomPair p : allMapObjects.getZooms()) {
        TLongObjectHashMap<BinaryMapDataObject> objects = allMapObjects.get(p);
        for (BinaryMapDataObject obj : objects.valueCollection()) {
            int x = obj.getPoint31XTile(0);
            int y = obj.getPoint31YTile(0);
            List<BinaryMapDataObject> l = osmandRegions.query(x, y);
            for (BinaryMapDataObject b : l) {
                if (osmandRegions.contain(b, x, y)) {
                    String dw = osmandRegions.getDownloadName(b);
                    WorldRegion wr = osmandRegions.getRegionDataByDownloadName(dw);
                    if (dw == null || wr == null) {
                        continue;
                    }
                    if (!Algorithms.isEmpty(dw) && wr.isRegionMapDownload()) {
                        Map<MapZoomPair, TLongObjectHashMap<BinaryMapDataObject>> mp = result.get(dw);
                        if (mp == null) {
                            mp = new LinkedHashMap<>();
                            result.put(dw, mp);
                        }
                        TLongObjectHashMap<BinaryMapDataObject> list = mp.get(p);
                        if (list == null) {
                            list = new TLongObjectHashMap<>();
                            mp.put(p, list);
                        }
                        list.put(obj.getId(), obj);
                    }
                }
            }
        }
    }
    return result;
}
Also used : WorldRegion(net.osmand.map.WorldRegion) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TLongObjectHashMap(gnu.trove.map.hash.TLongObjectHashMap) TLongObjectHashMap(gnu.trove.map.hash.TLongObjectHashMap) MapZoomPair(net.osmand.binary.MapZooms.MapZoomPair) BinaryMapDataObject(net.osmand.binary.BinaryMapDataObject) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) TLongObjectHashMap(gnu.trove.map.hash.TLongObjectHashMap) Map(java.util.Map)

Aggregations

MapZoomPair (net.osmand.binary.MapZooms.MapZoomPair)6 BinaryMapDataObject (net.osmand.binary.BinaryMapDataObject)4 TLongObjectHashMap (gnu.trove.map.hash.TLongObjectHashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Amenity (net.osmand.data.Amenity)2 CodedOutputStream (com.google.protobuf.CodedOutputStream)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 OutputStream (java.io.OutputStream)1 RandomAccessFile (java.io.RandomAccessFile)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1