@wemap/geo 3.1.7 → 3.1.9

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.7",
15
+ "version": "3.1.9",
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": "57ceac64e857a53046b297774286024a157a57af"
36
+ "gitHead": "c77e55703ee07d8928caa4667fc89405797f6324"
37
37
  }
@@ -11,11 +11,7 @@ class BoundingBox {
11
11
  this.southWest = southWest || null;
12
12
  this.northEast = northEast || null;
13
13
 
14
- if (this.southWest && this.northEast
15
- && (
16
- this.southWest.lat > this.northEast.lat
17
- || this.southWest.lng > this.northEast.lng)
18
- ) {
14
+ if (this.southWest && this.northEast && this.getNorth() < this.getSouth()) {
19
15
  throw new Error('Incorrect bounding box');
20
16
  }
21
17
  }
@@ -221,6 +217,14 @@ class BoundingBox {
221
217
  new Coordinates(bounds[1], bounds[0])
222
218
  );
223
219
  }
220
+
221
+ /**
222
+ * Returns the WSEN array
223
+ * @returns {Number[4]} the WSEN array
224
+ */
225
+ toArray() {
226
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()];
227
+ }
224
228
  }
225
229
 
226
230
  export default BoundingBox;
@@ -28,7 +28,8 @@ describe('Bounding Box', () => {
28
28
  expect(boundingBox.northEast).is.null;
29
29
  expect(boundingBox.southWest).is.null;
30
30
 
31
- expect(() => new BoundingBox(new Coordinates(10, -20), new Coordinates(-5, 40))).is.throw(Error);
31
+ expect(() => new BoundingBox(new Coordinates(10, -20), new Coordinates(-5, 40))).not.throw(Error);
32
+ expect(() => new BoundingBox(new Coordinates(-5, -20), new Coordinates(10, 40))).is.throw(Error);
32
33
 
33
34
  boundingBox = new BoundingBox(northEast, southWest);
34
35
  expect(boundingBox.northEast).equals(northEast);
@@ -55,7 +56,6 @@ describe('Bounding Box', () => {
55
56
  ))).false;
56
57
  });
57
58
 
58
-
59
59
  it('bounds', () => {
60
60
  boundingBox = new BoundingBox(northEast, southWest);
61
61
  expect(boundingBox.getNorth()).equals(northEast.lat);
@@ -173,5 +173,7 @@ describe('Bounding Box', () => {
173
173
  .be.closeTo(measure, 0.05 * measure);
174
174
  });
175
175
 
176
-
176
+ it('toArray', () => {
177
+ expect(new BoundingBox(northEast, southWest).toArray()).deep.equals([-20, -5, 40, 10]);
178
+ });
177
179
  });