annotate client/src/map/Maplayer.vue @ 1240:9b0a7b3ea297

inport sounding results
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 20 Nov 2018 17:37:30 +0100
parents 442399fc1b71
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 <template>
621
b17a4482d07d feat: UI adaptation of 4 slots
Thomas Junk <thomas.junk@intevation.de>
parents: 620
diff changeset
2 <div id="map" :class="mapStyle"></div>
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 </template>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
5 <style lang="sass" scoped>
1197
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1191
diff changeset
6 .nocursor
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1191
diff changeset
7 cursor: none
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1191
diff changeset
8
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
9 .mapsplit
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
10 height: 50vh
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
12 .mapfull
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
13 height: 100vh
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
14
1191
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
15 @media print
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
16 .mapfull
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
17 width: 2000px
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
18 height: 2828px
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
19
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
20 .mapsplit
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
21 width: 2000px
b23622905a3f switched entirely to sass instead of scss
Markus Kottlaender <markus@intevation.de>
parents: 1185
diff changeset
22 height: 2828px
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
23 </style>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
24
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
25 <script>
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
26 /*
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
27 * This is Free Software under GNU Affero General Public License v >= 3.0
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
28 * without warranty, see README.md and license for details.
1062
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
29 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
30 * SPDX-License-Identifier: AGPL-3.0-or-later
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
31 * License-Filename: LICENSES/AGPL-3.0.txt
1062
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
32 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
33 * Copyright (C) 2018 by via donau
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
34 * – Österreichische Wasserstraßen-Gesellschaft mbH
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
35 * Software engineering by Intevation GmbH
1062
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
36 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
37 * Author(s):
1062
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
38 * * Thomas Junk <thomas.junk@intevation.de>
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
39 * * Bernhard E. Reiter <bernhard.reiter@intevation.de>
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
40 */
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
41 import { HTTP } from "../application/lib/http";
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
42 import { mapGetters, mapState } from "vuex";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
43 import "ol/ol.css";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
44 import { Map, View } from "ol";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
45 import { WFS, GeoJSON } from "ol/format.js";
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
46 import { Stroke, Style, Fill } from "ol/style.js";
1159
f498494fceb5 zoom to bottleneck when clicked on map
Markus Kottlaender <markus@intevation.de>
parents: 1156
diff changeset
47 import { getCenter } from "ol/extent";
843
d2aa972df342 client: add example for setting style
Bernhard Reiter <bernhard@intevation.de>
parents: 842
diff changeset
48
848
22f7d33eee65 Make eslint happy again.
Sascha Wilde <wilde@intevation.de>
parents: 843
diff changeset
49 /* for the sake of debugging */
22f7d33eee65 Make eslint happy again.
Sascha Wilde <wilde@intevation.de>
parents: 843
diff changeset
50 /* eslint-disable no-console */
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
51 export default {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
52 name: "maplayer",
1062
d3bdad8ed8d3 client: simply code structure and add author
Bernhard Reiter <bernhard@intevation.de>
parents: 1043
diff changeset
53 props: ["lat", "long", "zoom", "split"],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
54 data() {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
55 return {
1140
2e06bc53b002 separating line/polygon/cut tools in UI
Markus Kottlaender <markus@intevation.de>
parents: 1139
diff changeset
56 projection: "EPSG:3857"
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
57 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
58 },
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
59 computed: {
1122
a4c74a95c177 minor store refactoring
Markus Kottlaender <markus@intevation.de>
parents: 1121
diff changeset
60 ...mapGetters("map", ["getLayerByName"]),
1238
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
61 ...mapState("map", [
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
62 "layers",
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
63 "openLayersMap",
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
64 "lineTool",
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
65 "polygonTool",
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
66 "cutTool"
442399fc1b71 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1237
diff changeset
67 ]),
1111
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
68 ...mapState("bottlenecks", ["selectedSurvey"]),
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
69 mapStyle() {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
70 return {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
71 mapfull: !this.split,
1197
49740dcba52c changed cut tool style
Markus Kottlaender <markus@intevation.de>
parents: 1191
diff changeset
72 mapsplit: this.split,
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
73 nocursor: this.hasActiveInteractions
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
74 };
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
75 },
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
76 hasActiveInteractions() {
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
77 return (
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
78 (this.lineTool && this.lineTool.getActive()) ||
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
79 (this.polygonTool && this.polygonTool.getActive()) ||
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
80 (this.cutTool && this.cutTool.getActive())
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
81 );
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
82 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
83 },
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
84 methods: {
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
85 identify(coordinate, pixel) {
1237
74562dc29e10 refactored drawtool
Markus Kottlaender <markus@intevation.de>
parents: 1197
diff changeset
86 if (!this.hasActiveInteractions) {
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
87 this.$store.commit("map/setIdentifiedFeatures", []);
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
88 // checking our WFS layers
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
89 var features = this.openLayersMap.getFeaturesAtPixel(pixel);
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
90 if (features) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
91 this.$store.commit("map/setIdentifiedFeatures", features);
1144
5f98d0c9d738 linted code
Markus Kottlaender <markus@intevation.de>
parents: 1143
diff changeset
92
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
93 // get selected bottleneck from identified features
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
94 for (let feature of features) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
95 let id = feature.getId();
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
96 // RegExp.prototype.test() works with number, str and undefined
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
97 if (/^bottlenecks\./.test(id)) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
98 this.$store.dispatch(
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
99 "bottlenecks/setSelectedBottleneck",
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
100 feature.get("objnam")
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
101 );
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
102 this.$store.commit("map/moveMap", {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
103 coordinates: getCenter(
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
104 feature
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
105 .getGeometry()
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
106 .clone()
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
107 .transform("EPSG:3857", "EPSG:4326")
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
108 .getExtent()
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
109 ),
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
110 zoom: 17,
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
111 preventZoomOut: true
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
112 });
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
113 }
1111
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
114 }
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
115 }
770
c12ec7fde3f2 client: add simple identify top area box
Bernhard Reiter <bernhard@intevation.de>
parents: 767
diff changeset
116
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
117 // DEBUG output and example how to remove the GeometryName
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
118 /*
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
119 for (let feature of features) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
120 console.log("Identified:", feature.getId());
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
121 for (let key of feature.getKeys()) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
122 if (key != feature.getGeometryName()) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
123 console.log(key, feature.get(key));
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
124 }
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
125 }
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
126 }
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
127 */
765
c1baaff348b0 client: add code to identify WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 764
diff changeset
128
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
129 // trying the GetFeatureInfo way for WMS
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
130 var wmsSource = this.getLayerByName(
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
131 "Inland ECDIS chart Danube"
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
132 ).data.getSource();
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
133 var url = wmsSource.getGetFeatureInfoUrl(
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
134 coordinate,
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
135 100 /* resolution */,
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
136 "EPSG:3857",
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
137 // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
138 { INFO_FORMAT: "text/plain" }
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
139 );
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
140
1160
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
141 if (url) {
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
142 // cannot directly query here because of SOP
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
143 console.log("GetFeatureInfo url:", url);
c8c26912754c disable identifying when draw/cut mode are active
Markus Kottlaender <markus@intevation.de>
parents: 1159
diff changeset
144 }
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
145 }
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
146 },
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
147 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
148 // build a function to be used for VectorSource.setLoader()
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
149 // make use of WFS().writeGetFeature to build the request
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
150 // and use our HTTP library to actually do it
703
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
151 // NOTE: a) the geometryName has to be given in featureRequestOptions,
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
152 // because we want to load depending on the bbox
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
153 // b) the VectorSource has to have the option strategy: bbox
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
154 featureRequestOptions["outputFormat"] = "application/json";
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
155 var loader = function(extent, resolution, projection) {
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
156 featureRequestOptions["bbox"] = extent;
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
157 featureRequestOptions["srsName"] = projection.getCode();
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
158 var featureRequest = new WFS().writeGetFeature(featureRequestOptions);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
159 // DEBUG console.log(featureRequest);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
160 HTTP.post(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
161 endpoint,
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
162 new XMLSerializer().serializeToString(featureRequest),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
163 {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
164 headers: {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
165 "X-Gemma-Auth": localStorage.getItem("token"),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
166 "Content-type": "text/xml; charset=UTF-8"
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
167 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
168 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
169 )
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
170 .then(response => {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
171 var features = new GeoJSON().readFeatures(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
172 JSON.stringify(response.data)
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
173 );
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
174 vectorSource.addFeatures(features);
754
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
175 // console.log(
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
176 // "loaded",
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
177 // features.length,
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
178 // featureRequestOptions.featureTypes,
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
179 // "features"
105c421f99b1 refac: small improvements to code structure
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
180 // );
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
181 // DEBUG console.log("loaded ", features, "for", vectorSource);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
182 // eslint-disable-next-line
713
badbc0207418 feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents: 709
diff changeset
183 })
badbc0207418 feat: systeminformation feature added
Thomas Junk <thomas.junk@intevation.de>
parents: 709
diff changeset
184 .catch(() => {
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
185 vectorSource.removeLoadedExtent(extent);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
186 });
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
187 };
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
188 return loader;
842
ee6f127f573c client: add first prototype for bottleneck iso layer
Bernhard Reiter <bernhard@intevation.de>
parents: 832
diff changeset
189 },
860
38b682eaa7b1 client: add updateing of bottleneck filter
Bernhard Reiter <bernhard@intevation.de>
parents: 859
diff changeset
190 updateBottleneckFilter(bottleneck_id, datestr) {
38b682eaa7b1 client: add updateing of bottleneck filter
Bernhard Reiter <bernhard@intevation.de>
parents: 859
diff changeset
191 console.log("updating filter with", bottleneck_id, datestr);
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
192 var layer = this.getLayerByName("Bottleneck isolines");
918
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
193 var wmsSrc = layer.data.getSource();
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
194
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
195 if (bottleneck_id != "does_not_exist") {
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
196 wmsSrc.updateParams({
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
197 cql_filter:
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
198 "date_info='" +
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
199 datestr +
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
200 "' AND bottleneck_id='" +
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
201 bottleneck_id +
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
202 "'"
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
203 });
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
204 layer.isVisible = true;
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
205 layer.data.setVisible(true);
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
206 } else {
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
207 layer.isVisible = false;
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
208 layer.data.setVisible(false);
054561be4d68 Switch bottleneck isolines layer off, when selection is empty.
Sascha Wilde <wilde@intevation.de>
parents: 902
diff changeset
209 }
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
210 },
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
211 onBeforePrint(/* evt */) {
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
212 // console.log("onBeforePrint(", evt ,")");
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
213 //
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
214 // the following code shows how to get the current map canvas
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
215 // and change it, however this does not work well enough, as
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
216 // another mechanism seems to update the size again before the rendering
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
217 // for printing is done:
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
218 // console.log(this.openLayersMap.getViewport());
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
219 // var canvas = this.openLayersMap.getViewport().getElementsByTagName("canvas")[0];
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
220 // console.log(canvas);
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
221 // canvas.width=1000;
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
222 // canvas.height=1414;
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
223 //
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
224 // An experiment which also did not work:
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
225 // this.openLayersMap.setSize([1000, 1414]); // estimate portait DIN A4
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
226 //
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
227 // according to documentation
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
228 // http://openlayers.org/en/latest/apidoc/module-ol_PluggableMap-PluggableMap.html#updateSize
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
229 // "Force a recalculation of the map viewport size. This should be called when third-party code changes the size of the map viewport."
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
230 // but did not help
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
231 // this.openLayersMap.updateSize();
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
232 },
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
233 onAfterPrint(/* evt */) {
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
234 // could be used to undo changes that have been done for printing
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
235 // though https://www.tjvantoll.com/2012/06/15/detecting-print-requests-with-javascript/
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
236 // reported that this was not feasable (back then).
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
237 // console.log("onAfterPrint(", evt, ")");
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
238 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
239 },
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
240 watch: {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
241 split() {
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
242 const map = this.openLayersMap;
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
243 this.$nextTick(() => {
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
244 map.updateSize();
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
245 });
860
38b682eaa7b1 client: add updateing of bottleneck filter
Bernhard Reiter <bernhard@intevation.de>
parents: 859
diff changeset
246 },
1111
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
247 selectedSurvey(newSelectedSurvey) {
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
248 if (newSelectedSurvey) {
861
aa4aaf04d41e client: improve update of bottleneck filters
Bernhard Reiter <bernhard@intevation.de>
parents: 860
diff changeset
249 this.updateBottleneckFilter(
1111
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
250 newSelectedSurvey.bottleneck_id,
f106aee673e7 selected bottleneck and surveys now handled by bottleneck store
Markus Kottlaender <markus@intevation.de>
parents: 1104
diff changeset
251 newSelectedSurvey.date_info
861
aa4aaf04d41e client: improve update of bottleneck filters
Bernhard Reiter <bernhard@intevation.de>
parents: 860
diff changeset
252 );
aa4aaf04d41e client: improve update of bottleneck filters
Bernhard Reiter <bernhard@intevation.de>
parents: 860
diff changeset
253 } else {
aa4aaf04d41e client: improve update of bottleneck filters
Bernhard Reiter <bernhard@intevation.de>
parents: 860
diff changeset
254 this.updateBottleneckFilter("does_not_exist", "1999-10-01");
aa4aaf04d41e client: improve update of bottleneck filters
Bernhard Reiter <bernhard@intevation.de>
parents: 860
diff changeset
255 }
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
256 }
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
257 },
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
258 mounted() {
783
ab9604a46075 client: add move after clicking search result
Bernhard Reiter <bernhard@intevation.de>
parents: 782
diff changeset
259 let map = new Map({
1121
035dc35e1dfc moved draw layer in map store's layers property
Markus Kottlaender <markus@intevation.de>
parents: 1115
diff changeset
260 layers: [...this.layers.map(x => x.data)],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
261 target: "map",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
262 controls: [],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
263 view: new View({
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
264 center: [this.long, this.lat],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
265 zoom: this.zoom,
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
266 projection: this.projection
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
267 })
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
268 });
1113
595654ad3f66 renamed mapstore to map (like other stores)
Markus Kottlaender <markus@intevation.de>
parents: 1112
diff changeset
269 this.$store.commit("map/setOpenLayersMap", map);
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
270
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
271 // TODO make display of layers more dynamic, e.g. from a list
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
272
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
273 // loading the full WFS layer, by not setting the loader function
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
274 // and without bboxStrategy
1103
dfe3966bb308 removed unnecessary methods and renamed variable
Markus Kottlaender <markus@intevation.de>
parents: 1071
diff changeset
275 var featureRequest = new WFS().writeGetFeature({
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
276 srsName: "EPSG:3857",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
277 featureNS: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
278 featurePrefix: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
279 featureTypes: ["fairway_dimensions"],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
280 outputFormat: "application/json"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
281 });
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
282
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
283 // NOTE: loading the full fairway_dimensions makes sure
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
284 // that all are available for the intersection with the profile
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
285 HTTP.post(
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
286 "/internal/wfs",
1103
dfe3966bb308 removed unnecessary methods and renamed variable
Markus Kottlaender <markus@intevation.de>
parents: 1071
diff changeset
287 new XMLSerializer().serializeToString(featureRequest),
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
288 {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
289 headers: {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
290 "X-Gemma-Auth": localStorage.getItem("token"),
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
291 "Content-type": "text/xml; charset=UTF-8"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
292 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
293 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
294 ).then(response => {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
295 var features = new GeoJSON().readFeatures(JSON.stringify(response.data));
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
296 var vectorSrc = this.getLayerByName(
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
297 "Fairway Dimensions"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
298 ).data.getSource();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
299 vectorSrc.addFeatures(features);
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
300 // would scale to the extend of all resulting features
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
301 // this.openLayersMap.getView().fit(vectorSrc.getExtent());
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
302 });
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
303
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
304 // load following layers with bboxStrategy (using our request builder)
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
305 var layer = null;
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
306
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
307 layer = this.getLayerByName("Waterway Area");
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
308 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
309 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
310 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
311 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
312 featureTypes: ["ienc_wtware"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
313 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
314 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
315 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
316 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
317 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
318 );
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
319
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
320 layer = this.getLayerByName("Waterway Axis");
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
321 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
322 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
323 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
324 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
325 featureTypes: ["ienc_wtwaxs"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
326 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
327 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
328 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
329 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
330 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
331 );
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
332
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
333 layer = this.getLayerByName("Distance marks");
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
334 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
335 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
336 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
337 featurePrefix: "ws-wamos",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
338 featureTypes: ["ienc_dismar"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
339 geometryName: "geom" //,
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
340 /* restrict loading approximately to extend of danube in Austria */
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
341 // filter: bboxFilter("geom", [13.3, 48.0, 17.1, 48.6], "EPSG:4326")
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
342 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
343 "/external/d4d",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
344 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
345 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
346 );
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
347 layer.data.setVisible(layer.isVisible);
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
348
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
349 layer = this.getLayerByName("Distance marks, Axis");
733
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
350 layer.data.getSource().setLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
351 this.buildVectorLoader(
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
352 {
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
353 featureNS: "gemma",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
354 featurePrefix: "gemma",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
355 featureTypes: ["distance_marks_geoserver"],
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
356 geometryName: "geom"
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
357 },
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
358 "/internal/wfs",
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
359 layer.data.getSource()
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
360 )
e57955c1996f client: improve code structure
Bernhard Reiter <bernhard@intevation.de>
parents: 716
diff changeset
361 );
745
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
362
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
363 layer = this.getLayerByName("Waterway Area, named");
745
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
364 layer.data.getSource().setLoader(
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
365 this.buildVectorLoader(
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
366 {
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
367 featureNS: "gemma",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
368 featurePrefix: "gemma",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
369 featureTypes: ["hydro_seaare"],
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
370 geometryName: "geom"
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
371 },
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
372 "/external/d4d",
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
373 layer.data.getSource()
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
374 )
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
375 );
f2691e0d4970 client: add wfs layer for named waterway areas.
Bernhard Reiter <bernhard@intevation.de>
parents: 738
diff changeset
376 layer.data.setVisible(layer.isVisible);
764
a6a8fe89eb84 client: add hooks for identify mode
Bernhard Reiter <bernhard@intevation.de>
parents: 754
diff changeset
377
957
93364f153da4 Backed out changeset c2b03f4755b6
Thomas Junk <thomas.junk@intevation.de>
parents: 956
diff changeset
378 layer = this.getLayerByName("Bottlenecks");
790
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
379 layer.data.getSource().setLoader(
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
380 this.buildVectorLoader(
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
381 {
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
382 featureNS: "gemma",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
383 featurePrefix: "gemma",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
384 featureTypes: ["bottlenecks"],
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
385 geometryName: "area"
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
386 },
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
387 "/internal/wfs",
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
388 layer.data.getSource()
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
389 )
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
390 );
858
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
391 HTTP.get("/system/style/Bottlenecks/stroke", {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
392 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
393 })
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
394 .then(response => {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
395 this.btlnStrokeC = response.data.code;
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
396 HTTP.get("/system/style/Bottlenecks/fill", {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
397 headers: { "X-Gemma-Auth": localStorage.getItem("token") }
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
398 })
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
399 .then(response => {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
400 this.btlnFillC = response.data.code;
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
401 var newstyle = new Style({
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
402 stroke: new Stroke({
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
403 color: this.btlnStrokeC,
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
404 width: 4
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
405 }),
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
406 fill: new Fill({
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
407 color: this.btlnFillC
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
408 })
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
409 });
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
410 layer.data.setStyle(newstyle);
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
411 })
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
412 .catch(error => {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
413 console.log(error);
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
414 });
848
22f7d33eee65 Make eslint happy again.
Sascha Wilde <wilde@intevation.de>
parents: 843
diff changeset
415 })
858
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
416 .catch(error => {
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
417 console.log(error);
e5ac0fb0c1c5 map styling: Very ugly hack to read bottleneck style from server.
Sascha Wilde <wilde@intevation.de>
parents: 848
diff changeset
418 });
790
1b82ae5e637e client: add bottleneck layer with first styling
Bernhard Reiter <bernhard@intevation.de>
parents: 783
diff changeset
419
879
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
420 window.addEventListener("beforeprint", this.onBeforePrint);
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
421 window.addEventListener("afterprint", this.onAfterPrint);
52fe3e20f750 client: improve print styling
Bernhard Reiter <bernhard@intevation.de>
parents: 865
diff changeset
422
842
ee6f127f573c client: add first prototype for bottleneck iso layer
Bernhard Reiter <bernhard@intevation.de>
parents: 832
diff changeset
423 // so none is shown
938
fe923c8ef08f client: add static legend image to contour_lines
Bernhard Reiter <bernhard@intevation.de>
parents: 918
diff changeset
424 this.updateBottleneckFilter("does_not_exist", "1999-10-01");
1104
9c15e3bf8066 removed unnecessary function and reduced code a bit
Markus Kottlaender <markus@intevation.de>
parents: 1103
diff changeset
425 this.openLayersMap.on(["singleclick", "dblclick"], event => {
9c15e3bf8066 removed unnecessary function and reduced code a bit
Markus Kottlaender <markus@intevation.de>
parents: 1103
diff changeset
426 this.identify(event.coordinate, event.pixel);
9c15e3bf8066 removed unnecessary function and reduced code a bit
Markus Kottlaender <markus@intevation.de>
parents: 1103
diff changeset
427 });
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
428 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
429 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
430 </script>