use of net.osmand.router.RoutingContext.RoutingSubregionTile in project OsmAnd-tools by osmandapp.
the class CheckRoadConnectivity method findAllBaseRoadIntersections.
private void findAllBaseRoadIntersections(BinaryMapIndexReader reader, TLongObjectHashMap<List<RouteDataObject>> all, TLongObjectHashMap<List<RouteDataObject>> onlyRoads, TLongHashSet registeredRoadIds) throws IOException {
RoutePlannerFrontEnd router = new RoutePlannerFrontEnd(false);
Builder builder = RoutingConfiguration.getDefault();
RoutingConfiguration config = builder.build("car", RoutingConfiguration.DEFAULT_MEMORY_LIMIT * 3);
RoutingContext ctx = router.buildRoutingContext(config, null, new BinaryMapIndexReader[] { reader }, RouteCalculationMode.BASE);
if (reader.getRoutingIndexes().size() != 1) {
throw new UnsupportedOperationException();
}
RouteRegion reg = reader.getRoutingIndexes().get(0);
List<RouteSubregion> baseSubregions = reg.getBaseSubregions();
List<RoutingSubregionTile> tiles = new ArrayList<RoutingContext.RoutingSubregionTile>();
for (RouteSubregion s : baseSubregions) {
List<RoutingSubregionTile> loadTiles = ctx.loadAllSubregionTiles(reader, s);
tiles.addAll(loadTiles);
}
for (RoutingSubregionTile tile : tiles) {
ArrayList<RouteDataObject> dataObjects = new ArrayList<RouteDataObject>();
ctx.loadSubregionTile(tile, false, dataObjects, null);
for (RouteDataObject o : dataObjects) {
registeredRoadIds.add(o.getId());
int len = o.getPointsLength() - 1;
double dist = MapUtils.squareRootDist31(o.getPoint31XTile(0), o.getPoint31YTile(0), o.getPoint31XTile(len), o.getPoint31YTile(len));
boolean shortFerry = "ferry".equals(o.getRoute()) && dist < 1000;
if (shortFerry) {
continue;
}
boolean link = o.getHighway() != null && (o.getHighway().endsWith("link"));
long b = calcPointId(o, 0);
long e = calcPointId(o, len);
if (!link) {
addPoint(onlyRoads, o, b);
addPoint(onlyRoads, o, e);
}
for (int i = 0; i < o.getPointsLength(); i++) {
addPoint(all, o, calcPointId(o, i));
}
}
}
}
Aggregations