Skip to content

Commit

Permalink
drop support for deprecated types/keys/values filter parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
tyrasd committed Nov 17, 2022
1 parent 515b729 commit f14e509
Show file tree
Hide file tree
Showing 19 changed files with 75 additions and 792 deletions.
28 changes: 8 additions & 20 deletions docs/endpoints.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ API Endpoints
.. note:: For **POST requests** the fields are given analogous to **GET requests**. When you just have a smaller set of spatial parameters,
a GET request fits perfectly. POST mostly makes sense when you start to use GeoJSON as input geometries.

The usage of the parameters **types**, **keys** and **values** is not recommended as they are deprecated. Please use the
filter_ parameter for your requests.

Elements Aggregation
--------------------

Expand All @@ -22,9 +19,6 @@ Elements Aggregation
:query format: 'json' or 'csv'; default: 'json'
:query showMetadata: add additional metadata information to the response: 'true', 'false', 'yes', 'no'; default: 'false'
:query timeout: custom timeout to limit the processing time in seconds; default: dependent on server settings, retrievable via the /metadata request
:query types: Deprecated! Use **filter** parameter instead! Old parameter which allowed to specify OSM type(s) ‘node’ and/or ‘way’ and/or ‘relation’ OR simple feature type(s) ‘point’ and/or ‘line’ and/or 'polygon’ and/or 'other'; default: all three OSM types
:query keys: Deprecated! Use **filter** parameter instead! Old parameter which allowed to specify OSM key(s) given as a list and combined with the 'AND' operator; default: empty
:query values: Deprecated! Use **filter** parameter instead! Old parameter which allowed to specify OSM value(s) given as a list and combined with the 'AND' operator; values(n) MUST fit to keys(n); default: empty

**Example request**:

Expand Down Expand Up @@ -217,9 +211,6 @@ What is the density of restaurants with wheelchair access in Heidelberg?

:query <other>: see above_
:query filter2: see filter_
:query keys2: Deprecated! see **filter2**
:query types2: Deprecated! use **filter2**
:query values2: Deprecated! see **filter2**

.. note:: The result of a **ratio request** may contain the value **"NaN"**, when the ratio calculation involves a division of zero by zero.

Expand Down Expand Up @@ -819,9 +810,6 @@ Compare length of different types of streets for two or more regions.

:query <other>: see above_
:query filter2: see filter_
:query keys2: Deprecated! see **filter2**
:query types2: Deprecated! use **filter2**
:query values2: Deprecated! see **filter2**

Users Aggregation
-----------------
Expand Down Expand Up @@ -1008,7 +996,7 @@ Contributions Aggregation

.. http:post :: /contributions/count
Get the count of the contributions provided to the OSM data. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters. List of endpoints:
Get the count of the contributions provided to the OSM data. List of endpoints:

* **/count**
* **/count/density**
Expand Down Expand Up @@ -1126,7 +1114,7 @@ Number of contributions to the building 'Stadthalle Heidelberg' between 2010 and

.. http:post :: /contributions/count/density
Get the density of the count of contributions in the total query area in counts per square-kilometers. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the density of the count of contributions in the total query area in counts per square-kilometers.

**Example request**:

Expand Down Expand Up @@ -1230,7 +1218,7 @@ Density of contributions to shops within the oldtown area of Heidelberg between

.. http:post :: /contributions/latest/count
Get the count of the latest contributions provided to the OSM data. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the count of the latest contributions provided to the OSM data.

**Example request**:

Expand Down Expand Up @@ -1334,7 +1322,7 @@ Number of the latest contributions to residential buildings with a geometry chan

.. http:post :: /contributions/latest/count/density
Get the density of the count of the latest contributions in the total query area in counts per square-kilometers. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the density of the count of the latest contributions in the total query area in counts per square-kilometers.

**Example request**:

Expand Down Expand Up @@ -1438,7 +1426,7 @@ Density of the latest contributions with a geometry change to shops within the o

.. http:post :: /contributions/count/groupBy/boundary
Get the count of the contributions provided to the OSM data grouped by the specified boundaries of the query. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the count of the contributions provided to the OSM data grouped by the specified boundaries of the query.

**Example request**:

Expand Down Expand Up @@ -1574,7 +1562,7 @@ Number of contributions to shops in different suburbs of Heidelberg (Altstadt an

.. http:post :: /contributions/count/density/groupBy/boundary
Get the density of the count of contributions in the total query area in counts per square-kilometers grouped by the specified boundaries of the query. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the density of the count of contributions in the total query area in counts per square-kilometers grouped by the specified boundaries of the query.

**Example request**:

Expand Down Expand Up @@ -1975,7 +1963,7 @@ Contributions Extraction

.. http:post :: /contributions/(geometryType)
Get the contributions provided to the OSM data. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the contributions provided to the OSM data.
This endpoint supports the geometry types ``bbox``, ``centroid`` and ``geometry``.

:query <other>: see above_ (except **format**)
Expand Down Expand Up @@ -2327,7 +2315,7 @@ Get the changes of pharmacies with opening hours in a certain area of Heidelberg

.. http:post :: /contributions/latest/(geometryType)
Get the the latest state of the contributions provided to the OSM data. This endpoint does not support the deprecated ``types``, ``keys``, ``values`` parameters.
Get the the latest state of the contributions provided to the OSM data.
This endpoint supports the geometry types ``bbox``, ``centroid`` and ``geometry``.

:query <other>: see above_ (except **format**)
Expand Down
3 changes: 0 additions & 3 deletions docs/filter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ The filter parameter combines the following: definition of the OSM type,
the geometry (simple feature) type, as well as the OSM tag. The filter syntax is defined in textual form.
A filter expression can be composed out of several actual filters, which are combined with boolean operators and parentheses.

.. note:: Please note that you **cannot combine**
the filter parameter with the **deprecated types, keys and values** parameters.

|
Selectors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ public class ParameterDescriptions {
+ "FeatureCollection. The first point has to be the same as the last point and "
+ "MultiPolygons are only supported in GeoJSON; no default value "
+ "(one boundary parameter must be defined)";
public static final String TYPES =
"OSM type(s) 'node' and/or 'way' and/or 'relation' OR simple feature type(s) 'point' and/or "
+ "'line' and/or 'polygon'; default: all three OSM types";
public static final String KEYS = "OSM key(s) e.g.: 'highway', 'building'; default: no key";
public static final String GROUP_BY_KEY = "OSM key e.g.: 'highway', 'building'; no default "
+ "value (one groupByKey parameter must be defined)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ public class ExceptionMessages {
+ "bcircles, or bpolys) does not fit its format, or you defined more than one boundary "
+ "parameter.";
public static final String DATABASE_ACCESS = "Keytables not found or access to database failed";
public static final String FILTER_PARAM = "The keys, values and types parameters must be empty, "
+ "when you set the filter parameter.";
public static final String FILTER_SYNTAX = "Invalid filter syntax. Please look at the additional "
+ "info and examples about the filter parameter at https://docs.ohsome.org/ohsome-api.";
public static final String GROUP_BY_KEY_PARAM =
"You need to give one groupByKey parameter, if you want to use groupBy/tag.";
public static final String GROUP_BY_KEYS_PARAM =
"You need to give one groupByKeys parameter, if you want to use groupBy/key.";
public static final String KEYS_VALUES_RATIO_INVALID = "There cannot be more input values in the "
+ "values|values2 than in the keys|keys2 parameter, as values_n must fit to keys_n.";
public static final String NO_DEFINED_PARAMS = "The query did not specify any parameter. "
+ "Please remember: " + ExceptionMessages.NO_BOUNDARY;
public static final String NO_BOUNDARY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public AggregateRequestExecutor(RequestResource requestResource,
*/
public Response aggregate() throws Exception {
final SortedMap<OSHDBTimestamp, ? extends Number> result;
MapReducer<OSMEntitySnapshot> mapRed = null;
mapRed = inputProcessor.processParameters();
MapReducer<OSMEntitySnapshot> mapRed = inputProcessor.processParameters();
var mapRedGeom = mapRed.map(OSMEntitySnapshot::getGeometry);
switch (requestResource) {
case COUNT:
Expand Down Expand Up @@ -136,7 +135,7 @@ public Response aggregateGroupByBoundary() throws Exception {
MapReducer<OSMEntitySnapshot> mapRed = inputProcessor.processParameters();
InputProcessingUtils utils = inputProcessor.getUtils();
var result = computeCountLengthPerimeterAreaGbB(requestResource,
processingData.getBoundaryType(), mapRed, inputProcessor);
processingData.getBoundaryType(), mapRed);
SortedMap<Integer, ? extends SortedMap<OSHDBTimestamp, ? extends Number>> groupByResult;
groupByResult = ExecutionUtils.nest(result);
GroupByResult[] resultSet = new GroupByResult[groupByResult.size()];
Expand Down Expand Up @@ -336,8 +335,7 @@ private ElementsResult[] fillElementsResult(SortedMap<OSHDBTimestamp, ? extends
*/
private <P extends Geometry & Polygonal> SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, Integer>,
? extends Number> computeCountLengthPerimeterAreaGbB(RequestResource requestResource,
BoundaryType boundaryType, MapReducer<OSMEntitySnapshot> mapRed,
InputProcessor inputProcessor) throws Exception {
BoundaryType boundaryType, MapReducer<OSMEntitySnapshot> mapRed) throws Exception {
if (boundaryType == BoundaryType.NOBOUNDARY) {
throw new BadRequestException(ExceptionMessages.NO_BOUNDARY);
}
Expand All @@ -347,9 +345,6 @@ private ElementsResult[] fillElementsResult(SortedMap<OSHDBTimestamp, ? extends
.collect(Collectors.toMap(idx -> idx, idx -> (P) arrGeoms.get(idx)));
MapAggregator<OSHDBCombinedIndex<OSHDBTimestamp, Integer>, OSMEntitySnapshot> mapAgg =
mapRed.aggregateByTimestamp().aggregateByGeometry(geoms);
if (processingData.isContainingSimpleFeatureTypes()) {
mapAgg = inputProcessor.filterOnSimpleFeatures(mapAgg);
}
Optional<FilterExpression> filter = processingData.getFilterExpression();
if (filter.isPresent()) {
mapAgg = mapAgg.filter(filter.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ public ContributionsExecutor(HttpServletRequest servletRequest,
*/
public Response count(boolean isUsersRequest, boolean isContributionsLatestCount)
throws UnsupportedOperationException, Exception {
MapReducer<OSMContribution> mapRed;
final SortedMap<OSHDBTimestamp, ? extends Number> result;
if (isContributionsLatestCount) {
// the setFullHistory flag needs to be set, because
Expand All @@ -87,7 +86,7 @@ public Response count(boolean isUsersRequest, boolean isContributionsLatestCount
inputProcessor.getProcessingData()
.setFullHistory(true);
}
mapRed = inputProcessor.processParameters();
MapReducer<OSMContribution> mapRed = inputProcessor.processParameters();
if (isUsersRequest) {
result = usersCount(mapRed);
} else {
Expand Down Expand Up @@ -191,7 +190,7 @@ private SortedMap<OSHDBTimestamp, Integer> contributionsCount(MapReducer<OSMCont
V extends Comparable<V> & Serializable> Response countGroupByBoundary(boolean isUsersRequest)
throws Exception {
inputProcessor.getProcessingData().setGroupByBoundary(true);
var mapRed = inputProcessor.processParameters();
MapReducer<OSMContribution> mapRed = inputProcessor.processParameters();
final var requestParameters = processingData.getRequestParameters();
List<Geometry> arrGeoms = processingData.getBoundaryList();
var arrGeomIds = inputProcessor.getUtils()
Expand All @@ -211,9 +210,6 @@ V extends Comparable<V> & Serializable> Response countGroupByBoundary(boolean is
if (filter.isPresent()) {
mapAgg = mapAgg.filter(filter.get());
}
if (isUsersRequest && processingData.isContainingSimpleFeatureTypes()) {
mapAgg = inputProcessor.filterOnSimpleFeatures(mapAgg);
}
SortedMap<OSHDBCombinedIndex<OSHDBTimestamp, V>, Integer> result;
if (isUsersRequest) {
result = mapAgg.filter(ExecutionUtils.contributionsFilter(servletRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import org.heigit.ohsome.ohsomeapi.controller.dataextraction.elements.ElementsGeometry;
import org.heigit.ohsome.ohsomeapi.inputprocessing.InputProcessingUtils;
import org.heigit.ohsome.ohsomeapi.inputprocessing.SimpleFeatureType;
import org.heigit.ohsome.ohsomeapi.utils.TimestampFormatter;
import org.heigit.ohsome.oshdb.filter.FilterExpression;
import org.heigit.ohsome.oshdb.osm.OSMEntity;
Expand Down Expand Up @@ -39,14 +36,7 @@ public class DataExtractionTransformer implements Serializable {
private final boolean includeOSMMetadata;
private final boolean includeContributionTypes;
private final ElementsGeometry outputGeometry;
private final InputProcessingUtils inputUtils;
private final ExecutionUtils exeUtils;
@Deprecated
private final Set<Integer> keysInt;
@Deprecated
private final Set<SimpleFeatureType> simpleFeatureTypes;
@Deprecated
private final boolean isContainingSimpleFeatureTypes;

/**
* Creates a new data extraction transformer, adhering to the given parameters.
Expand All @@ -66,37 +56,26 @@ public class DataExtractionTransformer implements Serializable {
* changeset id, timestamp, version number)
* @param includeContributionTypes set true if the result should include the contribution type
* for `/elements/contributions` resources
* @param inputUtils input processing utility object
* @param exeUtils the execution utils object
* @param keysInt (for the deprecated `keys` filter parameter) set the list of always to be
* returned OSM tags in the GeoJSON's features' properties
* @param outputGeometry specifies what should be returned as the GeoJSON feature's geometry:
* either the full geometry, its bbox or its centroid.
* @param simpleFeatureTypes if the query uses the (deprecated) types parameter, and it contains
* simple feature "geometry" types, specify the set of to be returned geometry types here
* @param isContainingSimpleFeatureTypes set true if the query uses the (deprecated) types
*/
public DataExtractionTransformer(String startTimestamp, String endTimestamp,
FilterExpression filter, boolean isContributionsEndpoint,
boolean isContributionsLatestEndpoint, boolean clipGeometries, boolean includeTags,
boolean includeOSMMetadata, boolean includeContributionTypes, InputProcessingUtils inputUtils,
ExecutionUtils exeUtils, Set<Integer> keysInt, ElementsGeometry outputGeometry,
Set<SimpleFeatureType> simpleFeatureTypes, boolean isContainingSimpleFeatureTypes) {
boolean includeOSMMetadata, boolean includeContributionTypes,
ExecutionUtils exeUtils, ElementsGeometry outputGeometry) {
this.isContributionsLatestEndpoint = isContributionsLatestEndpoint;
this.isContributionsEndpoint = isContributionsEndpoint;
this.exeUtils = exeUtils;
this.clipGeometries = clipGeometries;
this.startTimestamp = startTimestamp;
this.inputUtils = inputUtils;
this.simpleFeatureTypes = simpleFeatureTypes;
this.filter = filter;
this.keysInt = keysInt;
this.includeTags = includeTags;
this.includeOSMMetadata = includeOSMMetadata;
this.includeContributionTypes = includeContributionTypes;
this.outputGeometry = outputGeometry;
this.endTimestamp = endTimestamp;
this.isContainingSimpleFeatureTypes = isContainingSimpleFeatureTypes;
}

/**
Expand Down Expand Up @@ -156,7 +135,7 @@ public List<Feature> buildChangedFeatures(List<OSMContribution> contributions) {
properties.put(TIMESTAMP_PROPERTY, validTo);
properties.put(CONTRIBUTION_CHANGESET_ID_PROPERTY, contribution.getChangesetId());
}
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties, keysInt,
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties,
includeTags, includeOSMMetadata, includeContributionTypes, isContributionsEndpoint,
outputGeometry, contribution.getContributionTypes()));
}
Expand Down Expand Up @@ -192,7 +171,7 @@ public List<Feature> buildChangedFeatures(List<OSMContribution> contributions) {
if (!currentGeom.isEmpty()) {
boolean addToOutput = addEntityToOutput(currentEntity, currentGeom);
if (addToOutput) {
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties, keysInt,
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties,
includeTags, includeOSMMetadata, includeContributionTypes, isContributionsEndpoint,
outputGeometry, lastContribution.getContributionTypes()));
}
Expand All @@ -204,7 +183,7 @@ public List<Feature> buildChangedFeatures(List<OSMContribution> contributions) {
properties.put(TIMESTAMP_PROPERTY,
TimestampFormatter.getInstance().isoDateTime(lastContribution.getTimestamp()));
properties.put(CONTRIBUTION_CHANGESET_ID_PROPERTY, lastContribution.getChangesetId());
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties, keysInt, false,
output.add(exeUtils.createOSMFeature(currentEntity, currentGeom, properties, false,
includeOSMMetadata, includeContributionTypes, isContributionsEndpoint, outputGeometry,
lastContribution.getContributionTypes()));
}
Expand Down Expand Up @@ -238,7 +217,7 @@ public List<Feature> buildUnchangedFeatures(OSMEntitySnapshot snapshot) {
boolean addToOutput = addEntityToOutput(entity, geom);
if (addToOutput) {
return Collections.singletonList(exeUtils.createOSMFeature(entity, geom, properties,
keysInt, includeTags, includeOSMMetadata, includeContributionTypes,
includeTags, includeOSMMetadata, includeContributionTypes,
isContributionsEndpoint, outputGeometry, EnumSet.noneOf(ContributionType.class)));
} else {
return Collections.emptyList();
Expand All @@ -247,10 +226,6 @@ public List<Feature> buildUnchangedFeatures(OSMEntitySnapshot snapshot) {

/** Checks whether the given entity should be added to the output (true) or not (false). */
private boolean addEntityToOutput(OSMEntity currentEntity, Geometry currentGeom) {
if (isContainingSimpleFeatureTypes) {
return inputUtils.checkGeometryOnSimpleFeatures(currentGeom, simpleFeatureTypes);
} else {
return filter == null || filter.applyOSMGeometry(currentEntity, currentGeom);
}
return filter == null || filter.applyOSMGeometry(currentEntity, currentGeom);
}
}
Loading

0 comments on commit f14e509

Please sign in to comment.