diff client/src/map/Maplayer.vue @ 802:327aa4a18a1c

Fairway profile WIP
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 27 Sep 2018 13:36:43 +0200
parents 644172f201e8
children 68a39aea942a
line wrap: on
line diff
--- a/client/src/map/Maplayer.vue	Thu Sep 27 13:18:50 2018 +0200
+++ b/client/src/map/Maplayer.vue	Thu Sep 27 13:36:43 2018 +0200
@@ -36,6 +36,8 @@
 import lineIntersect from "@turf/line-intersect";
 import { displayError } from "../application/lib/errors.js";
 
+const DEMODATA = 2.5;
+
 export default {
   name: "maplayer",
   props: ["drawMode", "lat", "long", "zoom", "split"],
@@ -119,12 +121,9 @@
       this.$store
         .dispatch("fairwayprofile/loadProfile", geoJSON)
         .then(() => {
-          // FIXME: assuming that we have the fairway dimensions loaded
           var vectorSource = this.getLayerByName(
             "Fairway Dimensions"
           ).data.getSource();
-          console.log(vectorSource);
-          var diagStack = [];
           vectorSource.forEachFeatureIntersectingExtent(
             // need to use EPSG:3857 which is the proj of vectorSource
             profileLine
@@ -137,12 +136,10 @@
                 .getGeometry()
                 .clone()
                 .transform("EPSG:3857", "EPSG:4326");
-              console.log("intersecting:", intersectingPolygon);
               this.addToFairwayRectangle(
                 profileLine,
                 intersectingPolygon,
-                2.5, // FIXME use real fairway depth value for this feature
-                diagStack
+                DEMODATA
               );
             }
           );
@@ -155,23 +152,13 @@
           });
         });
     },
-    addToFairwayRectangle(profileLine, fairwayGeometry, depth, diagStack) {
+    addToFairwayRectangle(profileLine, fairwayGeometry, depth) {
       // both geometries have to be in EPSG:4326
       // uses turfjs distance() function
-      // pushes pairs of diagram points into diagStack
-      console.log(
-        "addToFairwayRectangle(",
-        profileLine,
-        fairwayGeometry,
-        depth,
-        diagStack,
-        ")"
-      );
+      let fairwayCoordinates = [];
       var line = turfLineString(profileLine.getCoordinates());
       var polygon = turfPolygon(fairwayGeometry.getCoordinates());
       var intersects = lineIntersect(line, polygon);
-      console.log(intersects.features);
-
       var l = intersects.features.length;
       if (l % 2 != 0) {
         console.log("Ignoring fairway because profile only intersects once.");
@@ -182,14 +169,17 @@
           let fEndPoint = intersects.features[i + 1].geometry.coordinates;
           let opts = { units: "kilometers" };
 
-          diagStack.push([
+          fairwayCoordinates.push([
             distance(pStartPoint, fStartPoint, opts) * 1000,
             distance(pStartPoint, fEndPoint, opts) * 1000,
             depth
           ]);
         }
       }
-      console.log("Resulting diagStack:", diagStack);
+      this.$store.commit(
+        "fairwayprofile/setFairwayCoordinates",
+        fairwayCoordinates
+      );
     },
     activateInteraction() {
       const interaction = this.createInteraction(this.drawMode);