annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
1 <template>
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
2 <div @click="drawLine" class="ui-element d-flex shadow drawtool">
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
3 <i :class="icon"></i>
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
4 </div>
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
5 </template>
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
6
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
7 <style lang="scss">
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
8 .drawtool {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
9 position: absolute;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
10 bottom: 0;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
11 right: 0;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
12 background-color: white;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
13 padding: $small-offset;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
14 border-radius: $border-radius;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
15 margin-left: $offset;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
16 height: $icon-width;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
17 width: $icon-height;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
18 margin-bottom: $offset;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
19 margin-right: $offset;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
20 z-index: 2;
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
21 }
752
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 649
diff changeset
22
903
2990a878b16b fix cut with scissors
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
23 .inverted {
752
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 649
diff changeset
24 color: #0077ff;
f09cbe80a864 refac: small improvements
Thomas Junk <thomas.junk@intevation.de>
parents: 649
diff changeset
25 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
26 </style>
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
27
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
28 <script>
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
29 /* This is Free Software under GNU Affero General Public License v >= 3.0
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
30 * without warranty, see README.md and license for details.
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
31 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
32 * SPDX-License-Identifier: AGPL-3.0-or-later
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
33 * License-Filename: LICENSES/AGPL-3.0.txt
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
34 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
35 * Copyright (C) 2018 by via donau
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
36 * – Österreichische Wasserstraßen-Gesellschaft mbH
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
37 * Software engineering by Intevation GmbH
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
38 *
1019
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
39 * Author(s):
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
40 * Thomas Junk <thomas.junk@intevation.de>
ca628dce90dd Licensing information added
Thomas Junk <thomas.junk@intevation.de>
parents: 975
diff changeset
41 */
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
42 import { mapState } from "vuex";
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
43
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
44 export default {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
45 name: "linetool",
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
46 methods: {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
47 drawLine() {
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
48 if (!this.selectedMorph && this.drawMode === "LineString") {
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
49 this.$store.commit("application/activateDrawModePolygon");
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
50 } else {
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
51 this.$store.commit("application/toggleDrawModeLine");
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
52 }
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
53 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
54 },
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
55 computed: {
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
56 ...mapState("application", ["drawMode"]),
1027
04a9e78dcc5f refac: remove morphstore. not necessary
Thomas Junk <thomas.junk@intevation.de>
parents: 1019
diff changeset
57 ...mapState("identifystore", ["identifiedFeatures"]),
04a9e78dcc5f refac: remove morphstore. not necessary
Thomas Junk <thomas.junk@intevation.de>
parents: 1019
diff changeset
58 ...mapState("fairwayprofile", ["selectedMorph"]),
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
59 icon() {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
60 return {
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
61 fa: true,
903
2990a878b16b fix cut with scissors
Thomas Junk <thomas.junk@intevation.de>
parents: 752
diff changeset
62 "fa-pencil": !this.selectedMorph,
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
63 "fa-pencil inverted":
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
64 !this.selectedMorph && this.drawMode === "LineString",
1049
e3df77b8074f changed cut icon
Markus Kottlaender <markus@intevation.de>
parents: 1027
diff changeset
65 "fa-area-chart": this.selectedMorph,
1063
7ec2133c6404 client: add area measurement. simpify code
Bernhard Reiter <bernhard@intevation.de>
parents: 1049
diff changeset
66 "fa-edit inverted": this.drawMode === "Polygon"
649
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
67 };
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
68 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
69 }
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
70 };
83081ba6c9c1 feat: Linetool added
Thomas Junk <thomas.junk@intevation.de>
parents:
diff changeset
71 </script>