fix cache and incomplete route offset
This commit is contained in:
parent
9db069dd05
commit
86b08b7568
4 changed files with 24 additions and 34 deletions
|
@ -111,7 +111,7 @@ public class BinaryMapIndexReader {
|
||||||
/*private*/ List<TransportIndex> transportIndexes = new ArrayList<TransportIndex>();
|
/*private*/ List<TransportIndex> transportIndexes = new ArrayList<TransportIndex>();
|
||||||
/*private*/ List<RouteRegion> routingIndexes = new ArrayList<RouteRegion>();
|
/*private*/ List<RouteRegion> routingIndexes = new ArrayList<RouteRegion>();
|
||||||
/*private*/ List<BinaryIndexPart> indexes = new ArrayList<BinaryIndexPart>();
|
/*private*/ List<BinaryIndexPart> indexes = new ArrayList<BinaryIndexPart>();
|
||||||
Map<TransportIndex, TLongObjectHashMap<IncompleteTransportRoute>> incompleteTransportRoutes = null;
|
TLongObjectHashMap<IncompleteTransportRoute> incompleteTransportRoutes = null;
|
||||||
|
|
||||||
protected CodedInputStream codedIS;
|
protected CodedInputStream codedIS;
|
||||||
|
|
||||||
|
@ -2655,22 +2655,20 @@ public class BinaryMapIndexReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<TransportIndex, TLongObjectHashMap<IncompleteTransportRoute>> getIncompleteTransportRoutes() throws InvalidProtocolBufferException, IOException {
|
|
||||||
|
public TLongObjectHashMap<IncompleteTransportRoute> getIncompleteTransportRoutes() throws InvalidProtocolBufferException, IOException {
|
||||||
if (incompleteTransportRoutes == null) {
|
if (incompleteTransportRoutes == null) {
|
||||||
incompleteTransportRoutes = new HashMap<TransportIndex, TLongObjectHashMap<IncompleteTransportRoute>>();
|
incompleteTransportRoutes = new TLongObjectHashMap<>();
|
||||||
for (TransportIndex ti : transportIndexes) {
|
for (TransportIndex ti : transportIndexes) {
|
||||||
if (ti.incompleteRoutesLength > 0) {
|
if (ti.incompleteRoutesLength > 0) {
|
||||||
TLongObjectHashMap<IncompleteTransportRoute> indexIncompleteRoutes = new TLongObjectHashMap<IncompleteTransportRoute>();
|
|
||||||
codedIS.seek(ti.incompleteRoutesOffset);
|
codedIS.seek(ti.incompleteRoutesOffset);
|
||||||
int oldLimit = codedIS.pushLimit(ti.incompleteRoutesLength);
|
int oldLimit = codedIS.pushLimit(ti.incompleteRoutesLength);
|
||||||
transportAdapter.readIncompleteRoutesList(indexIncompleteRoutes, ti.filePointer);
|
transportAdapter.readIncompleteRoutesList(incompleteTransportRoutes, ti.filePointer);
|
||||||
codedIS.popLimit(oldLimit);
|
codedIS.popLimit(oldLimit);
|
||||||
incompleteTransportRoutes.put(ti, indexIncompleteRoutes);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return incompleteTransportRoutes;
|
return incompleteTransportRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -253,7 +253,6 @@ public class BinaryMapTransportReaderAdapter {
|
||||||
|
|
||||||
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes, int transportIndexStart) throws IOException {
|
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes, int transportIndexStart) throws IOException {
|
||||||
boolean end = false;
|
boolean end = false;
|
||||||
int offset = codedIS.getTotalBytesRead();
|
|
||||||
while (!end) {
|
while (!end) {
|
||||||
int t = codedIS.readTag();
|
int t = codedIS.readTag();
|
||||||
int tag = WireFormat.getTagFieldNumber(t);
|
int tag = WireFormat.getTagFieldNumber(t);
|
||||||
|
@ -264,7 +263,7 @@ public class BinaryMapTransportReaderAdapter {
|
||||||
case OsmandOdb.IncompleteTransportRoutes.ROUTES_FIELD_NUMBER:
|
case OsmandOdb.IncompleteTransportRoutes.ROUTES_FIELD_NUMBER:
|
||||||
int l = codedIS.readRawVarint32();
|
int l = codedIS.readRawVarint32();
|
||||||
int olds = codedIS.pushLimit(l);
|
int olds = codedIS.pushLimit(l);
|
||||||
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute(offset, transportIndexStart);
|
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute(transportIndexStart);
|
||||||
net.osmand.data.IncompleteTransportRoute itr = incompleteRoutes.get(ir.getRouteId());
|
net.osmand.data.IncompleteTransportRoute itr = incompleteRoutes.get(ir.getRouteId());
|
||||||
if(itr != null) {
|
if(itr != null) {
|
||||||
itr.setNextLinkedRoute(ir);
|
itr.setNextLinkedRoute(ir);
|
||||||
|
@ -282,7 +281,7 @@ public class BinaryMapTransportReaderAdapter {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute(int readOffset, int transportIndexStart) throws IOException {
|
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute(int transportIndexStart) throws IOException {
|
||||||
net.osmand.data.IncompleteTransportRoute dataObject = new net.osmand.data.IncompleteTransportRoute();
|
net.osmand.data.IncompleteTransportRoute dataObject = new net.osmand.data.IncompleteTransportRoute();
|
||||||
boolean end = false;
|
boolean end = false;
|
||||||
while(!end){
|
while(!end){
|
||||||
|
@ -300,7 +299,7 @@ public class BinaryMapTransportReaderAdapter {
|
||||||
if (delta > transportIndexStart) {
|
if (delta > transportIndexStart) {
|
||||||
dataObject.setRouteOffset(delta);
|
dataObject.setRouteOffset(delta);
|
||||||
} else {
|
} else {
|
||||||
dataObject.setRouteOffset(readOffset - delta);
|
dataObject.setRouteOffset(transportIndexStart + delta);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OsmandOdb.IncompleteTransportRoute.OPERATOR_FIELD_NUMBER :
|
case OsmandOdb.IncompleteTransportRoute.OPERATOR_FIELD_NUMBER :
|
||||||
|
|
|
@ -13,7 +13,11 @@ public class IncompleteTransportRoute {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextLinkedRoute(IncompleteTransportRoute nextLinkedRoute) {
|
public void setNextLinkedRoute(IncompleteTransportRoute nextLinkedRoute) {
|
||||||
|
if (this.nextLinkedRoute == null) {
|
||||||
this.nextLinkedRoute = nextLinkedRoute;
|
this.nextLinkedRoute = nextLinkedRoute;
|
||||||
|
} else {
|
||||||
|
this.nextLinkedRoute.setNextLinkedRoute(nextLinkedRoute);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRouteId() {
|
public long getRouteId() {
|
||||||
|
|
|
@ -389,9 +389,7 @@ public class TransportStopsRouteReader {
|
||||||
List<TransportRoute> allRoutes = null;
|
List<TransportRoute> allRoutes = null;
|
||||||
for (BinaryMapIndexReader bmir : routesFilesCache.keySet()) {
|
for (BinaryMapIndexReader bmir : routesFilesCache.keySet()) {
|
||||||
// here we could limit routeMap indexes by only certain bbox around start / end (check comment on field)
|
// here we could limit routeMap indexes by only certain bbox around start / end (check comment on field)
|
||||||
if (!bmir.getIncompleteTransportRoutes().isEmpty()) {
|
IncompleteTransportRoute ptr = bmir.getIncompleteTransportRoutes().get(baseRoute.getId());
|
||||||
for (Entry<TransportIndex, TLongObjectHashMap<IncompleteTransportRoute>> entry : bmir.getIncompleteTransportRoutes().entrySet()) {
|
|
||||||
IncompleteTransportRoute ptr = entry.getValue().get(baseRoute.getId());
|
|
||||||
if (ptr != null) {
|
if (ptr != null) {
|
||||||
TIntArrayList lst = new TIntArrayList();
|
TIntArrayList lst = new TIntArrayList();
|
||||||
while (ptr != null) {
|
while (ptr != null) {
|
||||||
|
@ -406,15 +404,6 @@ public class TransportStopsRouteReader {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return allRoutes;
|
return allRoutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue