/** * 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 + " )" ); }
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); } }
/** * 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); }
/** * 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 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; }
theGeom = PreparedGeometryFactory.prepare(cloned);
PreparedGeometry prepared = PreparedGeometryFactory.prepare(geometry);
private LineString processLineString(String id, LineString input) { LineString part = exendLine(input, length, length); PreparedGeometry prepared = PreparedGeometryFactory.prepare(part); GeometryFactory factory = part.getFactory();
private ObservationIterator(Product product, SamplePointer pointer, BinningContext binningContext) { this.pointer = pointer; this.dataPeriod = binningContext.getDataPeriod(); Geometry geometryRegion = binningContext.getRegion(); if (geometryRegion != null) { this.region = PreparedGeometryFactory.prepare(binningContext.getRegion()); } else { this.region = null; } this.product = product; this.productHasTime = product.getStartTime() != null || product.getEndTime() != null; this.gc = product.getGeoCoding(); Ellipsoid ellipsoid = CRS.getEllipsoid(gc.getMapCRS()); earthRadius = ellipsoid != null ? ellipsoid.getSemiMajorAxis() : DefaultEllipsoid.WGS84.getSemiMajorAxis(); geometryFactory = new GeometryFactory(); maxDistanceOnEarth = binningContext.getMaxDistanceOnEarth(); }
private LineString processLineString(String id, LineString part) { PreparedGeometry prepared = PreparedGeometryFactory.prepare(part); GeometryFactory factory = part.getFactory();
PreparedGeometry prepared = PreparedGeometryFactory.prepare(source); neighbors.clear();
PreparedGeometry prepared = PreparedGeometryFactory.prepare(source); GeometryFactory factory = source.getFactory();
pg = PreparedGeometryFactory.prepare(g);