From c54cd1bedacefd0eac5674fff932fddd2e5c2232 Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Thu, 21 Jan 2021 17:55:19 +0100 Subject: [PATCH] fix filter parameter not set when using groupBy/boundary requests closes #99 --- .../ohsome/ohsomeapi/executor/AggregateRequestExecutor.java | 6 ++++++ .../ohsome/ohsomeapi/executor/ElementsRequestExecutor.java | 5 +++++ .../ohsome/ohsomeapi/executor/UsersRequestExecutor.java | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/AggregateRequestExecutor.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/AggregateRequestExecutor.java index a4fdc522..62024409 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/AggregateRequestExecutor.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/AggregateRequestExecutor.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.SortedMap; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -25,6 +26,7 @@ import org.heigit.bigspatialdata.oshdb.util.OSHDBTimestamp; import org.heigit.bigspatialdata.oshdb.util.geometry.Geo; import org.heigit.bigspatialdata.oshdb.util.time.TimestampFormatter; +import org.heigit.ohsome.filter.FilterExpression; import org.heigit.ohsome.ohsomeapi.Application; import org.heigit.ohsome.ohsomeapi.exception.BadRequestException; import org.heigit.ohsome.ohsomeapi.exception.ExceptionMessages; @@ -351,6 +353,10 @@ private ElementsResult[] fillElementsResult(SortedMap filter = processingData.getFilterExpression(); + if (filter.isPresent()) { + mapAgg = mapAgg.filter(filter.get()); + } preResult = mapAgg.map(OSMEntitySnapshot::getGeometry); switch (requestResource) { case COUNT: diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ElementsRequestExecutor.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ElementsRequestExecutor.java index 653a83cb..7f5aa0c2 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ElementsRequestExecutor.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/ElementsRequestExecutor.java @@ -9,6 +9,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; @@ -191,6 +192,10 @@ public static

Response aggregateGroupByBoundary if (processingData.isContainingSimpleFeatureTypes()) { mapAgg = inputProcessor.filterOnSimpleFeatures(mapAgg); } + Optional filter = processingData.getFilterExpression(); + if (filter.isPresent()) { + mapAgg = mapAgg.filter(filter.get()); + } ExecutionUtils exeUtils = new ExecutionUtils(processingData); var preResult = mapAgg.map(f -> exeUtils.mapSnapshotToTags(keysInt, valuesInt, f)) .aggregateBy(Pair::getKey, zeroFill).map(Pair::getValue) diff --git a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/UsersRequestExecutor.java b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/UsersRequestExecutor.java index 38717916..9b2b0a49 100644 --- a/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/UsersRequestExecutor.java +++ b/src/main/lombok/org/heigit/ohsome/ohsomeapi/executor/UsersRequestExecutor.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; import java.util.SortedMap; import java.util.stream.Collectors; import java.util.stream.IntStream; @@ -22,6 +23,7 @@ import org.heigit.bigspatialdata.oshdb.osm.OSMType; import org.heigit.bigspatialdata.oshdb.util.OSHDBTimestamp; import org.heigit.bigspatialdata.oshdb.util.tagtranslator.TagTranslator; +import org.heigit.ohsome.filter.FilterExpression; import org.heigit.ohsome.ohsomeapi.Application; import org.heigit.ohsome.ohsomeapi.exception.BadRequestException; import org.heigit.ohsome.ohsomeapi.exception.ExceptionMessages; @@ -313,6 +315,10 @@ public static

Response countGroupByBoundary( if (processingData.isContainingSimpleFeatureTypes()) { mapAgg = inputProcessor.filterOnSimpleFeatures(mapAgg); } + Optional filter = processingData.getFilterExpression(); + if (filter.isPresent()) { + mapAgg = mapAgg.filter(filter.get()); + } SortedMap, Integer> result = mapAgg.map(OSMContribution::getContributorUserId).countUniq(); SortedMap> groupByResult;