Maybe an other way is to use a mapfile in xml instead mapscript and so you can do what you want with the xml and transform it in .map when it's ok. With this solution you are "mapscipt independant" and you doesn't need mapscript.
I did something like that for adding a lot of layers.

Ludovic

Brent Fraser <[email protected]> a écrit :

Hopefully your favorite scripting language is Python (and not PHP or Perl) as the support is much better. I'm no expert in Mapscript, but in general your script would do something like:

1. Load the 'template' map file (containing most of the map/layer/class definitions) 2. Get the Layer object of interest, and iterate thru the class objects assigning the desired symbology
3. Generate and send the image to the browser

There is reference doc on the Mapserver site for Mapscript but I didn't see any tutorial. GeoMoose has some extensive PHP Mapscript you might be able to use as a guide.

Best Regards,
Brent Fraser


On 8/26/2011 11:50 AM, Mr. Puneet Kishor wrote:
On Aug 26, 2011, at 12:39 PM, Brent Fraser wrote:

Puneet,

 I think currently the short answer is Mapscript.

I had a similar need last year (http://lists.osgeo.org/pipermail/mapserver-users/2010-March/065050.html) where I needed to have the symbology stored in the database and the classes varied over time (users created new class defs in the database via a web page).

Steve Lime suggested an enahancement where classes were defined by a SLD file or url:

LAYER
 NAME 'extreme-symbology'
 DATA ...
 CONNECTION ...
 SLD 'some flle' or 'some url'
 ...
END

which is an elegant solution, but currently not implemented...

Yes, that would be a very nice solution, precisely the kind of thing I am looking for. In fact, even better would be

LAYER
 ..
 SLD 'some expression'

where 'some expression' could be stored in a file, or retrieve via a URL, or from a db query.

But, until that comes along, I could and will use MapScript. I compiled MS 6.0.1 yesterday, and discovered, much to my delight, that MapScript in my favorite programming language (the one that begins with P) is alive and doing well.

So, how would I go about implementing this in MapScript? I would have to create the layer definition on the fly, no? Any pointers?



Best Regards,
Brent Fraser


On 8/26/2011 8:35 AM, Mr. Puneet Kishor wrote:
hola,

I need some guidance on this (and my MapServer foo is severely rusted). My immediate need is to color a polygon layer (held in PostGIS) based on an attribute in a separate table. The number of CLASSes is considerable, more than 80 or so. This leads to a longer term need --

The coloring of these polys is a crucial and universal need in my field of work, and it horrendously complicated determining the correct color, and the calculations for the appropriate color keep on changing from time to time. In other words, many different applications need this ability to classify polys based on certain attributes. So, I am creating a web app that does nothing but tell what color to use -- you give it a set of attributes, and the web app replies with the color. It would be a RESTful app, sending the color information back as JSON. How could I use this information with MapServer?

In an ideal scenario, MapServer would query the data source, then, for each class in the layer, it would send a query to this color app, and the color app would tell MapServer what color to use to render the poly. The same app would be used by other apps, be they MapServer, OL, Polymaps, or even non-mapping apps such as R, etc.

Suggestions on how to proceed?

--
Puneet Kishor
_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users



_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users



_______________________________________________
mapserver-users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/mapserver-users

Reply via email to