Mercurial > gemma
changeset 797:644172f201e8
Fairway profile WIP
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Thu, 27 Sep 2018 12:01:31 +0200 |
parents | 0cc97135717c |
children | 383fac3e5d1e |
files | client/src/map/Maplayer.vue |
diffstat | 1 files changed, 38 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/map/Maplayer.vue Thu Sep 27 11:40:02 2018 +0200 +++ b/client/src/map/Maplayer.vue Thu Sep 27 12:01:31 2018 +0200 @@ -118,7 +118,35 @@ ); this.$store .dispatch("fairwayprofile/loadProfile", geoJSON) - .then() + .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 + .clone() + .transform("EPSG:4326", "EPSG:3857") + .getExtent(), + feature => { + // transform back to prepare for usage + var intersectingPolygon = feature + .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 + ); + } + ); + }) .catch(error => { const { status, data } = error.response; displayError({ @@ -126,48 +154,19 @@ message: `${status}: ${data.message || data}` }); }); - - // // 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 - // .clone() - // .transform("EPSG:4326", "EPSG:3857") - // .getExtent(), - // feature => { - // // transform back to prepare for usage - // var intersectingPolygon = feature - // .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 - // ); - // } - // ); }, addToFairwayRectangle(profileLine, fairwayGeometry, depth, diagStack) { // 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, - // ")" - // ); + console.log( + "addToFairwayRectangle(", + profileLine, + fairwayGeometry, + depth, + diagStack, + ")" + ); var line = turfLineString(profileLine.getCoordinates()); var polygon = turfPolygon(fairwayGeometry.getCoordinates()); var intersects = lineIntersect(line, polygon); @@ -190,7 +189,7 @@ ]); } } - //console.log("Resulting diagStack:", diagStack); + console.log("Resulting diagStack:", diagStack); }, activateInteraction() { const interaction = this.createInteraction(this.drawMode);