Search in sources :

Example 1 with IndexedPointInAreaLocator

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

the class RandomPointsBuilder method setExtent.

/**
 * Sets a polygonal mask.
 *
 * @param mask
 * @throws IllegalArgumentException if the mask is not polygonal
 */
public void setExtent(final Geometry mask) {
    if (!(mask instanceof Polygonal)) {
        throw new IllegalArgumentException("Only polygonal extents are supported");
    }
    this.maskPoly = mask;
    setExtent(mask.getBoundingBox());
    this.extentLocator = new IndexedPointInAreaLocator(mask);
}
Also used : IndexedPointInAreaLocator(com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator) Polygonal(com.revolsys.geometry.model.Polygonal)

Example 2 with IndexedPointInAreaLocator

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

the class IndexedPointInAreaStressTest method testGrid.

public void testGrid() {
    // Use fixed PM to try and get at least some points hitting the boundary
    final GeometryFactory geomFactory = GeometryFactory.fixed2d(0, 1.0, 1.0);
    // GeometryFactoryI geomFactory = new GeometryFactoryI();
    final PerturbedGridPolygonBuilder gridBuilder = new PerturbedGridPolygonBuilder(geomFactory);
    gridBuilder.setNumLines(20);
    gridBuilder.setLineWidth(10.0);
    gridBuilder.setSeed(1185072199562L);
    final Geometry area = gridBuilder.getGeometry();
    // PointInAreaLocator pia = new
    // GeometryFactoryIndexedPointInAreaLocator(area);
    final PointOnGeometryLocator pia = new IndexedPointInAreaLocator(area);
    final PointInAreaStressTester gridTester = new PointInAreaStressTester(geomFactory, area);
    gridTester.setNumPoints(100000);
    gridTester.setPIA(pia);
    final boolean isCorrect = gridTester.run();
    assertTrue(isCorrect);
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) IndexedPointInAreaLocator(com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator) GeometryFactory(com.revolsys.geometry.model.GeometryFactory) PointInAreaStressTester(com.revolsys.geometry.test.old.perf.algorithm.PointInAreaStressTester) PointOnGeometryLocator(com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)

Aggregations

IndexedPointInAreaLocator (com.revolsys.geometry.algorithm.locate.IndexedPointInAreaLocator)2 PointOnGeometryLocator (com.revolsys.geometry.algorithm.locate.PointOnGeometryLocator)1 Geometry (com.revolsys.geometry.model.Geometry)1 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)1 Polygonal (com.revolsys.geometry.model.Polygonal)1 PointInAreaStressTester (com.revolsys.geometry.test.old.perf.algorithm.PointInAreaStressTester)1