Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw error for Clustered Features with filters #227

Open
geographika opened this issue Apr 9, 2020 · 2 comments
Open

Throw error for Clustered Features with filters #227

geographika opened this issue Apr 9, 2020 · 2 comments

Comments

@geographika
Copy link
Contributor

geographika commented Apr 9, 2020

Feature Request

Add a warning or throw an error if an OL feature is clustered when trying to apply a filter similar to below.

var pointSimplePoint = {
    name: "OL Style",
    rules: [{
        name: "OL Style Rule 0",
        filter: [">=", "MyProp", "10"],
        symbolizers: [{
            kind: "Mark",
            wellKnownName: "Circle",
            color: "#FF0000",
            radius: 6
        }]
    }]
};

Is your feature request related to a problem? Please describe.

Spent several hours trying to work out why a style wasn't being applied to features before realising the layer had clustering. The features weren't displayed at all, rather than a default or non-style.

Describe the solution you'd like

In geoStylerFilterToOlParserFilter throw an error if a clustered feature is passed.

Check with t.get('features') or check the source for ol.source.Cluster?

Describe alternatives you've considered

Add a sourcemap to the npm release package, or a single file debug build (in node_modules/geostyler-openlayers-parser/browser)
This highlighted the problem quite quickly and allowed easy debugging.
This may be the better solution as it may be possible to style clustered filters using functions?

A single file debug build would be very useful for many situations when developing.

@jansule
Copy link
Contributor

jansule commented Apr 14, 2020

@geographika thanks for creating this issue.

In geoStylerFilterToOlParserFilter throw an error if a clustered feature is passed.
Check with t.get('features') or check the source for ol.source.Cluster?

Personally, I would rather refer from that, as this logic should be handled by users of the parser. The purpose of the parser is to provide a style object/function, the handling of when to apply such a style is not part of that.

@KaiVolland what do you think about that?

A single file debug build would be very useful for many situations when developing.

When developing/debugging we usually use our local react builds instead of the browser build. But I agree, for users that are not directly developing the parser and just want to see why something is not working as expected, having a debug browser build can be useful.

Would you be willing to provide a PR for that? This would mainly require an additional config file that extends browser-build.config.js and a corresponding build script in package.json.

@raitisbe
Copy link
Contributor

raitisbe commented May 28, 2021

I would prefer having a possibility to style clustered features instead. It's almost possible even right now if we provide

filter: ["!=", "features", "[object Object]"]

for the rule and use TextSymbolizer with {{features}} template.

image

The missing thing seems to be a way how to pass valueAdjust function to
OlStyleUtil.resolveAttributeTemplate = function (feature, template, noValueFoundText, valueAdjust) { .
Its never set anywhere or maybe I'm missing something.

raitisbe added a commit to hslayers/hslayers-ng that referenced this issue May 31, 2021
HACK is needed to style cluster layers. It wraps existing OL style function in a function which searches for for Text styles and in them for serialized feature arrays and instead sets the len
gth of this array as the label. If the geostyler text symbolizer had {{features}} as the text label template (which returns the "features" attribute of the parent/cluster feature) and returned
 '[object Object], [object Object]' the result would become "2". See geostyler/geostyler-openlayers-parser#227
@KaiVolland KaiVolland moved this to Todo in CodeSprint 2024 May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

4 participants