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

refine rules (add ranges/categories): expressions not applied/written correctly #19191

Closed
qgib opened this issue Jul 5, 2014 · 13 comments
Closed
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers

Comments

@qgib
Copy link
Contributor

qgib commented Jul 5, 2014

Author Name: baditaflorin - (baditaflorin -)
Original Redmine Issue: 10815
Affected QGIS version: master
Redmine category:symbology
Assignee: Nyall Dawson


new description:

#10815-7


old description:

Expected result . To filter only the numbers on the pntcnt that are higher then 4802

"pntcnt" > 4802

Instead i get only 5 values, from

0-0.2
0.2-0.4
0.4-0.6
0.6-0.8
0.8-1



Related issue(s): #18891 (duplicates)
Redmine related issue(s): 10479


@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: Nathan Woodrow (@NathanW2)


That isn't doing what you expected it to. What you are doing there is making a range based on the results from the expression "pntcnt" > 4802 which is from 0 -> 1.

What you are looking for isn't implemented yet.

@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: Nathan Woodrow (@NathanW2)


#18891


  • resolution was changed from to duplicate
  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: baditaflorin - (baditaflorin -)


Yes it is implemented, i discovered it now

CASE WHEN "pntcnt" <50 THEN "pntcnt" END

Thanks for the quick reply

@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: baditaflorin - (baditaflorin -)


This is strange, doing a query like this works

CASE WHEN ( "pntcnt" <100.1 ) THEN "pntcnt" END

But searching for bigger numbers not working

CASE WHEN ( "pntcnt" >100.1 ) THEN "pntcnt" END

Or if i search only for 200, i get all the values until 200, as seen in the photo

In this sense you say that is not implemented, that it works only with < ?


  • 7594 was configured as strange.jpg
  • status_id was changed from Closed to Reopened

@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: baditaflorin - (baditaflorin -)


If i choose refine by category, then the CASE ELSE is working, even with

CASE WHEN "pntcnt" >= 50.1000 AND "pntcnt" <= 100.1 THEN "pntcnt" END

As can be seen in the photo


  • 7595 was configured as refine_by_categories.jpg

@qgib
Copy link
Contributor Author

qgib commented Jul 5, 2014

Author Name: Jürgen Fischer (@jef-n)


  • category_id was configured as Symbology

@qgib
Copy link
Contributor Author

qgib commented Jul 7, 2014

Author Name: Giovanni Manghi (@gioman)


This is what I see (please correct me if I'm wrong):

categorized renderer

  • in the normal categorized renderer I can use an expression like (NUMPOINTS is a integer field)

@case WHEN "NUMPOINTS" >= 50.0000 AND "NUMPOINTS" <= 100.0 THEN "NUMPOINTS" END@

this will effectively create a subset of values and for each of them it will create a separate symbology class

  • in the rule based renderer when I refine a rule (by category), the same expression will result in a filter like (example for just one symbology class)

@"CASE WHEN ""NUMPOINTS"" >= 50.0000 AND ""NUMPOINTS"" <= 100.0 THEN ""NUMPOINTS"" END" = 68.0000@

and this is wrong, in fact if I remove the not necessary '"' the expression works

@case WHEN "NUMPOINTS" >= 50.0000 AND "NUMPOINTS" <= 100.0 THEN "NUMPOINTS" END = 68.0000@

(and otherwise testing the filter/expression fails with "Column 'CASE WHEN "NUMPOINTS" >= 50.0000 AND "NUMPOINTS" <= 100.0 THEN "NUMPOINTS" END' not found")

  • in a similar fashion an expression like

@ "NUMPOINTS" > 100@

will return 1 or 0 (depending if is true or not that the feature has more than 100 "NUMPOINTS").

This will work ok in the standard categorized renderer but in the rule based one, when refining by category it will result in rules with too many '"', example

@"CASE WHEN ""NUMPOINTS"" >= 50.0000 AND ""NUMPOINTS"" <= 100.0 THEN ""NUMPOINTS"" END" = 59.0000@

Similar observations can be done for graduated renderer:

  • in the standard graduated renderer an expression like

@case WHEN "NUMPOINTS" >= 50.0000 AND "NUMPOINTS" <= 100.0 THEN "NUMPOINTS" END@

can be used to effectively render (by ranges) only the features with "NUMPOINTS" between 50 and 100

  • when the same expression is used to refine a rule based rule by adding a range then is written wrong (example, for one symbology class):

"CASE WHEN ""NUMPOINTS"" >= 50.0000 AND ""NUMPOINTS"" <= 100.0 THEN ""NUMPOINTS"" END" >= 84.0000 AND "CASE WHEN ""NUMPOINTS"" >= 50.0000 AND ""NUMPOINTS"" <= 100.0 THEN ""NUMPOINTS"" END" <= 97.0000

  • similar observation for an expression like

@ "NUMPOINTS" > 100@

This does not seems to work on 2.2 either, where the expressions were introduced to allow more advanced categorized/graduated symbology, then it should be tagged as blocker, because is a new feature that does not work as expected (at least inside the rule based symbology).


  • status_id was changed from Reopened to Feedback
  • resolution was changed from duplicate to
  • os_version was changed from 7 to
  • operating_system was changed from Windows to
  • subject was changed from refine a rule to rules - colums filter not working to refine rules (add ranges/categories): expressions not applied/written correctly

@qgib
Copy link
Contributor Author

qgib commented May 21, 2015

Author Name: Giovanni Manghi (@gioman)


  • version was changed from 2.4.0 to master
  • status_id was changed from Feedback to Open

@qgib
Copy link
Contributor Author

qgib commented Sep 16, 2015

Author Name: Vladimir Udilov (Vladimir Udilov)


I can reproduce this bug in 2.10.1.
Basically when you refine a rule (adding range or category both) using an expression instead of just a field, left parts of sub-rules that are created are escaped as if they were a field name. See attached screenshot - double quotes inside expression and unneeded quotes around expression can be seen.
Escaping was probably added when fixing this bug: Issue #15129


  • 9066 was configured as refine_bug.png

@qgib
Copy link
Contributor Author

qgib commented Oct 10, 2015

Author Name: Nyall Dawson (@nyalldawson)


Some more detail in #21603

@qgib
Copy link
Contributor Author

qgib commented Oct 11, 2015

Author Name: Nyall Dawson (@nyalldawson)


  • assigned_to_id was configured as Nyall Dawson

@qgib
Copy link
Contributor Author

qgib commented Oct 12, 2015

Author Name: Nyall Dawson (@nyalldawson)


Fixed in changeset "ae85376614f27da2d3f4b389e26539709a1be5e0".


  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Aug 7, 2017

Author Name: Jürgen Fischer (@jef-n)


  • description was changed from new description:

https://issues.qgis.org/issues/10815#note-7


old description:

Expected result . To filter only the numbers on the pntcnt that are higher then 4802

"pntcnt" > 4802

Instead i get only 5 values, from

0-0.2
0.2-0.4
0.4-0.6
0.6-0.8
0.8-1 to new description:

#19191 (comment)


old description:

Expected result . To filter only the numbers on the pntcnt that are higher then 4802

"pntcnt" > 4802

Instead i get only 5 values, from

0-0.2
0.2-0.4
0.4-0.6
0.6-0.8
0.8-1

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers labels May 25, 2019
@qgib qgib closed this as completed May 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers
Projects
None yet
Development

No branches or pull requests

1 participant