use of net.osmand.osm.util.CheckRoadConnectivity in project OsmAnd-tools by osmandapp.
the class IndexRouteCreator method appendMissingRoadsForBaseMap.
private void appendMissingRoadsForBaseMap(Connection conn, BinaryMapIndexReader reader) throws IOException, SQLException {
TLongObjectHashMap<RouteDataObject> map = new CheckRoadConnectivity().collectDisconnectedRoads(reader);
// to add
PreparedStatement ps = conn.prepareStatement(COPY_BASE);
for (RouteDataObject rdo : map.valueCollection()) {
// addWayToIndex(id, nodes, insertStat, rTree)
int minX = Integer.MAX_VALUE;
int maxX = 0;
int minY = Integer.MAX_VALUE;
int maxY = 0;
long id = rdo.getId();
for (int i = 0; i < rdo.getPointsLength(); i++) {
int x = rdo.getPoint31XTile(i);
int y = rdo.getPoint31YTile(i);
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
long point = (x << 31) + y;
registerBaseIntersectionPoint(point, false, id, i, i);
}
ps.setLong(1, id);
ps.execute();
try {
baserouteTree.insert(new LeafElement(new Rect(minX, minY, maxX, maxY), id));
} catch (RTreeInsertException e1) {
throw new IllegalArgumentException(e1);
} catch (IllegalValueException e1) {
throw new IllegalArgumentException(e1);
}
}
ps.close();
}
Aggregations