Skip to content

Commit

Permalink
Merge pull request #1583 from dbauszus-glx/categorized-featurefilter
Browse files Browse the repository at this point in the history
Theme filter and layer.featureFilter to filter features in style.
  • Loading branch information
RobAndrewHurst authored Oct 22, 2024
2 parents 86404ee + 4733e0c commit b1bcdbb
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 192 deletions.
2 changes: 0 additions & 2 deletions lib/layer/_layer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import formats from './format/_format.mjs';
import fade from './fade.mjs';
import changeEnd from './changeEnd.mjs'
import featureHover from './featureHover.mjs';
import featureFilter from './featureFilter.mjs';
import * as featureFormats from './featureFormats.mjs';
import * as featureFields from './featureFields.mjs';
import featureStyle from './featureStyle.mjs';
Expand All @@ -43,7 +42,6 @@ export default {
featureFormats,
featureFields,
featureHover,
featureFilter,
featureStyle,
fade,
styleParser,
Expand Down
2 changes: 1 addition & 1 deletion lib/layer/changeEnd.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
### mapp.layer.changeEnd(layer)
@module /layer/featureFilter
@module /layer/changeEnd
*/

export default function (layer) {
Expand Down
44 changes: 0 additions & 44 deletions lib/layer/featureFilter.mjs

This file was deleted.

16 changes: 3 additions & 13 deletions lib/layer/featureStyle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,6 @@ export default function featureStyle(layer) {
return null
}

// A filter flag is set either in the layer styles object or in the theme.
if ((layer.style.filter || layer.style.theme?.filter)

// The current filter contains field keys.
&& layer.filter.current && Object.keys(layer.filter.current).length

// Check whether the feature should be caught by layer feature filter.
&& mapp.layer.featureFilter(layer.filter.current, feature)) {

// The feature will not be visible.
return null
}

// Set style.default as feature.style.
feature.style = layer.style.default

Expand All @@ -72,6 +59,9 @@ export default function featureStyle(layer) {
mapp.layer.themes[layer.style.theme?.type]?.(layer.style.theme, feature)
}

// The feature must not be displayed.
if (feature.style === null) return;

// Style cluster point features.
clusterStyle(feature, layer)

Expand Down
6 changes: 6 additions & 0 deletions lib/layer/themes/categorized.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ export default function categorized(theme, feature) {

if (!cat) return;

if (cat.style === null) {

feature.style = null;
return;
}

// Spread cat style to retain scale property
feature.style = {
...feature.style,
Expand Down
Loading

0 comments on commit b1bcdbb

Please sign in to comment.