Skip to content

Commit

Permalink
Merge pull request #21 from cevi/feature/pdf-map-export
Browse files Browse the repository at this point in the history
- New PDF-map export using MapFish.
- Added command-line for user-defined map scaling
- Added command-line options to enable/disable features
- Removed default file name for GPX file
  • Loading branch information
wp99cp authored Nov 15, 2021
2 parents f5e4120 + 6f47e8d commit c136afb
Show file tree
Hide file tree
Showing 18 changed files with 1,718 additions and 206 deletions.
13 changes: 9 additions & 4 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ Ziel dieses Projektes ist es, den Prozess rund um das Erstellen einer J+S-Marsch
Velo-Tour zu automatisieren und zu beschleunigen.

Heute gibt es bereits verschiedenste Online-Tool, die J+S-Leiter*innen und Wanderfreudigen das Planen einer Wanderung
erleichtern. Ich selber verwende meistens die kostenpflichtige Online-Karte von SchweizMobil. SchweizMobil ist Dank den
magnetischen Wegen (d.h. die eingezeichnete Route folgt automatisch dem Wanderweg/der Strasse) und der Zeitberechnung (
gemäss der Formel der Schweizer Wanderwege) bereits eine grosse Hilfe beim Planen. Ebenfalls geeignet ist die offizielle
App des Bundesamts für Landestopografie swisstopo.
erleichtern:

- Die kostenpflichtige Online-Karte von SchweizMobil. SchweizMobil ist Dank den magnetischen Wegen (d.h. die
eingezeichnete Route folgt automatisch dem Wanderweg/der Strasse) und der Zeitberechnung (gemäss der Formel der
Schweizer Wanderwege) bereits eine grosse Hilfe beim Planen.

- Für mobile Endgeräte, eignet sich ebenfalls die offizielle App des Bundesamts für Landestopografie swisstopo.
Analog zur SchweizMobil, bietet auch die swisstopo App eine Funktion zur Routenplanung mit magnetischen Wegen.


Ist man mit einer grösseren Gruppe unterwegs (so zum Beispiel in einem J+S-Lager), ist eine ausführliche Planung
unumgänglich. Doch genau in diesen Szenarien stossen die existierenden Tools an ihr Grenzen. Dieses Projekt setzt genau
Expand Down
21 changes: 21 additions & 0 deletions pdf_map_export/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Docker Container running MapFish
As of version 1.4.0, the script is divided into two main components:

- A python script executed directly by the end user (entry-point `../python_program/main.py`)
- A docker container running a MapFish instance used to create PDF-map exports via a web api.

## Run MapFish inside a Local Docker Container:
MapFish is an open-source tool to create reports containing maps. This script uses MapFish to create the PDF-map
exports. We relay directly on the default `camptocamp/mapfish_print` docker container, customized by binding of our
settings.

Once you have Docker installed on your system, you can start the MapFish print server by calling:

docker run --name=mapfish-print-test \
--mount type=bind,source=<path_to_pdf_map_export_folder>,target=/usr/local/tomcat/webapps/ROOT/print-apps/swisstopo \
--publish=8080:8080 camptocamp/mapfish_print

## Test your MapFish Instance
You can test if the container is running properly by opening [http://localhost:8080](http://localhost:8080/). Now you
can copy-past the content of the `test_query.json` file and click on `Create And Get Print`. If the test PDF gets
created properly, your installation was successfully.
2 changes: 2 additions & 0 deletions pdf_map_export/cevi_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions pdf_map_export/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
templates:

#===========================================================================
A4 landscape: !template
#===========================================================================

reportTemplate: report.jrxml
attributes:

map: !map
maxDpi: 400
width: 813
height: 566

northArrow: !northArrow
size: 50
default:
graphic: "north_arrow.png"

overlayLayers: !staticLayers
default:
layers:
- type: grid
origin: [ 2700000, 1200000 ]
spacing: [ 1000, 1000 ]
renderAsSvg: true
gridColor: "#FFFFFF"
rotateLabels: False
labelColor: black
valueFormat: "###,###"
formatGroupingSeparator: " "
font:
name:
- Liberation Sans
- Helvetica
- Nimbus Sans L
- Liberation Sans
- FreeSans
- Sans-serif
size: 6
style:
version: 2
"*":
symbolizers:
- type: "line"
strokeWidth: 0.1
strokeOpacity: 0.5
strokeColor: gray

scalebar: !scalebar
width: 200
height: 25
default:
fontSize: 8
renderAsSvg: True
unit: m
type: line

processors:
- !addOverlayLayers
inputMapper:
overlayLayers: staticLayers
map: map
- !reportBuilder # compile all reports in current directory
directory: '.'
- !createMap { }
- !createScalebar { }
- !createNorthArrow {}

Binary file added pdf_map_export/north_arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions pdf_map_export/report.jrxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd"
name="report" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="814" leftMargin="14"
rightMargin="14" topMargin="14" bottomMargin="14" uuid="9a3e59f5-6675-48cf-ad74-9c42b5a5b290">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<property name="com.jaspersoft.studio.unit." value="pixel"/>
<parameter name="mapSubReport" class="java.lang.String"/>
<parameter name="scalebarSubReport" class="java.lang.String"/>
<parameter name="northArrowGraphic" class="java.lang.String"/>
<title>
<band height="567" splitType="Stretch">
<subreport>
<reportElement x="1" y="0" width="813" height="566" backcolor="#B1F2BE"
uuid="fa145068-76a5-4834-98ed-ce65b1976b3d">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<subreportExpression><![CDATA[$P{mapSubReport}]]></subreportExpression>
</subreport>
<rectangle>
<reportElement x="600" y="518" width="210" height="45" forecolor="#FFFFFF"
uuid="c9901651-0788-428f-b7a3-0f1623195781">
<property name="com.jaspersoft.studio.unit.x" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
</rectangle>
<subreport>
<reportElement x="605" y="523" width="200" height="25" uuid="fa145068-76a5-4834-98ed-ce65b1976b3d">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<subreportExpression><![CDATA[$P{scalebarSubReport}]]></subreportExpression>
</subreport>
<staticText>
<reportElement x="605" y="545" width="200" height="16" uuid="a03c1801-86f0-4389-9fc7-3a5e6f7a30dc">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="9"/>
</textElement>
<text><![CDATA[https://disclaimer.admin.ch © swisstopo]]></text>
</staticText>
<image evaluationTime="Report">
<reportElement x="10" y="10" width="280" height="39" uuid="e7375b56-57f5-4abb-8f88-45734b26ed1b"/>
<imageExpression><![CDATA["cevi_logo.svg"]]></imageExpression>
</image>
<image>
<reportElement x="750" y="20" width="50" height="50" uuid="fa145068-76a5-4834-98ed-ce65b1976b3d">
<property name="local_mesure_unitwidth" value="pixel"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="local_mesure_unitheight" value="pixel"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable">
<![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.io.File(new java.net.URI($P{northArrowGraphic})))]]>
</imageExpression>
</image>
</band>
</title>
</jasperReport>
Loading

0 comments on commit c136afb

Please sign in to comment.