[mapserver-users] Extreme data-driven Symbology with CGI mapserver
Lime, Steve D (DNR)
Steve.Lime at state.mn.us
Fri Mar 26 07:11:27 PDT 2010
Hi Brent: Producing legends with bound styling is indeed problematic. MapServer has no way to know how many variations are possible and it doesn't cache those encountered in a map draw. Binding a class name might help but the binding is at the feature level and a class name would generally apply to a group of features. Still, it might provide a useful key for a hash of styles that could be rendered as a legend.
Might be more interesting to be able to configure a file or URL-based SLD reference for a layer from within the mapfile. For example:
LAYER
NAME 'extreme-symbology'
DATA ...
CONNECTION ...
SLD 'some flle' or 'some url'
...
END
Then you'd have some other sort of production process, either scheduled or live to build the SLD from your database. Just a thought.
Yet another idea would be to take advantage of includes. We might consider allowing a URL-based include to get a snippet of mapfile content. Producing that text (e.g. all the classes, and styles) wouldn't require mapscript at all.
An option that would work now would be to produce the include file through a scheduled process. Just write a small script to write that piece of a mapfile and schedule it to run at some interval. Nice and simple and no MapScript.
Steve
________________________________________
From: mapserver-users-bounces at lists.osgeo.org [mapserver-users-bounces at lists.osgeo.org] On Behalf Of Brent Fraser [bfraser at geoanalytic.com]
Sent: Thursday, March 25, 2010 1:14 PM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] Extreme data-driven Symbology with CGI mapserver
All,
I'm looking for advice (or at least a reality check).
The short story:
----------------
Can CGI mapserver generate a legend "on the fly" for a varying number of classes
(class names from a database)?
The Long story:
---------------
I'm storing feature geometry in a database and I'd like to store symbology
too. In theory, this would allow a users/admins to add layers and classes in an
adhoc manner, and I'd like mapserver (in std CGI mode, I'd like to avoid
MapScript if possible) to automatically render the features AND produce a
meaningful standard graphic legend.
So my database tables would look like:
Tables for storing things:
--------------------------
Geom Table (lots of rows, one per feature):
pkGeomID The primary key
WKT The WKT/WKB geometry of a feature
fkClassID Foreign key to Class table
Class Table (a few rows, for unique symbology):
pkClassid
ClassName A nice name to put in the legend
fkLayerID Foreign key to Layer table
Color The color of the line (eg "255 0 0")
Layer Table (only a couple of rows, just for organizing the classes):
pkLayerID
LayerName A nice name to put in the legend
And a view, joining the above tables,
so Mapserver can render the features:
--------------------------------------
Render View:
pkGeomID WKT LayerName ClassName Color
While this will likely work for rendering the features, I'm doubtful that
mapserver will be able to keep track of the class names for a legend. While I
can set the color from a database attribute:
CLASS
NAME 'SetByCGI?'
STYLE
COLOR [Color]
END # Style
END # Class
it is not possible to set the CLASS NAME that way. It is possible (I think) to
set it with a CGI variable (something like
&map.layer[0].Class[0]=NAME+"Trails") but that would not allow for the
dynamic number of classes. Or would it? If I put 10 class defs in my map file,
then pass as many names as needed (up to 10) in the URL perhaps I could get a
meaningful legend.
Or maybe WFS is the answer... Or I'll likely need to switch to MapScript. If
there's any interest in doing this via CGI, perhaps we could collaborate on an
enhancement.
Thanks!
Brent Fraser
_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/mapserver-users
More information about the MapServer-users
mailing list