@Override public PagesSpatialIndex get() { if (rtree.isEmpty()) { return EMPTY_INDEX; } return new PagesRTreeIndex(session, addresses, types, outputChannels, channels, rtree, radiusChannel, spatialRelationshipTest, filterFunctionFactory, partitions); } }
private long computeMemorySizeInBytes(ItemBoundable item) { return ENVELOPE_INSTANCE_SIZE + ((GeometryWithPosition) item.getItem()).getEstimatedMemorySizeInBytes(); }
private long computeMemorySizeInBytes(AbstractNode root) { if (root.getLevel() == 0) { return ABSTRACT_NODE_INSTANCE_SIZE + ENVELOPE_INSTANCE_SIZE + root.getChildBoundables().stream().mapToLong(child -> computeMemorySizeInBytes((ItemBoundable) child)).sum(); } return ABSTRACT_NODE_INSTANCE_SIZE + ENVELOPE_INSTANCE_SIZE + root.getChildBoundables().stream().mapToLong(child -> computeMemorySizeInBytes((AbstractNode) child)).sum(); }
/** @see org.geotools.data.FeatureResults#reader() */ public FeatureReader<SimpleFeatureType, SimpleFeature> reader(Envelope envelope) throws IOException { List results = index.query(envelope); final Iterator resultsIterator = results.iterator(); return new FeatureReader<SimpleFeatureType, SimpleFeature>() { /** @see org.geotools.data.FeatureReader#getFeatureType() */ public SimpleFeatureType getFeatureType() { return getSchema(); } /** @see org.geotools.data.FeatureReader#next() */ public SimpleFeature next() throws IOException, IllegalAttributeException, NoSuchElementException { return (SimpleFeature) resultsIterator.next(); } /** @see org.geotools.data.FeatureReader#hasNext() */ public boolean hasNext() throws IOException { return resultsIterator.hasNext(); } /** @see org.geotools.data.FeatureReader#close() */ public void close() throws IOException {} }; }
private static STRtree buildRTree(LongArrayList addresses, List<List<Block>> channels, int geometryChannel, Optional<Integer> radiusChannel, Optional<Integer> partitionChannel) STRtree rtree = new STRtree(); Operator relateOperator = OperatorFactoryLocal.getInstance().getOperator(Operator.Type.Relate); rtree.insert(getEnvelope(ogcGeometry, radius), new GeometryWithPosition(ogcGeometry, partition, position)); rtree.build(); return rtree;
public boolean add(SimpleFeature feature) { ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); index.insert(bounds, feature); return false; }
public SpatialIndexFeatureCollection(SimpleFeatureType schema) { this.index = new STRtree(); this.schema = schema; }
public PagesSpatialIndexSupplier( Session session, LongArrayList addresses, List<Type> types, List<Integer> outputChannels, List<List<Block>> channels, int geometryChannel, Optional<Integer> radiusChannel, Optional<Integer> partitionChannel, SpatialPredicate spatialRelationshipTest, Optional<JoinFilterFunctionCompiler.JoinFilterFunctionFactory> filterFunctionFactory, Map<Integer, Rectangle> partitions) { this.session = session; this.addresses = addresses; this.types = types; this.outputChannels = outputChannels; this.channels = channels; this.spatialRelationshipTest = spatialRelationshipTest; this.filterFunctionFactory = filterFunctionFactory; this.partitions = partitions; this.rtree = buildRTree(addresses, channels, geometryChannel, radiusChannel, partitionChannel); this.radiusChannel = radiusChannel; this.memorySizeInBytes = INSTANCE_SIZE + (rtree.isEmpty() ? 0 : STRTREE_INSTANCE_SIZE + computeMemorySizeInBytes(rtree.getRoot())); }
/** Will build the STRtree index if required. */ public int size() { return index.size(); }
public boolean isEmpty() { return index.itemsTree().isEmpty(); }
@SuppressWarnings("unchecked") public Iterator<SimpleFeature> iterator() { Envelope everything = new Envelope( Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); final List<SimpleFeature> list = (List<SimpleFeature>) index.query(everything); return (Iterator<SimpleFeature>) list.iterator(); }
public boolean addAll(Collection<? extends SimpleFeature> collection) { for (SimpleFeature feature : collection) { try { ReferencedEnvelope bounds = ReferencedEnvelope.reference(feature.getBounds()); index.insert(bounds, feature); } catch (Throwable t) { } } return false; }
public SpatialIndexFeatureCollection() { this.index = new STRtree(); }
@SuppressWarnings("unchecked") public SimpleFeatureIterator features() { Envelope everything = new Envelope( Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); final List<SimpleFeature> list = (List<SimpleFeature>) index.query(everything); final Iterator<SimpleFeature> iterator = list.iterator(); return new SimpleFeatureIterator() { public SimpleFeature next() throws NoSuchElementException { return iterator.next(); } public boolean hasNext() { return iterator.hasNext(); } public void close() {} }; }
public void add(T te) { rectangles.add(te); si.insert(new Envelope(te.getLeft(), te.getRight(), te.getBottom(), te.getTop()), te); }
public synchronized void clear() { index = null; index = new STRtree(); listeners.clear(); listeners = null; }
/** @see org.geotools.data.FeatureResults#collection() */ public SimpleFeatureCollection collection() throws IOException { DefaultFeatureCollection fc = new DefaultFeatureCollection(); List<SimpleFeature> results = index.query(bounds); for (Iterator<SimpleFeature> it = results.iterator(); it.hasNext(); ) { fc.add(it.next()); } return fc; }
rtree.query(envelope, item -> { GeometryWithPosition geometryWithPosition = (GeometryWithPosition) item; OGCGeometry buildGeometry = geometryWithPosition.getGeometry();
public List<T> intersects(Rectangle r) { List rv = si.query(new Envelope(r.getLeft(), r.getRight(), r.getTop(), r.getBottom())); return rv; }