From ac49b47bd8cfed9908010f47448e49c56ec40aa9 Mon Sep 17 00:00:00 2001 From: "Dan \"Ducky\" Little" Date: Thu, 7 Nov 2024 15:16:53 -0600 Subject: [PATCH 1/2] Honor filtered results in the super tab - Changes the return signature for filtered results to be grouped by path. - Updates results of the super tab to use that selector for rendering HTML. --- src/gm3/components/serviceManager/results.js | 10 +++++++--- src/gm3/selectors/query.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/gm3/components/serviceManager/results.js b/src/gm3/components/serviceManager/results.js index 31613102..d7f2bf68 100644 --- a/src/gm3/components/serviceManager/results.js +++ b/src/gm3/components/serviceManager/results.js @@ -28,7 +28,8 @@ export const QueryResults = ({ const queryId = "query-id-0"; const queryDef = { ...query, - results: allResults, + // this will filter down to just matching results + results, }; const zoomToResults = useCallback(() => { @@ -66,14 +67,17 @@ export const QueryResults = ({ const serviceTitle = serviceDef.resultsTitle || `${serviceDef.title} Results`; let layerCount = 0, - allFeatureCount = 0, - featureCount = results.length; + allFeatureCount = 0; for (const path in allResults) { if (allResults[path].failed !== true) { layerCount += 1; allFeatureCount += allResults[path].length; } } + let featureCount = 0; + for (const path in results) { + featureCount += results[path].length; + } const bufferEnabled = featureCount <= config.bufferMaxFeatures; diff --git a/src/gm3/selectors/query.js b/src/gm3/selectors/query.js index 2193e07b..66847dc7 100644 --- a/src/gm3/selectors/query.js +++ b/src/gm3/selectors/query.js @@ -17,9 +17,9 @@ export const getQueryResults = createSelector( getAllResults, getFilter, (results, filter) => { - let features = []; + const features = {}; for (const path in results) { - features = features.concat(matchFeatures(results[path], filter)); + features[path] = matchFeatures(results[path], filter); } return features; } From 88fc8fa3f880e52d0010cd07c7364662bc6e8832 Mon Sep 17 00:00:00 2001 From: "Dan \"Ducky\" Little" Date: Thu, 7 Nov 2024 15:57:40 -0600 Subject: [PATCH 2/2] Ensure bufferResults honors filtered results --- src/gm3/actions/query.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gm3/actions/query.js b/src/gm3/actions/query.js index be090518..ad4080e8 100644 --- a/src/gm3/actions/query.js +++ b/src/gm3/actions/query.js @@ -5,6 +5,7 @@ import { vectorFeatureQuery } from "../query/vector"; import { wfsGetFeatureQuery } from "../query/wfs"; import { wmsGetFeatureInfoQuery } from "../query/wms"; import { getMapSourceName } from "../util"; +import { getQueryResults } from "../selectors/query"; import { changeTool, @@ -152,13 +153,14 @@ export const bufferResults = createAsyncThunk( "query/buffer-results", (arg, { getState, dispatch }) => { const state = getState(); - const query = state.query; + const results = getQueryResults(state); + console.log("RESULTS=", results); // flatten the query results down to just a // list of features let features = []; - for (const path in query.results) { - features = features.concat(query.results[path]); + for (const path in results) { + features = features.concat(results[path]); } if (features.length > 0) {