Fix transport message

This commit is contained in:
Victor Shcherb 2011-07-19 00:45:48 +02:00
parent b222da6b64
commit 3cd598fdcf

View file

@ -1,13 +1,13 @@
package net.osmand.binary;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import static net.osmand.binary.BinaryMapIndexReader.TRANSPORT_STOP_ZOOM;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
import net.osmand.data.TransportStop;
@ -72,7 +72,7 @@ public class BinaryMapTransportReaderAdapter {
// offset from start for each SIZE_OFFSET_ARRAY elements
// (SIZE_OFFSET_ARRAY + 1) offset = offsets[0] + skipOneString()
TIntArrayList offsets = new TIntArrayList();
Map<Integer, String> cacheOfStrings = new LinkedHashMap<Integer, String>();
TIntObjectMap<String> cacheOfStrings = new TIntObjectHashMap<String>();
int windowOffset = 0;
List<String> window = new ArrayList<String>();
@ -104,7 +104,7 @@ public class BinaryMapTransportReaderAdapter {
st.length = codedIS.readRawVarint32();
st.fileOffset = codedIS.getTotalBytesRead();
// Do not cache for now save memory
// readStringTable(st, 0, 20, true);
// readStringTable(st, 0, 20, true);
ind.stringTable = st;
codedIS.seek(st.length + st.fileOffset);
break;
@ -191,6 +191,10 @@ public class BinaryMapTransportReaderAdapter {
if (ind >= st.windowOffset && (ind - st.windowOffset) < st.window.size()) {
return st.window.get(ind - st.windowOffset);
}
int startOffset = ind - IndexStringTable.WINDOW_SIZE / 4;
if(startOffset < 0){
startOffset = 0;
}
lastRead = readStringTable(st, ind - IndexStringTable.WINDOW_SIZE / 4, IndexStringTable.WINDOW_SIZE, false);
}
return null;