Skip to content

Commit

Permalink
fix: areaOfInterest should not override previously set bbox (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd authored Aug 31, 2023
1 parent b6f1250 commit 22aef0e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public MapReducer<X> tagInterpreter(TagInterpreter tagInterpreter) {
public MapReducer<X> areaOfInterest(@NotNull OSHDBBoundingBox bboxFilter) {
MapReducer<X> ret = this.copy();
if (this.polyFilter == null) {
ret.bboxFilter = bboxFilter.intersection(bboxFilter);
ret.bboxFilter = ret.bboxFilter.intersection(bboxFilter);
} else {
ret.polyFilter = Geo.clip(ret.polyFilter, bboxFilter);
ret.bboxFilter = OSHDBGeometryBuilder.boundingBoxOf(ret.polyFilter.getEnvelopeInternal());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,28 @@ void bbox() throws Exception {
assertEquals(2, result.intValue());
}

@Test
void bboxesNotIntersecting() throws Exception {
Integer result = createMapReducerOSMEntitySnapshot()
.filter("type:node")
.areaOfInterest(OSHDBBoundingBox.bboxWgs84Coordinates(0, 0, 1, 1))
.areaOfInterest(bbox)
.timestamps(timestamps1)
.count();
assertEquals(0, result.intValue());
}

@Test
void bboxesIntersecting() throws Exception {
Integer result = createMapReducerOSMEntitySnapshot()
.filter("type:node")
.areaOfInterest(OSHDBBoundingBox.bboxWgs84Coordinates(-180, -90, 180, 90))
.areaOfInterest(bbox)
.timestamps(timestamps1)
.count();
assertEquals(2, result.intValue());
}

@Test
void polygon() throws Exception {
Integer result = createMapReducerOSMEntitySnapshot()
Expand Down

0 comments on commit 22aef0e

Please sign in to comment.