[mapserver-users] Real dynamic legends

Armin Burger armin.burger at libero.it
Tue Oct 8 17:59:53 EDT 2002


Hello everybody,

I was thinking about the possibility to have 'real' dynamic legends. That is,
legends that show only the items (of active layers) that are visible in the
current map extent. For complex layers definitions with plenty of classes one
loses a bit the overview if all classes are always drawn in the legend even
if only 10 % or so of them are visible in the map. Real dynamic legends could
make it much easier to identify the map contents via legend.


One possibility I see for such legends could be using MapScript with
'queryByRect' on all active layers and the current map extent. The results
are written in an array with unique result values for the classitem. Then one
had to compare these results with the class definitions of the layer and draw
the legend icons.

One restriction of this approach I found is that it seems not to be possible
to get class expressions via MapScript. A question to the PHP MapScript
developers: Would it be possible to add this possibility to MapScript?

Assumed one had this expression it can be a bit difficult to match results
found via the query with class definitions. There are quite a lot of
different class definitions possible. And at the end, the speed of such a
query will decrease very much if a lot of features are visible in the map (it
could be much faster, however, using PostGIS instead of shapefiles and a
'select distinct' query).


Therefore a question to the MapServer developers: Is it conceivable to
implement such a dynamic legend function directly in the main MapServer
functionality?

Reading shapefiles and map file with complex class definitions and rendering
a map will take only very few seconds even for relatively large datasets. So
I think producing lists of affected layer classes in a similar step or even
simultaneous should be also quite fast. Maybe I'm wrong...

Regarding MapScript functionality I'm thinking of a function like
$map->drawDynLegend() that instead of an image returns a multiple array of
active layers with a sub-array of affected classes (classes in the current
extent) for each layer. One could then use these classes and draw the legend
icons for them.

Any ideas?

Armin

--
 Armin Burger
 Via della fiera, 7 -  I-39050 Cornaiano BZ -  Italia
_



More information about the mapserver-users mailing list