Hi list, If you are Python users then the mappyfile library (disclosure - I've been working on it since the start of this year), could solve many of the issues of working and manipulating Mapfiles. http://mappyfile.readthedocs.io/en/latest/ Online example: http://mappyfile.geographika.net/ https://github.com/geographika/mappyfile
Validation and deprecation warnings on on the roadmap. Regards, Seth -- web:http://geographika.co.uk twitter: @geographika On Mon, Oct 16, 2017, at 05:22 PM, Lime, Steve D (MNIT) wrote: > Need the mapfile equivalent of SASS... A standard, platform- > independent pre-processor would be nice. I’ve heard of folks using the > C pre-processor to do this sort of thing so they’d have a version of a > mapfile (and no includes) full of #define and #ifdef structures. In > some cases I’ve gone nuts with includes and then used a super simple > MapScript script that reads and then immediately saves things to an > optimized (sort of compiled) version with no includes.> > Something like variables (and maybe functions) could potentially be > built into mapfile processing itself. I could see (for example) > setting a block like so at the mapfile level:> > VARIABLES > ‘key1’ ‘value1’ > ‘key2’ ‘value2’ > … > END > > And then setting a mechanism to reference them as the file is > processed (COLOR {key1}). The nice thing about this approach is that > includes would take their cue from the parent mapfile and could behave > differently for different parents. That would be great for doing > something like map themes. Just thinking out loud.> > Steve > > *From:* mapserver-users [mailto:mapserver-users- > [email protected]] *On Behalf Of *[email protected] > *Sent:* Friday, October 13, 2017 6:41 AM *To:* mapserver- > [email protected]; Jörg Thomsen (WhereGroup) > <[email protected]> *Subject:* Re: [mapserver-users] > passing variables to includes> > Hi Jörg, > > I also had this same thought and it would be a good mechanism. But I > solved it with my own preprocessing. > > I have been doing Nautical charts with Mapserver for a couple of > years and realized that I was reusing the same layers up to 18 times. > > So I did templates where I had LAYER->NAME, LAYER->GROUP, LAYER->DATA > and STYLE->COLOR as variables in Mapserver templates. Color for > instance has fixed names like "DEPVS", that means depth very shallow. > But depending on if it is day mode, dawn dusk mode or night mode the > colors have different rgb or hex values. All variables are stored in > csv files. The variables are read into associative arrays in a bash > script. Then I use my Mapserver mapfile templates that are > processed with a very long sed statement that substitutes the > variables depending on color mode and scale level. > > Layer names and groups have one csv file that tells how to assemble > all the layers. To make it even more flexible, I can also use > offical IHO colors, Swedish or French color tables to get different > look and feel. > > An example is for instance the layer template for rivers: > > #### Rivers Lines #### > > LAYER NAME "Rivers_line_{CL}" GROUP "{GROUP}" METADATA > "ows_title" "Rivers" "ows_enable_request" "*" > "gml_include_items" "all" "wms_feature_mime_type" "text/html" > END TEMPLATE blank.html TYPE LINE STATUS ON > MAXSCALEDENOM {MAXSCALE} DATA "{PATH}" CLASS NAME > "Rivers (lines)" STYLE > # DEPVS RGB # COLOR {DEPVS_rgb} > COLOR "{DEPVS}" WIDTH 1.5 > # RGB # COLOR {OUTLL_rgb} > OUTLINECOLOR "{OUTLL}" OUTLINEWIDTH 0.3 END END END > > > All this can be seen in the git hub: > https://github.com/LarsSchy/SMAC-M I finally got permission from my > company to release it this summer, so that we can discuss this. I > would like to do a demo site with open data, but haven't had time to > do this yet. > > The script: process_layer_color.sh shows the real processing part and > the sed script. > > https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/generate_map_files/scripts/process_layer_colors.sh > > Have fun > > Lars Schylberg Saab AB> > -----Originalmeddelande----- > > Från: "Jörg Thomsen (WhereGroup)" <[email protected]> > > Till: [email protected] Datum: 2017-10-13 09:43 Ämne: > > [mapserver-users] passing variables to includes > > > > Hi, > > > > I had a MapServer Training this week and one of the participations > > asks a nice question: > > > > Is it possible to pass variables to includes? I think this is a > > very good idea, it could save a lot of includefiles. In know it's > > very close to mapscript, but has anyone done this without? > >> _________________________________________________ > mapserver-users mailing list > [email protected] > https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________ mapserver-users mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/mapserver-users
