Mercurial > gemma
comparison client/src/store/fairway.js @ 2368:96b0314f2bd6
fairway_profile: consuming the offered waterlevel WIP
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 21 Feb 2019 12:21:42 +0100 |
parents | 242c170e00ce |
children | 13de09e30645 |
comparison
equal
deleted
inserted
replaced
2367:0aedae39726e | 2368:96b0314f2bd6 |
---|---|
20 import { getLength } from "ol/sphere.js"; | 20 import { getLength } from "ol/sphere.js"; |
21 import { displayError } from "../lib/errors.js"; | 21 import { displayError } from "../lib/errors.js"; |
22 import { featureToFairwayCoordinates } from "../lib/geo.js"; | 22 import { featureToFairwayCoordinates } from "../lib/geo.js"; |
23 import { LAYERS } from "@/store/map.js"; | 23 import { LAYERS } from "@/store/map.js"; |
24 | 24 |
25 const DEMOLEVEL = 149.345; | |
26 | |
27 // initial state | 25 // initial state |
28 const init = () => { | 26 const init = () => { |
29 return { | 27 return { |
30 additionalSurvey: null, | 28 additionalSurvey: null, |
31 minAlt: 0, | 29 minAlt: 0, |
32 maxAlt: 0, | 30 maxAlt: 0, |
33 currentProfile: {}, | 31 currentProfile: {}, |
34 waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], | 32 waterLevels: {}, |
35 selectedWaterLevel: DEMOLEVEL, | 33 selectedWaterLevel: "", |
36 fairwayData: [], | 34 fairwayData: [], |
37 startPoint: null, | 35 startPoint: null, |
38 endPoint: null, | 36 endPoint: null, |
39 previousCuts: [], | 37 previousCuts: [], |
40 profileLoading: false, | 38 profileLoading: false, |
65 state.selectedWaterLevel = level; | 63 state.selectedWaterLevel = level; |
66 }, | 64 }, |
67 profileLoaded: (state, answer) => { | 65 profileLoaded: (state, answer) => { |
68 const { response, surveyDate } = answer; | 66 const { response, surveyDate } = answer; |
69 const { data } = response; | 67 const { data } = response; |
68 const { waterlevel } = response.data.properties; | |
69 const { value, when } = waterlevel; | |
70 const coordinates = data.geometry.coordinates; | 70 const coordinates = data.geometry.coordinates; |
71 if (!coordinates) return; | 71 if (!coordinates) return; |
72 const startPoint = state.startPoint; | 72 const startPoint = state.startPoint; |
73 const endPoint = state.endPoint; | 73 const endPoint = state.endPoint; |
74 const geoJSON = data; | 74 const geoJSON = data; |
75 const result = prepareProfile({ geoJSON, startPoint, endPoint }); | 75 const result = prepareProfile({ geoJSON, startPoint, endPoint }); |
76 // Use Vue.set() to make new object properties rective | 76 // Use Vue.set() to make new object properties rective |
77 // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats | 77 // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats |
78 Vue.set(state.waterLevels, when, { value }); | |
79 if (state.selectedWaterLevel === "") state.selectedWaterLevel = when; | |
78 Vue.set(state.currentProfile, surveyDate, { | 80 Vue.set(state.currentProfile, surveyDate, { |
79 points: result.points, | 81 points: result.points, |
80 length: result.lengthPolyLine | 82 length: result.lengthPolyLine |
81 }); | 83 }); |
82 if (!state.minAlt || state.minAlt > result.minAlt) { | 84 if (!state.minAlt || state.minAlt > result.minAlt) { |