Mercurial > gemma
view 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 |
line wrap: on
line source
/* * This is Free Software under GNU Affero General Public License v >= 3.0 * without warranty, see README.md and license for details. * * SPDX-License-Identifier: AGPL-3.0-or-later * License-Filename: LICENSES/AGPL-3.0.txt * * Copyright (C) 2018 by via donau * – Österreichische Wasserstraßen-Gesellschaft mbH * Software engineering by Intevation GmbH * * Author(s): * Thomas Junk <thomas.junk@intevation.de> */ import { prepareProfile } from "../application/lib/geo"; const DEMOLEVEL = 149.345; const FairwayProfile = { namespaced: true, state: { availableSurveys: null, totalLength: 0, minAlt: 0, maxAlt: 0, currentProfile: {}, waterLevels: [{ year: "2016", level: DEMOLEVEL, color: "#005DFF" }], selectedWaterLevel: DEMOLEVEL, fairwayCoordinates: [], startPoint: null, endPoint: null }, getters: { length: state => { return state.totalLength; } }, mutations: { setAvailableSurveys: (state, surveys) => { state.availableSurveys = surveys; }, setSelectedWaterLevel: (state, level) => { state.selectedWaterLevel = level; }, profileLoaded: (state, answer) => { const { response, surveyDate } = answer; 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[surveyDate] = 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; }, clearCurrentProfile: state => { state.currentProfile = {}; } } }; export default FairwayProfile;