Declarative Maps

There is a request in comments for more details and examples of declarative programming with MapServer. Before I elaborate, I must stress that I'm advocating a new-ish, different way of looking at MapServer. It's not widely recognized that the instructions encoded in a MapServer mapfile comprise a domain-specific language. (Norman Vine, for one, gets it.) The reference itself is concerned only with the content of a configuration file, and doesn't acknowledge the existence of a language. Like it or not (and I do have my issues with the syntax and semantics of it), there is a map language. To embrace the map language is to benefit from simplicity, usability, and portability. Now, don't misunderstand, there's nothing inherently wrong with imperative programming. The problem is that imperative mapscripting exposes its practitioners to the many rough edges and pitfalls of MapServer's internal API, and produces less than portable applications.


Re: Declarative Maps

Author: Tim Schaub

Thanks Sean. None of that was obvious to me until described that way. You'll certainly forgive those of us who stumbled into mapserv, immediately found limitations, and jumped to mapscript for the flexibility. Writing mapserver patches is a whole lot more intimidating than writing (smelly) mapscript work-arounds. Until the restrictions you mention are lifted (and more), mapscript will continue to provide an efficient (if not always elegant) way to get things done. Perhaps your advice would be "something missing in mapserv, shp2img, etc? jump on the development team." This is not a practical alternative for folks who need to deliver something next week. I'll take the advice to limit imperative (mapscript) programming and appreciate your ideas.

Re: Declarative Maps

Author: Homme Zwaagstra

I agree that the declarative approach has much to be said for it, and would be much more useful if mapserver (including mapscript!) was open to mapfile input from non file based sources (e.g. mapfiles could come from standard input, or strings). Practicality, however, is often a balance between extremes. In this case initial mapfiles can often be created using your favourite templating/text-based approach. Mapscript sessions can then be instantiated with these mapfiles (saving much imperative drudgery) and used to tweak the map as required.