Geographic Information Systems Asked by Mökin muori on May 31, 2021
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?
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
Answered by nmtoken on May 31, 2021
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
Answered by SamTux on May 31, 2021
SamTux's answer has a very complete example on serving WMTS layers with MapServer. You can also serve the layer directly by pointing the DATA
to the WMTS Capabilities endpoint of the WMTS layer:
LAYER
NAME cascaded_wmts_layer
TYPE RASTER
DATA "http://serviciosgis.catastrobogota.gov.co/arcgis/rest/services/Mapa_Reference/map_base_3857/MapServer/WMTS/1.0.0/WMTSCapabilities.xml"
STATUS OFF
PROJECTION
"init=epsg:3857"
END
END
Mapfile layer DATA can be nearly anything readable by GDAL. To tell if something is readable by GDAL you can just run gdalinfo __file_or_url__
, like so:
gdalinfo http://serviciosgis.catastrobogota.gov.co/arcgis/rest/services/Mapa_Referencia/mapa_base_3857/MapServer/WMTS/1.0.0/WMTSCapabilities.xml
Answered by Pete on May 31, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP