From f7f07419d3b7883d5355b3e3db9e7e35883f641f Mon Sep 17 00:00:00 2001 From: Mark Prins <1165786+mprins@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:15:54 +0200 Subject: [PATCH] HTM-1195: increase default maximum number of features to 30 and make it configurable per instance using a property --- .../org/tailormap/api/controller/FeaturesController.java | 5 ++++- src/main/java/org/tailormap/api/util/Constants.java | 1 - src/main/resources/application.properties | 1 + src/test/resources/application.properties | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/tailormap/api/controller/FeaturesController.java b/src/main/java/org/tailormap/api/controller/FeaturesController.java index 6d72cc62b1..d793550d1f 100644 --- a/src/main/java/org/tailormap/api/controller/FeaturesController.java +++ b/src/main/java/org/tailormap/api/controller/FeaturesController.java @@ -87,6 +87,9 @@ public class FeaturesController implements Constants { @Value("${tailormap-api.pageSize:100}") private int pageSize; + @Value("${tailormap-api.features.maxitems:30}") + private int maxFeatures; + @Value("${tailormap-api.features.wfs_count_exact:false}") private boolean exactWfsCounts; @@ -383,7 +386,7 @@ private FeaturesResponse getFeaturesByXY( } Query q = new Query(fs.getName().toString()); q.setFilter(finalFilter); - q.setMaxFeatures(DEFAULT_MAX_FEATURES); + q.setMaxFeatures(maxFeatures); executeQueryOnFeatureSourceAndClose( simplifyGeometry, diff --git a/src/main/java/org/tailormap/api/util/Constants.java b/src/main/java/org/tailormap/api/util/Constants.java index e252aead01..4a75b0c2b1 100644 --- a/src/main/java/org/tailormap/api/util/Constants.java +++ b/src/main/java/org/tailormap/api/util/Constants.java @@ -6,7 +6,6 @@ package org.tailormap.api.util; public interface Constants { - int DEFAULT_MAX_FEATURES = 10; String FID = "__fid"; String ID = "id"; String NAME_REGEX = "^[a-zA-Z0-9-_]+"; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 51687fae6c..9555485d42 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -18,6 +18,7 @@ tailormap-api.pageSize=100 # whether the api should attempt to provide exact feature counts for all WFS requests # may result in double query execution, once for counting and once for the actual data tailormap-api.features.wfs_count_exact=false +tailormap-api.features.maxitems=30 # whether the API should use GeoTools "Unique Collection" (use DISTINCT in SQL statements) or just # retrieve all values when calculating the unique values for a property. diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index f3d6164fa5..78a603e0ed 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -4,7 +4,7 @@ management.endpoints.web.base-path=/api/actuator tailormap-api.new-admin-username=tm-admin tailormap-api.timeout=5000 tailormap-api.management.hashed-password=#{null} - +tailormap-api.features.maxitems=30 spring.profiles.active=test spring.profiles.default=test spring.main.allow-bean-definition-overriding=true