Moving this to the dev list.
It seems to me that in order for a Filter to be passed to GetLegendGraphic instead of a Rule name, I'd have to render the entire layer internally first with the Filter applied, then check which Rules are valid and create the legend graphic based on that. Seems like a bit too much overhead just to create a single legend graphic. Perhaps there is a better way.
Interested to hear if anyone has any ideas (or just confirm if my assumption is correct)>
Regards,
Miles
Miles Jordan wrote:
Hi Guys,
Is there any current way to use a Filter on GetLegendGraphic requests?
I have 10 Rules colouring features different colours. When I request a
subset of the features for my map using GetMap with a Filter, I'd like a
way for the legend to only show the styles of the features that are on
the map, so I need to construct my GetLegendGraphic request accordingly.
I know you can specify a Rule in the GetLegendGRaphic request, but
there's really no way of my application knowing which Rule to ask for,
seeing as it is only used by Geoserver internally. What would be more
useful is to request a legend graphic for a layer based on a Filter.
Any ideas? I'm happy to have a go at it if nobody knows a way I can
already do it.
Regards,
Miles
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________
Miles Jordan ha scritto:
Moving this to the dev list.
It seems to me that in order for a Filter to be passed to
GetLegendGraphic instead of a Rule name, I'd have to render the
entire layer internally first with the Filter applied, then check
which Rules are valid and create the legend graphic based on that.
Seems like a bit too much overhead just to create a single legend
graphic. Perhaps there is a better way.
Interested to hear if anyone has any ideas (or just confirm if my
assumption is correct)>
I think your assumption is correct. Doing that without actually
hitting the data would require doing some symbolic comparison
between the filters, which would rapidly become impossible to
judge statically as complex filters come into the picture.
E.g. if a rule says "ATT > 10" and the filter says "ATT > 5"
you can understand that the filter will activate
that rule by writing a symbolic expression comparator, but
what if the rule says "ATT LIKE 'M%'" and the filter is
"ATT LIKE '%ABC%'"? There is no way to tell if the rule
will be hit by the filter without going through all the
data (same goes if the rule and the filter use different
attributes).
I also agree that doing a full data scan every time you do
a GetLegendGraphics is probably asking for too much work
on the server side (not to mention you'd have to extend
the request to accept the current bbox to know what
exactly you're rendering)
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Andrea Aime ha scritto:
I also agree that doing a full data scan every time you do
a GetLegendGraphics is probably asking for too much work
on the server side (not to mention you'd have to extend
the request to accept the current bbox to know what
exactly you're rendering)
That said... if someone really wants to implement this code
path in a way that it is activated only when the user asks
for it... why not? 
It could be implementing without actually loading features
(at least for databases) by counting the number of features
that are in the bbox, satisfy the current filter and the
rule filter. If > 0 the rule is active.
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Andrea Aime wrote:
Andrea Aime ha scritto:
I also agree that doing a full data scan every time you do a
GetLegendGraphics is probably asking for too much work on the server
side (not to mention you'd have to extend the request to accept the
current bbox to know what exactly you're rendering)
That said... if someone really wants to implement this code path in a
way that it is activated only when the user asks for it... why not? :- )
It could be implementing without actually loading features (at least
for databases) by counting the number of features that are in the
bbox, satisfy the current filter and the rule filter. If > 0 the rule
is active.
Cheers
Andrea
Thanks for the info Andrea.
I started to do it before I realised how much extra work it would take the server to process. But I didn't think of doing it without loading features. I'll give that a shot.
Regards,
Miles
___________________________________________________________________________
Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not the
intended recipient, you are notified that use or dissemination of this communication is
strictly prohibited by Commonwealth law. If you have received this transmission in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 3209 and
DELETE the message.
Visit our web site at http://www.antarctica.gov.au/
___________________________________________________________________________
Miles Jordan ha scritto:
Andrea Aime wrote:
Andrea Aime ha scritto:
I also agree that doing a full data scan every time you do a GetLegendGraphics is probably asking for too much work on the
server side (not to mention you'd have to extend the request to
accept the current bbox to know what exactly you're rendering)
That said... if someone really wants to implement this code path in
a way that it is activated only when the user asks for it... why
not? :- )
It could be implementing without actually loading features (at
least for databases) by counting the number of features that are in
the bbox, satisfy the current filter and the rule filter. If > 0
the rule is active.
Cheers Andrea
Thanks for the info Andrea.
I started to do it before I realised how much extra work it would
take the server to process. But I didn't think of doing it without
loading features. I'll give that a shot.
Yep. Mix the filters, grab a feature collection (or the feature source)
and issue a getCount(Query) or a size() on the collection.
How efficient that is going to be, it's up to the store implementation,
e.g., shapefiles will load the features anyways just to count them
because the filters have to be evaluated in memory.
But at least they won't be rendered
Cheers
Andrea
--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
The CSS module also has some filter analysis code that can test two filters and see if the result of And'ing them is logically equivalent to Filter.EXCLUDE. False negatives are acceptable for my use case (I am just reducing the number of rules produced to save processor time and disk space; ineffectual rules don't actually cause a problem aside from bogus legend entries), but I guess for you this is not the case.
In its current state, it can figure out binary comparisons (<, ==, <>...) and ands/ors/nots thereof pretty well, but nothing else.
--
David Winslow
OpenGeo - http://opengeo.org/
On 07/15/2010 03:58 AM, Andrea Aime wrote:
Miles Jordan ha scritto:
Andrea Aime wrote:
Andrea Aime ha scritto:
I also agree that doing a full data scan every time you do a
GetLegendGraphics is probably asking for too much work on the
server side (not to mention you'd have to extend the request to
accept the current bbox to know what exactly you're rendering)
That said... if someone really wants to implement this code path in
a way that it is activated only when the user asks for it... why
not? :- )
It could be implementing without actually loading features (at
least for databases) by counting the number of features that are in
the bbox, satisfy the current filter and the rule filter. If> 0
the rule is active.
Cheers Andrea
Thanks for the info Andrea.
I started to do it before I realised how much extra work it would
take the server to process. But I didn't think of doing it without
loading features. I'll give that a shot.
Yep. Mix the filters, grab a feature collection (or the feature source)
and issue a getCount(Query) or a size() on the collection.
How efficient that is going to be, it's up to the store implementation,
e.g., shapefiles will load the features anyways just to count them
because the filters have to be evaluated in memory.
But at least they won't be rendered
Cheers
Andrea