@Override /** * Note that the remove operation won't adjust this.bound accordingly */ public boolean remove(final Rectangle bound, final T item) { return this.tree.remove(bound.asEnvelope(), item); }
@SuppressWarnings("unchecked") @Override public List<T> get(final Rectangle bound) { return this.tree.query(bound.asEnvelope()); }
@Override /** * Note that the remove operation won't adjust this.bound accordingly */ public boolean remove(final Rectangle bound, final T item) { return this.tree.remove(bound.asEnvelope(), item); }
@SuppressWarnings("unchecked") @Override public List<T> get(final Rectangle bound) { return this.tree.query(bound.asEnvelope()); }
/** * Query country names which intersect the given bound * * @param bound * Bounding box * @return A {@link StringList} of country names */ public StringList countryCodesOverlappingWith(final Rectangle bound) { return new StringList(query(bound.asEnvelope(), true).stream() .map(polygon -> getGeometryProperty(polygon, ISOCountryTag.KEY)) .collect(Collectors.toList())); }
/** * Query country boundaries, which intersect the given bound * * @param bound * Bounding box * @return a list of {@link CountryBoundary} */ public List<CountryBoundary> boundaries(final Rectangle bound) { return this.boundariesHelper(() -> this.query(bound.asEnvelope(), true), polygon -> true); }
@Override public void add(final Rectangle bound, final T item) { this.tree.insert(bound.asEnvelope(), item); if (this.bound != null) { this.bound = this.bound.combine(bound); } else { this.bound = bound; } }
@Override public void add(final Rectangle bound, final T item) { this.tree.insert(bound.asEnvelope(), item); if (this.bound != null) { this.bound = this.bound.combine(bound); } else { this.bound = bound; } }
/** * Query country boundaries which cover/partially cover given {@link PolyLine} * * @param polyLine * Any {@link PolyLine} or {@link Polygon} * @return a list of {@link CountryBoundary} */ public List<CountryBoundary> boundaries(final PolyLine polyLine) { return this.boundariesHelper(() -> this.query(polyLine.bounds().asEnvelope()), boundary -> boundary.intersects(JTS_POLYLINE_CONVERTER.convert(polyLine))); }
/** * Query country boundaries which cover given {@link Location} * * @param location * Any {@link Location} * @return a list of {@link CountryBoundary} */ public List<CountryBoundary> boundaries(final Location location) { return this.boundariesHelper(() -> this.query(location.bounds().asEnvelope()), boundary -> boundary.covers(JTS_POINT_CONVERTER.convert(location))); }
/** * Constructor with limited bounds * * @param bounds * {@link Rectangle} bounds for boundary map calculation */ public CountryBoundaryMap(final Rectangle bounds) { this.envelope = bounds.asEnvelope(); this.countryNameToBoundaryMap = new MultiMap<>(); this.rawIndex = new STRtree(); this.gridIndex = null; this.reducer = new GeometryPrecisionReducer(JtsPrecisionManager.getPrecisionModel()); this.reducer.setPointwise(true); this.reducer.setChangePrecisionModel(true); }
/** * Query country boundaries which cover/partially cover given {@link PolyLine}, with an * extension square box * * @param polyLine * Any {@link PolyLine} or {@link Polygon} * @param extension * Extension {@link Distance} * @return a list of {@link CountryBoundary} */ public List<CountryBoundary> boundaries(final PolyLine polyLine, final Distance extension) { return this.boundariesHelper( () -> this.query(polyLine.bounds().expand(extension).asEnvelope()), boundary -> boundary.intersects(JTS_POLYLINE_CONVERTER.convert(polyLine))); }