@wemap/geo 3.1.4 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "directory": "packages/geo"
13
13
  },
14
14
  "name": "@wemap/geo",
15
- "version": "3.1.4",
15
+ "version": "3.1.6",
16
16
  "bugs": {
17
17
  "url": "https://github.com/wemap/wemap-modules-js/issues"
18
18
  },
@@ -33,5 +33,5 @@
33
33
  "lodash.isnumber": "^3.0.3",
34
34
  "lodash.isstring": "^4.0.1"
35
35
  },
36
- "gitHead": "6c7ae4b3ebf1c24e46f3dccb84cfe91cc5534af4"
36
+ "gitHead": "f7967fd5b465e1e2be1c575ef0f2150adde4825f"
37
37
  }
@@ -109,6 +109,26 @@ class BoundingBox {
109
109
  return this;
110
110
  }
111
111
 
112
+ /**
113
+ * Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.
114
+ * For example, a ratio of 0.5 extends the bounds by 50% in each direction.
115
+ * Negative values will retract the bounds.
116
+ * @param {Number} bufferRatio
117
+ * @returns {BoundingBox} `this`
118
+ */
119
+ pad(bufferRatio) {
120
+ const sw = this.southWest;
121
+ const ne = this.northEast;
122
+
123
+ const heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio;
124
+ const widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
125
+
126
+ this.southWest = new Coordinates(sw.lat - heightBuffer, sw.lng - widthBuffer);
127
+ this.northEast = new Coordinates(ne.lat + heightBuffer, ne.lng + widthBuffer);
128
+
129
+ return this;
130
+ }
131
+
112
132
  /**
113
133
  * Returns the southwest corner of the bounding box.
114
134
  *