Search in sources :

Example 11 with RobustLineIntersector

use of com.revolsys.geometry.algorithm.RobustLineIntersector in project com.revolsys.open by revolsys.

the class LineIntersectorBenchmark method run.

@Override
public void run() {
    exercise(new NonRobustLineIntersector());
    exercise(new RobustLineIntersector());
}
Also used : NonRobustLineIntersector(com.revolsys.geometry.algorithm.NonRobustLineIntersector) NonRobustLineIntersector(com.revolsys.geometry.algorithm.NonRobustLineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector)

Example 12 with RobustLineIntersector

use of com.revolsys.geometry.algorithm.RobustLineIntersector in project com.revolsys.open by revolsys.

the class CGAlgorithmFunctions method segmentIntersects.

public static boolean segmentIntersects(final Geometry g1, final Geometry g2) {
    final Point[] pt1 = CoordinatesListUtil.getPointArray(g1);
    final Point[] pt2 = CoordinatesListUtil.getPointArray(g2);
    final RobustLineIntersector ri = new RobustLineIntersector();
    ri.computeIntersectionPoints(pt1[0], pt1[1], pt2[0], pt2[1]);
    return ri.hasIntersection();
}
Also used : Point(com.revolsys.geometry.model.Point) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector)

Example 13 with RobustLineIntersector

use of com.revolsys.geometry.algorithm.RobustLineIntersector in project com.revolsys.open by revolsys.

the class NodingFunctions method MCIndexNodingWithPrecision.

public static Geometry MCIndexNodingWithPrecision(final Geometry geom, final double scaleFactor) {
    final List segs = newNodedSegmentStrings(geom);
    final LineIntersector li = new RobustLineIntersector(scaleFactor);
    final Noder noder = new MCIndexNoder(new IntersectionAdder(li));
    noder.computeNodes(segs);
    final Collection nodedSegStrings = noder.getNodedSubstrings();
    return fromSegmentStrings(nodedSegStrings);
}
Also used : LineIntersector(com.revolsys.geometry.algorithm.LineIntersector) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) IntersectionAdder(com.revolsys.geometry.noding.IntersectionAdder) MCIndexNoder(com.revolsys.geometry.noding.MCIndexNoder) Noder(com.revolsys.geometry.noding.Noder) ScaledNoder(com.revolsys.geometry.noding.ScaledNoder)

Example 14 with RobustLineIntersector

use of com.revolsys.geometry.algorithm.RobustLineIntersector in project com.revolsys.open by revolsys.

the class RobustLineIntersectorTest method testCollinear4.

public void testCollinear4() {
    final RobustLineIntersector i = new RobustLineIntersector();
    final Point p1 = new PointDoubleXY(30, 10);
    final Point p2 = new PointDoubleXY(20, 10);
    final Point q1 = new PointDoubleXY(10, 10);
    final Point q2 = new PointDoubleXY(30, 10);
    i.computeIntersectionPoints(p1, p2, q1, q2);
    assertEquals(LineIntersector.COLLINEAR_INTERSECTION, i.getIntersectionCount());
    assertTrue(i.hasIntersection());
}
Also used : RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Example 15 with RobustLineIntersector

use of com.revolsys.geometry.algorithm.RobustLineIntersector in project com.revolsys.open by revolsys.

the class RobustLineIntersectorTest method test2Lines.

// public RobustLineIntersectorTest(String Name_)
public void test2Lines() {
    final RobustLineIntersector i = new RobustLineIntersector();
    final Point p1 = new PointDoubleXY(10, 10);
    final Point p2 = new PointDoubleXY(20, 20);
    final Point q1 = new PointDoubleXY(20, 10);
    final Point q2 = new PointDoubleXY(10, 20);
    final Point x = new PointDoubleXY(15, 15);
    i.computeIntersectionPoints(p1, p2, q1, q2);
    assertEquals(LineIntersector.POINT_INTERSECTION, i.getIntersectionCount());
    assertEquals(1, i.getIntersectionCount());
    assertEquals(x, i.getIntersection(0));
    assertTrue(i.isProper());
    assertTrue(i.hasIntersection());
}
Also used : RobustLineIntersector(com.revolsys.geometry.algorithm.RobustLineIntersector) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY)

Aggregations

RobustLineIntersector (com.revolsys.geometry.algorithm.RobustLineIntersector)17 Point (com.revolsys.geometry.model.Point)10 LineIntersector (com.revolsys.geometry.algorithm.LineIntersector)6 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)5 IntersectionAdder (com.revolsys.geometry.noding.IntersectionAdder)3 MCIndexNoder (com.revolsys.geometry.noding.MCIndexNoder)3 Noder (com.revolsys.geometry.noding.Noder)2 ScaledNoder (com.revolsys.geometry.noding.ScaledNoder)2 ArrayList (java.util.ArrayList)2 Collection (java.util.Collection)2 List (java.util.List)2 NonRobustLineIntersector (com.revolsys.geometry.algorithm.NonRobustLineIntersector)1 GeometryGraph (com.revolsys.geometry.geomgraph.GeometryGraph)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 LineString (com.revolsys.geometry.model.LineString)1