2

I need to create a Mapserver map file that would read maps from (external) WMTS interface and serve them as WMS.

How should I get started? Could anyone link to useful instructions or give an example?

  • You seem to have two questions, one is how to cascade a wmts through MapServer. The other is whether there is any benefit in doing so. – nmtoken Dec 18 '17 at 10:17
  • Thanks for comment, nmtoken. I edited my post slightly since the other question was actually irrelevant. – Mökin muori Dec 18 '17 at 10:30
2

The connection to the WMTS is made through the service configuration XML file of GDAL, which can be obtained through the following command:

gdal_translate http://serviciosgis.catastrobogota.gov.co/arcgis/rest/services/Mapa_Reference/map_base_3857/MapServer/WMTS/1.0.0/WMTSCapabilities.xml wmts.xml -of WMTS

As a result you get the following file:

<GDAL_WMTS>
  <GetCapabilitiesUrl>http://serviciosgis.catastrobogota.gov.co/arcgis/rest/services/Mapa_Referencia/mapa_base_3857/MapServer/WMTS/1.0.0/WMTSCapabilities.xml</GetCapabilitiesUrl>
  <Layer>Mapa_Referencia_mapa_base_3857</Layer>
  <Style>default</Style>
  <TileMatrixSet>default028mm</TileMatrixSet>
  <DataWindow>
    <UpperLeftX>-8530516.724611044</UpperLeftX>
    <UpperLeftY>787485.3238264732</UpperLeftY>
    <LowerRightX>-7912313.895742185</LowerRightX>
    <LowerRightY>171205.2146587537</LowerRightY>
  </DataWindow>
  <BandsCount>4</BandsCount>
  <Cache />
  <UnsafeSSL>true</UnsafeSSL>
  <ZeroBlockHttpCodes>204,404</ZeroBlockHttpCodes>
  <ZeroBlockOnServerException>true</ZeroBlockOnServerException>
</GDAL_WMTS>

I recommend verifying that this file can be loaded as a raster layer in the QGIS software.

Once, you can do the configuration in the Mapfile and specify the connection through the GDAL driver, here is a mapfile example:

MAP
  DEFRESOLUTION 96
  EXTENT -8251807.87026254 515749.224663909 -8244059.40876483 520717.918565494
  IMAGETYPE "png24"
  NAME "MAPA_REFERENCIA"
  RESOLUTION 96
  SHAPEPATH ""
  SIZE 1378 884
  STATUS ON
  UNITS METERS

  OUTPUTFORMAT
    NAME "png24"
    MIMETYPE "image/png"
    DRIVER "AGG/PNG"
    EXTENSION "png"
    IMAGEMODE RGB
    TRANSPARENT FALSE
  END # OUTPUTFORMAT

  OUTPUTFORMAT
    NAME "print"
    MIMETYPE "image/png"
    DRIVER "AGG/PNG"
    EXTENSION "png"
    IMAGEMODE RGB
    TRANSPARENT FALSE
  END # OUTPUTFORMAT

  PROJECTION
     "init=epsg:3857"
  END # PROJECTION
  LEGEND
    KEYSIZE 20 10
    KEYSPACING 5 5
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    STATUS OFF
  END # LEGEND

  QUERYMAP
    SIZE -1 -1
    STATUS OFF
    STYLE HILITE
  END # QUERYMAP

  SCALEBAR
    INTERVALS 4
    LABEL
      SIZE 10
      OFFSET 0 0
      SHADOWSIZE 1 1
    END # LABEL
    SIZE 200 3
    STATUS OFF
    UNITS MILES
  END # SCALEBAR

  WEB
    METADATA
      "distance_units"      "MS_METERS"
      "mapmanager_version"  "1.0.0.0"
      "wms_title"           "IDECA Mapa de Referencia"
      "wms_onlineresource"  "http://localhost/cgi-bin/mapserv.fcgi?map=/srv/http/mapfiles/ideca.map"
      "wms_srs"             "EPSG:3857 EPSG:4326 EPSG:3116"
      "wms_enable_request"  "*"   ##necessary
      "wms_contactperson"   "Samuel Mesa"
      "wms_contactorganization" "Universidad Nacional de Colombia - Sede Bogota"
      "wms_contactposition" "Profesor"
    END # METADATA
  END # WEB

  LAYER
    COMPOSITE
    END # COMPOSITE
    DATA "./wmts.xml"
    EXTENT -8530516.72461104 171205.214658754 -7912313.89574219 787485.323826473
    METADATA
      "coordsys_name" "Popular Visualisation CRS / Mercator (deprecated)"
      "wms_title"    "Mapa Referencia"   ##required
    END # METADATA
    NAME "mapa_referencia"
    PROJECTION
      "init=epsg:3857"
    END # PROJECTION
    STATUS ON
    TILEITEM "location"
    TYPE RASTER
    UNITS METERS
  END # LAYER

END # MAP

Finally, the WMS service connection is tested on the GIS client of your choice.

http://localhost/cgi-bin/mapserv.fcgi?map=/srv/http/mapfiles/ideca.map&Service=WMS&Request=GetCapabilities
0

AFAIK it is not directly possible to use an WMTS as an input data source in MapServer (unlike WMS). You will need to work out how to convert the input into a supported GDAL raster format. I don't think it's covered by the GDAL WMS format driver. It might be something that could be configured as a VRT

  • You could do this using a recent version of GeoServer – Ian Turton Dec 19 '17 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.