System.out.println("\n=== Simple test map.osm ===");
importMapOSM();
// START SNIPPET: searchBBox
GraphDatabaseService database = new GraphDatabaseFactory().newEmbeddedDatabase(databasePath);
try {
SpatialDatabaseService spatialService = new SpatialDatabaseService(database);
Layer layer = spatialService.getLayer("map.osm");
LayerIndexReader spatialIndex = layer.getIndex();
System.out.println("Have " + spatialIndex.count() + " geometries in " + spatialIndex.getBoundingBox());
Envelope bbox = new Envelope(12.94, 12.96, 56.04, 56.06);
try (Transaction tx = database.beginTx()) {
List<SpatialDatabaseRecord> results = GeoPipeline
.startIntersectWindowSearch(layer, bbox)
.toSpatialDatabaseRecordList();
doGeometryTestsOnResults(bbox, results);
tx.success();
}
} finally {
database.shutdown();
}
// END SNIPPET: searchBBox
checkIndexAndFeatureCount("map.osm");
}