[mapserver-users] Real dynamic legends

Lowell Filak lfilak at medinaco.org
Fri Oct 11 10:54:36 EDT 2002


This may have already been cleared up, but I think the intent of "get class expressions" was a $calssObj->getExpression similar to $classObj->setExpression. Currently, tracking a class expression is possible but all the book keeping needs to be done in the mapscript app to track what the current expression is. However MS must already have book keeping in place internally so the correct expression is used when a draw function is called.?
Lowell F.

The following message was sent by "Steve Lime" <steve.lime at dnr.state.mn.us> on Wed, 09 Oct 2002 17:56:01 -0500.

> > Hello everybody,
> 
> Hi Armin:
> 
> > 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.
> 
> Yup, I agree.
> 
> > 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.
> 
> Seems like a lot of work when the information needed for this is already
> available as a map is drawn.
> 
> > 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?
> 
> I'm not sure what you mean by "get class expressions". I believe the
> perl/python version has a classify method that will allow a shape to be
> evaluated for a given layer. I'll have to check though.
> 
> > 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?
> 
> It's possible. We would just need to add a bit of book keeping to the
> map file structure (i.e. like keeping a count of drawn features by
> class). This might make the mapfile structures less thread safe
> though....
> 
> > 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.
> 
> I would propose extending the legend object by adding a "type"
> parameter.
> 
> > Any ideas?
> 
> > Armin
> 
> Steve
> 
> 
> Stephen Lime
> Data & Applications Manager
> 
> Minnesota DNR
> 500 Lafayette Road
> St. Paul, MN 55155
> 651-297-2937




More information about the mapserver-users mailing list