Search in sources :

Example 26 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class PointInAreaPerfTester method run.

/**
 * @return true if all point locations were computed correctly
 */
public boolean run() {
    final Stopwatch sw = new Stopwatch();
    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 Location loc = this.pia1.locate(pt);
            this.locationCount[loc.getIndex()]++;
        }
    }
    // 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) Point(com.revolsys.geometry.model.Point) Location(com.revolsys.geometry.model.Location)

Example 27 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class SimpleRectangleIntersector method run.

public void run(final boolean useSegInt, final boolean useSideInt) {
    if (useSegInt) {
    // System.out.println("Using Segment Intersector");
    }
    if (useSideInt) {
    // System.out.println("Using Side Intersector");
    }
    // System.out.println("# pts: " + this.pts.length);
    final RectangleLineIntersector rectSegIntersector = new RectangleLineIntersector(this.rectEnv);
    final SimpleRectangleIntersector rectSideIntersector = new SimpleRectangleIntersector(this.rectEnv);
    final Stopwatch sw = new Stopwatch();
    for (int i = 0; i < this.pts.length; i++) {
        for (int j = 0; j < this.pts.length; j++) {
            if (i == j) {
                continue;
            }
            boolean segResult = false;
            if (useSegInt) {
                segResult = rectSegIntersector.intersects(this.pts[i], this.pts[j]);
            }
            boolean sideResult = false;
            if (useSideInt) {
                sideResult = rectSideIntersector.intersects(this.pts[i], this.pts[j]);
            }
            if (useSegInt && useSideInt) {
                if (segResult != sideResult) {
                    throw new IllegalStateException("Seg and Side values do not match");
                }
            }
        }
    }
// System.out.println("Finished in " + sw.getTimeString());
// System.out.println();
}
Also used : Stopwatch(com.revolsys.geometry.util.Stopwatch) RectangleLineIntersector(com.revolsys.geometry.algorithm.RectangleLineIntersector) Point(com.revolsys.geometry.model.Point)

Example 28 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class PreparedLineIntersectsPerfTest method test.

public void test(final Geometry g, final List lines) {
    // System.out.println("AOI # pts: " + g.getVertexCount() + " # lines: "
    // + lines.size() + " # pts in line: " + NUM_LINE_PTS);
    final Stopwatch sw = new Stopwatch();
    int count = 0;
    for (int i = 0; i < MAX_ITER; i++) {
        // count = testPrepGeomNotCached(g, lines);
        count = testPrepGeomCached(g, lines);
    // count = testOriginal(g, lines);
    }
// System.out.println("Count of intersections = " + count);
// System.out.println("Finished in " + sw.getTimeString());
}
Also used : Stopwatch(com.revolsys.geometry.util.Stopwatch)

Example 29 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class QuadtreeCorrectTest method queryGrid.

void queryGrid(final int nGridCells, final double cellSize) {
    final Stopwatch sw = new Stopwatch();
    sw.start();
    int gridSize = (int) Math.sqrt(nGridCells);
    gridSize += 1;
    final double extent = MAX_EXTENT - MIN_EXTENT;
    final double gridInc = extent / gridSize;
    for (int i = 0; i < gridSize; i++) {
        for (int j = 0; j < gridSize; j++) {
            final double x = MIN_EXTENT + gridInc * i;
            final double y = MIN_EXTENT + gridInc * j;
            final BoundingBox env = new BoundingBoxDoubleXY(x, y, x + cellSize, y + cellSize);
            queryTest(env);
        // queryTime(env);
        }
    }
// System.out.println("Time = " + sw.getTimeString());
}
Also used : BoundingBox(com.revolsys.geometry.model.BoundingBox) Stopwatch(com.revolsys.geometry.util.Stopwatch) BoundingBoxDoubleXY(com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)

Example 30 with Stopwatch

use of com.revolsys.geometry.util.Stopwatch in project com.revolsys.open by revolsys.

the class FileBufferResultValidatorTest method runAll.

void runAll(final List geoms, final double dist) {
    final Stopwatch sw = new Stopwatch();
    // dist);
    for (final Iterator i = geoms.iterator(); i.hasNext(); ) {
        final Geometry g = (Geometry) i.next();
        runBuffer(g, dist);
        runBuffer(g.reverse(), dist);
        System.out.print(".");
    }
// System.out.println(" " + sw.getTimeString());
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) Stopwatch(com.revolsys.geometry.util.Stopwatch) Iterator(java.util.Iterator)

Aggregations

Stopwatch (com.revolsys.geometry.util.Stopwatch)30 Point (com.revolsys.geometry.model.Point)14 Geometry (com.revolsys.geometry.model.Geometry)6 QuadEdgeDelaunayTinBuilder (com.revolsys.elevation.tin.quadedge.QuadEdgeDelaunayTinBuilder)3 DD (com.revolsys.geometry.math.DD)3 BoundingBox (com.revolsys.geometry.model.BoundingBox)3 PointDoubleXY (com.revolsys.geometry.model.impl.PointDoubleXY)2 Iterator (java.util.Iterator)2 RectangleLineIntersector (com.revolsys.geometry.algorithm.RectangleLineIntersector)1 PointOnGeometryLocator (com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)1 SimplePointInAreaLocator (com.revolsys.geometry.algorithm.locate.SimplePointInAreaLocator)1 Interval (com.revolsys.geometry.index.bintree.Interval)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Location (com.revolsys.geometry.model.Location)1 BoundingBoxDoubleXY (com.revolsys.geometry.model.impl.BoundingBoxDoubleXY)1 SineStarFactory (com.revolsys.geometry.model.util.SineStarFactory)1 Constructor (java.lang.reflect.Constructor)1 Method (java.lang.reflect.Method)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1