comparison client/src/map/Maplayer.vue @ 829:797063af6dc8

client: complete simple survey selection * Change code to only request a profile if a selectedMorph is there and use the selected date and bottleneck id for the backend request.
author Bernhard Reiter <bernhard@intevation.de>
date Thu, 27 Sep 2018 23:45:58 +0200
parents 68a39aea942a
children d9da1ea14abf
comparison
equal deleted inserted replaced
826:90a601884ff2 829:797063af6dc8
49 vectorSource: null 49 vectorSource: null
50 }; 50 };
51 }, 51 },
52 computed: { 52 computed: {
53 ...mapGetters("mapstore", ["layers", "getLayerByName"]), 53 ...mapGetters("mapstore", ["layers", "getLayerByName"]),
54 ...mapState("mapstore", ["openLayersMap"]), 54 ...mapState("mapstore", ["openLayersMap", "selectedMorph"]),
55 mapStyle() { 55 mapStyle() {
56 return { 56 return {
57 mapfull: !this.split, 57 mapfull: !this.split,
58 mapsplit: this.split 58 mapsplit: this.split
59 }; 59 };
91 event.feature.setId("drawn.1"); // unique id for new feature 91 event.feature.setId("drawn.1"); // unique id for new feature
92 }); 92 });
93 draw.on("drawend", this.drawEnd); 93 draw.on("drawend", this.drawEnd);
94 return draw; 94 return draw;
95 }, 95 },
96 findFeature(profileLine) {
97 return new Feature({
98 geometry: profileLine,
99 // FIXME: hardcoded bottleneck and survey date
100 bottleneck: "AT_Bottleneck_44",
101 date: "2017-11-20"
102 });
103 },
104 drawEnd(event) { 96 drawEnd(event) {
105 const length = getLength(event.feature.getGeometry()); 97 const length = getLength(event.feature.getGeometry());
106 this.$store.commit("mapstore/setCurrentMeasurement", length); 98 this.$store.commit("mapstore/setCurrentMeasurement", length);
107 // also place the a rounded length in a property, so identify can show it 99 // also place the a rounded length in a property, so identify can show it
108 event.feature.set("length", Math.round(length * 10) / 10); 100 event.feature.set("length", Math.round(length * 10) / 10);
101
102 // if a survey has been selected, request a profile
103 // TODO an improvement could be to check if the line intersects
104 // with the bottleneck area's polygon before trying the server request
105 if (this.selectedMorph) {
106 console.log("requesting profile for", this.selectedMorph);
107 this.requestProfile(event, this.selectedMorph);
108 }
109 },
110 requestProfile(event, survey) {
111 // survey has to have the properties bottleneck_id and date_info
109 112
110 // prepare to send the first line seqment to the server as GeoJSON 113 // prepare to send the first line seqment to the server as GeoJSON
111 const inputLineString = event.feature.getGeometry().clone(); 114 const inputLineString = event.feature.getGeometry().clone();
112 inputLineString.transform("EPSG:3857", "EPSG:4326"); 115 inputLineString.transform("EPSG:3857", "EPSG:4326");
113 const [start, end] = inputLineString.getCoordinates(); 116 const [start, end] = inputLineString.getCoordinates();
114 this.$store.commit("fairwayprofile/setStartPoint", start); 117 this.$store.commit("fairwayprofile/setStartPoint", start);
115 this.$store.commit("fairwayprofile/setEndPoint", end); 118 this.$store.commit("fairwayprofile/setEndPoint", end);
116 const profileLine = new LineString([start, end]); 119 const profileLine = new LineString([start, end]);
117 const feature = this.findFeature(profileLine); 120 const feature = new Feature({
121 geometry: profileLine,
122 bottleneck: survey.bottleneck_id,
123 dat: survey.date_info
124 });
118 const geoJSON = new GeoJSON({ geometryName: "geometry" }).writeFeature( 125 const geoJSON = new GeoJSON({ geometryName: "geometry" }).writeFeature(
119 feature 126 feature
120 ); 127 );
121 this.$store 128 this.$store
122 .dispatch("fairwayprofile/loadProfile", geoJSON) 129 .dispatch("fairwayprofile/loadProfile", geoJSON)