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);
}
}
}
}
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;
}
Aggregations