Mercurial > gemma
comparison client/src/fairway/store.js @ 1025:a55f20dc8d8d
refac: store profiles by date
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 24 Oct 2018 13:09:54 +0200 |
parents | e89be4af3a9f |
children | 04a9e78dcc5f |
comparison
equal
deleted
inserted
replaced
1024:96ea805d44b9 | 1025:a55f20dc8d8d |
---|---|
22 state: { | 22 state: { |
23 availableSurveys: null, | 23 availableSurveys: null, |
24 totalLength: 0, | 24 totalLength: 0, |
25 minAlt: 0, | 25 minAlt: 0, |
26 maxAlt: 0, | 26 maxAlt: 0, |
27 currentProfile: [], | 27 currentProfile: {}, |
28 waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], | 28 waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], |
29 selectedWaterLevel: DEMOLEVEL, | 29 selectedWaterLevel: DEMOLEVEL, |
30 fairwayCoordinates: [], | 30 fairwayCoordinates: [], |
31 startPoint: null, | 31 startPoint: null, |
32 endPoint: null | 32 endPoint: null |
41 state.availableSurveys = surveys; | 41 state.availableSurveys = surveys; |
42 }, | 42 }, |
43 setSelectedWaterLevel: (state, level) => { | 43 setSelectedWaterLevel: (state, level) => { |
44 state.selectedWaterLevel = level; | 44 state.selectedWaterLevel = level; |
45 }, | 45 }, |
46 profileLoaded: (state, response) => { | 46 profileLoaded: (state, answer) => { |
47 const { response, surveyDate } = answer; | |
47 const { data } = response; | 48 const { data } = response; |
48 const coordinates = data.geometry.coordinates; | 49 const coordinates = data.geometry.coordinates; |
49 if (!coordinates) return; | 50 if (!coordinates) return; |
50 const startPoint = state.startPoint; | 51 const startPoint = state.startPoint; |
51 const endPoint = state.endPoint; | 52 const endPoint = state.endPoint; |
52 const geoJSON = data; | 53 const geoJSON = data; |
53 const result = prepareProfile({ geoJSON, startPoint, endPoint }); | 54 const result = prepareProfile({ geoJSON, startPoint, endPoint }); |
54 state.currentProfile = result.points; | 55 state.currentProfile[surveyDate] = result.points; |
55 state.minAlt = result.minAlt; | 56 state.minAlt = result.minAlt; |
56 state.maxAlt = result.maxAlt; | 57 state.maxAlt = result.maxAlt; |
57 state.totalLength = result.lengthPolyLine; | 58 state.totalLength = result.lengthPolyLine; |
58 }, | 59 }, |
59 setStartPoint: (state, start) => { | 60 setStartPoint: (state, start) => { |
64 }, | 65 }, |
65 setFairwayCoordinates: (state, coordinates) => { | 66 setFairwayCoordinates: (state, coordinates) => { |
66 state.fairwayCoordinates = coordinates; | 67 state.fairwayCoordinates = coordinates; |
67 }, | 68 }, |
68 clearCurrentProfile: state => { | 69 clearCurrentProfile: state => { |
69 state.currentProfile = []; | 70 state.currentProfile = {}; |
70 } | 71 } |
71 } | 72 } |
72 }; | 73 }; |
73 | 74 |
74 export default FairwayProfile; | 75 export default FairwayProfile; |