@Test public void queryAllBounds() throws IOException, SQLException { MBTilesFeatureSource fs = getMadagascarSource("water"); List<RectangleLong> bounds = fs.getTileBoundsFor(new Query("water"), 7); assertThat(bounds, contains(new RectangleLong(0, 127, 0, 127))); }
protected List<RectangleLong> getTileBoundsFor(Query query, long z) throws SQLException { RectangleLong levelBounds = mbtiles.getTileBounds(z, false); if (query == null || query.getFilter() == null || query.getFilter() == Filter.INCLUDE) { return Collections.singletonList(levelBounds); } List<RectangleLong> rectangles = Optional.ofNullable(ExtractMultiBoundsFilterVisitor.getBounds(query.getFilter())) .map(o -> o.stream()) .orElse(Stream.empty()) .filter(e -> !Double.isInfinite(e.getWidth())) .map( e -> { try { return mbtiles.toTilesRectangle(e, z); } catch (SQLException ex) { throw new RuntimeException(ex); } }) .map(tr -> tr.intersection(levelBounds)) .collect(Collectors.toList()); if (rectangles.isEmpty()) { return Collections.singletonList(levelBounds); } List<RectangleLong> result = new ArrayList<>(); for (RectangleLong rect : rectangles) { if (result.isEmpty()) { result.add(rect); continue; } boolean mergedAny = false; do { mergedAny = false; ListIterator<RectangleLong> it = result.listIterator(); while (it.hasNext()) { RectangleLong next = it.next(); if (next.intersects(rect)) { it.remove(); rect.expandToInclude(next); mergedAny = true; } } } while (mergedAny); result.add(rect); } return result; }
MBTilesFeatureSource extends ContentFeatureSource { protected List<RectangleLong> getTileBoundsFor(Query query, long z) throws SQLException { RectangleLong levelBounds = mbtiles.getTileBounds(z, false); if (query == null || query.getFilter() == null || query.getFilter() == Filter.INCLUDE) { return Collections.singletonList(levelBounds); } List<RectangleLong> rectangles = Optional.ofNullable(ExtractMultiBoundsFilterVisitor.getBounds(query.getFilter())) .map(o -> o.stream()) .orElse(Stream.empty()) .filter(e -> !Double.isInfinite(e.getWidth())) .map( e -> { try { return mbtiles.toTilesRectangle(e, z); } catch (SQLException ex) { throw new RuntimeException(ex); } }) .map(tr -> tr.intersection(levelBounds)) .collect(Collectors.toList()); if (rectangles.isEmpty()) { return Collections.singletonList(levelBounds); } List<RectangleLong> result = new ArrayList<>(); for (RectangleLong rect : rectangles) { if (result.isEmpty()) { result.add(rect); continue; } boolean mergedAny = false; do { mergedAny = false; ListIterator<RectangleLong> it = result.listIterator(); while (it.hasNext()) { RectangleLong next = it.next(); if (next.intersects(rect)) { it.remove(); rect.expandToInclude(next); mergedAny = true; } } } while (mergedAny); result.add(rect); } return result; } }
MBTilesFeatureSource extends ContentFeatureSource { protected List<RectangleLong> getTileBoundsFor(Query query, long z) throws SQLException { RectangleLong levelBounds = mbtiles.getTileBounds(z, false); if (query == null || query.getFilter() == null || query.getFilter() == Filter.INCLUDE) { return Collections.singletonList(levelBounds); } List<RectangleLong> rectangles = Optional.ofNullable(ExtractMultiBoundsFilterVisitor.getBounds(query.getFilter())) .map(o -> o.stream()) .orElse(Stream.empty()) .filter(e -> !Double.isInfinite(e.getWidth())) .map( e -> { try { return mbtiles.toTilesRectangle(e, z); } catch (SQLException ex) { throw new RuntimeException(ex); } }) .map(tr -> tr.intersection(levelBounds)) .collect(Collectors.toList()); if (rectangles.isEmpty()) { return Collections.singletonList(levelBounds); } List<RectangleLong> result = new ArrayList<>(); for (RectangleLong rect : rectangles) { if (result.isEmpty()) { result.add(rect); continue; } boolean mergedAny = false; do { mergedAny = false; ListIterator<RectangleLong> it = result.listIterator(); while (it.hasNext()) { RectangleLong next = it.next(); if (next.intersects(rect)) { it.remove(); rect.expandToInclude(next); mergedAny = true; } } } while (mergedAny); result.add(rect); } return result; } MBTilesFeatureSource(
            ContentEntry entry,
            SimpleFeatureType schema,
            MBTilesFile mbtiles,
            MBtilesCache tileCache); }
MBTilesFeatureSource extends ContentFeatureSource { protected List<RectangleLong> getTileBoundsFor(Query query, long z) throws SQLException { RectangleLong levelBounds = mbtiles.getTileBounds(z, false); if (query == null || query.getFilter() == null || query.getFilter() == Filter.INCLUDE) { return Collections.singletonList(levelBounds); } List<RectangleLong> rectangles = Optional.ofNullable(ExtractMultiBoundsFilterVisitor.getBounds(query.getFilter())) .map(o -> o.stream()) .orElse(Stream.empty()) .filter(e -> !Double.isInfinite(e.getWidth())) .map( e -> { try { return mbtiles.toTilesRectangle(e, z); } catch (SQLException ex) { throw new RuntimeException(ex); } }) .map(tr -> tr.intersection(levelBounds)) .collect(Collectors.toList()); if (rectangles.isEmpty()) { return Collections.singletonList(levelBounds); } List<RectangleLong> result = new ArrayList<>(); for (RectangleLong rect : rectangles) { if (result.isEmpty()) { result.add(rect); continue; } boolean mergedAny = false; do { mergedAny = false; ListIterator<RectangleLong> it = result.listIterator(); while (it.hasNext()) { RectangleLong next = it.next(); if (next.intersects(rect)) { it.remove(); rect.expandToInclude(next); mergedAny = true; } } } while (mergedAny); result.add(rect); } return result; } MBTilesFeatureSource(
            ContentEntry entry,
            SimpleFeatureType schema,
            MBTilesFile mbtiles,
            MBtilesCache tileCache);  }
MBTilesFeatureSource extends ContentFeatureSource { protected List<RectangleLong> getTileBoundsFor(Query query, long z) throws SQLException { RectangleLong levelBounds = mbtiles.getTileBounds(z, false); if (query == null || query.getFilter() == null || query.getFilter() == Filter.INCLUDE) { return Collections.singletonList(levelBounds); } List<RectangleLong> rectangles = Optional.ofNullable(ExtractMultiBoundsFilterVisitor.getBounds(query.getFilter())) .map(o -> o.stream()) .orElse(Stream.empty()) .filter(e -> !Double.isInfinite(e.getWidth())) .map( e -> { try { return mbtiles.toTilesRectangle(e, z); } catch (SQLException ex) { throw new RuntimeException(ex); } }) .map(tr -> tr.intersection(levelBounds)) .collect(Collectors.toList()); if (rectangles.isEmpty()) { return Collections.singletonList(levelBounds); } List<RectangleLong> result = new ArrayList<>(); for (RectangleLong rect : rectangles) { if (result.isEmpty()) { result.add(rect); continue; } boolean mergedAny = false; do { mergedAny = false; ListIterator<RectangleLong> it = result.listIterator(); while (it.hasNext()) { RectangleLong next = it.next(); if (next.intersects(rect)) { it.remove(); rect.expandToInclude(next); mergedAny = true; } } } while (mergedAny); result.add(rect); } return result; } MBTilesFeatureSource(
            ContentEntry entry,
            SimpleFeatureType schema,
            MBTilesFile mbtiles,
            MBtilesCache tileCache);   }