Mercurial > gemma
view client/src/fairway/store.js @ 973:b6fec8f85599
Generate TINs and octrees in sounding result importer.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 18 Oct 2018 13:09:49 +0200 |
parents | b9aaa093a9fb |
children | 15c3cc6f29a4 |
line wrap: on
line source
import { HTTP } from "../application/lib/http"; import { prepareProfile } from "../application/lib/geo"; const DEMOLEVEL = 149.345; const FairwayProfile = { namespaced: true, state: { totalLength: 0, minAlt: 0, maxAlt: 0, currentProfile: [], waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], selectedWaterLevel: DEMOLEVEL, fairwayCoordinates: [], startPoint: null, endPoint: null }, getters: { selectedWaterLevel: state => { return state.selectedWaterLevel; }, fairwayCoordinates: state => { return state.fairwayCoordinates; }, waterLevels: state => { return state.waterLevels; }, currentProfile: state => { return state.currentProfile; }, startPoint: state => { return state.startPoint; }, endPoint: state => { return state.endPoint; }, length: state => { return state.totalLength; }, minAlt: state => { return state.minAlt; }, maxAlt: state => { return state.maxAlt; }, totalLength: state => { return state.totalLength; } }, mutations: { setSelectedWaterLevel: (state, level) => { state.selectedWaterLevel = level; }, profileLoaded: (state, response) => { const { data } = response; const coordinates = data.geometry.coordinates; if (!coordinates) return; const startPoint = state.startPoint; const endPoint = state.endPoint; const geoJSON = data; const result = prepareProfile({ geoJSON, startPoint, endPoint }); state.currentProfile = result.points; state.minAlt = result.minAlt; state.maxAlt = result.maxAlt; state.totalLength = result.lengthPolyLine; }, setStartPoint: (state, start) => { state.startPoint = start; }, setEndPoint: (state, end) => { state.endPoint = end; }, setFairwayCoordinates: (state, coordinates) => { state.fairwayCoordinates = coordinates; } }, actions: { loadProfile({ commit }, geoJSON) { return new Promise((resolve, reject) => { HTTP.post("/cross", geoJSON, { headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) .then(response => { commit("profileLoaded", response); resolve(response); }) .catch(error => { reject(error); }); }); } } }; export default FairwayProfile;