<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
You can specify a type in the gml metadata and that will impact how the conversion is done in the mvt encoding. Something like:<br>
<br>
   gml_mapcolor7_type integer<br>
<br>
Otherwise things are treated as strings...<br>
<br>
—Steve<br>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> karsten <karsten@terragis.net><br>
<b>Sent:</b> Tuesday, February 5, 2019 3:01:51 PM<br>
<b>To:</b> mapserver-users@lists.osgeo.org<br>
<b>Cc:</b> Lime, Steve D (MNIT)<br>
<b>Subject:</b> RE: [mapserver-users] styling based on attribute for MapServer derived MVTiles</font>
<div> </div>
</div>
<style>
<!--
@font-face
        {font-family:Cambria Math}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Verdana}
@page WordSection1
        {margin:1.0in 1.0in 1.0in 1.0in}
p.x_MsoNormal
        {font-size:12pt;
        font-family:"Times New Roman",serif;
        margin:0in 0in 0pt}
li.x_MsoNormal
        {font-size:12pt;
        font-family:"Times New Roman",serif;
        margin:0in 0in 0pt}
div.x_MsoNormal
        {font-size:12pt;
        font-family:"Times New Roman",serif;
        margin:0in 0in 0pt}
a:link
        {text-decoration:underline;
        color:blue}
span.x_MsoHyperlink
        {text-decoration:underline;
        color:blue}
a:visited
        {text-decoration:underline;
        color:purple}
span.x_MsoHyperlinkFollowed
        {text-decoration:underline;
        color:purple}
span.x_EmailStyle17
        {font-family:"Calibri",sans-serif;
        color:#1f497d}
.x_MsoChpDefault
        {font-size:10pt}
div.x_WordSection1
        {}
-->
</style>
<div lang="EN-US" link="blue" vlink="purple">
<div dir="ltr" align="left"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">Great, Thanks Steve
</font></span></div>
<div dir="ltr" align="left"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">I added </font></span><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial"> "gml_include_items" "mapcolor7"</font></span></div>
<div dir="ltr" align="left"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">to the Metadata block and got it working.
</font></span></div>
<div dir="ltr" align="left"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">One quirk seems to be that when I am trying to the values as integer (from the mapcolor7 column) specifying the style as in 1.) below did not work.
</font></span></div>
<div dir="ltr" align="left"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">However it I treat them as characters instead, quoted them and used "type": "categorical" in the json file for the style as in 2.) below it is working.</font></span></div>
<div><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial"></font></span> </div>
<div><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">Cheers</font></span></div>
<div><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">Karsten</div>
<div dir="ltr" align="left"><br>
</div>
</font></span>
<div><span class="x_219225520-05022019"></span><font face="Arial"><font color="#000080"><font size="2">1<span class="x_219225520-05022019">.)</span></font></font></font></div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">----------------------------</font></span></span></font></font></font></div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019">{<br>
    "id": "country-fill",<br>
    "type": "fill",<br>
    "source": "compass",<br>
    "source-layer": "allcountries",<br>
    "paint": {<br>
      "fill-color": {<br>
        "property": "mapcolor7",<br>
        "stops": [<br>
            [1, "#fdaf6b"],<br>
            [2, "#fdc663"],<br>
            [3, "#fae364"],<br>
            [4, "#d3e46f"],<br>
            [5, "#aadb78"],<br>
            [6, "#a3cec5"],<br>
            [7, "#ceb5cf"]<br>
        ]<br>
      }<br>
    }<br>
}</span></font></font></font></div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019"></span></font></font></font> </div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019">2.)</span></font></font></font></div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019"><span class="x_219225520-05022019"><font color="#000080" size="2" face="Arial">----------------------------</font></span></span></font></font></font></div>
<div><font face="Arial"><font color="#000080"><font size="2"><span class="x_219225520-05022019">{<br>
    "id": "country-fill",<br>
    "type": "fill",<br>
    "source": "compass",<br>
    "source-layer": "allcountries",<br>
    "paint": {<br>
      "fill-color": {<br>
        "property": "mapcolor7",<br>
<strong>        "type": "categorical",</strong><br>
        "stops": [<br>
            ["1", "#fdaf6b"],<br>
            ["2", "#fdc663"],<br>
            ["3", "#fae364"],<br>
            ["4", "#d3e46f"],<br>
            ["5", "#aadb78"],<br>
            ["6", "#a3cec5"],<br>
            ["7", "#ceb5cf"]<br>
        ]<br>
      }<br>
    }<br>
}</span></font></font></font></div>
<div><br>
</div>
<div lang="en-us" class="x_OutlookMessageHeader" dir="ltr" align="left">
<hr tabindex="-1">
<font size="2" face="Tahoma"><b>From:</b> Lime, Steve D (MNIT) [mailto:steve.lime@state.mn.us]
<br>
<b>Sent:</b> Tuesday, February 05, 2019 21:15<br>
<b>To:</b> karsten; mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> RE: [mapserver-users] styling based on attribute for MapServer derived MVTiles<br>
</font><br>
</div>
<div></div>
<div class="x_WordSection1">
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d">I believe the default WxS behavior is to expose no attributes. You need to be explicit and I don’t see the gml_include_items metadata property in the mapfile
 for the layer allcountries. You’d need something like:</span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d">“gml_include_items”    “mapcolor7”</span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d">Added to the allcountries layer. The mvt-demo does this for most layers…</span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d">--Steve</span></p>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Calibri",sans-serif; color:#1f497d"> </span></p>
<div>
<div style="border-top:#e1e1e1 1pt solid; border-right:medium none; border-bottom:medium none; padding-bottom:0in; padding-top:3pt; padding-left:0in; border-left:medium none; padding-right:0in">
<p class="x_MsoNormal"><b><span style="font-size:11pt; font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11pt; font-family:"Calibri",sans-serif"> mapserver-users [mailto:mapserver-users-bounces@lists.osgeo.org]
<b>On Behalf Of </b>karsten<br>
<b>Sent:</b> Monday, February 04, 2019 4:33 PM<br>
<b>To:</b> mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> [mapserver-users] styling based on attribute for MapServer derived MVTiles</span></p>
</div>
</div>
<p class="x_MsoNormal"> </p>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Dear All,</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">I was working on the configuration of MapServer generated MVT tiles for a demo country world map and had success with MS v 7.2 outputting tiles in MVT format ( all
 thanks to <a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fsdlime%2Fmvt-demo&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214573577&sdata=5L4SwL6sPn9%2BFDEQbvM1%2BKzCQ6KtXdc6OACIm4afEDc%3D&reserved=0" originalsrc="https://github.com/sdlime/mvt-demo" shash="EBANl031uGVoGUF/Uk5csje3639LkZ2ESFg34QoPT8W7S0SNb9qkZaIaDHIbtqbvBkBhpPVLmu8AKXl592Q7Ix3xGjEalvOo/mr4P52nFSyVZT8VBFJC/KV3HVCjBE788EfIaAF5pHFaR+NmV03+9lvER0wbbsArcWhvNkkNRSM=">
https://github.com/sdlime/mvt-demo</a> ).</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">I am trying to work on the client side style for my demo map (using mapbox-gl.js) and defined them in a similar way as JSON as in Steve's mvt-demo above. The whole
 thing is later intended to be used in a benchmark for MapServer MVT rendering speed versus T-Rex ( see
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.sourcepole.ch%2F2018%2F09%2F06%2Fthe-tale-of-a-vector-tile-benchmark%2F&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214583591&sdata=x0OMGP7hH2SvVQysWctAAAlzU5kML4sxg1m9ZHj3yNM%3D&reserved=0" originalsrc="http://blog.sourcepole.ch/2018/09/06/the-tale-of-a-vector-tile-benchmark/" shash="eA+/TAWc6qlCR8n7cAqyrg1GkfCClqJq4soy3ggU/HyxnyCKnNWCipB80fHnngw/nJhNZLqJ7O2yhEHEae9wM74Asn3DJ4BjhIk0eNPTg1ceOcw7JTqe+AOoXIjU8MlxMsFLVxBcP7sbjaPZdxb3CrdjOc4VYXa9fBKYhQ0pQEM=">
http://blog.sourcepole.ch/2018/09/06/the-tale-of-a-vector-tile-benchmark/</a> ) .</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">For now I am struggling with specifying the correct style syntax for the client side and it seem that I missing something as I was not yet able to successfully use
 attribute properties to render Countries as different colors based on an attribute field of my PostGIS source.</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Below is the configuration of my 'allcountries' layer. The mapcolor7 filed is an integer field (in the input PostGIS source) but my set-up fails to output multiple
 colors , instead I am getting all default black for the country fill color. A second layer where I specified only Italy as one Country 'country-italy' to show up renders fine -  see
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkarstenv%2Fmvt-benchmark%2Fblob%2Fmaster%2FMapServer%2Fcountries_mvt.png&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214593596&sdata=sCT0dCxsOVV8WK61g86riyFrnHwMUW3kDTq1FncEYIk%3D&reserved=0" originalsrc="https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/countries_mvt.png" shash="HNHpT/Xads94y2kjhHgiUpl3X8C9nv3L3IObeFVx0IX1kC9ivwEq4mRcJsg8ixfi+Dcl6PprBuwYLfjoJhIxv81RQeIxdEDm6WYmpAuVgJQ+l2JiKKGkhxcx9YG/XCNiYcNS/q/OBWYIjrO+hXpFZ5TglZJYyguzxBhDyyu03w4=">
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/countries_mvt.png</a></span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">My complete style JSON is at
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkarstenv%2Fmvt-benchmark%2Fblob%2Fmaster%2FMapServer%2Fms_ne_simple.json&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214593596&sdata=rW0SwiqaGZDf1P%2FhVw4677fS69GIdjaQnk5G2cKLWow%3D&reserved=0" originalsrc="https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ms_ne_simple.json" shash="dmkE+iznHOVJq1/CubUsnxeRpe/FanMbbg14GgLc5OHZOkxFQiaDzi1b30JhE7QVs9eqynafpqm8xNfgYBeIU3knTOhoXCR+Dp2IKVofWIyf5/IZSG1dkl1MxJvpf3/mJzQOQ5+EzUHKlWUivWsupPj0/uzLn0XpozMELqAap0Q=">
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ms_ne_simple.json</a></span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">and the corresponding map file is here
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fkarstenv%2Fmvt-benchmark%2Fblob%2Fmaster%2FMapServer%2Fne.map&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214603601&sdata=N4PGCLEg6xD8VMz6bA%2BnaQPFDyITriOP5V40S4AGt%2FA%3D&reserved=0" originalsrc="https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ne.map" shash="yBJbWXGMKdIBxUjLZWYvqyxEDP0D8mF7Qe8ywfLtlXd0kQGV2KfceAj4jp2OqYLDrDYxtx6RUKpBslO7YuGYvvwPMXsQJqsdftO8oYHZhZozCcbzKHlHov2p9TPR2dn+sCR47/0U8h8wJR0eh8uXnogLTdXe5CPg+8ThCsVlbjQ=">
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ne.map</a></span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Would anyone know what I need to change in order to render the countries with different colors according to the 'mapcolor7' attribute ?</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">To me it seems that somehow the attribute is not available to the renderer even though in the MapServer map file I am selecting all fields in the sub-query ...</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy"> </span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Thanks</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Karsten</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">--------------------------------------------</span></p>
</div>
<div>
<p class="x_MsoNormal"><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">{<br>
    "id": "country-fill",<br>
    "type": "fill",<br>
    "source": "compass",<br>
    "source-layer": "allcountries",<br>
    "paint": {<br>
      "fill-color": {<br>
        "property": "mapcolor7",<br>
        "stops": [<br>
            [1, "#fdaf6b"],<br>
            [2, "#fdc663"],<br>
            [3, "#fae364"],<br>
            [4, "#d3e46f"],<br>
            [5, "#aadb78"],<br>
            [6, "#a3cec5"],<br>
            [7, "#ceb5cf"]<br>
        ]<br>
      }<br>
    }<br>
},{<br>
    "id": "country-italy",<br>
    "type": "fill",<br>
    "source": "compass",<br>
    "source-layer": "italy",<br>
    "paint": {<br>
      "fill-color": "#fdc663"<br>
      }<br>
  }</span></p>
</div>
<div>
<p class="x_MsoNormal"> </p>
</div>
<p class="x_MsoNormal"><span style="font-size:11pt; font-family:"Verdana",sans-serif">Karsten Vennemann<br>
</span><span style="font-size:10pt; font-family:"Arial",sans-serif; color:navy">Terra GIS
</span></p>
</div>
</div>
</body>
</html>