# HG changeset patch # User Markus Kottlaender # Date 1543319966 -3600 # Node ID 553aadd970875a0d5eafe40ae4e7bd41dc8b93f7 # Parent 5b9b8eabcd014370a7f10ab0e5ac7589692eb687 new cross profile workflow (WIP) Needs fixing of some bugs and not so nice looks. diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/App.vue --- a/client/src/components/App.vue Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/components/App.vue Tue Nov 27 12:59:26 2018 +0100 @@ -11,18 +11,18 @@
- + +
- +
-
@@ -86,7 +86,7 @@ } }, components: { - Surveys: () => import("./map/fairway/Surveys"), + Profiles: () => import("./map/fairway/Profiles"), Infobar: () => import("./map/fairway/Infobar"), Pdftool: () => import("./map/Pdftool"), Zoom: () => import("./map/Zoom"), diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/Main.vue --- a/client/src/components/map/Main.vue Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/components/map/Main.vue Tue Nov 27 12:59:26 2018 +0100 @@ -2,11 +2,9 @@
@@ -36,37 +34,15 @@ Maplayer, FairwayProfile }, - data() { - return { - width: null, - height: null, - margin: { - top: 20, - right: 40, - bottom: 30, - left: 40 - } - }; - }, computed: { ...mapState("application", ["showSplitscreen"]), ...mapState("fairwayprofile", [ - "currentProfile", "minAlt", "maxAlt", "totalLength", - "waterLevels", - "fairwayCoordinates", "selectedWaterLevel" ]), ...mapState("bottlenecks", ["surveys", "selectedSurvey"]), - additionalSurveys() { - if (!this.surveys) return []; - if (!this.selectedSurvey) return this.surveys; - return this.surveys.filter(survey => { - return survey.date_info !== this.selectedSurvey.date_info; - }); - }, xAxis() { return [this.xScale.x, this.xScale.y]; }, @@ -78,9 +54,6 @@ const DELTA = this.maxAlt * 1.1 - this.maxAlt; return [this.maxAlt * 1 + DELTA, -DELTA]; }, - margins() { - return this.margin; - }, yScaleLeft() { return { lo: this.minAlt, diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/Maplayer.vue --- a/client/src/components/map/Maplayer.vue Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/components/map/Maplayer.vue Tue Nov 27 12:59:26 2018 +0100 @@ -433,6 +433,7 @@ this.openLayersMap.on(["singleclick", "dblclick"], event => { this.identify(event.coordinate, event.pixel); }); + this.$store.dispatch("bottlenecks/loadBottlenecks"); } }; diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/fairway/Fairwayprofile.vue --- a/client/src/components/map/fairway/Fairwayprofile.vue Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/components/map/fairway/Fairwayprofile.vue Tue Nov 27 12:59:26 2018 +0100 @@ -23,94 +23,6 @@ >{{ selectedBottleneck }} ({{ selectedSurvey.date_info }})
-
- - Additional Surveys - -
-
-
- Start: -
- Lat: {{ startPoint[1] }} -
- Lon: {{ startPoint[0] }} -
-
- End: -
- Lat: {{ endPoint[1] }} -
- Lon: {{ endPoint[0] }} -
- - -
-
Enter label for cross profile: -
- -
- -
-
Saved cross profiles: - - Enter coordinates manually: -
- -
- -
-
-
@@ -144,20 +56,6 @@ .show .profile height: 50vh - -.waterlevelselection - margin-top: $large-offset - margin-right: $large-offset - -.additionalsurveys - margin-top: $large-offset - margin-bottom: auto - margin-right: $large-offset - margin-left: auto - max-width: 300px - -.additionalsurveys input - margin-right: $small-offset diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/toolbar/Cuttool.vue --- a/client/src/components/map/toolbar/Cuttool.vue Tue Nov 27 12:49:53 2018 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ - - - diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/toolbar/Profiles.vue --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/src/components/map/toolbar/Profiles.vue Tue Nov 27 12:59:26 2018 +0100 @@ -0,0 +1,29 @@ + + + diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/components/map/toolbar/Toolbar.vue --- a/client/src/components/map/toolbar/Toolbar.vue Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/components/map/toolbar/Toolbar.vue Tue Nov 27 12:59:26 2018 +0100 @@ -3,7 +3,7 @@
- + @@ -70,7 +70,7 @@ Layers: () => import("./Layers.vue"), Linetool: () => import("./Linetool.vue"), Polygontool: () => import("./Polygontool.vue"), - Cuttool: () => import("./Cuttool.vue"), + Profiles: () => import("./Profiles.vue"), Pdftool: () => import("./Pdftool.vue") }, computed: { diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/main.js --- a/client/src/main.js Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/main.js Tue Nov 27 12:59:26 2018 +0100 @@ -64,7 +64,8 @@ faPlus, faMinus, faSortAmountUp, - faSortAmountDown + faSortAmountDown, + faSpinner } from "@fortawesome/free-solid-svg-icons"; import { faAdn } from "@fortawesome/free-brands-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; @@ -107,7 +108,8 @@ faPlus, faMinus, faSortAmountUp, - faSortAmountDown + faSortAmountDown, + faSpinner ); Vue.component("font-awesome-icon", FontAwesomeIcon); diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/store/application.js --- a/client/src/store/application.js Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/store/application.js Tue Nov 27 12:59:26 2018 +0100 @@ -30,6 +30,7 @@ showLayers: true, showPdfTool: false, showContextBox: false, + showProfiles: false, contextBoxContent: null, // bottlenecks, imports, staging expandToolbar: false, countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"], @@ -84,6 +85,9 @@ showContextBox: (state, show) => { state.showContextBox = show; }, + showProfiles: (state, show) => { + state.showProfiles = show; + }, contextBoxContent: (state, context) => { state.contextBoxContent = context; if (context) { diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/store/bottlenecks.js --- a/client/src/store/bottlenecks.js Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/store/bottlenecks.js Tue Nov 27 12:59:26 2018 +0100 @@ -22,7 +22,8 @@ bottlenecks: [], selectedBottleneck: null, surveys: [], - selectedSurvey: null + selectedSurvey: null, + surveysLoading: false }; }; @@ -42,6 +43,9 @@ }, setSelectedSurvey(state, survey) { state.selectedSurvey = survey; + }, + surveysLoading: (state, loading) => { + state.surveysLoading = loading; } }, actions: { @@ -50,6 +54,9 @@ commit("setSelectedSurvey", null); commit("fairwayprofile/clearCurrentProfile", null, { root: true }); } + if (name) { + commit("application/showProfiles", true, { root: true }); + } commit("setSelectedBottleneck", name); dispatch("querySurveys", name); }, @@ -79,6 +86,7 @@ }, querySurveys({ commit }, name) { if (name) { + commit("surveysLoading", true); HTTP.get("/surveys/" + name, { headers: { "X-Gemma-Auth": localStorage.getItem("token"), @@ -86,16 +94,22 @@ } }) .then(response => { - commit("setSurveys", response.data.surveys); + const surveys = response.data.surveys.sort( + (a, b) => (a.date_info < b.date_info ? 1 : -1) + ); + commit("setSelectedSurvey", surveys[0]); + commit("setSurveys", surveys); }) .catch(error => { commit("setSurveys", []); + commit("setSelectedSurvey", null); const { status, data } = error.response; displayError({ title: "Backend Error", message: `${status}: ${data.message || data}` }); - }); + }) + .finally(() => commit("surveysLoading", false)); } else { commit("setSurveys", []); } diff -r 5b9b8eabcd01 -r 553aadd97087 client/src/store/fairway.js --- a/client/src/store/fairway.js Tue Nov 27 12:49:53 2018 +0100 +++ b/client/src/store/fairway.js Tue Nov 27 12:59:26 2018 +0100 @@ -37,7 +37,8 @@ fairwayCoordinates: [], startPoint: null, endPoint: null, - previousCuts: [] + previousCuts: [], + profileLoading: false }; }; @@ -103,6 +104,9 @@ }, previousCuts: (state, previousCuts) => { state.previousCuts = previousCuts; + }, + profileLoading: (state, loading) => { + state.profileLoading = loading; } }, actions: { @@ -116,27 +120,34 @@ .clear(); }, loadProfile({ commit, state }, survey) { - return new Promise((resolve, reject) => { - const profileLine = new LineString([state.startPoint, state.endPoint]); - const geoJSON = generateFeatureRequest( - profileLine, - survey.bottleneck_id, - survey.date_info - ); - HTTP.post("/cross", geoJSON, { - headers: { "X-Gemma-Auth": localStorage.getItem("token") } - }) - .then(response => { - commit("profileLoaded", { - response: response, - surveyDate: survey.date_info - }); - resolve(response); + if (state.startPoint && state.endPoint) { + return new Promise((resolve, reject) => { + commit("profileLoading", true); + const profileLine = new LineString([ + state.startPoint, + state.endPoint + ]); + const geoJSON = generateFeatureRequest( + profileLine, + survey.bottleneck_id, + survey.date_info + ); + HTTP.post("/cross", geoJSON, { + headers: { "X-Gemma-Auth": localStorage.getItem("token") } }) - .catch(error => { - reject(error); - }); - }); + .then(response => { + commit("profileLoaded", { + response: response, + surveyDate: survey.date_info + }); + resolve(response); + }) + .catch(error => { + reject(error); + }) + .finally(() => commit("profileLoading", false)); + }); + } }, cut({ commit, dispatch, rootState, rootGetters }, cut) { const length = getLength(cut.getGeometry()); @@ -165,28 +176,29 @@ const profileLine = new LineString([start, end]); dispatch("loadProfile", rootState.bottlenecks.selectedSurvey) .then(() => { - rootGetters["map/getLayerByName"]("Fairway Dimensions") - .data.getSource() - .forEachFeatureIntersectingExtent( - // need to use EPSG:3857 which is the proj of vectorSource - profileLine + rootState.map.cutTool.setActive(false); + rootGetters["map/getVSourceByName"]( + "Fairway Dimensions" + ).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:4326", "EPSG:3857") - .getExtent(), - feature => { - // transform back to prepare for usage - var intersectingPolygon = feature - .getGeometry() - .clone() - .transform("EPSG:3857", "EPSG:4326"); - const fairwayCoordinates = calculateFairwayCoordinates( - profileLine, - intersectingPolygon, - DEMODATA - ); - commit("setFairwayCoordinates", fairwayCoordinates); - } - ); + .transform("EPSG:3857", "EPSG:4326"); + const fairwayCoordinates = calculateFairwayCoordinates( + profileLine, + intersectingPolygon, + DEMODATA + ); + commit("setFairwayCoordinates", fairwayCoordinates); + } + ); }) .then(() => { commit("application/showSplitscreen", true, { root: true });