view client/src/bottlenecks/store.js @ 1090:dbf0221b1cf1

bottleneck list uses different wfs endpoint now to reduce own server-side-code the bottleneck list is now retreived as a feature collection and includes more details.
author Markus Kottlaender <markus@intevation.de>
date Tue, 30 Oct 2018 11:35:36 +0100
parents c9badb264d16
children
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):
 * Markus Kottländer <markuks.kottlaender@intevation.de>
 */
import { HTTP } from "../application/lib/http";
import { WFS } from "ol/format.js";

const Bottlenecks = {
  namespaced: true,
  state: {
    bottlenecks: []
  },
  mutations: {
    setBottlenecks: (state, bottlenecks) => {
      state.bottlenecks = bottlenecks;
    }
  },
  actions: {
    loadBottlenecks({ commit }) {
      var bottleneckFeatureCollectionRequest = new WFS().writeGetFeature({
        srsName: "EPSG:4326",
        featureNS: "gemma",
        featurePrefix: "gemma",
        featureTypes: ["bottleneck_overview"],
        outputFormat: "application/json"
      });

      HTTP.post(
        "/internal/wfs",
        new XMLSerializer().serializeToString(
          bottleneckFeatureCollectionRequest
        ),
        {
          headers: {
            "X-Gemma-Auth": localStorage.getItem("token"),
            "Content-type": "text/xml; charset=UTF-8"
          }
        }
      ).then(response => {
        commit("setBottlenecks", response.data.features);
      });
    }
  }
};

export default Bottlenecks;