annotate client/src/map/Maplayer.vue @ 705:6aa09d12157f

client: add detection of drawend * Add a function to listen for the end of the draw interaction. Log the result for now.
author Bernhard Reiter <bernhard@intevation.de>
date Fri, 21 Sep 2018 10:25:02 +0200
parents e9c28c42c927
children d47fa556a3e8
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
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 <style lang="scss">
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
6 .mapsplit {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
7 height: 50vh;
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
10 .mapfull {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 height: 100vh;
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 </style>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
15 <script>
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 import { HTTP } from "../application/lib/http";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
17 import "ol/ol.css";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18 import { Map, View } from "ol";
663
db749c02127c Client: slightly improve wfs loading for marks
Bernhard Reiter <bernhard@intevation.de>
parents: 659
diff changeset
19 import { bbox as bboxFilter } from "ol/format/filter.js";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
20 import { WFS, GeoJSON } from "ol/format.js";
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
21 import { mapGetters } from "vuex";
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
22 import Draw from "ol/interaction/Draw.js";
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
23 import { Vector as VectorSource } from "ol/source.js";
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
24 import { Vector as VectorLayer } from "ol/layer.js";
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
25
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
26 export default {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
27 name: "maplayer",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
28 props: ["drawMode", "lat", "long", "zoom", "split"],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
29 data() {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
30 return {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
31 projection: "EPSG:3857",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
32 openLayersMap: null,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
33 interaction: null,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
34 vectorLayer: null,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
35 vectorSource: null
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
36 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
37 },
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
38 computed: {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
39 ...mapGetters("mapstore", ["layers"]),
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
40 mapStyle() {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
41 return {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
42 mapfull: !this.split,
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
43 mapsplit: this.split
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
44 };
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
45 },
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
46 layerData() {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
47 const l = this.layers.map(x => {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
48 return x.data;
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
49 });
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
50 return [...l, this.vectorLayer];
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
51 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
52 },
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
53 methods: {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
54 createVectorSource() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
55 this.vectorSource = new VectorSource({ wrapX: false });
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
56 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
57 createVectorLayer() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
58 this.vectorLayer = new VectorLayer({
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
59 source: this.vectorSource
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
60 });
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
61 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
62 removeCurrentInteraction() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
63 this.openLayersMap.removeInteraction(this.interaction);
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
64 this.interaction = null;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
65 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
66 createInteraction() {
705
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
67 var draw = new Draw({
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
68 source: this.vectorSource,
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
69 type: this.drawMode
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
70 });
705
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
71 draw.on("drawend", this.drawEnd);
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
72 return draw;
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
73 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
74 activateInteraction() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
75 const interaction = this.createInteraction(this.drawMode);
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
76 this.interaction = interaction;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
77 this.openLayersMap.addInteraction(interaction);
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
78 },
705
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
79 drawEnd(event) {
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
80 console.log(event);
6aa09d12157f client: add detection of drawend
Bernhard Reiter <bernhard@intevation.de>
parents: 703
diff changeset
81 },
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
82 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
83 // 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
84 // 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
85 // and use our HTTP library to actually do it
703
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
86 // NOTE: a) the geometryName has to be given in featureRequestOptions,
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
87 // because we want to load depending on the bbox
e9c28c42c927 client: improve WFS loader
Bernhard Reiter <bernhard@intevation.de>
parents: 702
diff changeset
88 // 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
89 featureRequestOptions["outputFormat"] = "application/json";
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
90 var loader = function(extent, resolution, projection) {
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
91 featureRequestOptions["bbox"] = extent;
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
92 featureRequestOptions["srsName"] = projection.getCode();
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
93 var featureRequest = new WFS().writeGetFeature(featureRequestOptions);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
94 // DEBUG console.log(featureRequest);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
95 HTTP.post(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
96 endpoint,
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
97 new XMLSerializer().serializeToString(featureRequest),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
98 {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
99 headers: {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
100 "X-Gemma-Auth": localStorage.getItem("token"),
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
101 "Content-type": "text/xml; charset=UTF-8"
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
102 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
103 }
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
104 )
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
105 .then(response => {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
106 var features = new GeoJSON().readFeatures(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
107 JSON.stringify(response.data)
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
108 );
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
109 vectorSource.addFeatures(features);
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
110 console.log(
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
111 "loaded",
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
112 features.length,
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
113 featureRequestOptions.featureTypes,
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
114 "features"
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
115 );
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
116 // DEBUG console.log("loaded ", features, "for", vectorSource);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
117 // eslint-disable-next-line
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
118 }).catch(error => {
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
119 vectorSource.removeLoadedExtent(extent);
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
120 });
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
121 };
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
122 return loader;
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
123 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
124 },
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
125 watch: {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
126 drawMode() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
127 if (this.interaction) {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
128 this.removeCurrentInteraction();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
129 } else {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
130 this.activateInteraction();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
131 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
132 },
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
133 split() {
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
134 const map = this.openLayersMap;
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
135 this.$nextTick(() => {
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
136 map.updateSize();
594
6987b5c926b8 fix: leveraging vue.nexttick instead of timeout
Thomas Junk <thomas.junk@intevation.de>
parents: 593
diff changeset
137 });
593
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
138 }
c4a4dc612191 feat: Toggleable fairway profile
Thomas Junk <thomas.junk@intevation.de>
parents: 585
diff changeset
139 },
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
140 mounted() {
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
141 this.createVectorSource();
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
142 this.createVectorLayer();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
143 this.openLayersMap = new Map({
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
144 layers: this.layerData,
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
145 target: "map",
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
146 controls: [],
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
147 view: new View({
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
148 center: [this.long, this.lat],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
149 zoom: this.zoom,
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
150 projection: this.projection
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
151 })
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
152 });
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
153
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
154 var featureRequest2 = new WFS().writeGetFeature({
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
155 // srsName: "urn:ogc:def:crs:EPSG::4326",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
156 srsName: "EPSG:3857",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
157 featureNS: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
158 featurePrefix: "gemma",
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
159 featureTypes: ["fairway_dimensions"],
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
160 outputFormat: "application/json"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
161 });
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
162
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
163 HTTP.post(
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
164 "/internal/wfs",
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
165 new XMLSerializer().serializeToString(featureRequest2),
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
166 {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
167 headers: {
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
168 "X-Gemma-Auth": localStorage.getItem("token"),
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
169 "Content-type": "text/xml; charset=UTF-8"
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
170 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
171 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
172 ).then(response => {
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
173 var features = new GeoJSON().readFeatures(JSON.stringify(response.data));
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
174 var vectorSrc = this.layers[2].data.getSource();
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
175 vectorSrc.addFeatures(features);
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
176 // would scale to the extend of all resulting features
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
177 // this.openLayersMap.getView().fit(vectorSrc.getExtent());
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
178 });
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
179
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
180 // FIXME hardwired for now
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
181 var featureRequestOptions3 = {
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
182 featurePrefix: "ws-wamos",
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
183 featureTypes: ["ienc_wtware"],
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
184 geometryName: "geom"
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
185 };
620
ef00684e021f client: add showing special buoys
Bernhard Reiter <bernhard@intevation.de>
parents: 594
diff changeset
186
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
187 this.layers[3].data
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
188 .getSource()
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
189 .setLoader(
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
190 this.buildVectorLoader(
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
191 featureRequestOptions3,
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
192 "/external/d4d",
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
193 this.layers[3].data.getSource()
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
194 )
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
195 );
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
196
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
197 // FIXME hardwired for now
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
198 var featureRequest4 = new WFS().writeGetFeature({
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
199 featurePrefix: "ws-wamos",
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
200 featureTypes: ["ienc_wtwaxs"],
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
201 outputFormat: "application/json"
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
202 });
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
203
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
204 HTTP.post(
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
205 "/external/d4d",
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
206 new XMLSerializer().serializeToString(featureRequest4),
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
207 {
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
208 headers: {
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
209 "X-Gemma-Auth": localStorage.getItem("token"),
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
210 "Content-type": "text/xml; charset=UTF-8"
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
211 }
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
212 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
213 ).then(response => {
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
214 var features = new GeoJSON().readFeatures(JSON.stringify(response.data));
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents: 630
diff changeset
215 var vectorSrc = this.layers[4].data.getSource();
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
216 vectorSrc.addFeatures(features);
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
217 });
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
218
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
219 // FIXME this is hardwired for now to try for an external point layer
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
220 var featureRequestOptions5 = {
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
221 featurePrefix: "ws-wamos",
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
222 featureTypes: ["ienc_dismar"],
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
223 geometryName: "geom",
663
db749c02127c Client: slightly improve wfs loading for marks
Bernhard Reiter <bernhard@intevation.de>
parents: 659
diff changeset
224 /* restrict loading approximately to extend of danube in Austria */
db749c02127c Client: slightly improve wfs loading for marks
Bernhard Reiter <bernhard@intevation.de>
parents: 659
diff changeset
225 filter: bboxFilter("geom", [13.3, 48.0, 17.1, 48.6], "EPSG:4326")
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
226 };
628
ef9c733cc6aa client: show more wfs layers
Bernhard Reiter <bernhard@intevation.de>
parents: 626
diff changeset
227
702
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
228 this.layers[5].data
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
229 .getSource()
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
230 .setLoader(
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
231 this.buildVectorLoader(
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
232 featureRequestOptions5,
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
233 "/external/d4d",
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
234 this.layers[5].data.getSource()
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
235 )
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
236 );
aaf5dbfb9512 client: improve loading of WFS features
Bernhard Reiter <bernhard@intevation.de>
parents: 701
diff changeset
237 this.layers[5].data.setVisible(this.layers[5].isVisible);
659
ef658c66cfca schema: disable sfcgal
Bernhard Reiter <bernhard@intevation.de>
parents: 649
diff changeset
238
ef658c66cfca schema: disable sfcgal
Bernhard Reiter <bernhard@intevation.de>
parents: 649
diff changeset
239 // FIXME this is hardwired for now
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
240 var featureRequestOptions6 = {
659
ef658c66cfca schema: disable sfcgal
Bernhard Reiter <bernhard@intevation.de>
parents: 649
diff changeset
241 featureNS: "gemma",
ef658c66cfca schema: disable sfcgal
Bernhard Reiter <bernhard@intevation.de>
parents: 649
diff changeset
242 featurePrefix: "gemma",
690
f595b3455d75 Schema: Add view for waterway axis
Bernhard Reiter <bernhard@intevation.de>
parents: 667
diff changeset
243 featureTypes: ["distance_marks_geoserver"],
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
244 geometryName: "geom"
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
245 };
659
ef658c66cfca schema: disable sfcgal
Bernhard Reiter <bernhard@intevation.de>
parents: 649
diff changeset
246
701
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
247 this.layers[6].data
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
248 .getSource()
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
249 .setLoader(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
250 this.buildVectorLoader(
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
251 featureRequestOptions6,
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
252 "/internal/wfs",
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
253 this.layers[6].data.getSource()
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
254 )
8149772c62d6 client: add bbox loading strategy to riverkilometre
Bernhard Reiter <bernhard@intevation.de>
parents: 690
diff changeset
255 );
585
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
256 }
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
257 };
ef307bd6b5d8 refac: restructured client application
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
258 </script>