Search in sources :

Example 1 with SimplePointInAreaLocator

use of com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator in project com.revolsys.open by revolsys.

the class PointInAreaStressTester method run.

/**
 * @return true if all point locations were computed correctly
 */
public boolean run() {
    final Stopwatch sw = new Stopwatch();
    // default is to use the simple, non-indexed tester
    if (this.pia2 == null) {
        this.pia2 = new SimplePointInAreaLocator(this.area);
    }
    final int ptGridWidth = (int) Math.sqrt(this.numPts);
    final BoundingBox areaEnv = this.area.getBoundingBox();
    final double xStep = areaEnv.getWidth() / (ptGridWidth - 1);
    final double yStep = areaEnv.getHeight() / (ptGridWidth - 1);
    for (int i = 0; i < ptGridWidth; i++) {
        for (int j = 0; j < ptGridWidth; j++) {
            // compute test point
            final double x = this.geomFactory.makePrecise(0, areaEnv.getMinX() + i * xStep);
            final double y = this.geomFactory.makePrecise(1, areaEnv.getMinY() + j * yStep);
            final Point pt = new PointDoubleXY(x, y);
            final boolean isEqual = testPIA(pt);
            if (!isEqual) {
                return false;
            }
        }
    }
    // System.out.println("Test completed in " + sw.getTimeString());
    printStats();
    return true;
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Stopwatch(com.revolsys.geometry.util.Stopwatch) Point(com.revolsys.geometry.model.Point) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) SimplePointInAreaLocator(com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator) Point(com.revolsys.geometry.model.Point)

Aggregations

SimplePointInAreaLocator (com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator)1 BoundingBox (com.revolsys.geometry.model.BoundingBox)1 Point (com.revolsys.geometry.model.Point)1 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)1 Stopwatch (com.revolsys.geometry.util.Stopwatch)1