Prev (Control maps and DEM files) | Home | Manual | (Working with Projects) Next
If you have a hot tip for free maps or a spiffy trick about what to do with maps add few words here.
QMapShack’s TMS file specification allows Java Script to build URLs. This can be used to build a WMS URL if the WMS server supports the projection commonly used for TMS. This is either EPSG:3857 or EPSG:900913.
This is an example how to do it. You have to replace the URL before &BBOX=” + bbox + “&WIDTH=256&HEIGHT=256 with what ever is needed for the WMS server. This might be a bit tricky.
<TMS> <Layer idx="0"> <Title>NRW DTK Sammeldienst</Title> <Script><![CDATA[( function convert(z1,x1,y1) { function M(n){return 256*n*(156543.03392804062/(1<<z1))-20037508.342789244} y=(1<<z1)-1-y1; bbox=M(x1)+','+M(y)+','+M(x1+1)+','+M(y+1); return "http://www.wms.nrw.de/geobasis/wms_nw_dtk?LAYERS=nw_dtk_col&FORMAT=image/png&SRS=EPSG:3857&EXCEPTIONS=application/vnd.ogc.se_inimage&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=" + bbox + "&WIDTH=256&HEIGHT=256"; } )]]></Script> </Layer> <Copyright>Geobasis NRW 2015</Copyright> </TMS>
The official documentation of WMS standard can be found on http://www.opengeospatial.org/standards/wms.
The following version loads the French BRGM WMS tiles (adapted from QLandkarteGT xml config file) :
<TMS> <Layer idx="0"> <Title>IGN BRGM France</Title> <Script><![CDATA[( function convert(z1,x1,y1) { function M(n){return 256*n*(156543.03392804062/(1<<z1))-20037508.342789244} y=(1<<z1)-1-y1; bbox=M(x1)+','+M(y)+','+M(x1+1)+','+M(y+1); return "http://mapsref.brgm.fr/wxs/refcom-brgm/refign?LAYERS=FONDS_SCAN&FORMAT=image/png&SRS=EPSG:3857&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=" + bbox + "&WIDTH=256&HEIGHT=256"; } )]]></Script> </Layer> <Copyright>France IGN BRGM</Copyright> </TMS>
The same logic can be implemented on the export command of ArcGIS server maps. Here is an example URL:
"http://www.pcn.minambiente.it/arcgis/rest/services/immagini/IGM_25000/MapServer/export?dpi=96&transparent=true&format=png8&bbox=" + bbox + " &bboxSR=3857&imageSR=3857&size=256,256&f=image"
In most cases the request will work as expected, even though the native projection wouldn’t be 3857 (Web Mercator). For documentation of export command refer to:http://resources.arcgis.com/en/help/arcgis-rest-api/index.html#/Export_Map/02r3000000v7000000/.
As an individual, you can apply for a free non-commercial access to the French IGN WMTS servers (for example through their “Géoportail API”, but also works with other WMTS clients like QGIS and QMapShack). Lots of thanks to them for this free access because their maps are truly awesome. The original source of information about this is at the following URL (in French):
http://dogeo.fr/wmts_ign/
The terms of use enforce a few restrictions listed at the following URL:
http://professionnels.ign.fr/licence-api-geoportail-libre-et-gratuite
You can register for this free “licence géoservices IGN pour usage grand public” at the following URL:
http://professionnels.ign.fr/api-web
You will be prompted to select which layers you want. Although the same procedure probably applies to any of the available layers, the process described here has only been tried with the map layer called “cartes IGN” (or “GEOGRAPHICALGRIDSYSTEMS.MAPS” on the WMTS server).
Note that you will also need to provide your IP address (external IP: that is the IP of your internet router) during the application process. Usually you can easily find this IP in your router status page, or alternatively you can visit websites such as this one:
The WMTS access may be denied if you try to connect from another IP (and this may be a problem if your ISP keeps changing your IP). This problem can be diagnosed by trying to access a map tile directly from a web browser (use the sample URL below). In case of IP mismatch you will obtain an error message saying “wrong IP address” instead of the map tile. The registered IP can be modified on the “IGN Espace Pro” website, under your account, you should click on “mes commandes” and then “modifier mon contrat”. Note that they say it can take up to 12h before the new IP is actually activated.
Shortly after your order (less than one hour), you will receive a confirmation e-mail, and you will be able to retrieve a personal ID (24 character key) from your personal account on the IGN website.
You can test the WMTS access directly in your web browser by fetching a random map tile, for example:
(don’t forget to replace [YOUR_ID] with your actual 24 character personal key)
The WMTS “capabilities” can then be fetched at the following URL:
https://wxs.ign.fr/[YOUR_ID]/geoportail/wmts?SERVICE=WMTS&REQUEST=GetCapabilities
(don’t forget to replace [YOUR_ID] with your actual 24 character personal key)
Unfortunately, unlike other WMTS servers, this capabilities file does not directly work in QMapShack (although it works “as is” in QGIS). To work around this, you will have to modify it with a text editor to include a <ResourceURL> line at the end of the layer description (just before the </Layer> directive) for the “GEOGRAPHICALGRIDSYSTEMS.MAPS” layer (must be adjusted and tested for other layers).
Download: IGN.wmts
(again, don’t forget to replace the 3 occurrences of [YOUR_ID] with your actual 24 character personal key)
Note that this file was working as of September 22, 2015 but may stop working in the future in case IGN changes its WMTS server configuration.
There are two ways to add a transparent contour line layer to your map view:
Some maps for Garmin devices provide a separate img file with contour lines. Add this file to your QMS map directory and you can use it as contour line overlay in map views.
Sources for vector contour line maps:
Some TMS tile servers provide contour line only layers. To use such a layer in QMS, add a *.tms file to your map directory.
Sample TMS file for the contour line layer from OpenSnowMap:
<TMS> <Title>OpenSnowMap Contour Lines</Title> <MinZoomLevel>1</MinZoomLevel> <MaxZoomLevel>1024</MaxZoomLevel> <Layer idx="0"> <ServerUrl>http://www.opensnowmap.org/opensnowmap-overlay/%1/%2/%3.png</ServerUrl> </Layer> <Copyright>Openstreetmap contributors | Rendering: www.opensnowmap.org | DEM: ASTER GDEM is a product of METI and NASA SRTM V4.1 from CGIAR-CSI EU-DEM: Produced using Copernicus data and information funded by the European Union </Copyright> </TMS>
Other sources for transparent contour line tiles:
<ServerUrl>http://129.206.74.245:8006/tms_il.ashx?x=%2&y=%3&z=%1</ServerUrl>
In order to use openmtbmap.org or velomap.org maps within QMapShack you first need to create a gmapsupp.img from the map tiles. For Windows user, there is an integrated batchfile, which will do all necessary steps; so this tutorial is for Linux users. More information you may find here.
In Linux, please check if package p7zip-full is installed – we need it to unpack the .exe file. Open the console and execute sudo apt-get install p7zip-full . We need Mkgmap, too. Also Java is required.
The folder should now contain all map tiles, the contour lines, the layout file and the extracted files from mkgmap.
Now start your console, browse to your folder and copy the following code:
java -Xmx2048M -jar --index --family-id=6528 --description="openmtbmap_alps" --series-name="openmtbmap_alps" --family-name="openmtbmap_alps" --product-id=1 --gmapsupp 6*.img 7*.img widealp.TYP
Then press <Enter> and a gmapsupp.img will be created, which you can easily rename to opentmtbmap_alps.img. Now copy this file onto your GPS unit and in your QMapShack maps folder as well.
If you would like do it with some other layout, simply replace the *.TYP (f.e. easyalps.TYP). If you prefer another country be careful: all 6x.img and 7x.img must be from the particular openmtbmap country file! Also don’t forget to replace the –family-id with the one from your country.
This is really a quick way, to integrate your favorite openmtbmaps or velomaps into QMapShack.
If you prefer a GUI: you can still use QLandkarteGT for creating gmapsupp.img, too.
Links (with further information and some tutorials):
If you want to update your maps regularly you might consider using the script below. The script requires the following tools to be installed:
wget
(downloading)7z
(extraction)mkgmap
(creation of gmapsupp.img)The script below is configured to download the OpenMTBMap for Bavaria, convert it to OpenMTBMap_<date>.img
using traddby.TYP and move it to ~/.qmapshack_maps/
.
If this does not match your requirements, you will need to adopt the values FILESRC, IMGFMT, QMSMAPDIR and TYPE:
FILESRC: Navigate here, find the file you want to download and write the URL to FILESRC
IMGFMT: Name of the resulting file, see man 1 date
QMSMAPDIR: Path to your QMS-Map folder (~
will not work, use ${HOME}
instead)
Depending on your system’s configuration you will need to change MKGMAP to allow proper execution of mkgmap
(see section above).
#! /bin/sh # configuration FILESRC="http://ftp5.gwdg.de/pub/misc/openstreetmap/openmtbmap/odbl/germany/mtbbayern.exe" IMGFMT="OpenMTBMap_%Y-%m-%d.img" QMSMAPDIR="${HOME}/.qmapshack_maps/" TYPE="traddby.TYP" MKGMAP="mkgmap" # code starts here, no changes below here required error_check() { if [ $1 != 0 ]; then echo ${red}ERROR${NC} exit 1 else echo ${green}OK${NC} fi } tool_check() { which $1 2>&1 1>/dev/null if [ $? != 0 ]; then echo ${red}ERROR: $1 missing${NC} exit 1 fi } red="\033[0;31m" green="\033[0;32m" NC="\033[0m" TMP=`mktemp` if [ ! -f "${TMP}" ]; then echo ${red}ERROR: failed to get temp. file${NC} exit 1 fi tool_check "wget" tool_check "7z" ${MKGMAP} >/dev/null 2>&1 if [ $? != 0 ]; then echo ${red}ERROR: mkgmap can\'t be executed${NC} echo ${red}ERROR: make sure MKGMAP is set properly in script configuration${NC} exit 1 fi echo -n " * Downloading... " wget -q -O "$TMP" "$FILESRC" error_check $? echo -n " * Decompressing... " 7z e -o"${TMP}_" ${TMP} >/dev/null error_check $? FILETIME=`stat -c %Y ${TMP}` IMGFILE=`date -d@${FILETIME} +"${IMGFMT}"` echo -n " * Building ${IMGFILE}... " cd "${TMP}_" FID=`ls -x 7*.img | cut -c1-4` ${MKGMAP} --show-profiles=1 --product-id=1 --family-id=${FID} --index --gmapsupp 6*.img 7*.img ${TYPE} >/dev/null error_check $? echo -n " * Moving gmapsupp.img to ${QMSMAPDIR}... " mv "${TMP}_/gmapsupp.img" "${QMSMAPDIR}/${IMGFILE}" error_check $? echo -n " * Cleanup... " rm -rf "${TMP}" "${TMP}_" error_check $?
Script converts to OSGEO TMS (http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/) (Optimized by KartenFreak, thank you)
<TMS> <Title>NZTopo</Title> <MinZoomLevel>6</MinZoomLevel> <MaxZoomLevel>15</MaxZoomLevel> <Layer idx="0"> <Title>NZTopo</Title> <Script><![CDATA[( function convert(z1,x1,y1) { return "http://nz1.nztopomaps.com/" + z1 + "/" + x1 + "/" + ((1<<z1) - y1 - 1) + ".png"; } )]]></Script> </Layer> </TMS>
Quick way to prepare raster map for QMapShack
Prev (Control maps and DEM files) | Home | Manual | (Working with Projects) Next