Skip to content

Commit

Permalink
Merge pull request #872 from theduckylittle/gm-698/filter-tab-results
Browse files Browse the repository at this point in the history
Honor filtered results in the super tab
  • Loading branch information
klassenjs authored Nov 7, 2024
2 parents 88dd75f + 88fc8fa commit aab2fa8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/gm3/actions/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 7 additions & 3 deletions src/gm3/components/serviceManager/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/gm3/selectors/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit aab2fa8

Please sign in to comment.