Skip to content

Commit

Permalink
change GeoPackageReader to take Bounds instead of Envelope
Browse files Browse the repository at this point in the history
  • Loading branch information
bdon committed Feb 14, 2025
1 parent 5ca2d1b commit ebfebf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.onthegomap.planetiler.Profile;
import com.onthegomap.planetiler.collection.FeatureGroup;
import com.onthegomap.planetiler.config.Bounds;
import com.onthegomap.planetiler.config.PlanetilerConfig;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.FileUtils;
Expand Down Expand Up @@ -44,10 +45,10 @@ public class GeoPackageReader extends SimpleReader<SimpleFeature> {
private final GeoPackage geoPackage;
private final MathTransform coordinateTransform;

private final Envelope bounds;
private final Bounds bounds;

GeoPackageReader(String sourceProjection, String sourceName, Path input, Path tmpDir, boolean keepUnzipped,
Envelope bounds) {
Bounds bounds) {

super(sourceName);
this.keepUnzipped = keepUnzipped;
Expand Down Expand Up @@ -115,7 +116,7 @@ public static void process(String sourceProjection, String sourceName, List<Path
SourceFeatureProcessor.processFiles(
sourceName,
sourcePaths,
path -> new GeoPackageReader(sourceProjection, sourceName, path, tmpDir, keepUnzipped, config.bounds().latLon()),
path -> new GeoPackageReader(sourceProjection, sourceName, path, tmpDir, keepUnzipped, config.bounds()),
writer, config, profile, stats
);
}
Expand Down Expand Up @@ -154,7 +155,7 @@ public void readFeatures(Consumer<SimpleFeature> next) throws Exception {
Iterable<FeatureRow> results;

if (this.bounds != null && indexer.isIndexed() && srsId == 4326) {
var l = this.bounds;
var l = this.bounds.latLon();
indexer.setIndexLocation(FeatureIndexType.RTREE);
var boundingBox = new BoundingBox(l.getMinX(), l.getMinY(), l.getMaxX(), l.getMaxY());
results = indexer.query(boundingBox);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.onthegomap.planetiler.TestUtils;
import com.onthegomap.planetiler.config.Bounds;
import com.onthegomap.planetiler.geo.GeoUtils;
import com.onthegomap.planetiler.stats.Stats;
import com.onthegomap.planetiler.util.FileUtils;
Expand Down Expand Up @@ -82,7 +83,7 @@ void testReadGeoPackageSpatialIndex(String dbName, int expectedCount) throws Exc

try (
var reader =
new GeoPackageReader(proj, "test", path, tmpDir, false, new Envelope(-77.0306, -77.0192, 38.8894, 38.9014))
new GeoPackageReader(proj, "test", path, tmpDir, false, new Bounds(new Envelope(-77.0306, -77.0192, 38.8894, 38.9014)));
) {
String id = "path=" + path + " proj=" + proj;
assertEquals(86, reader.getFeatureCount(), id);
Expand Down

0 comments on commit ebfebf5

Please sign in to comment.