Java Code Examples for com.vividsolutions.jts.geom.Polygon#intersects()

The following examples show how to use com.vividsolutions.jts.geom.Polygon#intersects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CoordinateSequenceExperiment2.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void run(int nPts) {
    double size = 100.0;
    double armLen = 50.0;
    int nArms = 10;
    long startTime = System.currentTimeMillis();        
    Polygon poly = GeometryTestFactory.createSineStar(fact, 0.0, 0.0, size,
            armLen, nArms, nPts);
    long endTime = System.currentTimeMillis();
    long totalTime = endTime - startTime;
    String totalTimeStr = totalTime < 10000 ? totalTime + " ms"
                                            : totalTime / 1000.0 + " s";
    System.out.println("Sine Star Creation Executed in " + totalTimeStr);        

    Polygon box = GeometryTestFactory.createBox(fact, 0, 0, 1, 100.0);

    startTime = System.currentTimeMillis();
    poly.intersects(box);

    endTime = System.currentTimeMillis();
    totalTime = endTime - startTime;
    totalTimeStr = totalTime < 10000 ? totalTime + " ms"
                                            : totalTime / 1000.0 + " s";
    System.out.println("n Pts: " + nPts + "   Executed in " + totalTimeStr);
}
 
Example 2
Source File: CoordinateSequenceExperiment2.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void run2(int nPts) throws IOException {
    double size = 100.0;
    double armLen = 50.0;
    int nArms = 10;
    long startTime = System.currentTimeMillis();
    Polygon poly = GeometryTestFactory.createSineStar(fact, 0.0, 0.0, size,
            armLen, nArms, nPts);
    Polygon box = GeometryTestFactory.createSineStar(fact, 0.0, size / 2,
            size, armLen, nArms, nPts);
    long endTime = System.currentTimeMillis();
    long totalTime = endTime - startTime;
    String totalTimeStr = totalTime < 10000 ? totalTime + " ms"
                                            : totalTime / 1000.0 + " s";
    System.out.println("Sine Star Creation Executed in " + totalTimeStr);        
            

    //RobustDeterminant.callCount = 0;
    System.out.println("n Pts: " + nPts);

    startTime = System.currentTimeMillis();
    poly.intersects(box);

    //poly.intersection(box);
    endTime = System.currentTimeMillis();
    totalTime = endTime - startTime;
    totalTimeStr = totalTime < 10000 ? totalTime + " ms"
                                            : (double) totalTime / 1000.0 +
        " s";

    //System.out.println("   signOfDet2x2 calls: " + RobustDeterminant.callCount);
    System.out.println("   Executed in " + totalTimeStr);
}