From 5e51a5c2e6b8be450748334d3ab60bdd5e300a05 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Fri, 4 Jun 2021 15:46:12 +0200 Subject: [PATCH] explicitly test negated versions of geometry filters --- .../ohsome/oshdb/filter/GeometryFilter.java | 5 ----- .../ohsome/oshdb/filter/ApplyOSMGeometryTest.java | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilter.java b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilter.java index 01460c483..5ef5b921a 100644 --- a/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilter.java +++ b/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/GeometryFilter.java @@ -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 geometrySupplier) { return valueRange.test(metricEvaluator.applyAsDouble(geometrySupplier.get())); diff --git a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java index 0ae18a7e8..5475f78b2 100644 --- a/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java +++ b/oshdb-filter/src/test/java/org/heigit/ohsome/oshdb/filter/ApplyOSMGeometryTest.java @@ -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 @@ -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 @@ -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) + }) + )); } }