-
Notifications
You must be signed in to change notification settings - Fork 0
/
core_boundingBoxes_valid3DBoundingBox.js.html
364 lines (346 loc) · 16 KB
/
core_boundingBoxes_valid3DBoundingBox.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>core/boundingBoxes/valid3DBoundingBox.js - Jest-GeoJSON</title>
<meta
name="description"
content="An extended set of matcher functions for the Jest Javascript unit testing framework tailored to evaluating GeoJSON data."
/>
<meta
name="keywords"
content="jest-geojson, jest, testing, validation, geojson, test, gis, assertions, matchers, jest-tests, jest-matchers, javascript, node, npm"
/>
<meta
name="keyword"
content="jest-geojson, jest, testing, validation, geojson, test, gis, assertions, matchers, jest-tests, jest-matchers, javascript, node, npm"
/>
<meta property="og:title" content="Jest-GeoJSON Documentation" />
<meta property="og:type" content="article" />
<meta
property="og:image"
content="https://github.com/M-Scott-Lassiter/jest-geojson/blob/main/images/banner.svg"
/>
<meta property="og:site_name" content="Jest-GeoJSON" />
<meta property="og:url" content="https://github.com/M-Scott-Lassiter/jest-geojson" />
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css" />
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css" />
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav class="wrap">
<input type="text" id="nav-search" placeholder="Search" />
<h2><a href="index.html">Home</a></h2>
<h2>
<a
href="https://github.com/M-Scott-Lassiter/jest-geojson"
target="_blank"
class="menu-item"
id="repository"
>Github Repo</a
>
</h2>
<h3>Namespaces</h3>
<ul>
<li><a href="Core.html">Core</a></li>
<li>
<a href="Core.BoundingBoxes.html">Core.BoundingBoxes</a>
<ul class="methods">
<li data-type="method">
<a href="Core.BoundingBoxes.html#.valid2DBoundingBox"
>valid2DBoundingBox</a
>
</li>
<li data-type="method">
<a href="Core.BoundingBoxes.html#.valid3DBoundingBox"
>valid3DBoundingBox</a
>
</li>
<li data-type="method">
<a href="Core.BoundingBoxes.html#.validBoundingBox">validBoundingBox</a>
</li>
</ul>
</li>
<li>
<a href="Core.Coordinates.html">Core.Coordinates</a>
<ul class="methods">
<li data-type="method">
<a href="Core.Coordinates.html#.valid2DCoordinate">valid2DCoordinate</a>
</li>
<li data-type="method">
<a href="Core.Coordinates.html#.valid3DCoordinate">valid3DCoordinate</a>
</li>
<li data-type="method">
<a href="Core.Coordinates.html#.validCoordinate">validCoordinate</a>
</li>
</ul>
</li>
<li>
<a href="Core.FeatureCollections.html">Core.FeatureCollections</a>
<ul class="methods">
<li data-type="method">
<a href="Core.FeatureCollections.html#.featureCollection"
>featureCollection</a
>
</li>
</ul>
</li>
<li>
<a href="Core.Features.html">Core.Features</a>
<ul class="methods">
<li data-type="method">
<a href="Core.Features.html#.feature">feature</a>
</li>
<li data-type="method"><a href="Core.Features.html#.hasID">hasID</a></li>
</ul>
</li>
<li>
<a href="Core.Geometries.html">Core.Geometries</a>
<ul class="methods">
<li data-type="method">
<a href="Core.Geometries.html#.anyGeometry">anyGeometry</a>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.geometryCollection"
>geometryCollection</a
>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.lineStringGeometry"
>lineStringGeometry</a
>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.multiLineStringGeometry"
>multiLineStringGeometry</a
>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.multiPointGeometry"
>multiPointGeometry</a
>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.multiPolygonGeometry"
>multiPolygonGeometry</a
>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.pointGeometry">pointGeometry</a>
</li>
<li data-type="method">
<a href="Core.Geometries.html#.polygonGeometry">polygonGeometry</a>
</li>
</ul>
</li>
<li>
<a href="Core.Utilities.html">Core.Utilities</a>
<ul class="methods">
<li data-type="method">
<a href="Core.Utilities.html#.commonGeometryValidation"
>commonGeometryValidation</a
>
</li>
<li data-type="method">
<a href="Core.Utilities.html#.validGeoJSON">validGeoJSON</a>
</li>
</ul>
</li>
<li><a href="Matchers.html">Matchers</a></li>
<li>
<a href="Matchers.BoundingBoxes.html">Matchers.BoundingBoxes</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.BoundingBoxes.html#.isValid2DBoundingBox"
>isValid2DBoundingBox</a
>
</li>
<li data-type="method">
<a href="Matchers.BoundingBoxes.html#.isValid3DBoundingBox"
>isValid3DBoundingBox</a
>
</li>
<li data-type="method">
<a href="Matchers.BoundingBoxes.html#.isValidBoundingBox"
>isValidBoundingBox</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Coordinates.html">Matchers.Coordinates</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Coordinates.html#.isValid2DCoordinate"
>isValid2DCoordinate</a
>
</li>
<li data-type="method">
<a href="Matchers.Coordinates.html#.isValid3DCoordinate"
>isValid3DCoordinate</a
>
</li>
<li data-type="method">
<a href="Matchers.Coordinates.html#.isValidCoordinate"
>isValidCoordinate</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.FeatureCollections.html">Matchers.FeatureCollections</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.FeatureCollections.html#.toBeFeatureCollection"
>toBeFeatureCollection</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Features.html">Matchers.Features</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Features.html#.toBeFeature">toBeFeature</a>
</li>
<li data-type="method">
<a href="Matchers.Features.html#.toHaveID">toHaveID</a>
</li>
<li data-type="method">
<a href="Matchers.Features.html#.toHaveStringID">toHaveStringID</a>
</li>
</ul>
</li>
<li>
<a href="Matchers.Functional.html">Matchers.Functional</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Functional.html#.toBeValidGeoJSON"
>toBeValidGeoJSON</a
>
</li>
</ul>
</li>
<li>
<a href="Matchers.Geometries.html">Matchers.Geometries</a>
<ul class="methods">
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeAnyGeometry">toBeAnyGeometry</a>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeGeometryCollection"
>toBeGeometryCollection</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeLineStringGeometry"
>toBeLineStringGeometry</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeMultiLineStringGeometry"
>toBeMultiLineStringGeometry</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeMultiPointGeometry"
>toBeMultiPointGeometry</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBeMultiPolygonGeometry"
>toBeMultiPolygonGeometry</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBePointGeometry"
>toBePointGeometry</a
>
</li>
<li data-type="method">
<a href="Matchers.Geometries.html#.toBePolygonGeometry"
>toBePolygonGeometry</a
>
</li>
</ul>
</li>
</ul>
</nav>
<div id="main">
<h1 class="page-title">core/boundingBoxes/valid3DBoundingBox.js</h1>
<section>
<article>
<pre
class="prettyprint source linenums"
><code>const { valid2DBoundingBox } = require('./valid2DBoundingBox')
/**
* Verifies a three dimensional bounding box meets WGS-84 and GeoJSON validity requirements.
*
* @memberof Core.BoundingBoxes
* @see https://github.com/M-Scott-Lassiter/jest-geojson/issues/7
* @param {number[]} bboxArray A six element WGS-84 array of numbers in format [west, south, depth, east, north, altitude].
* @returns {boolean} True if a valid 3D GeoJSON coordinate. If invalid, it will throw an error.
* @throws {Error} Input must be an array of only four elements of type number
* @throws {Error} Depth and altitude must be numeric.
* @throws {RangeError} Longitude must be a number between -180 and 180
* @throws {RangeError} Latitude must be a number between -90 and 90
* @throws {RangeError} North must be greater than or equal to south
* @throws {RangeError} Altitude must be greater than or equal to depth
* @example
* const goodBBox = valid3DBoundingBox([-10, -20, -100, 20, 10, 0]) // true
* const crossesAntimeridian = valid3DBoundingBox([170, -20, -22.5, 20, -170, 12345.678]) // true
*
* const badExample1 = valid3DBoundingBox([-10, -91, 0, 10, 20, 0]) // throws error for south being out of range
* const badExample2 = valid3DBoundingBox([-10, -10, "0", 10, 20, 0]) // throws error for non-numeric value
*/
function valid3DBoundingBox(bboxArray) {
if (!Array.isArray(bboxArray) || bboxArray.length !== 6) {
throw new Error('Bounding box must be an array of only six elments.')
}
// Reuse functionality from 2D bounding box. The lat/lon values must satisfy the same criteria
valid2DBoundingBox([bboxArray[0], bboxArray[1], bboxArray[3], bboxArray[4]])
if (
typeof bboxArray[2] !== 'number' ||
typeof bboxArray[5] !== 'number' ||
// eslint-disable-next-line no-self-compare
bboxArray[2] !== bboxArray[2] || // Accounts for NaN
// eslint-disable-next-line no-self-compare
bboxArray[5] !== bboxArray[5] // Accounts for NaN
) {
throw new Error('Bounding box depth and altitude must be numeric and cannot be NaN.')
}
if (bboxArray[5] < bboxArray[2]) {
throw new Error('Bounding box altitude value must be greater than depth.')
}
return true
}
exports.valid3DBoundingBox = valid3DBoundingBox
</code></pre>
</article>
</section>
</div>
<br class="clear" />
<footer>
Documentation generated by
<a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> using the
<a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>
prettyPrint()
</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/search.js" defer></script>
</body>
</html>