Search in sources :

Example 1 with CheckRoadConnectivity

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();
}
Also used : RTreeInsertException(rtree.RTreeInsertException) Rect(rtree.Rect) CheckRoadConnectivity(net.osmand.osm.util.CheckRoadConnectivity) IllegalValueException(rtree.IllegalValueException) RouteDataObject(net.osmand.binary.RouteDataObject) PreparedStatement(java.sql.PreparedStatement) LeafElement(rtree.LeafElement)

Aggregations

PreparedStatement (java.sql.PreparedStatement)1 RouteDataObject (net.osmand.binary.RouteDataObject)1 CheckRoadConnectivity (net.osmand.osm.util.CheckRoadConnectivity)1 IllegalValueException (rtree.IllegalValueException)1 LeafElement (rtree.LeafElement)1 RTreeInsertException (rtree.RTreeInsertException)1 Rect (rtree.Rect)1