Merge pull request #9351 from osmandapp/issue_9298
fix for incomplete roads reading #9298
This commit is contained in:
commit
fe32670e44
5 changed files with 19 additions and 18 deletions
|
@ -2655,6 +2655,7 @@ public class BinaryMapIndexReader {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public TLongObjectHashMap<IncompleteTransportRoute> getIncompleteTransportRoutes() throws InvalidProtocolBufferException, IOException {
|
||||
if (incompleteTransportRoutes == null) {
|
||||
incompleteTransportRoutes = new TLongObjectHashMap<>();
|
||||
|
@ -2662,7 +2663,7 @@ public class BinaryMapIndexReader {
|
|||
if (ti.incompleteRoutesLength > 0) {
|
||||
codedIS.seek(ti.incompleteRoutesOffset);
|
||||
int oldLimit = codedIS.pushLimit(ti.incompleteRoutesLength);
|
||||
transportAdapter.readIncompleteRoutesList(incompleteTransportRoutes);
|
||||
transportAdapter.readIncompleteRoutesList(incompleteTransportRoutes, ti.filePointer);
|
||||
codedIS.popLimit(oldLimit);
|
||||
}
|
||||
}
|
||||
|
@ -2670,5 +2671,4 @@ public class BinaryMapIndexReader {
|
|||
return incompleteTransportRoutes;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.google.protobuf.WireFormat;
|
|||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.data.IncompleteTransportRoute;
|
||||
import net.osmand.data.TransportSchedule;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.data.TransportStopExit;
|
||||
|
@ -71,7 +72,6 @@ public class BinaryMapTransportReaderAdapter {
|
|||
return bottom;
|
||||
}
|
||||
|
||||
|
||||
IndexStringTable stringTable = null;
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
return ((char) i)+"";
|
||||
}
|
||||
|
||||
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes) throws IOException {
|
||||
public void readIncompleteRoutesList(TLongObjectHashMap<net.osmand.data.IncompleteTransportRoute> incompleteRoutes, int transportIndexStart) throws IOException {
|
||||
boolean end = false;
|
||||
while (!end) {
|
||||
int t = codedIS.readTag();
|
||||
|
@ -263,7 +263,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
case OsmandOdb.IncompleteTransportRoutes.ROUTES_FIELD_NUMBER:
|
||||
int l = codedIS.readRawVarint32();
|
||||
int olds = codedIS.pushLimit(l);
|
||||
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute();
|
||||
net.osmand.data.IncompleteTransportRoute ir = readIncompleteRoute(transportIndexStart);
|
||||
net.osmand.data.IncompleteTransportRoute itr = incompleteRoutes.get(ir.getRouteId());
|
||||
if(itr != null) {
|
||||
itr.setNextLinkedRoute(ir);
|
||||
|
@ -281,7 +281,7 @@ public class BinaryMapTransportReaderAdapter {
|
|||
|
||||
}
|
||||
|
||||
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute() throws IOException {
|
||||
public net.osmand.data.IncompleteTransportRoute readIncompleteRoute(int transportIndexStart) throws IOException {
|
||||
net.osmand.data.IncompleteTransportRoute dataObject = new net.osmand.data.IncompleteTransportRoute();
|
||||
boolean end = false;
|
||||
while(!end){
|
||||
|
@ -295,7 +295,12 @@ public class BinaryMapTransportReaderAdapter {
|
|||
dataObject.setRouteId(codedIS.readUInt64());
|
||||
break;
|
||||
case OsmandOdb.IncompleteTransportRoute.ROUTEREF_FIELD_NUMBER :
|
||||
dataObject.setRouteOffset(codedIS.readRawVarint32());
|
||||
int delta = codedIS.readRawVarint32();
|
||||
if (delta > transportIndexStart) {
|
||||
dataObject.setRouteOffset(delta);
|
||||
} else {
|
||||
dataObject.setRouteOffset(transportIndexStart + delta);
|
||||
}
|
||||
break;
|
||||
case OsmandOdb.IncompleteTransportRoute.OPERATOR_FIELD_NUMBER :
|
||||
skipUnknownField(t);
|
||||
|
@ -318,7 +323,6 @@ public class BinaryMapTransportReaderAdapter {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return dataObject;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,11 @@ public class IncompleteTransportRoute {
|
|||
}
|
||||
|
||||
public void setNextLinkedRoute(IncompleteTransportRoute nextLinkedRoute) {
|
||||
this.nextLinkedRoute = nextLinkedRoute;
|
||||
if (this.nextLinkedRoute == null) {
|
||||
this.nextLinkedRoute = nextLinkedRoute;
|
||||
} else {
|
||||
this.nextLinkedRoute.setNextLinkedRoute(nextLinkedRoute);
|
||||
}
|
||||
}
|
||||
|
||||
public long getRouteId() {
|
||||
|
|
|
@ -865,7 +865,6 @@ public class TransportRoutePlanner {
|
|||
lst.add(segment);
|
||||
}
|
||||
} else {
|
||||
// MapUtils.getDistance(s.getLocation(), route.getForwardStops().get(158).getLocation());
|
||||
System.err.println(String.format("Routing error: missing stop '%s' in route '%s' id: %d",
|
||||
s.toString(), route.getRef(), route.getId() / 2));
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import gnu.trove.iterator.TIntObjectIterator;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
@ -15,6 +16,7 @@ import gnu.trove.map.hash.TIntObjectHashMap;
|
|||
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.binary.BinaryMapTransportReaderAdapter.TransportIndex;
|
||||
import net.osmand.data.IncompleteTransportRoute;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.TransportRoute;
|
||||
|
@ -43,7 +45,6 @@ public class TransportStopsRouteReader {
|
|||
List<TransportStop> stops = r.searchTransportIndex(sr);
|
||||
TIntObjectHashMap<TransportRoute> routesToLoad = mergeTransportStops(r, loadedTransportStops, stops);
|
||||
loadRoutes(r, routesToLoad);
|
||||
|
||||
for (TransportStop stop : stops) {
|
||||
// skip missing stops
|
||||
if (stop.isMissingStop()) {
|
||||
|
@ -405,11 +406,4 @@ public class TransportStopsRouteReader {
|
|||
}
|
||||
return allRoutes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue