view client/src/application/Main.vue @ 767:dedf252b3e01

feat: fairwayprofile partially with retrieved data from the server An intersection is made. Data is retrieved from the server. Data is transformed to X/Y. Min and Max alt is calculated. Total length is calculated. Height information is calculated. Scale on the left axis is adjusted. Missing: * drawing of current ground profile. * drawing of rectangle for ship * labels for Axis
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 25 Sep 2018 17:39:00 +0200
parents badbc0207418
children c98f88ac08a4
line wrap: on
line source

<template>
    <div class="main d-flex flex-column">
        <Maplayer :drawMode="drawMode" :split="isSplitscreen" :lat="6155376" :long="1819178" :zoom="11"></Maplayer>
        <div v-if="isSplitscreen" class="profile d-flex flex-row">
            <FairwayProfile :data="currentProfile" :height="height" :width="width" :xScale="xAxis" :yScaleLeft="yAxisLeft" :yScaleRight="yAxisRight" :margin="margins"></FairwayProfile>
        </div>
    </div>
</template>

<style lang="scss">
.profile {
  background-color: white;
  height: 50vh;
}
</style>

<script>
import Maplayer from "../map/Maplayer";
import FairwayProfile from "../fairway/Fairwayprofile";
import { mapGetters } from "vuex";
import debounce from "debounce";

export default {
  name: "mainview",
  components: {
    Maplayer,
    FairwayProfile
  },
  data() {
    return {
      width: null,
      height: null,
      xScale: {
        x: 0,
        y: 300
      },
      yScaleRight: {
        lo: -6,
        hi: 1
      },
      margin: {
        top: 20,
        right: 40,
        bottom: 20,
        left: 40
      }
    };
  },
  computed: {
    ...mapGetters("application", ["isSplitscreen", "drawMode"]),
    ...mapGetters("fairwayprofile", ["currentProfile", "minAlt", "maxAlt"]),
    xAxis() {
      return [this.xScale.x, this.xScale.y];
    },
    yAxisLeft() {
      return [this.yScaleLeft.lo, this.yScaleLeft.hi];
    },
    yAxisRight() {
      return [this.yScaleRight.lo, this.yScaleRight.hi];
    },
    margins() {
      return this.margin;
    },
    yScaleLeft() {
      return {
        lo: this.minAlt,
        hi: this.maxAlt
      };
    }
  },
  created() {
    window.addEventListener("resize", debounce(this.scaleFairwayProfile), 100);
  },
  updated() {
    this.scaleFairwayProfile();
  },
  destroyed() {
    window.removeEventListener("resize", debounce(this.scaleFairwayProfile));
  },
  methods: {
    scaleFairwayProfile() {
      if (!document.querySelector(".profile")) return;
      const clientHeight = document.querySelector(".profile").clientHeight;
      const clientWidth = document.querySelector(".profile").clientWidth;
      if (!clientHeight || !clientWidth) return;
      this.height = document.querySelector(".profile").clientHeight - 25;
      this.width = document.querySelector(".profile").clientWidth - 100;
    }
  }
};
</script>