Search in sources :

Example 1 with TIntLongMap

use of gnu.trove.map.TIntLongMap in project OsmAnd-tools by osmandapp.

the class ObfFileInMemory method readTransportData.

public void readTransportData(BinaryMapIndexReader indexReader, TransportIndex ind, boolean override) throws IOException {
    SearchRequest<TransportStop> sr = BinaryMapIndexReader.buildSearchTransportRequest(MapUtils.get31TileNumberX(lonleft), MapUtils.get31TileNumberX(lonright), MapUtils.get31TileNumberY(lattop), MapUtils.get31TileNumberY(latbottom), -1, null);
    List<TransportStop> sti = indexReader.searchTransportIndex(ind, sr);
    // merged could not be overridden
    TIntLongMap routesData = putTransportStops(sti, override);
    if (routesData.size() > 0) {
        int[] filePointers = routesData.keys();
        // reads all route
        TIntObjectHashMap<TransportRoute> transportRoutes = indexReader.getTransportRoutes(filePointers);
        TIntIterator it = transportRoutes.keySet().iterator();
        while (it.hasNext()) {
            int offset = it.next();
            TransportRoute route = transportRoutes.get(offset);
            Long routeId = route.getId();
            if (override || !this.transportRoutes.containsKey(routeId)) {
                this.transportRoutes.put(routeId, route);
            }
        }
    }
}
Also used : TIntIterator(gnu.trove.iterator.TIntIterator) TransportRoute(net.osmand.data.TransportRoute) TIntLongMap(gnu.trove.map.TIntLongMap) TransportStop(net.osmand.data.TransportStop)

Example 2 with TIntLongMap

use of gnu.trove.map.TIntLongMap in project OsmAnd-tools by osmandapp.

the class ObfFileInMemory method putTransportStops.

public TIntLongMap putTransportStops(Collection<TransportStop> newData, boolean override) {
    TIntLongMap routesStopsData = new TIntLongHashMap();
    for (TransportStop ts : newData) {
        Long tid = ts.getId();
        if (routesStopsData != null) {
            int[] referencesToRoutes = ts.getReferencesToRoutes();
            if (referencesToRoutes != null && referencesToRoutes.length > 0) {
                for (int ref : referencesToRoutes) {
                    routesStopsData.put(ref, tid);
                }
            }
        }
        TransportStop previousStop = transportStops.get(tid);
        if (previousStop != null) {
            if (override) {
                mergeStop(ts, previousStop);
                transportStops.put(tid, ts);
            } else {
                mergeStop(previousStop, ts);
            }
        } else {
            transportStops.put(tid, ts);
        }
    }
    return routesStopsData;
}
Also used : TIntLongHashMap(gnu.trove.map.hash.TIntLongHashMap) TIntLongMap(gnu.trove.map.TIntLongMap) TransportStop(net.osmand.data.TransportStop)

Aggregations

TIntLongMap (gnu.trove.map.TIntLongMap)2 TransportStop (net.osmand.data.TransportStop)2 TIntIterator (gnu.trove.iterator.TIntIterator)1 TIntLongHashMap (gnu.trove.map.hash.TIntLongHashMap)1 TransportRoute (net.osmand.data.TransportRoute)1