[mapserver-users] styling based on attribute for MapServer derived MVTiles

karsten karsten at terragis.net
Mon Mar 11 14:37:51 PDT 2019


Thanks , will use this from now on.
Cheers
Karsten
 

  _____  

From: Lime, Steve D (MNIT) [mailto:steve.lime at state.mn.us] 
Sent: Saturday, February 09, 2019 15:55
To: karsten; mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] styling based on attribute for MapServer
derived MVTiles


You can specify a type in the gml metadata and that will impact how the
conversion is done in the mvt encoding. Something like:

   gml_mapcolor7_type integer

Otherwise things are treated as strings...

-Steve

  _____  

From: karsten <karsten at terragis.net>
Sent: Tuesday, February 5, 2019 3:01:51 PM
To: mapserver-users at lists.osgeo.org
Cc: Lime, Steve D (MNIT)
Subject: RE: [mapserver-users] styling based on attribute for MapServer
derived MVTiles 
 
Great, Thanks Steve 
I added  "gml_include_items" "mapcolor7"
to the Metadata block and got it working. 
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. 
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.
 
Cheers
Karsten

1.)
----------------------------
{
    "id": "country-fill",
    "type": "fill",
    "source": "compass",
    "source-layer": "allcountries",
    "paint": {
      "fill-color": {
        "property": "mapcolor7",
        "stops": [
            [1, "#fdaf6b"],
            [2, "#fdc663"],
            [3, "#fae364"],
            [4, "#d3e46f"],
            [5, "#aadb78"],
            [6, "#a3cec5"],
            [7, "#ceb5cf"]
        ]
      }
    }
}
 
2.)
----------------------------
{
    "id": "country-fill",
    "type": "fill",
    "source": "compass",
    "source-layer": "allcountries",
    "paint": {
      "fill-color": {
        "property": "mapcolor7",
        "type": "categorical",
        "stops": [
            ["1", "#fdaf6b"],
            ["2", "#fdc663"],
            ["3", "#fae364"],
            ["4", "#d3e46f"],
            ["5", "#aadb78"],
            ["6", "#a3cec5"],
            ["7", "#ceb5cf"]
        ]
      }
    }
}

  _____  

From: Lime, Steve D (MNIT) [mailto:steve.lime at state.mn.us] 
Sent: Tuesday, February 05, 2019 21:15
To: karsten; mapserver-users at lists.osgeo.org
Subject: RE: [mapserver-users] styling based on attribute for MapServer
derived MVTiles



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:

 

"gml_include_items"    "mapcolor7"

 

Added to the allcountries layer. The mvt-demo does this for most layers.

 

--Steve

 

From: mapserver-users [mailto:mapserver-users-bounces at lists.osgeo.org] On
Behalf Of karsten
Sent: Monday, February 04, 2019 4:33 PM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] styling based on attribute for MapServer derived
MVTiles

 

Dear All,

 

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 https://github.com/sdlime/mvt-demo
<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com
%2Fsdlime%2Fmvt-demo&data=02%7C01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4
f29f40e08d68bad2b0d%7Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C63684997321
4573577&sdata=5L4SwL6sPn9%2BFDEQbvM1%2BKzCQ6KtXdc6OACIm4afEDc%3D&reserved=0>
).

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
http://blog.sourcepole.ch/2018/09/06/the-tale-of-a-vector-tile-benchmark/
<https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fblog.source
pole.ch%2F2018%2F09%2F06%2Fthe-tale-of-a-vector-tile-benchmark%2F&data=02%7C
01%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b0462
4c445198f26b89c2159828c%7C0%7C0%7C636849973214583591&sdata=x0OMGP7hH2SvVQysW
ctAAAlzU5kML4sxg1m9ZHj3yNM%3D&reserved=0>  ) .

 

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.

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
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/countries_mv
t.png
<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%7
Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214593596&sdata=sCT0dCx
sOVV8WK61g86riyFrnHwMUW3kDTq1FncEYIk%3D&reserved=0> 

 

My complete style JSON is at
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ms_ne_simple
.json
<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%7
Ceb14b04624c445198f26b89c2159828c%7C0%7C0%7C636849973214593596&sdata=rW0Swiq
aGZDf1P%2FhVw4677fS69GIdjaQnk5G2cKLWow%3D&reserved=0> 

and the corresponding map file is here
https://github.com/karstenv/mvt-benchmark/blob/master/MapServer/ne.map
<https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com
%2Fkarstenv%2Fmvt-benchmark%2Fblob%2Fmaster%2FMapServer%2Fne.map&data=02%7C0
1%7Csteve.lime%40state.mn.us%7C8cad89d7aa6f4f29f40e08d68bad2b0d%7Ceb14b04624
c445198f26b89c2159828c%7C0%7C0%7C636849973214603601&sdata=N4PGCLEg6xD8VMz6bA
%2BnaQPFDyITriOP5V40S4AGt%2FA%3D&reserved=0> 

 

Would anyone know what I need to change in order to render the countries
with different colors according to the 'mapcolor7' attribute ?

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 ...

 

Thanks

Karsten

 

--------------------------------------------

{
    "id": "country-fill",
    "type": "fill",
    "source": "compass",
    "source-layer": "allcountries",
    "paint": {
      "fill-color": {
        "property": "mapcolor7",
        "stops": [
            [1, "#fdaf6b"],
            [2, "#fdc663"],
            [3, "#fae364"],
            [4, "#d3e46f"],
            [5, "#aadb78"],
            [6, "#a3cec5"],
            [7, "#ceb5cf"]
        ]
      }
    }
},{
    "id": "country-italy",
    "type": "fill",
    "source": "compass",
    "source-layer": "italy",
    "paint": {
      "fill-color": "#fdc663"
      }
  }

 

Karsten Vennemann
Terra GIS 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20190311/2c7ff6c6/attachment-0001.html>


More information about the mapserver-users mailing list