MapFish Print - under the hood
Andreas Jobst
In the last article of our series on printing maps online, we want to shed some light on the current status of the open source tool MapFish Print and present some insights into its functionalities and the technologies that power the application.
Written in Java, MapFish Print is a backend solution for various use cases ranging from the printing of individual maps to the generation of complex reports. MapFish Print, in its current version 3.28.1, constitutes one of the most complete printing solutions on the web that can be easily integrated into most WebGIS. Version 3.28.1 of MapFish Print, which has gone through several rounds of bug fixing, is built on GeoTools for integrating and styling geodata, with JasperReports as reporting engine. The Spring integration framework enables a pluggable architecture and makes the application easily extendable for new functionality, while GeoTools allows us to include additional data types, if needed.
To assure MapFish Print can be run in the preferred way, we provide a total of four different options for deploying MapFish Print. For testing purposes, we can recommend the command-line approach, as it is easy and fast to use. For operation, MapFish Print is usually deployed as a war file, which enables a stable deployment in Java servlet environments (e.g. Tomcat). We also offer docker images for integrating MapFish Print to a cloud environment (e.g. Kubernetes), especially useful if high scalability is a requirement. Finally MapFish Print can also be integrated into a project on the source-code level, as a Java-library.
In order to configure the layout for a custom report MapFish Print offers maximum flexibility with the jasper report jrxml file (precise location of all map elements in the report) and through the parameters (e.g. width, height, DPI etc.) that are set in a yaml file stored on the application server. The print request is then generated by the client as a JSON object and sent to the server which renders the PDF or PNG.
The styling of the geodata is handled by GeoTools and conforms to SLD (Styled Layer Descriptor) styling, the official XML schema for the styling of geodata issued by the Open Geospatial Consortium (OGC).
Alternatively custom JSON styling, which is comparable to the styling used by OpenLayers, is another styling option offered within MapFish Print. For those JSON styles, conditional formatting is available, which enables the user to quickly implement rules to style parts of the data differently.
Regarding data types, MapFish Print supports a growing number of commonly used data types and data services covering both vector (GML, GeoJSON, WFS) and raster data (XYZ tiles such as OSM, WMS, WMTS and GeoTIFF). Any geodata that comes in the form of a map service (WFS or WMS) can simply be integrated into the map canvas of the report by loading the service. With the integration of JasperReports Engine it is also possible to include external data sets from separate databases.
With this series on web based map printing coming to an end we can conclude that MapFish Print is a complete solution for generating prints of simple maps or extensive reports. It supports most of the commonly used types of geographical data and offers a high level of customization.
Finally, we would like to point the reader to the documentation (http://mapfish.github.io/mapfish-print-doc/) and the code repository of MapFish Print, which is also publicly available on Github (https://github.com/mapfish/mapfish-print).
Career
Interested in working in an inspiring environment and joining our motivated and multicultural teams?