# HG changeset patch # User Thomas Junk # Date 1545311910 -3600 # Node ID 1fde2f48977bf60c137bd643c5bd481b7caee644 # Parent 49c04bb64e0aee2964d48b1e01f2b1457656b166 fix: calculate center to zoom to via turfjs diff -r 49c04bb64e0a -r 1fde2f48977b client/package.json --- a/client/package.json Thu Dec 20 13:45:32 2018 +0100 +++ b/client/package.json Thu Dec 20 14:18:30 2018 +0100 @@ -21,6 +21,7 @@ "@fortawesome/free-regular-svg-icons": "^5.5.0", "@fortawesome/free-solid-svg-icons": "^5.5.0", "@fortawesome/vue-fontawesome": "^0.1.2", + "@turf/center": "^6.0.1", "@turf/distance": "^6.0.1", "@turf/helpers": "^6.1.4", "@turf/line-intersect": "^6.0.2", diff -r 49c04bb64e0a -r 1fde2f48977b client/src/components/staging/StagingDetail.vue --- a/client/src/components/staging/StagingDetail.vue Thu Dec 20 13:45:32 2018 +0100 +++ b/client/src/components/staging/StagingDetail.vue Thu Dec 20 14:18:30 2018 +0100 @@ -149,6 +149,7 @@ import { WFS } from "ol/format.js"; import { or as orFilter, equalTo as equalToFilter } from "ol/format/filter.js"; import { displayError } from "@/lib/errors.js"; +import center from "@turf/center"; export default { name: "stagingdetail", @@ -234,15 +235,7 @@ return item.status === STATES.APPROVED; }, moveToBottleneck(index) { - const props = this.bottlenecks[index].properties; - console.assert(props, "no props found!"); //inserted during bug hunt - const { bbox } = props; - console.assert(bbox, "no bbox found"); //inserted during bug hunt - const [lat1, long1, lat2, long2] = bbox; - const coordinates = [ - lat1 + (lat2 - lat1) / 2, - long1 + (long2 - long1) / 2 - ]; + const { coordinates } = center(this.bottlenecks[index]).geometry; this.moveMap(coordinates); }, moveMap(coordinates) { diff -r 49c04bb64e0a -r 1fde2f48977b client/src/store/map.js --- a/client/src/store/map.js Thu Dec 20 13:45:32 2018 +0100 +++ b/client/src/store/map.js Thu Dec 20 14:18:30 2018 +0100 @@ -385,9 +385,7 @@ state.cutTool = cutTool; }, moveMap: (state, { coordinates, zoom, preventZoomOut }) => { - console.assert(state.openLayersMap, "no Map found"); // inserted during bug hunt let view = state.openLayersMap.getView(); - console.assert(view, "no view found"); // inserted during bug hunt const currentZoom = view.getZoom(); view.animate({ zoom: preventZoomOut ? Math.max(zoom, currentZoom) : zoom, diff -r 49c04bb64e0a -r 1fde2f48977b client/yarn.lock --- a/client/yarn.lock Thu Dec 20 13:45:32 2018 +0100 +++ b/client/yarn.lock Thu Dec 20 14:18:30 2018 +0100 @@ -710,7 +710,7 @@ resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== -"@turf/bbox@*": +"@turf/bbox@*", "@turf/bbox@6.x": version "6.0.1" resolved "https://registry.yarnpkg.com/@turf/bbox/-/bbox-6.0.1.tgz#b966075771475940ee1c16be2a12cf389e6e923a" integrity sha512-EGgaRLettBG25Iyx7VyUINsPpVj1x3nFQFiGS3ER8KCI1MximzNLsam3eXRabqQDjyAKyAE1bJ4EZEpGvspQxw== @@ -718,6 +718,14 @@ "@turf/helpers" "6.x" "@turf/meta" "6.x" +"@turf/center@^6.0.1": + version "6.0.1" + resolved "https://registry.yarnpkg.com/@turf/center/-/center-6.0.1.tgz#40a17d0a170df5bba09ad93e133b904d8eb14601" + integrity sha512-bh/SLBwRC2QYcbVOxMFBtiARuMzMzfh4YuVtguYAjyBEIA4HXnnEZT+yZlzfcG3oikG7XgV8vg9eegcmwQe+MQ== + dependencies: + "@turf/bbox" "6.x" + "@turf/helpers" "6.x" + "@turf/distance@^6.0.1": version "6.0.1" resolved "https://registry.yarnpkg.com/@turf/distance/-/distance-6.0.1.tgz#0761f28784286e7865a427c4e7e3593569c2dea8"