# HG changeset patch # User Sascha L. Teichmann # Date 1570006877 -7200 # Node ID 92515c49c566341900f60745b574f6ff8e2dcf13 # Parent 07f632cd26259ecd839af025c0360c8182533eb6# Parent 8a6c410f6f03ca8f50022c11f17d0bb2b86215f5 Merged default into 'iso-areas' branch. diff -r 07f632cd2625 -r 92515c49c566 Makefile --- a/Makefile Wed Oct 02 11:00:09 2019 +0200 +++ b/Makefile Wed Oct 02 11:01:17 2019 +0200 @@ -40,7 +40,7 @@ v="gemma-$$(hg id -i)" ;\ tar --transform "s@^@$${v}/@" \ -cJf "../$${v}.tar.xz" \ - cmd/gemma/gemma schema web misc example_conf.toml + cmd/gemma/gemma schema style-templates web misc example_conf.toml clean: $(MAKE) -f Makefile.build -C client $@ diff -r 07f632cd2625 -r 92515c49c566 README.md --- a/README.md Wed Oct 02 11:00:09 2019 +0200 +++ b/README.md Wed Oct 02 11:01:17 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 07f632cd2625 -r 92515c49c566 client/src/components/Bottlenecks.vue --- a/client/src/components/Bottlenecks.vue Wed Oct 02 11:00:09 2019 +0200 +++ b/client/src/components/Bottlenecks.vue Wed Oct 02 11:01:17 2019 +0200 @@ -162,6 +162,10 @@ preventZoomOut: true }); }); + this.$store.commit( + "bottlenecks/setBottleneckForPrint", + bottleneck.properties.name + ); }, loadSurveys(bottleneck) { if (bottleneck === this.openBottleneck) { diff -r 07f632cd2625 -r 92515c49c566 client/src/components/Pdftool.vue --- a/client/src/components/Pdftool.vue Wed Oct 02 11:00:09 2019 +0200 +++ b/client/src/components/Pdftool.vue Wed Oct 02 11:01:17 2019 +0200 @@ -119,6 +119,7 @@ import { displayError } from "@/lib/errors"; import { pdfgen, templateLoader } from "@/lib/mixins"; import sanitize from "sanitize-filename"; +import { containsCoordinate } from "ol/extent"; const paperSizes = { // in millimeter, landscape [width, height] @@ -153,13 +154,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 +168,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 } } ] } @@ -187,7 +197,11 @@ }, computed: { ...mapState("application", ["showPdfTool", "logoForPDF"]), - ...mapState("bottlenecks", ["selectedBottleneck", "selectedSurvey"]), + ...mapState("bottlenecks", [ + "selectedBottleneck", + "selectedSurvey", + "bottleneckForPrint" + ]), ...mapState("map", ["isolinesLegendImgDataURL"]), ...mapGetters("map", ["openLayersMap"]), generatePdfLable() { @@ -195,16 +209,37 @@ }, filename() { let filename = "map"; - if (this.selectedBottleneck) { - filename = `BN-${sanitize(this.selectedBottleneck)}`; - if (this.selectedSurvey) { - filename += "-sr" + this.selectedSurvey.date_info.replace(/-/g, ""); + if (this.bottleneckForPrint) { + if (this.isBottleneckInView()) { + filename = `BN-${sanitize(this.bottleneckForPrint)}`; + if (this.selectedSurvey) { + filename += "-sr" + this.selectedSurvey.date_info.replace(/-/g, ""); + } } } return `${filename}-${this.dateForPDF()}.pdf`; } }, methods: { + // Check if the view contains the selected bottleneck + // to avoid including bottleneck info in pdf in case view has changed to another location + isBottleneckInView() { + let map = this.openLayersMap(); + // Get extent of the viewport + let viewExtent = map.getView().calculateExtent(map.getSize()); + let btnExtent = map // Extent of the selected bottleneck + .getLayer("BOTTLENECKS") + .getSource() + .getFeatures() + .find(f => f.get("objnam") === this.bottleneckForPrint) + .getGeometry().extent_; + // Get center of bottleneck from extent + let centerCoordinat = [ + (btnExtent[0] + btnExtent[2]) / 2, + (btnExtent[1] + btnExtent[3]) / 2 + ]; + return containsCoordinate(viewExtent, centerCoordinat); + }, close() { this.$store.commit("application/showPdfTool", false); }, @@ -639,8 +674,9 @@ }, addLegend(position, offset, rounding, brcolor) { if ( - this.selectedBottleneck && + this.bottleneckForPrint && this.selectedSurvey && + this.isBottleneckInView() && this.openLayersMap() .getLayer("BOTTLENECKISOLINE") .getVisible() @@ -680,8 +716,9 @@ }, addBottleneckInfo(position, offset, rounding, color, brcolor) { if ( - this.selectedBottleneck && + this.bottleneckForPrint && this.selectedSurvey && + this.isBottleneckInView() && this.openLayersMap() .getLayer("BOTTLENECKISOLINE") .getVisible() @@ -749,39 +786,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 07f632cd2625 -r 92515c49c566 client/src/components/Popup.vue --- a/client/src/components/Popup.vue Wed Oct 02 11:00:09 2019 +0200 +++ b/client/src/components/Popup.vue Wed Oct 02 11:01:17 2019 +0200 @@ -14,6 +14,23 @@ :class="{ 'p-3': popup.padding !== false }" v-html="popup.content" > +
+
+ + From + + +
+
+ + To + + +
+