Mercurial > gemma
comparison client/src/map/Maplayer.vue @ 1022:74229d9f7028
refac: restructure maptool for understandability
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Wed, 24 Oct 2018 12:03:51 +0200 |
parents | e89be4af3a9f |
children | a55f20dc8d8d |
comparison
equal
deleted
inserted
replaced
1021:957613a71b35 | 1022:74229d9f7028 |
---|---|
192 }) | 192 }) |
193 .then(() => { | 193 .then(() => { |
194 var vectorSource = this.getLayerByName( | 194 var vectorSource = this.getLayerByName( |
195 "Fairway Dimensions" | 195 "Fairway Dimensions" |
196 ).data.getSource(); | 196 ).data.getSource(); |
197 vectorSource.forEachFeatureIntersectingExtent( | 197 this.calculateIntersection(vectorSource, profileLine); |
198 // need to use EPSG:3857 which is the proj of vectorSource | 198 }) |
199 profileLine | 199 .then(() => { |
200 .clone() | |
201 .transform("EPSG:4326", "EPSG:3857") | |
202 .getExtent(), | |
203 feature => { | |
204 // transform back to prepare for usage | |
205 var intersectingPolygon = feature | |
206 .getGeometry() | |
207 .clone() | |
208 .transform("EPSG:3857", "EPSG:4326"); | |
209 this.addToFairwayRectangle( | |
210 profileLine, | |
211 intersectingPolygon, | |
212 DEMODATA | |
213 ); | |
214 } | |
215 ); | |
216 this.$store.commit("application/openSplitScreen"); | 200 this.$store.commit("application/openSplitScreen"); |
217 }) | 201 }) |
218 .catch(error => { | 202 .catch(error => { |
219 const { status, data } = error.response; | 203 const { status, data } = error.response; |
220 displayError({ | 204 displayError({ |
221 title: "Backend Error", | 205 title: "Backend Error", |
222 message: `${status}: ${data.message || data}` | 206 message: `${status}: ${data.message || data}` |
223 }); | 207 }); |
224 }); | 208 }); |
225 }, | 209 }, |
226 addToFairwayRectangle(profileLine, fairwayGeometry, depth) { | 210 calculateIntersection(vectorSource, profileLine) { |
211 const transformedLine = profileLine | |
212 .clone() | |
213 .transform("EPSG:4326", "EPSG:3857") | |
214 .getExtent(); | |
215 const featureCallback = feature => { | |
216 // transform back to prepare for usage | |
217 var intersectingPolygon = feature | |
218 .getGeometry() | |
219 .clone() | |
220 .transform("EPSG:3857", "EPSG:4326"); | |
221 const fairwayCoordinates = this.calculateFairwayCoordinates( | |
222 profileLine, | |
223 intersectingPolygon, | |
224 DEMODATA | |
225 ); | |
226 this.$store.commit( | |
227 "fairwayprofile/setFairwayCoordinates", | |
228 fairwayCoordinates | |
229 ); | |
230 }; | |
231 vectorSource.forEachFeatureIntersectingExtent( | |
232 // need to use EPSG:3857 which is the proj of vectorSource | |
233 transformedLine, | |
234 featureCallback | |
235 ); | |
236 }, | |
237 calculateFairwayCoordinates(profileLine, fairwayGeometry, depth) { | |
227 // both geometries have to be in EPSG:4326 | 238 // both geometries have to be in EPSG:4326 |
228 // uses turfjs distance() function | 239 // uses turfjs distance() function |
229 let fairwayCoordinates = []; | 240 let fairwayCoordinates = []; |
230 var line = turfLineString(profileLine.getCoordinates()); | 241 var line = turfLineString(profileLine.getCoordinates()); |
231 var polygon = turfPolygon(fairwayGeometry.getCoordinates()); | 242 var polygon = turfPolygon(fairwayGeometry.getCoordinates()); |
245 distance(pStartPoint, fEndPoint, opts) * 1000, | 256 distance(pStartPoint, fEndPoint, opts) * 1000, |
246 depth | 257 depth |
247 ]); | 258 ]); |
248 } | 259 } |
249 } | 260 } |
250 this.$store.commit( | 261 return fairwayCoordinates; |
251 "fairwayprofile/setFairwayCoordinates", | |
252 fairwayCoordinates | |
253 ); | |
254 }, | 262 }, |
255 activateInteraction() { | 263 activateInteraction() { |
256 const interaction = this.createInteraction(this.drawMode); | 264 const interaction = this.createInteraction(this.drawMode); |
257 this.interaction = interaction; | 265 this.interaction = interaction; |
258 this.openLayersMap.addInteraction(interaction); | 266 this.openLayersMap.addInteraction(interaction); |