Skip to content

Commit

Permalink
explicitly test negated versions of geometry filters
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd committed Jun 4, 2021
1 parent 674445e commit 5e51a5c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ public boolean applyOSM(OSMEntity entity) {
return true;
}

@Override
boolean applyOSMNegated(OSMEntity entity) {
return true;
}

@Override
public boolean applyOSMGeometry(OSMEntity entity, Supplier<Geometry> geometrySupplier) {
return valueRange.test(metricEvaluator.applyAsDouble(geometrySupplier.get()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class ApplyOSMGeometryTest extends FilterTest {
public void testGeometryTypeFilterPoint() {
FilterExpression expression = parser.parse("geometry:point");
assertTrue(expression.applyOSMGeometry(createTestOSMEntityNode(), gf.createPoint()));
// negated
assertFalse(expression.negate().applyOSMGeometry(createTestOSMEntityNode(), gf.createPoint()));
}

@Test
Expand Down Expand Up @@ -113,6 +115,11 @@ public void testGeometryFilterArea() {
// approx 4.9m²
OSHDBGeometryBuilder.getGeometry(new OSHDBBoundingBox(0, 0, 2E-5, 2E-5))
));
// negated
assertTrue(expression.applyOSMGeometry(entity,
// approx 0.3m²
OSHDBGeometryBuilder.getGeometry(new OSHDBBoundingBox(0, 0, 5E-6, 5E-6))
));
}

@Test
Expand Down Expand Up @@ -140,5 +147,13 @@ public void testGeometryFilterLength() {
new Coordinate(2E-5, 0)
})
));
// negated
assertTrue(expression.negate().applyOSMGeometry(entity,
// approx 0.6m
gf.createLineString(new Coordinate[] {
new Coordinate(0, 0),
new Coordinate(5E-6, 0)
})
));
}
}

0 comments on commit 5e51a5c

Please sign in to comment.