src/main/java/de/blau/android/util/BentleyOttmannForOsm.java
/**
     * Find intersections between Ways
     * 
     * @param ways a List of Ways
     * @return a List of Mercator Coordinates for intersections
     */
Find intersections between Ways

@param ways a List of Ways
@return a List of Mercator Coordinates for intersections
Find intersections between Ways @param ways a List of Ways @return a List of Mercator Coordinates for intersections
@NonNull
    public static List<Coordinates> findIntersections(@NonNull List<Way> ways) {
        final BentleyOttmann bentleyOttmann = new BentleyOttmann(Coordinates::new);
        final List<ISegment> segments = new ArrayList<>();
        for (Way w : ways) {
            List<Node> nodes = w.getNodes();
            for (int i = 0; i < nodes.size() - 1; i++) {
                Coordinates c1 = getCoordinates(nodes.get(i));
                Coordinates c2 = getCoordinates(nodes.get(i + 1));
                segments.add(new Segment(c1, c2));
            }
        }
        bentleyOttmann.addSegments(segments);
        bentleyOttmann.findIntersections();
        List<IPoint> intersections = bentleyOttmann.intersections();
        List<Coordinates> coordinates = new ArrayList<>();
        for (IPoint p : intersections) {
            coordinates.add(new Coordinates(p.x(), p.y()));
        }
        return coordinates;
    }
@ NonNull public static List < Coordinates > findIntersections ( @ NonNull List < Way > ways ) { final BentleyOttmann bentleyOttmann = new BentleyOttmann ( Coordinates :: new ) ; final List < ISegment > segments = new ArrayList < > ( ) ; for ( Way w : ways ) { List < Node > nodes = w . getNodes ( ) ; for ( int i = 0 ; i < nodes . size ( ) - 1 ; i ++ ) { Coordinates c1 = getCoordinates ( nodes . get ( i ) ) ; Coordinates c2 = getCoordinates ( nodes . get ( i + 1 ) ) ; segments . add ( new Segment ( c1 , c2 ) ) ; } } bentleyOttmann . addSegments ( segments ) ; bentleyOttmann . findIntersections ( ) ; List < IPoint > intersections = bentleyOttmann . intersections ( ) ; List < Coordinates > coordinates = new ArrayList < > ( ) ; for ( IPoint p : intersections ) { coordinates . add ( new Coordinates ( p . x ( ) , p . y ( ) ) ) ; } return coordinates ; }
Find intersections between Ways
Find intersections between Ways