view client/src/linetool/Linetool.vue @ 1063:7ec2133c6404

client: add area measurement. simpify code * Add a third draw mode which can only be activated when no morphology is selected and we are already in LineString mode. It adds an area calculation. Because the Polygon drawMode ends on a double click, there needs to be an extra callback for this to run identify so that the area calculation is shown all times. * Add Bernhard as author to some files and also simplify copyright note. * Remove DRAWMODES in the code to simplify as this is just one indirection used once in stores/application.js. * Use mapState instead mapGetters to get the drawMode at all places to save some code lines.
author Bernhard Reiter <bernhard@intevation.de>
date Thu, 25 Oct 2018 23:16:53 +0200
parents e3df77b8074f
children 23b1d8c0e782
line wrap: on
line source

<template>
    <div @click="drawLine" class="ui-element d-flex shadow drawtool">
        <i :class="icon"></i>
    </div>
</template>

<style lang="scss">
.drawtool {
  position: absolute;
  bottom: 0;
  right: 0;
  background-color: white;
  padding: $small-offset;
  border-radius: $border-radius;
  margin-left: $offset;
  height: $icon-width;
  width: $icon-height;
  margin-bottom: $offset;
  margin-right: $offset;
  z-index: 2;
}

.inverted {
  color: #0077ff;
}
</style>

<script>
/* 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 { mapState } from "vuex";

export default {
  name: "linetool",
  methods: {
    drawLine() {
      if (!this.selectedMorph && this.drawMode === "LineString") {
        this.$store.commit("application/activateDrawModePolygon");
      } else {
        this.$store.commit("application/toggleDrawModeLine");
      }
    }
  },
  computed: {
    ...mapState("application", ["drawMode"]),
    ...mapState("identifystore", ["identifiedFeatures"]),
    ...mapState("fairwayprofile", ["selectedMorph"]),
    icon() {
      return {
        fa: true,
        "fa-pencil": !this.selectedMorph,
        "fa-pencil inverted":
          !this.selectedMorph && this.drawMode === "LineString",
        "fa-area-chart": this.selectedMorph,
        "fa-edit inverted": this.drawMode === "Polygon"
      };
    }
  }
};
</script>