# HG changeset patch # User Sascha Wilde # Date 1569492983 -7200 # Node ID 819eafe60f4122968a9606c2372b1d0cd619cc6d # Parent 778b1302524495d4a4102aa62660e16445a131cd# Parent 43c52a2d4f176b973d538021c4f134b02d4a3123 Merged diff -r 778b13025244 -r 819eafe60f41 README.md --- a/README.md Thu Sep 26 11:32:33 2019 +0200 +++ b/README.md Thu Sep 26 12:16:23 2019 +0200 @@ -40,7 +40,8 @@ - You will need a PostgreSQL cluster with PostGIS. -- To install the **gemma** schema and roles use the script +- To install the **gemma** schema, roles and some default system configuration + use the script `./schema/install-db.sh`. - `./schema/install-db.sh --help` shows you available options. @@ -57,7 +58,7 @@ - Install and run GeoServer as described here: http://docs.geoserver.org/stable/en/user/installation/ -- Add tables you want to publish as OGC-Service Layers via GeoServer in +- Add addional tables you want to publish as OGC-Service Layers via GeoServer in the database. For example publish the bottleneck areas: ``` INSERT INTO sys_admin.published_services (name, as_wfs) VALUES @@ -92,6 +93,16 @@ ./cmd/gemma/gemma ``` +## Adding default style templates for geoserver + +- To add default style layers for geoserver run the script: + ``` + ./style-templates/upload-styles.sh + ``` + +- `./style-templates/upload-styles.sh --help` shows an overview of its options. + + ## Proxying OGC services through gemma - Add services you want to publish via gemma (e.g. for same-origin policy diff -r 778b13025244 -r 819eafe60f41 client/src/components/Pdftool.vue --- a/client/src/components/Pdftool.vue Thu Sep 26 11:32:33 2019 +0200 +++ b/client/src/components/Pdftool.vue Thu Sep 26 12:16:23 2019 +0200 @@ -153,13 +153,12 @@ { type: "scalebar", position: "bottomright", - offset: { x: 2, y: 2 } + offset: { x: 1, y: 1 } }, { type: "textbox", position: "bottomleft", - offset: { x: 2, y: 2 }, - width: 60, + offset: { x: 1, y: 1 }, fontSize: 8, text: this.$gettext("Generated by") + " " + "{user}, {date}" }, @@ -168,6 +167,16 @@ position: "topleft", offset: { x: 6, y: 4 }, size: 2 + }, + { + type: "bottleneck", + position: "topright", + offset: { x: 2, y: 2 } + }, + { + type: "legend", + position: "topright", + offset: { x: 2, y: 25 } } ] } @@ -749,39 +758,44 @@ // bottleneck this.pdf.doc.setFontStyle("italic"); - this.pdf.doc.text(x + padding, y + padding, str1_1, textOptions); + this.pdf.doc.text(x + padding, y + padding + 2, str1_1, textOptions); this.pdf.doc.setFontStyle("bold"); - this.pdf.doc.text(x + padding + w1_1, y + padding, str1_2, textOptions); + this.pdf.doc.text( + x + padding + w1_1, + y + padding + 2, + str1_2, + textOptions + ); // survey date this.pdf.doc.setFontStyle("italic"); - this.pdf.doc.text(x + padding, y + padding + 4, str2_1, textOptions); + this.pdf.doc.text(x + padding, y + padding + 6, str2_1, textOptions); this.pdf.doc.setFontStyle("normal"); this.pdf.doc.text( x + padding + w2_1, - y + padding + 4, + y + padding + 6, str2_2, textOptions ); // ref gauge this.pdf.doc.setFontStyle("italic"); - this.pdf.doc.text(x + padding, y + padding + 8, str3_1, textOptions); + this.pdf.doc.text(x + padding, y + padding + 10, str3_1, textOptions); this.pdf.doc.setFontStyle("normal"); this.pdf.doc.text( x + padding + w3_1, - y + padding + 8, + y + padding + 10, str3_2, textOptions ); // depth relative to this.pdf.doc.setFontStyle("italic"); - this.pdf.doc.text(x + padding, y + padding + 12, str4_1, textOptions); + this.pdf.doc.text(x + padding, y + padding + 14, str4_1, textOptions); this.pdf.doc.setFontStyle("normal"); this.pdf.doc.text( x + padding + w4_1, - y + padding + 12, + y + padding + 14, str4_2, textOptions ); diff -r 778b13025244 -r 819eafe60f41 style-templates/distance_marks_ashore_geoserver.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/distance_marks_ashore_geoserver.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,30 @@ + + + + distance_marks_ashore_geoserver + + + + + + + circle + + {{ .distance_marks_ashore_stroke }} + + + {{ .distance_marks_ashore_fill }} + {{ .distance_marks_ashore_fill_opacity }} + + + 10 + + + + + + + diff -r 778b13025244 -r 819eafe60f41 style-templates/distance_marks_geoserver.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/distance_marks_geoserver.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,450 @@ + + + + distance_marks_geoserver + + distance_marks_geoserver + + + + + + hectometre + + 1000 + + + hectometre + 1000 + + + + + 0 + + + 8500000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + #5555FF + 1 + + + 10 + + + + + + + + hectometre + + 500 + + + hectometre + 500 + + + + + 0 + + + 1100000 + 8500000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + 100 + + + + hectometre + + 100 + + + hectometre + 100 + + + + + 0 + + + 800000 + 1100000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + 50 + + + + hectometre + + 50 + + + hectometre + 50 + + + + + 0 + + + 200000 + 800000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + 20 + + + + hectometre + + 20 + + + hectometre + 20 + + + + + 0 + + + 60000 + 200000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + 10 + + + + hectometre + + 10 + + + hectometre + 10 + + + + + 0 + + + 10000 + 60000 + + + + + hectometre + 10 + + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + 1 + 10000 + + + + hectometre + 10 + + + + Sans Serif + 10 + bold + + + + + 0 + -0.5 + + + + + #000000 + + + + + + + + circle + + {{ .distance_marks_fill }} + {{ .distance_marks_fill_opacity }} + + + {{ .distance_marks_stroke }} + 1 + + + 10 + + + + + + + diff -r 778b13025244 -r 819eafe60f41 style-templates/sounding_differences.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/sounding_differences.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,157 @@ + + + + sounding_differences + + sounding_differences + + differences + + + FeatureTypeStyle defining colour classes for height attribute + + + {{ range . -}} + + {{- if not .HasLow }} + ≤ {{ printf "%g" .High }} + + + height + {{ printf "%f" .High }} + + + {{- else if not .HasHigh }} + > {{ printf "%g" .Low }} + + + height + {{ printf "%f" .Low }} + + + {{- else }} + ≤ {{ printf "%g" .High }} + + + + height + {{ printf "%f" .Low }} + + + height + {{ printf "%f" .High }} + + + + {{- end }} + + + {{ .Color }} + 0.5 + + + + {{ end }} + + + contour_lines_emph + + + FeatureTypeStyle for emphasized contour lines + + + + + + + + + + {{ range . -}} + {{ if .HasHigh -}} + + + 0.000000 + height + + {{ printf "%f" .High }} + + {{ end -}} + {{ end }} + + + 5e3 + + + 1.5 + + + + 0.000000 + height + + {{ range . -}} + {{ if .HasHigh -}} + {{ printf "%f" .High }} + {{ .Color }} + {{ end -}} + {{ end }} + + + + + + + + contour_lines_label + + + FeatureTypeStyle for labels at contour lines + + + + 5e3 + + + + + 0.000000 + height + + {{ range . -}} + {{ if .HasHigh -}} + + {{- printf "%f" .High -}} + + {{- printf "%g" .High -}} + + {{ end -}} + {{ end }} + + + + Avenir + Helvetica + Arial + sans-serif + + + + 5 + + + + #070707 + + + + + + + diff -r 778b13025244 -r 819eafe60f41 style-templates/sounding_results_contour_lines_geoserver.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/sounding_results_contour_lines_geoserver.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,157 @@ + + + + sounding_results_contour_lines + + sounding_results_contour_lines + + contour_line_colours + + + FeatureTypeStyle defining colour classes for height attribute + + + {{ range . -}} + + {{- if not .HasLow }} + ≤ {{ printf "%g" .High }} + + + height + {{ printf "%f" .High }} + + + {{- else if not .HasHigh }} + > {{ printf "%g" .Low }} + + + height + {{ printf "%f" .Low }} + + + {{- else }} + ≤ {{ printf "%g" .High }} + + + + height + {{ printf "%f" .Low }} + + + height + {{ printf "%f" .High }} + + + + {{- end }} + + + {{ .Color }} + 0.5 + + + + {{ end }} + + + contour_lines_emph + + + FeatureTypeStyle for emphasized contour lines + + + + + + + + + + {{ range . -}} + {{ if .HasHigh -}} + + + 0.000000 + height + + {{ printf "%f" .High }} + + {{ end -}} + {{ end }} + + + 5e3 + + + 1.5 + + + + 0.000000 + height + + {{ range . -}} + {{ if .HasHigh -}} + {{ printf "%f" .High }} + {{ .Color }} + {{ end -}} + {{ end }} + + + + + + + + contour_lines_label + + + FeatureTypeStyle for labels at contour lines + + + + 5e3 + + + + + 0.000000 + height + + {{ range . -}} + {{ if .HasHigh -}} + + {{- printf "%f" .High -}} + + {{- printf "%g" .High -}} + + {{ end -}} + {{ end }} + + + + Avenir + Helvetica + Arial + sans-serif + + + + 5 + + + + #070707 + + + + + + + diff -r 778b13025244 -r 819eafe60f41 style-templates/upload-styles.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/upload-styles.sh Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,119 @@ +#!/bin/bash -e +# +# This is Free Software under GNU Affero General Public License v >= 3.0 +# without warranty, see README.md and license for details. +# +# SPDX-License-Identifier: AGPL-3.0-or-later +# License-Filename: LICENSES/AGPL-3.0.txt +# +# Copyright (C) 2019 by via donau +# – Österreichische Wasserstraßen-Gesellschaft mbH +# Software engineering by Intevation GmbH +# +# Author(s): +# * Sascha Wilde + +ME=`basename "$0"` +BASEDIR=`dirname "$0"` + +usage() +{ + cat <&2 "$1" + exit 23 +} + +# Defaults: + +g_port=8000 +g_host="localhost" +g_user="sophie" +g_pw="so2Phie4" + +# Parse options: + +OPTS=`getopt \ + -l help,g_port:,g_host:,g_user:,g_pw: \ + -o P:g:u: -n "$ME" -- "$@"` +[ $? -eq 0 ] || { usage ; exit 1 ; } + +eval set -- "$OPTS" + +while true ; do + case "$1" in + --g_port|-P) + g_port="$2" + shift 2 + ;; + --g_host|-g) + g_host="$2" + shift 2 + ;; + --g_user|-u) + g_user="$2" + shift 2 + ;; + --g_pw) + g_pw="$2" + shift 2 + ;; + --help) + { usage ; exit 0 ; } + ;; + --) + shift + break + ;; + esac +done + +if [ $# != 0 ] ; then + { usage ; exit 23 ; } +fi + +# Main ------------------------------------------------------------ + +# Login to gemma server +login=$(curl -f -s -S -X POST \ + -d "{\"user\":\"${g_user}\",\"password\":\"${g_pw}\"}" \ + "http://${g_host}:${g_port}/api/login") +token=$(jq -r '.token' <<<"$login") +if [ -z "$token" ] +then + echo "could not login to gemma server" >&2 + exit 1 +fi + +roles=$(jq -r '.roles' <<<"$login") + +basedir=$( dirname $( realpath "${BASH_SOURCE[0]}" )) +datadir="${basedir}/." + +if jq -e 'any(. == "sys_admin")' <<<"$roles" > /dev/null +then + echo "== Configuring geoserver styles" >&2 + for style in $(basename -s .sld-template $(ls $datadir/*.sld-template)) + do + curl -f -s -S -H "X-Gemma-Auth:${token}" -X POST \ + -F style=@"${datadir}/${style}.sld-template" \ + "http://${g_host}:${g_port}/api/geo/style/${style}" + done +else + echo >&2 'Not authorized as sys_admin' +fi diff -r 778b13025244 -r 819eafe60f41 style-templates/waterway_area.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/waterway_area.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,23 @@ + + + + waterway_area + + A yellow polygon style + + + yellow polygon + + + {{ .waterway_area_stroke }} + 1 + + + + + + + diff -r 778b13025244 -r 819eafe60f41 style-templates/waterway_axis.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/waterway_axis.sld-template Thu Sep 26 12:16:23 2019 +0200 @@ -0,0 +1,24 @@ + + + + waterway_axis + + A cyan line style + + + cyan line + + + {{ .waterway_axis_stroke }} + 5 5 + + + + + + + +