Mercurial > gemma
changeset 944:feef06db5d9d geo-style
Merged default into geo-style branch.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 10 Oct 2018 00:16:31 +0200 |
parents | 7899867c7bf5 (current diff) 532c8392048f (diff) |
children | f87e0af0ac7a |
files | schema/gemma.sql |
diffstat | 11 files changed, 126 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/application/Morphtool.vue Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/application/Morphtool.vue Wed Oct 10 00:16:31 2018 +0200 @@ -95,10 +95,11 @@ ...mapGetters("application", ["drawMode"]), ...mapState("mapstore", ["identifiedFeatures", "selectedMorph"]), selectedBottleneck: function() { - if (this.identifiedFeatures) { + if (this.identifiedFeatures && !this.drawMode) { for (let feature of this.identifiedFeatures) { let id = feature.getId(); - if (id && id.replace(/[.][^.]*$/, "") === "bottlenecks") { + // RegExp.prototype.test() works with number, str and undefined + if (/^bottlenecks\./.test(id)) { this.$store.commit("mapstore/setSelectedMorph", null); return feature; } @@ -146,6 +147,9 @@ this.$store.commit("mapstore/setIdentifiedFeatures", []); this.$store.commit("mapstore/setSelectedMorph", null); this.surveyList = null; + if (this.drawMode) { + this.$store.commit("application/toggleDrawModeLine"); + } } } };
--- a/client/src/application/assets/application.scss Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/application/assets/application.scss Wed Oct 10 00:16:31 2018 +0200 @@ -5,7 +5,7 @@ $icon-width: 2rem; $large-offset: 2rem; $layerselect-height: 20rem; -$layerselect-width: 20rem; +$layerselect-width: 22rem; $identify-height: 20rem; $identify-width: 20rem; $offset: 1rem;
--- a/client/src/layers/Identify.vue Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/layers/Identify.vue Wed Oct 10 00:16:31 2018 +0200 @@ -1,7 +1,7 @@ <template> <div class="identifymenu"> <div @click="collapse" class="d-flex flex-column ui-element minimizer"> - <div> + <div :class="infoStyle"> <i class="fa fa-info"></i> </div> </div> @@ -87,11 +87,6 @@ collapsed: true }; }, - watch: { - identifiedFeatures() { - this.collapsed = !this.identifiedFeatures; - } - }, computed: { ...mapState("mapstore", ["identifiedFeatures"]), identifyStyle() { @@ -103,6 +98,13 @@ identifyexpanded: !this.collapsed, identifycollapsed: this.collapsed }; + }, + infoStyle() { + return { + info: true, + "text-info": + this.identifiedFeatures && this.identifiedFeatures.length > 0 + }; } }, methods: {
--- a/client/src/layers/Layerselect.vue Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/layers/Layerselect.vue Wed Oct 10 00:16:31 2018 +0200 @@ -1,9 +1,15 @@ <template> + <div> <div class="form-check d-flex flex-row flex-start selection"> <input class="form-check-input" @change="visibilityToggled" :id="layername" type="checkbox" :checked="isVisible"> <LegendElement :layername="layername" :layerindex="layerindex"></LegendElement> <label class="layername form-check-label">{{layername}}</label> </div> + <div v-if="isVisible && (layername == 'Bottleneck isolines')" class="card"> + <img src="../application/assets/legend_contour_lines.png" + class="rounded mx-auto d-block"> + </div> + </div> </template> <style lang="scss">
--- a/client/src/map/Maplayer.vue Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/map/Maplayer.vue Wed Oct 10 00:16:31 2018 +0200 @@ -33,11 +33,12 @@ import { WFS, GeoJSON } from "ol/format.js"; // import GeometryType from "ol/geom/GeometryType.js"; import LineString from "ol/geom/LineString.js"; +import Point from "ol/geom/Point.js"; import Draw from "ol/interaction/Draw.js"; import { Vector as VectorLayer } from "ol/layer.js"; import { Vector as VectorSource } from "ol/source.js"; import { getLength } from "ol/sphere.js"; -import { Stroke, Style, Fill } from "ol/style.js"; +import { Icon, Stroke, Style, Fill } from "ol/style.js"; import distance from "@turf/distance"; import { @@ -83,9 +84,49 @@ createVectorSource() { this.vectorSource = new VectorSource({ wrapX: false }); }, + drawStyleFunction(feature) { + // adapted from OpenLayer's LineString Arrow Example + var geometry = feature.getGeometry(); + var styles = [ + // linestring + new Style({ + stroke: new Stroke({ + color: "#369aca", + width: 2 + }) + }) + ]; + + geometry.forEachSegment(function(start, end) { + var dx = end[0] - start[0]; + var dy = end[1] - start[1]; + var rotation = Math.atan2(dy, dx); + // arrows + styles.push( + new Style({ + geometry: new Point(end), + image: new Icon({ + // we need to make sure the image is loaded by Vue Loader + src: require("../application/assets/linestring_arrow.png"), + // fiddling with the anchor's y value does not help to + // position the image more centered on the line ending, as the + // default line style seems to be slightly uncentered in the + // anti-aliasing, but the image is not placed with subpixel + // precision + anchor: [0.75, 0.5], + rotateWithView: true, + rotation: -rotation + }) + }) + ); + }); + + return styles; + }, createVectorLayer() { this.vectorLayer = new VectorLayer({ - source: this.vectorSource + source: this.vectorSource, + style: this.drawStyleFunction }); }, removeCurrentInteraction() { @@ -292,7 +333,6 @@ }; return loader; }, - // TODOISO call if new survey is selected updateBottleneckFilter(bottleneck_id, datestr) { console.log("updating filter with", bottleneck_id, datestr); var layer = this.getLayerByName("Bottleneck isolines"); @@ -503,8 +543,6 @@ layer.data.getSource() ) ); - // TODOSTYLE add backend request (like search for 'HTTP') - // and use result to construct a new style like HTTP.get("/system/style/Bottlenecks/stroke", { headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) @@ -538,9 +576,7 @@ window.addEventListener("afterprint", this.onAfterPrint); // so none is shown - // this.updateBottleneckFilter("1999-10-01", "AT_Bottleneck_44"); - // test date - this.updateBottleneckFilter("AT_Bottleneck_44", "2018-08-30"); + this.updateBottleneckFilter("does_not_exist", "1999-10-01"); this.activateIdentifyMode(); } };
--- a/client/src/map/store.js Mon Oct 08 14:53:17 2018 +0200 +++ b/client/src/map/store.js Wed Oct 10 00:16:31 2018 +0200 @@ -32,33 +32,6 @@ isVisible: true }, { - name: "Bottleneck isolines", - data: new TileLayer({ - source: new TileWMS({ - preload: 0, - projection: "EPSG:3857", - url: window.location.origin + "/api/internal/wms", - params: { - LAYERS: "sounding_results_contour_lines_geoserver", - VERSION: "1.1.1", - TILED: true - }, - tileLoadFunction: function(tile, src) { - // console.log("calling for", tile, src); - HTTP.get(src, { - headers: { - "X-Gemma-Auth": localStorage.getItem("token") - }, - responseType: "blob" - }).then(response => { - tile.getImage().src = URL.createObjectURL(response.data); - }); - } // TODO tile.setState(TileState.ERROR); - }) - }), - isVisible: true - }, - { name: "Fairway Dimensions", data: new VectorLayer({ source: new VectorSource(), @@ -143,6 +116,51 @@ isVisible: false }, { + name: "Bottlenecks", + data: new VectorLayer({ + source: new VectorSource({ + strategy: bboxStrategy + }), + style: new Style({ + stroke: new Stroke({ + color: "rgba(230, 230, 10, .8)", + width: 4 + }), + fill: new Fill({ + color: "rgba(230, 230, 10, .3)" + }) + }) + }), + isVisible: true + }, + { + name: "Bottleneck isolines", + data: new TileLayer({ + source: new TileWMS({ + preload: 0, + projection: "EPSG:3857", + url: window.location.origin + "/api/internal/wms", + params: { + LAYERS: "sounding_results_contour_lines_geoserver", + VERSION: "1.1.1", + TILED: true + }, + tileLoadFunction: function(tile, src) { + // console.log("calling for", tile, src); + HTTP.get(src, { + headers: { + "X-Gemma-Auth": localStorage.getItem("token") + }, + responseType: "blob" + }).then(response => { + tile.getImage().src = URL.createObjectURL(response.data); + }); + } // TODO tile.setState(TileState.ERROR); + }) + }), + isVisible: false + }, + { name: "Distance marks, Axis", forLegendStyle: { point: true, resolution: 8 }, data: new VectorLayer({ @@ -177,24 +195,6 @@ } }), isVisible: true - }, - { - name: "Bottlenecks", - data: new VectorLayer({ - source: new VectorSource({ - strategy: bboxStrategy - }), - style: new Style({ - stroke: new Stroke({ - color: "rgba(230, 230, 10, .8)", - width: 4 - }), - fill: new Fill({ - color: "rgba(230, 230, 10, .3)" - }) - }) - }), - isVisible: true } ], // note that some identified features may not have an id
--- a/pkg/octree/vertex.go Mon Oct 08 14:53:17 2018 +0200 +++ b/pkg/octree/vertex.go Wed Oct 10 00:16:31 2018 +0200 @@ -425,28 +425,23 @@ for head, lines := range heads { for i, line := range *lines { tail := quant(line[len(line)-1]) - if hs := heads[tail]; hs != nil { + for hs := heads[tail]; hs != nil && len(*hs) > 0; hs = heads[tail] { l := len(*hs) last := (*hs)[l-1] - if l == 1 { - delete(heads, tail) - } else { - (*hs)[l-1] = nil - *hs = (*hs)[:l-1] - } + (*hs)[l-1] = nil + *hs = (*hs)[:l-1] line = line.Join(last) - if head == quant(line[len(line)-1]) { // its a ring + if tail = quant(line[len(line)-1]); head == tail { // its a ring out = append(out, line) // remove from current lines copy((*lines)[i:], (*lines)[i+1:]) (*lines)[len(*lines)-1] = nil *lines = (*lines)[:len(*lines)-1] - } else { - // overwrite in current lines - (*lines)[i] = line + goto again } - goto again + // overwrite in current lines + (*lines)[i] = line } } }
--- a/schema/gemma.sql Mon Oct 08 14:53:17 2018 +0200 +++ b/schema/gemma.sql Wed Oct 10 00:16:31 2018 +0200 @@ -107,10 +107,12 @@ reference_water_level varchar(20) PRIMARY KEY ); -CREATE TABLE distance_mark_functions ( - -- XXX: Redundant information to object code in isrs code of dist. mark - distance_mark_function varchar(8) PRIMARY KEY +CREATE TABLE catdis ( + catdis smallint PRIMARY KEY + -- TODO: Do we need name and/or definition from IENC feature catalogue? + -- (see page 171 of edition 2.3) ); +INSERT INTO catdis VALUES (1), (2), (3), (4); CREATE TABLE position_codes ( position_code char(2) PRIMARY KEY @@ -287,10 +289,7 @@ CREATE TABLE distance_marks ( location_code isrs PRIMARY KEY, geom geography(POINT, 4326) NOT NULL, - distance_mark_function varchar(8) - NOT NULL REFERENCES distance_mark_functions, - -- XXX: attribute "function" in DRC 2.1.7 as well as CATDIS seem - -- to encode the same thing as the object code in ISRS location code. + catdis smallint NOT NULL REFERENCES catdis, position_code char(2) NOT NULL REFERENCES position_codes ) @@ -300,7 +299,7 @@ CREATE VIEW waterway.distance_marks_geoserver AS SELECT location_code::VARCHAR, geom::Geometry(POINT, 4326), - distance_mark_function, + catdis, position_code, (location_code).hectometre FROM waterway.distance_marks
--- a/schema/isrs.sql Mon Oct 08 14:53:17 2018 +0200 +++ b/schema/isrs.sql Wed Oct 10 00:16:31 2018 +0200 @@ -39,7 +39,8 @@ IF char_length(isrs_text) <> isrs_len THEN RAISE 'ISRS location code must be % characters long', isrs_len - USING ERRCODE = 'invalid_parameter_value'; + USING ERRCODE = 'invalid_parameter_value', + DETAIL = 'Failing value: ' || isrs_text; ELSE RETURN CAST(( substring(isrs_text from 1 for 2),