<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>Hi list,<br></div>
<div><br></div>
<div>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. <br></div>
<div><br></div>
<div><a href="http://mappyfile.readthedocs.io/en/latest/">http://mappyfile.readthedocs.io/en/latest/</a><br></div>
<div>Online example: <a href="http://mappyfile.geographika.net/">http://mappyfile.geographika.net/</a><br></div>
<div><a href="https://github.com/geographika/mappyfile">https://github.com/geographika/mappyfile</a><br></div>
<div><br></div>
<div>Validation and deprecation warnings on on the roadmap. <br></div>
<div>Regards,<br></div>
<div><br></div>
<div>Seth</div>
<div><br></div>
<div><br></div>
<div id="sig62266145"><div class="signature">--</div>
<div class="signature">web:http://geographika.co.uk</div>
<div class="signature">twitter: @geographika</div>
</div>
<div><br></div>
<div><br></div>
<div>On Mon, Oct 16, 2017, at 05:22 PM, Lime, Steve D (MNIT) wrote:<br></div>
<blockquote type="cite"><div><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">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.</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">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:</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">VARIABLES</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">  ‘key1’ ‘value1’</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">  ‘key2’ ‘value2’</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">  …</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">END</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">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.</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">Steve</span></span><br></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"><span class="colour" style="color:rgb(31, 73, 125)"><span class="font" style="font-family:Calibri, sans-serif"><span class="size" style="font-size:11pt"> </span></span></span></span></span><br></p><div><div style="border-right-width:initial;border-bottom-width:initial;border-left-width:initial;border-right-style:none;border-bottom-style:none;border-left-style:none;border-right-color:initial;border-bottom-color:initial;border-left-color:initial;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;border-top-width:1pt;border-top-style:solid;border-top-color:rgb(225, 225, 225);padding-top:3pt;padding-right:0in;padding-bottom:0in;padding-left:0in;"><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"><b><span class="font" style="font-family:Calibri, sans-serif"><span class="size" style="font-size:11pt">From:</span></span></b><span class="font" style="font-family:Calibri, sans-serif"><span class="size" style="font-size:11pt"> mapserver-users [mailto:mapserver-users-bounces@lists.osgeo.org] <b>On Behalf Of </b>lars.schylberg@blixtmail.se<br> <b>Sent:</b> Friday, October 13, 2017 6:41 AM<br> <b>To:</b> mapserver-users@lists.osgeo.org; Jörg Thomsen (WhereGroup) <joerg.thomsen@wheregroup.com><br> <b>Subject:</b> Re: [mapserver-users] passing variables to includes</span></span></span></span></p></div>
</div>
<p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><div><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt">Hi Jörg,<br> <br> I also had this same thought and it would be a good mechanism.<br> But I solved it with my own preprocessing.<br> <br> I have been doing Nautical charts with Mapserver for a<br> couple of years and realized that I was reusing<br> the same layers up to 18 times. <br> <br> So I did templates where I had LAYER->NAME, LAYER->GROUP,<br> LAYER->DATA and STYLE->COLOR as variables in Mapserver templates. <br> Color for instance has fixed names like "DEPVS",<br> that means depth very shallow. <br> But depending on if it is day mode, dawn dusk mode or night mode<br> the colors have different rgb or hex values. <br> All variables are stored in csv files.  The variables are read into<br> associative arrays in a bash script.  Then  I use my Mapserver<br> mapfile templates that are processed with a very long sed statement<br> that substitutes the variables depending on color mode and scale level.  <br> <br> Layer names and groups have one csv file that tells how to<br> assemble all the layers.  To make it even more flexible, I can<br> also use offical IHO colors, Swedish or French color tables<br> to get different look and feel.<br> <br> An example is for instance the layer template for rivers:<br> <br> #### Rivers Lines ####<br> <br> LAYER<br>     NAME  "Rivers_line_{CL}"<br>     GROUP "{GROUP}"<br>     METADATA<br>         "ows_title"   "Rivers"<br>         "ows_enable_request"   "*"<br>         "gml_include_items" "all"<br>         "wms_feature_mime_type" "text/html"<br>     END<br>     TEMPLATE blank.html<br>     TYPE LINE<br>     STATUS ON<br>     MAXSCALEDENOM {MAXSCALE}<br>     DATA "{PATH}"<br>     CLASS<br>         NAME "Rivers (lines)"<br>         STYLE<br>            # DEPVS<br>            # RGB # COLOR {DEPVS_rgb}<br>            COLOR "{DEPVS}"<br>            WIDTH 1.5<br>            # RGB # COLOR {OUTLL_rgb}<br>            OUTLINECOLOR "{OUTLL}"<br>            OUTLINEWIDTH 0.3<br>         END<br>     END<br> END<br> <br> <br> All this can be seen in the git hub:  <a style="text-decoration: underline; color: blue;" href="https://github.com/LarsSchy/SMAC-M"> https://github.com/LarsSchy/SMAC-M</a><br> I finally got permission from my company to release it this summer, so that we can discuss this.<br> I would like to do a demo site with open data, but haven't had time to do this yet.<br> <br> The script: process_layer_color.sh shows the real processing part and the sed script.<br> <br> <a style="text-decoration: underline; color: blue;" href="https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/generate_map_files/scripts/process_layer_colors.sh">https://github.com/LarsSchy/SMAC-M/blob/master/chart-installation/generate_map_files/scripts/process_layer_colors.sh</a><br> <br> Have fun<br> <br> Lars Schylberg<br> Saab AB</span></span></p><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"> </span></span><br></p><div><p style="margin: 0in 0in 0.0001pt;"><span class="font" style="font-family:"Times New Roman", serif"><span class="size" style="font-size:12pt"><span class="font" style="font-family:"Lucida Console""><span class="size" style="font-size:10pt">-----Originalmeddelande-----<br> > Från: "Jörg Thomsen (WhereGroup)" <<a style="text-decoration: underline; color: blue;" href="mailto:joerg.thomsen@wheregroup.com">joerg.thomsen@wheregroup.com</a>><br> > Till: <a style="text-decoration: underline; color: blue;" href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br> > Datum: 2017-10-13 09:43<br> > Ämne: [mapserver-users] passing variables to includes<br> ><br> > Hi,<br> ><br> > I had a MapServer Training this week and one of the participations asks<br> > a nice question:<br> ><br> > Is it possible to pass variables to includes? I think this is a very<br> > good idea, it could save a lot of includefiles. In know it's very close<br> > to mapscript, but has anyone done this without?<br> ></span></span></span></span></p></div>
</div>
</div>
<div><u>_______________________________________________</u><br></div>
<div>mapserver-users mailing list<br></div>
<div><a style="text-decoration: underline; color: blue;" href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br></div>
<div><a style="text-decoration: underline; color: blue;" href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br></div>
</blockquote><div><br></div>
</body>
</html>