MapServer MVT Support – How to Compile MapServer 8 with MVT Support

compilemapbox-vector-tilemapserver

I have compiled MapServer 8.0.0 and works well, except it will not generate an MVT tile, instead, it returns this message
loadOutputFormat(): General error message. OUTPUTFORMAT (mvt) clause references driver (mvt), but this driver isn't configured.

I used the following to compile

cmake -DCMAKE_INSTALL_PREFIX=/opt \
    -DCMAKE_PREFIX_PATH=/usr/local:/opt \
    -DWITH_CLIENT_WFS=ON \
    -DWITH_CLIENT_WMS=ON \
    -DWITH_CURL=ON \
    -DWITH_SOS=ON \
    -DWITH_PHP=ON \
    -DWITH_JAVA=OFF \
    -DWITH_PERL=ON \
    -DWITH_CSHARP=OFF \
    -DWITH_PYTHON=ON \
    -DWITH_RUBY=OFF \
    -DWITH_EXEMPI=ON \
    -DWITH_KML=ON \
    -DWITH_POSTGIS=ON \
    -DWITH_RSVG=ON \
    -DWITH_SVGCAIRO=0 \
    -DWITH_LIBXML2=ON \
    -DWITH_PROTOBUFC=0 \
    ../ >../configure.out.txt

My Mapserv -v is here

MapServer version 8.0.0 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=RSVG SUPPORTS=ICONV SUPPORTS=XMP SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=OGCAPI_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE INPUT=FLATGEOBUF

I have a MapServer 7.4.3 that does create MVT, and the only real difference I can see is that the other has SUPPORTS=PBF. (but I am not sure how to compile with PBF to test that theory).

How do I compile Mapserver 8 to support MVT tile generation?


I am using Ubuntu

I needed these two packages (libprotobuf-c-dev) being the one I was missing

sudo apt install protobuf-c-compiler libprotobuf-c-dev

Then it compiled like a dream with the

-DWITH_PROTOBUFC=ON

Best Answer

You didn't mention what operating system you are referring to, but that is ok. If you are on Ubuntu you will need to install the protobuf-c library with a command such as sudo apt-get install protobuf-c-compiler

Then, you can enable MVT support during your CMake command for MapServer, through the switch -DWITH_PROTOBUFC=1

Finally, you can verify that MVT support is included by executing mapserv -v and looking for SUPPORTS=PBF in the response, such as:

MapServer version 8.1.0-dev (MS4W 5.0.0-dev) OUTPUT=PNG OUTPUT=JPEG 
OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE 
SUPPORTS=CAIRO SUPPORTS=SVG_SYMBOLS SUPPORTS=SVGCAIRO SUPPORTS=ICONV 
SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT 
SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER 
SUPPORTS=SOS_SERVER SUPPORTS=OGCAPI_SERVER SUPPORTS=FASTCGI 
SUPPORTS=THREADS SUPPORTS=GEOS SUPPORTS=PBF INPUT=JPEG INPUT=POSTGIS 
INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE INPUT=FLATGEOBUF

On Windows it is much more difficult, but good news is that I do compile MVT support into MS4W, for Windows users, to make it easy for all to use out-of-the-box : https://ms4w.com

Related Question