# HG changeset patch # User Bernhard Reiter # Date 1569441665 -7200 # Node ID e0d04cd8f992e0500a6fb57e5fd96b905b36ae56 # Parent 3130c005abef7191327006ebbb8c92935f5f004a Add SLD templates dir for geoserver with one template * Add script to upload SLD templates to gemma. * Add sounding_results_area.sld-template for polygons, still visible at all zoom level for debugging (see xml commented out line). diff -r 3130c005abef -r e0d04cd8f992 style-templates/sounding_results_area.sld-template --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/sounding_results_area.sld-template Wed Sep 25 22:01:05 2019 +0200 @@ -0,0 +1,99 @@ + + + + sounding_results_areas + + sounding_results_areas + + area_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 }} + + + #404040 + 0.5 + + + + {{ end }} + + + area_labels + + + FeatureTypeStyle for labels at colour areas + + + + + + + height + + + Avenir + Helvetica + Arial + sans-serif + + + + 5 + + + + #070707 + + + + + + + diff -r 3130c005abef -r e0d04cd8f992 style-templates/upload-styles.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/style-templates/upload-styles.sh Wed Sep 25 22:01:05 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