Graphical user interface between Mapsforge tile server and QMapShack
QMapShack currently does not support local Mapsforge maps out of the box. Prebuilt Mapsforge maps are provided amongst others by mapsforge.org and openandromaps.org.
QMapShack however is able to handle maps provided as tiles by a Tile Map Service (TMS), which is mainly used by web mapping tile servers. To make local Mapsforge maps nevertheless available within QMapShack, a local tile server can be set up to render these Mapsforge maps and to interact with QMapShack via TMS protocol. The corresponding Mapsforge tile server is available at this mapsforgesrv repository.
This project’s intension is to easily let the user interactively and comfortably select the numerous available options of Mapsforge tile server. In addition, option settings as well as position and font size of graphical user interface automatically get saved and restored. Mapsforge tile server and QMapShack get started/restarted using these options without need to manually set up any configuration files.
Graphical user interface is a single script written in Tcl/Tk scripting language and is executable on Microsoft Windows and Linux operating system. Language-neutral script file Mapsforge-for-QMapShack.tcl requires an additional user settings file and at least one localized resource file. Additional files must follow Tcl/Tk syntax rules too.
User settings file is named Mapsforge-for-QMapShack.ini. A template file is provided.
Resource files are named Mapsforge-for-QMapShack.<locale>, where <locale> matches locale’s 2 lowercase letters ISO 639-1 code. English localized resource file Mapsforge-for-QMapShack.en, French localized resource file Mapsforge-for-QMapShack.fr and German localized resource file Mapsforge-for-QMapShack.de are provided. Script can be easily localized to any other system’s locale by providing a corresponding resource file using English resource file as a template.
Screenshot of graphical user interface:

-
QMapShack
Windows: If not yet installed, download and install latest QMapShack version from download section.
Linux: If not yet installed, install QMapShack package using Linux package manager.
(Ubuntu: apt install qmapshack gdal-bin gdal-data proj-bin proj-data routino)
macOS: As latest ready to install QMapShack version 1.17.1 is rather old, consider to easily build your own current version following the build process for Mac rules.
Note: Run QMapShack at least once and initialize map & cache folders by File -> Setup Map Paths before using Mapsforge-for-QMapShack. -
Java runtime environment (JRE) or Java development kit (JDK)
JRE version 11 or higher is required. JRE version 17 or higher is recommended.
Each JDK contains JRE as subset.
Windows: If not yet installed, download and install JRE or JDK, e.g. from Oracle, OpenLogic or Adoptium.
Linux: If not yet installed, install JRE or JDK using Linux package manager.
(Ubuntu: apt install openjdk-<version>-jre or apt install openjdk-<version>-jdk with required or newer <version>)
macOS: If not yet installed, install JDK using Homebrew package manager by brew install java. -
Mapsforge tile server
Open mapsforgesrv releases.
Download most recently released jar file mapsforgesrv-fatjar.jar from <release>_for_java11_tasks assets.
Windows: Copy downloaded jar file into Mapsforge tile server’s installation folder, e.g. into folder %ProgramFiles%/MapsforgeSrv.
Linux / macOS: Copy downloaded jar file into Mapsforge tile server’s installation folder, e.g. into folder ~/MapsforgeSrv.
Note: Mapsforge tile server version 0.22.0.0 or higher is required. -
Alternative Marlin rendering engine (optional, recommended)
Marlin is an open source Java2D rendering engine optimized for performance, replacing the standard built into Java. Download is available at Marlin-renderer releases.
For JRE version lower than 17, download jar file marlin-*.jar
from Marlin-renderer <latest version> for JDK11+ section's assets.
For JRE version 17 or higher, download jar file marlin-*.jar
from Marlin-renderer <latest version> for JDK17+ section's assets.
Windows: Copy downloaded jar file into Mapsforge tile server’s installation folder, e.g. into folder %ProgramFiles%/MapsforgeSrv.
Linux / macOS: Copy downloaded jar file into Mapsforge tile server’s installation folder, e.g. into folder ~/MapsforgeSrv. -
Tcl/Tk scripting language version 8.6 or higher binaries
Windows: Download and install latest stable version of Tcl/Tk, currently 9.0.
See https://wiki.tcl-lang.org/page/Binary+Distributions for available binary distributions. Recommended Windows binary distribution is from teclab’s tcltk Windows repository. Select most recent installation file tcltk90-9.0.<x.y>.Win10.nightly.<date>.tgz. Unpack zipped tar archive (file extension .tgz) into your Tcl/Tk installation folder, e.g. %ProgramFiles%/Tcl.
Note: 7-Zip file archiver/extractor is able to unpack .tgz archives.
Linux: Install packages tcl, tcllib, tcl-thread, tk, tklib, x11-utils and wmctrl using Linux package manager. (Ubuntu: apt install tcl tcllib tcl-thread tk tklib x11-utils wmctrl)
macOS: If not yet installed, install tcl-tk using Homebrew package manager by brew install tcl-tk. Unfortunately, tklib containing required package tooltip is not part of tcl-tk. Advanced users can either download tklib0.9 from sourceforge.net and install into folder <root>/Cellar/tcl-tk/<version>/lib/tklib0.9. Alternatively and easier: download Windows distribution mentioned above, extract subfolder tklib0.9 from archive and install as folder <root>/Cellar/tcl-tk/<version>/lib/tklib0.9. -
Mapsforge maps
Download Mapsforge maps for example from openandromaps.org. Each downloaded OpenAndroMaps map archive contains a map file (file extension .map).
Note:
Mapsforge tile server itself does not use points-of-interest files (POI, file extension .poi) supplied for download there. As QMapShack is not able to handle this kind of POI files, QMapShack suitable POI files can be found here. -
Mapsforge themes
Mapsforge themes Elevate and Elements (file extension .xml) suitable for OpenAndroMaps are available for download at openandromaps.org.
Note:
In order "Hillshading on map" to be applied to rendered map tiles, hillshading has to be enabled in theme file too. Elevate and Elements themes version 5 or higher do enable hillshading. -
DEM data (optional, required for hillshading)
Download and store DEM (Digital Elevation Model) data for the regions to be rendered.
Notes:
Either HGT files or ZIP archives containing 1 single equally named HGT file may be supplied.
Example: ZIP archive N49E008.zip containing 1 single HGT file N49E008.hgt.
While 1" (arc second) resolution DEM data have a significantly higher accuracy than 3" resolution, hillshading assumes significantly much more time. Therefore 3" resolution usually is better choice.- HGT files with 3" resolution SRTM (Shuttle Radar Topography Mission) data are available for whole world at viewfinderpanoramas.org. Unzip downloaded ZIP files to DEM folder.
- HGT files with 1" resolution DEM data are available for selected regions at viewfinderpanoramas.org. Unzip downloaded ZIP files to DEM folder.
- ZIP archives with 3" and 1" resolution compiled and resampled by Sonny are available for selected regions at Sonny's Digital LiDAR Terrain Models of European Countries. LiDAR data where available are more precise than SRTM data. Store downloaded ZIP files to DEM folder. -
Mapsforge for QMapShack graphical user interface script
Download language-neutral script file Mapsforge-for-QMapShack.tcl, user settings file Mapsforge-for-QMapShack.ini and at least one localized resource file.
Windows: Copy downloaded files into Mapsforge tile server’s installation folder, e.g. into folder %ProgramFiles%/MapsforgeSrv.
Linux / macOS: Copy downloaded files into Mapsforge tile server’s installation folder, e.g. into folder ~/MapsforgeSrv.
Note: Edit user-defined script variables settings section of user settings file Mapsforge-for-QMapShack.ini to match files and folders of your local installation of Java, Mapsforge tile server and QMapShack. Always use character slash “/” as directory separator in Mapsforge-for-QMapShack.ini file, for Microsoft Windows too!
Windows:
Associate file extension .tcl to Tcl/Tk window shell’s binary wish.exe. Right-click script file and open file’s properties window. Change data type .tcl to be opened by Wish application e.g. by executable %ProgramFiles%/Tcl/bin/wish.exe. Once file extension has been associated, double-click script file to run.
Linux:
Either run script file from command line by
wish <path-to-script>/Mapsforge-for-QMapShack.tcl
or create a desktop starter file Mapsforge-for-QMapShack.desktop
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=Mapsforge-for-QMapShack
Exec=wish <path-to-script>/Mapsforge-for-QMapShack.tcl
or associate file extension .tcl to Tcl/Tk window shell’s binary /usr/bin/wish to run script file by double-click file in file manager.
macOS:
Either run script file from command line by
wish <path-to-script>/Mapsforge-for-QMapShack.tcl
or use Automator -> Application -> Run Shell Script -> /usr/local/bin/wish "$@" to create an application for Tcl/Tk window shell’s binary wish, then associate all .tcl files to this application and run script file by double-click file in file manager.
Having .tcl files associated to this application, a desktop starter from script file can be created by Make Alias and dragging the alias and dropping it to desktop.
- After selecting tasks(s), map(s), theme file, theme style, style's overlays etc. in graphical user interface, hit Start button to start Mapsforge tile server and QMapShack. When QMapShack has started successfully, activate QMapShack's map(s) Mapsforge Map … to show map(s) and/or Mapsforge Hillshading … to show hillshading selected in graphical user interface. When changing settings while QMapShack is running, a reload of maps is required to adopt new settings. To reload, first hit Start button again and QMapShack's tile cache containing tiles already loaded with previous settings gets cleared. Second, right-click QMapShack's maps list and force QMapShack to reload maps.
- Closing either graphical user interface or QMapShack window also closes Mapsforge tile server.
- Use keyboard keys Ctrl-plus to increase and keyboard keys Ctrl-minus to decrease font size of graphical user interface and/or output console.
- See output console for Mapsforge tile server’s and QMapShack's output.
Screenshot of QMapShack showing Heidelberg (Germany) and using
- OpenAndroMaps map file Germany_oam.osm.map
- OpenAndroMaps poi file Germany_oam.osm.poi showing Accommodations -> Hotel,Guest Houses
- OpenAndroMaps rendering theme Elevate
- Theme file's style elv-hiking aka Hiking
- Style's default overlays plus additional overlay elv-waymarks aka Waymarks
- Hillshading settings as above
- Output console
While console output of Mapsforge tile server and/or QMapShack can be informative and helpful to verify what is happening as well as to analyze errors, writing to console costs some performance. Therefore the console should be hidden if not needed. - Built-in world map
Since the built-in Mapsforge world map only shows the coastline, it only serves as a rough overview. Due to map's low resolution, coastlines show inaccurate at high resolution.
In order not to cover an accurate map, the built-in world map has been automatically deactivated at higher zoom levels.
Starting with Mapsforge tile server version 0.23.0.3, built-in world map is rendered with lower priority than user-defined accurate maps. Zoom level restriction was therefore removed. - Hillshading
- When selecting "Hillshading on map", map and hillshading are rendered into one single map.
Same result can be achieved faster by not enabling hillshading in graphical user interface but enabling QMapShack's built-in hillshading. - When selecting "Hillshading as map", map and hillshading are rendered as two separate maps. Post-processing hillshading, gray value of flat area gets mapped to full transparency. Thus the flatter the area, the more the original colors of the map shine through. Finally, hillshading can be used as an alpha-transparent overlay for any map.
OpenTopoMap uses same hillshading technique as hillshading algorithm "diffuselight".
Activate first QMapShack's maps "Mapsforge Map" and second "Mapsforge Hillshading" if "Hillshading as map" was selected. Former shows map tiles without hillshading, latter shows hillshading as alpha-transparent overlay. Map "Mapsforge Hillshading" can also be used as overlay for other maps not containing hillshading, e.g. OpenStreetMap.
Same result can not be achieved by QMapShack's built-in hillshading
- When selecting "Hillshading on map", map and hillshading are rendered into one single map.
- If QMapShack is showing rendered Mapsforge map a bit blurry, then within QMapShack
- first open “View -> Setup Map View” and set “Scale” to “Square”
- then hit “symbol grid” button at upper right corner above and set “Projection” to “World Mercator (OSM)”
As with QMapShack 1.17.1, projection “World Mercator (OSM)” built-in settings have been changed. As a workaround for QMapShack 1.17.1, replace “Projection & Datum” string manually fromEPSG:3857to
+proj=merc +a=6378137 +b=6378137 +lat_ts=0.001 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +type=crs
This workaround is no longer required for QMapShack 1.18.0 or newer.
