/** * Inserts a collection of Geometrys into the index. * * @param geoms a collection of Geometrys to insert */ public void insert(Collection geoms) { for (Iterator i = geoms.iterator(); i.hasNext(); ) { Geometry geom = (Geometry) i.next(); index.insert(geom.getEnvelopeInternal(), PreparedGeometryFactory.prepare(geom)); } }
/** * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. * * @param geom the geometry to prepare * @return the prepared geometry */ public static PreparedGeometry prepare(Geometry geom) { return (new PreparedGeometryFactory()).create(geom); }
/** * Constructor * @param polygon * Polygon that makes up the shape of the influence * @param scalar * Multiplier on the cost of a route. */ public Influence(final Polygon polygon, final double scalar) { this.preparedPolygon = (PreparedPolygon) preparedFactory.create(polygon); this.scalar = scalar; }
protected AbstractPreparedGeometryFilter(FilterFactory factory, Expression e1, Expression e2, MatchAction matchAction) { super(factory, e1, e2, matchAction); pGeomFac = new PreparedGeometryFactory(); if( e1!=null ) setExpression1(e1); if( e2!=null ) setExpression2(e2); }
protected AbstractPreparedGeometryFilter(FilterFactory factory, Expression e1, Expression e2) { super(factory, e1, e2); pGeomFac = new PreparedGeometryFactory(); if( e1!=null ) setExpression1(e1); if( e2!=null ) setExpression2(e2); }
public static void main(String[] args) throws Exception { Geometry circle = createCircle(); PreparedGeometry prepCircle = PreparedGeometryFactory.prepare(circle); int count = 0; int inCount = 0; for (int i = 0; i < MAX_ITER; i++) { count++; Point randPt = createRandomPoint(); if (prepCircle.intersects(randPt)) { inCount++; } //System.out.println("Approximation to PI: " + (4.0 * inCount / (double) count)); } double approxPi = 4.0 * inCount / (double) count; double approxDiffPct = 1.0 - approxPi/Math.PI; System.out.println("Approximation to PI: " + approxPi + " ( % difference from actual = " + 100 * approxDiffPct + " )" ); }
/** * Creates a new {@link PreparedGeometry} appropriate for the argument {@link Geometry}. * * @param geom the geometry to prepare * @return the prepared geometry */ public static PreparedGeometry prepare(Geometry geom) { return (new PreparedGeometryFactory()).create(geom); }
PreparedGeometry preparedGeom = pgFact.create(geometry);
/** * Adds an index to this class internally to compute spatial relations faster. In JTS this * is called a {@link com.vividsolutions.jts.geom.prep.PreparedGeometry}. This * isn't done by default because it takes some time to do the optimization, and it uses more * memory. Calling this method isn't thread-safe so be careful when this is done. If it was * already indexed then nothing happens. */ public void index() { if (preparedGeometry == null) preparedGeometry = PreparedGeometryFactory.prepare(geom); }
PreparedGeometry preparedGeom = pgFact.create(geometry);
/** * Adds an index to this class internally to compute spatial relations faster. In JTS this * is called a {@link com.vividsolutions.jts.geom.prep.PreparedGeometry}. This * isn't done by default because it takes some time to do the optimization, and it uses more * memory. Calling this method isn't thread-safe so be careful when this is done. If it was * already indexed then nothing happens. */ public void index() { if (preparedGeometry == null) preparedGeometry = PreparedGeometryFactory.prepare(geom); }
private void checkPreparedShape() { if (this.preparedShape == null && !preparationAttempted) { preparationAttempted = true; try { this.preparedShape = PreparedGeometryFactory.prepare(value); } catch (Throwable t) { // } } }
public void setGeometryBoundary(Geometry geometryBoundary) { if (geometryBoundary == null) { this.geometryBoundary = null; } else { this.geometryBoundary = PreparedGeometryFactory.prepare(geometryBoundary); } }
public void setBoundsGeometry(Geometry geometryBoundary) { if (geometryBoundary == null) { this.boundsGeometry = null; } else { this.boundsGeometry = PreparedGeometryFactory.prepare(geometryBoundary); } }
public void setGeometryBoundary(Geometry geometryBoundary) { if (geometryBoundary == null) { this.boundsGeometry = null; } else { this.boundsGeometry = PreparedGeometryFactory.prepare(geometryBoundary); } }
public void setBoundsGeometry(Geometry geometryBoundary) { if (geometryBoundary == null) { this.boundsGeometry = null; } else { this.boundsGeometry = PreparedGeometryFactory.prepare(geometryBoundary); } }
/** * Inserts a collection of Geometrys into the index. * * @param geoms a collection of Geometrys to insert */ public void insert(Collection geoms) { for (Iterator i = geoms.iterator(); i.hasNext(); ) { Geometry geom = (Geometry) i.next(); index.insert(geom.getEnvelopeInternal(), PreparedGeometryFactory.prepare(geom)); } }
public static void main(String[] args) throws Exception { Geometry circle = createCircle(); PreparedGeometry prepCircle = PreparedGeometryFactory.prepare(circle); int count = 0; int inCount = 0; for (int i = 0; i < MAX_ITER; i++) { count++; Point randPt = createRandomPoint(); if (prepCircle.intersects(randPt)) { inCount++; } //System.out.println("Approximation to PI: " + (4.0 * inCount / (double) count)); } double approxPi = 4.0 * inCount / (double) count; double approxDiffPct = 1.0 - approxPi/Math.PI; System.out.println("Approximation to PI: " + approxPi + " ( % difference from actual = " + 100 * approxDiffPct + " )" ); }
private Shapefile load() { if (state.compareAndSet(NOT_LOADED, LOADED)) { try { final List<PreparedGeometry> geometries = new ArrayList<>(); for (String typeName : datastore.getTypeNames()) { SimpleFeatureSource source = datastore.getFeatureSource(typeName); crs = source.getBounds().getCoordinateReferenceSystem(); final SimpleFeatureCollection features = source.getFeatures(); SimpleFeatureIterator it = features.features(); while (it.hasNext()) { SimpleFeature feature = it.next(); Geometry g = (Geometry) feature.getDefaultGeometry(); if (bufferDistance > 0) g = g.buffer(bufferDistance); geometries.add(PreparedGeometryFactory.prepare(g)); this.features.add(feature); } it.close(); } this.geometries = geometries; } catch (IOException e) { throw new RuntimeException(e); } } else if (state.get() == CLOSED) throw new RuntimeException("Shapefile is closed and can't be accessed"); return this; }