Fields in expression evaluator always null if field only referenced inside length([Field])

18 views
Skip to first unread message

Ben Harper

unread,
Oct 24, 2017, 6:02:12 AM10/24/17
to mapnik
I've discovered what looks like a bug in Mapnik, but I'm finding it hard to track down where the bug might be.

If you create one or more rules that have filter expressions like this:

length([field]) % 5 = 0
length([field]) % 5 = 1
length([field]) % 5 = 2

Then, during evaluation, [field] is always null. I've verified that by stepping through the evaluation code.

If I change any of the expressions to something:

length([field]) % 5 = 0 or [field] = 'foobar'

then all expressions are evaluated correctly, and [field] is fed through correctly from the DB.

I've verified that this has nothing to do with the DB fetch - the correct [field] is fetched from the DB in both cases.
I'm assuming this bug is due to some piece of code that tries to analyze the expressions in a style, and avoid populating those fields that aren't needed. If I'm correct in this hunch, then where does that code lie?
If I know where it is, then I can probably fix it.

My Mapnik version is 3.0.15.

Thanks,
Ben

Dane Springmeyer

unread,
Nov 1, 2017, 10:50:17 PM11/1/17
to rog...@gmail.com, map...@googlegroups.com
Ben,

That does sound like you've found a bug. I think the problem may be that the function call type (https://github.com/mapnik/mapnik/blob/master/include/mapnik/function_call.hpp) needs to be added/handled in the attribute_collector:

https://github.com/mapnik/mapnik/blob/333ef9fde145f88339eaccba810305707bae9b0e/include/mapnik/attribute_collector.hpp#L59-L85


--
You received this message because you are subscribed to the Google Groups "mapnik" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapnik+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Harper

unread,
Nov 2, 2017, 3:16:19 AM11/2/17
to mapnik

Thanks Dane!

I'm off work for a few days, but will look into that, and try cook up a unit test and a fix when I'm back.

Dane Springmeyer

unread,
Nov 3, 2017, 9:11:23 PM11/3/17
to map...@googlegroups.com
Sounds good Ben.
Reply all
Reply to author
Forward
0 new messages