@turf/isobands 6.5.0 → 7.0.0-alpha.1

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/dist/js/index.js CHANGED
@@ -1,3568 +1,14 @@
1
- 'use strict';
2
-
3
- var bbox = require('@turf/bbox');
4
- var area = require('@turf/area');
5
- var booleanPointInPolygon = require('@turf/boolean-point-in-polygon');
6
- var explode = require('@turf/explode');
7
- var invariant = require('@turf/invariant');
8
- var helpers = require('@turf/helpers');
9
- var objectAssign = require('object-assign');
10
- var meta = require('@turf/meta');
11
-
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var bbox__default = /*#__PURE__*/_interopDefaultLegacy(bbox);
15
- var area__default = /*#__PURE__*/_interopDefaultLegacy(area);
16
- var booleanPointInPolygon__default = /*#__PURE__*/_interopDefaultLegacy(booleanPointInPolygon);
17
- var explode__default = /*#__PURE__*/_interopDefaultLegacy(explode);
18
- var objectAssign__default = /*#__PURE__*/_interopDefaultLegacy(objectAssign);
19
-
20
- /**
21
- * Takes a {@link Point} grid and returns a correspondent matrix {Array<Array<number>>}
22
- * of the 'property' values
23
- *
24
- * @name gridToMatrix
25
- * @param {FeatureCollection<Point>} grid of points
26
- * @param {Object} [options={}] Optional parameters
27
- * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
28
- * @param {boolean} [options.flip=false] returns the matrix upside-down
29
- * @param {boolean} [options.flags=false] flags, adding a `matrixPosition` array field ([row, column]) to its properties,
30
- * the grid points with coordinates on the matrix
31
- * @returns {Array<Array<number>>} matrix of property values
32
- * @example
33
- * var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
34
- * var cellSize = 3;
35
- * var grid = turf.pointGrid(extent, cellSize);
36
- * // add a random property to each point between 0 and 60
37
- * for (var i = 0; i < grid.features.length; i++) {
38
- * grid.features[i].properties.elevation = (Math.random() * 60);
39
- * }
40
- * gridToMatrix(grid);
41
- * //= [
42
- * [ 1, 13, 10, 9, 10, 13, 18],
43
- * [34, 8, 5, 4, 5, 8, 13],
44
- * [10, 5, 2, 1, 2, 5, 4],
45
- * [ 0, 4, 56, 19, 1, 4, 9],
46
- * [10, 5, 2, 1, 2, 5, 10],
47
- * [57, 8, 5, 4, 5, 0, 57],
48
- * [ 3, 13, 10, 9, 5, 13, 18],
49
- * [18, 13, 10, 9, 78, 13, 18]
50
- * ]
51
- */
52
- function gridToMatrix(grid, options) {
53
- // Optional parameters
54
- options = options || {};
55
- if (!helpers.isObject(options)) throw new Error("options is invalid");
56
- var zProperty = options.zProperty || "elevation";
57
- var flip = options.flip;
58
- var flags = options.flags;
59
-
60
- // validation
61
- invariant.collectionOf(grid, "Point", "input must contain Points");
62
-
63
- var pointsMatrix = sortPointsByLatLng(grid, flip);
64
-
65
- var matrix = [];
66
- // create property matrix from sorted points
67
- // looping order matters here
68
- for (var r = 0; r < pointsMatrix.length; r++) {
69
- var pointRow = pointsMatrix[r];
70
- var row = [];
71
- for (var c = 0; c < pointRow.length; c++) {
72
- var point = pointRow[c];
73
- // Check if zProperty exist
74
- if (point.properties[zProperty]) row.push(point.properties[zProperty]);
75
- else row.push(0);
76
- // add flags
77
- if (flags === true) point.properties.matrixPosition = [r, c];
78
- }
79
- matrix.push(row);
80
- }
81
-
82
- return matrix;
83
- }
84
-
85
- /**
86
- * Sorts points by latitude and longitude, creating a 2-dimensional array of points
87
- *
88
- * @private
89
- * @param {FeatureCollection<Point>} points GeoJSON Point features
90
- * @param {boolean} [flip=false] returns the matrix upside-down
91
- * @returns {Array<Array<Point>>} points ordered by latitude and longitude
92
- */
93
- function sortPointsByLatLng(points, flip) {
94
- var pointsByLatitude = {};
95
-
96
- // divide points by rows with the same latitude
97
- meta.featureEach(points, function (point) {
98
- var lat = invariant.getCoords(point)[1];
99
- if (!pointsByLatitude[lat]) pointsByLatitude[lat] = [];
100
- pointsByLatitude[lat].push(point);
101
- });
102
-
103
- // sort points (with the same latitude) by longitude
104
- var orderedRowsByLatitude = Object.keys(pointsByLatitude).map(function (lat) {
105
- var row = pointsByLatitude[lat];
106
- var rowOrderedByLongitude = row.sort(function (a, b) {
107
- return invariant.getCoords(a)[0] - invariant.getCoords(b)[0];
108
- });
109
- return rowOrderedByLongitude;
110
- });
111
-
112
- // sort rows (of points with the same latitude) by latitude
113
- var pointMatrix = orderedRowsByLatitude.sort(function (a, b) {
114
- if (flip) return invariant.getCoords(a[0])[1] - invariant.getCoords(b[0])[1];
115
- else return invariant.getCoords(b[0])[1] - invariant.getCoords(a[0])[1];
116
- });
117
-
118
- return pointMatrix;
119
- }
120
-
121
- /*!
122
- * @license GNU Affero General Public License.
123
- * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
124
- * v. 1.2.0
125
- * https://github.com/RaumZeit/MarchingSquares.js
126
- *
127
- * MarchingSquaresJS is free software: you can redistribute it and/or modify
128
- * it under the terms of the GNU Affero General Public License as published by
129
- * the Free Software Foundation, either version 3 of the License, or
130
- * (at your option) any later version.
131
- *
132
- * MarchingSquaresJS is distributed in the hope that it will be useful,
133
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
134
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
135
- * GNU Affero General Public License for more details.
136
- *
137
- * As additional permission under GNU Affero General Public License version 3
138
- * section 7, third-party projects (personal or commercial) may distribute,
139
- * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the
140
- * requirement that said third-party project for that reason alone becomes
141
- * subject to any requirement of the GNU Affero General Public License version 3.
142
- * Any modifications to MarchingSquaresJS, however, must be shared with the public
143
- * and made available.
144
- *
145
- * In summary this:
146
- * - allows you to use MarchingSquaresJS at no cost
147
- * - allows you to use MarchingSquaresJS for both personal and commercial purposes
148
- * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any
149
- * license as long as this license notice is included
150
- * - enables you to keep the source code of your program that uses MarchingSquaresJS
151
- * undisclosed
152
- * - forces you to share any modifications you have made to MarchingSquaresJS,
153
- * e.g. bug-fixes
154
- *
155
- * You should have received a copy of the GNU Affero General Public License
156
- * along with MarchingSquaresJS. If not, see <http://www.gnu.org/licenses/>.
157
- */
158
- var defaultSettings = {
159
- successCallback: null,
160
- verbose: false,
161
- polygons: false,
162
- };
163
-
164
- var settings = {};
165
-
166
- /*
167
- Compute isobands(s) of a scalar 2D field given a certain
168
- threshold and a bandwidth by applying the Marching Squares
169
- Algorithm. The function returns a list of path coordinates
170
- either for individual polygons within each grid cell, or the
171
- outline of connected polygons.
172
- */
173
- function isoBands(data, minV, bandwidth, options) {
174
- /* process options */
175
- options = options ? options : {};
176
-
177
- var optionKeys = Object.keys(defaultSettings);
178
-
179
- for (var i = 0; i < optionKeys.length; i++) {
180
- var key = optionKeys[i];
181
- var val = options[key];
182
- val =
183
- typeof val !== "undefined" && val !== null ? val : defaultSettings[key];
184
-
185
- settings[key] = val;
186
- }
187
-
188
- if (settings.verbose)
189
- console.log(
190
- "MarchingSquaresJS-isoBands: computing isobands for [" +
191
- minV +
192
- ":" +
193
- (minV + bandwidth) +
194
- "]"
195
- );
196
-
197
- var grid = computeBandGrid(data, minV, bandwidth);
198
-
199
- var ret;
200
- if (settings.polygons) {
201
- if (settings.verbose)
202
- console.log(
203
- "MarchingSquaresJS-isoBands: returning single polygons for each grid cell"
204
- );
205
- ret = BandGrid2Areas(grid);
206
- } else {
207
- if (settings.verbose)
208
- console.log(
209
- "MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"
210
- );
211
- ret = BandGrid2AreaPaths(grid);
212
- }
213
-
214
- if (typeof settings.successCallback === "function")
215
- settings.successCallback(ret);
216
-
217
- return ret;
218
- }
219
-
220
- /*
221
- Thats all for the public interface, below follows the actual
222
- implementation
223
- */
224
-
225
- /* Some private variables */
226
- var Node0 = 64,
227
- Node1 = 16,
228
- Node2 = 4,
229
- Node3 = 1;
230
-
231
- /*
232
- The look-up tables for tracing back the contour path
233
- of isoBands
234
- */
235
-
236
- var isoBandNextXTL = [];
237
- var isoBandNextYTL = [];
238
- var isoBandNextOTL = [];
239
-
240
- var isoBandNextXTR = [];
241
- var isoBandNextYTR = [];
242
- var isoBandNextOTR = [];
243
-
244
- var isoBandNextXRT = [];
245
- var isoBandNextYRT = [];
246
- var isoBandNextORT = [];
247
-
248
- var isoBandNextXRB = [];
249
- var isoBandNextYRB = [];
250
- var isoBandNextORB = [];
251
-
252
- var isoBandNextXBL = [];
253
- var isoBandNextYBL = [];
254
- var isoBandNextOBL = [];
255
-
256
- var isoBandNextXBR = [];
257
- var isoBandNextYBR = [];
258
- var isoBandNextOBR = [];
259
-
260
- var isoBandNextXLT = [];
261
- var isoBandNextYLT = [];
262
- var isoBandNextOLT = [];
263
-
264
- var isoBandNextXLB = [];
265
- var isoBandNextYLB = [];
266
- var isoBandNextOLB = [];
267
-
268
- isoBandNextXRT[85] = isoBandNextXRB[85] = -1;
269
- isoBandNextYRT[85] = isoBandNextYRB[85] = 0;
270
- isoBandNextORT[85] = isoBandNextORB[85] = 1;
271
- isoBandNextXLT[85] = isoBandNextXLB[85] = 1;
272
- isoBandNextYLT[85] = isoBandNextYLB[85] = 0;
273
- isoBandNextOLT[85] = isoBandNextOLB[85] = 1;
274
-
275
- isoBandNextXTL[85] = isoBandNextXTR[85] = 0;
276
- isoBandNextYTL[85] = isoBandNextYTR[85] = -1;
277
- isoBandNextOTL[85] = isoBandNextOBL[85] = 0;
278
- isoBandNextXBR[85] = isoBandNextXBL[85] = 0;
279
- isoBandNextYBR[85] = isoBandNextYBL[85] = 1;
280
- isoBandNextOTR[85] = isoBandNextOBR[85] = 1;
281
-
282
- /* triangle cases */
283
- isoBandNextXLB[1] = isoBandNextXLB[169] = 0;
284
- isoBandNextYLB[1] = isoBandNextYLB[169] = -1;
285
- isoBandNextOLB[1] = isoBandNextOLB[169] = 0;
286
- isoBandNextXBL[1] = isoBandNextXBL[169] = -1;
287
- isoBandNextYBL[1] = isoBandNextYBL[169] = 0;
288
- isoBandNextOBL[1] = isoBandNextOBL[169] = 0;
289
-
290
- isoBandNextXRB[4] = isoBandNextXRB[166] = 0;
291
- isoBandNextYRB[4] = isoBandNextYRB[166] = -1;
292
- isoBandNextORB[4] = isoBandNextORB[166] = 1;
293
- isoBandNextXBR[4] = isoBandNextXBR[166] = 1;
294
- isoBandNextYBR[4] = isoBandNextYBR[166] = 0;
295
- isoBandNextOBR[4] = isoBandNextOBR[166] = 0;
296
-
297
- isoBandNextXRT[16] = isoBandNextXRT[154] = 0;
298
- isoBandNextYRT[16] = isoBandNextYRT[154] = 1;
299
- isoBandNextORT[16] = isoBandNextORT[154] = 1;
300
- isoBandNextXTR[16] = isoBandNextXTR[154] = 1;
301
- isoBandNextYTR[16] = isoBandNextYTR[154] = 0;
302
- isoBandNextOTR[16] = isoBandNextOTR[154] = 1;
303
-
304
- isoBandNextXLT[64] = isoBandNextXLT[106] = 0;
305
- isoBandNextYLT[64] = isoBandNextYLT[106] = 1;
306
- isoBandNextOLT[64] = isoBandNextOLT[106] = 0;
307
- isoBandNextXTL[64] = isoBandNextXTL[106] = -1;
308
- isoBandNextYTL[64] = isoBandNextYTL[106] = 0;
309
- isoBandNextOTL[64] = isoBandNextOTL[106] = 1;
310
-
311
- /* single trapezoid cases */
312
- isoBandNextXLT[2] = isoBandNextXLT[168] = 0;
313
- isoBandNextYLT[2] = isoBandNextYLT[168] = -1;
314
- isoBandNextOLT[2] = isoBandNextOLT[168] = 1;
315
- isoBandNextXLB[2] = isoBandNextXLB[168] = 0;
316
- isoBandNextYLB[2] = isoBandNextYLB[168] = -1;
317
- isoBandNextOLB[2] = isoBandNextOLB[168] = 0;
318
- isoBandNextXBL[2] = isoBandNextXBL[168] = -1;
319
- isoBandNextYBL[2] = isoBandNextYBL[168] = 0;
320
- isoBandNextOBL[2] = isoBandNextOBL[168] = 0;
321
- isoBandNextXBR[2] = isoBandNextXBR[168] = -1;
322
- isoBandNextYBR[2] = isoBandNextYBR[168] = 0;
323
- isoBandNextOBR[2] = isoBandNextOBR[168] = 1;
324
-
325
- isoBandNextXRT[8] = isoBandNextXRT[162] = 0;
326
- isoBandNextYRT[8] = isoBandNextYRT[162] = -1;
327
- isoBandNextORT[8] = isoBandNextORT[162] = 0;
328
- isoBandNextXRB[8] = isoBandNextXRB[162] = 0;
329
- isoBandNextYRB[8] = isoBandNextYRB[162] = -1;
330
- isoBandNextORB[8] = isoBandNextORB[162] = 1;
331
- isoBandNextXBL[8] = isoBandNextXBL[162] = 1;
332
- isoBandNextYBL[8] = isoBandNextYBL[162] = 0;
333
- isoBandNextOBL[8] = isoBandNextOBL[162] = 1;
334
- isoBandNextXBR[8] = isoBandNextXBR[162] = 1;
335
- isoBandNextYBR[8] = isoBandNextYBR[162] = 0;
336
- isoBandNextOBR[8] = isoBandNextOBR[162] = 0;
337
-
338
- isoBandNextXRT[32] = isoBandNextXRT[138] = 0;
339
- isoBandNextYRT[32] = isoBandNextYRT[138] = 1;
340
- isoBandNextORT[32] = isoBandNextORT[138] = 1;
341
- isoBandNextXRB[32] = isoBandNextXRB[138] = 0;
342
- isoBandNextYRB[32] = isoBandNextYRB[138] = 1;
343
- isoBandNextORB[32] = isoBandNextORB[138] = 0;
344
- isoBandNextXTL[32] = isoBandNextXTL[138] = 1;
345
- isoBandNextYTL[32] = isoBandNextYTL[138] = 0;
346
- isoBandNextOTL[32] = isoBandNextOTL[138] = 0;
347
- isoBandNextXTR[32] = isoBandNextXTR[138] = 1;
348
- isoBandNextYTR[32] = isoBandNextYTR[138] = 0;
349
- isoBandNextOTR[32] = isoBandNextOTR[138] = 1;
350
-
351
- isoBandNextXLB[128] = isoBandNextXLB[42] = 0;
352
- isoBandNextYLB[128] = isoBandNextYLB[42] = 1;
353
- isoBandNextOLB[128] = isoBandNextOLB[42] = 1;
354
- isoBandNextXLT[128] = isoBandNextXLT[42] = 0;
355
- isoBandNextYLT[128] = isoBandNextYLT[42] = 1;
356
- isoBandNextOLT[128] = isoBandNextOLT[42] = 0;
357
- isoBandNextXTL[128] = isoBandNextXTL[42] = -1;
358
- isoBandNextYTL[128] = isoBandNextYTL[42] = 0;
359
- isoBandNextOTL[128] = isoBandNextOTL[42] = 1;
360
- isoBandNextXTR[128] = isoBandNextXTR[42] = -1;
361
- isoBandNextYTR[128] = isoBandNextYTR[42] = 0;
362
- isoBandNextOTR[128] = isoBandNextOTR[42] = 0;
363
-
364
- /* single rectangle cases */
365
- isoBandNextXRB[5] = isoBandNextXRB[165] = -1;
366
- isoBandNextYRB[5] = isoBandNextYRB[165] = 0;
367
- isoBandNextORB[5] = isoBandNextORB[165] = 0;
368
- isoBandNextXLB[5] = isoBandNextXLB[165] = 1;
369
- isoBandNextYLB[5] = isoBandNextYLB[165] = 0;
370
- isoBandNextOLB[5] = isoBandNextOLB[165] = 0;
371
-
372
- isoBandNextXBR[20] = isoBandNextXBR[150] = 0;
373
- isoBandNextYBR[20] = isoBandNextYBR[150] = 1;
374
- isoBandNextOBR[20] = isoBandNextOBR[150] = 1;
375
- isoBandNextXTR[20] = isoBandNextXTR[150] = 0;
376
- isoBandNextYTR[20] = isoBandNextYTR[150] = -1;
377
- isoBandNextOTR[20] = isoBandNextOTR[150] = 1;
378
-
379
- isoBandNextXRT[80] = isoBandNextXRT[90] = -1;
380
- isoBandNextYRT[80] = isoBandNextYRT[90] = 0;
381
- isoBandNextORT[80] = isoBandNextORT[90] = 1;
382
- isoBandNextXLT[80] = isoBandNextXLT[90] = 1;
383
- isoBandNextYLT[80] = isoBandNextYLT[90] = 0;
384
- isoBandNextOLT[80] = isoBandNextOLT[90] = 1;
385
-
386
- isoBandNextXBL[65] = isoBandNextXBL[105] = 0;
387
- isoBandNextYBL[65] = isoBandNextYBL[105] = 1;
388
- isoBandNextOBL[65] = isoBandNextOBL[105] = 0;
389
- isoBandNextXTL[65] = isoBandNextXTL[105] = 0;
390
- isoBandNextYTL[65] = isoBandNextYTL[105] = -1;
391
- isoBandNextOTL[65] = isoBandNextOTL[105] = 0;
392
-
393
- isoBandNextXRT[160] = isoBandNextXRT[10] = -1;
394
- isoBandNextYRT[160] = isoBandNextYRT[10] = 0;
395
- isoBandNextORT[160] = isoBandNextORT[10] = 1;
396
- isoBandNextXRB[160] = isoBandNextXRB[10] = -1;
397
- isoBandNextYRB[160] = isoBandNextYRB[10] = 0;
398
- isoBandNextORB[160] = isoBandNextORB[10] = 0;
399
- isoBandNextXLB[160] = isoBandNextXLB[10] = 1;
400
- isoBandNextYLB[160] = isoBandNextYLB[10] = 0;
401
- isoBandNextOLB[160] = isoBandNextOLB[10] = 0;
402
- isoBandNextXLT[160] = isoBandNextXLT[10] = 1;
403
- isoBandNextYLT[160] = isoBandNextYLT[10] = 0;
404
- isoBandNextOLT[160] = isoBandNextOLT[10] = 1;
405
-
406
- isoBandNextXBR[130] = isoBandNextXBR[40] = 0;
407
- isoBandNextYBR[130] = isoBandNextYBR[40] = 1;
408
- isoBandNextOBR[130] = isoBandNextOBR[40] = 1;
409
- isoBandNextXBL[130] = isoBandNextXBL[40] = 0;
410
- isoBandNextYBL[130] = isoBandNextYBL[40] = 1;
411
- isoBandNextOBL[130] = isoBandNextOBL[40] = 0;
412
- isoBandNextXTL[130] = isoBandNextXTL[40] = 0;
413
- isoBandNextYTL[130] = isoBandNextYTL[40] = -1;
414
- isoBandNextOTL[130] = isoBandNextOTL[40] = 0;
415
- isoBandNextXTR[130] = isoBandNextXTR[40] = 0;
416
- isoBandNextYTR[130] = isoBandNextYTR[40] = -1;
417
- isoBandNextOTR[130] = isoBandNextOTR[40] = 1;
418
-
419
- /* single hexagon cases */
420
- isoBandNextXRB[37] = isoBandNextXRB[133] = 0;
421
- isoBandNextYRB[37] = isoBandNextYRB[133] = 1;
422
- isoBandNextORB[37] = isoBandNextORB[133] = 1;
423
- isoBandNextXLB[37] = isoBandNextXLB[133] = 0;
424
- isoBandNextYLB[37] = isoBandNextYLB[133] = 1;
425
- isoBandNextOLB[37] = isoBandNextOLB[133] = 0;
426
- isoBandNextXTL[37] = isoBandNextXTL[133] = -1;
427
- isoBandNextYTL[37] = isoBandNextYTL[133] = 0;
428
- isoBandNextOTL[37] = isoBandNextOTL[133] = 0;
429
- isoBandNextXTR[37] = isoBandNextXTR[133] = 1;
430
- isoBandNextYTR[37] = isoBandNextYTR[133] = 0;
431
- isoBandNextOTR[37] = isoBandNextOTR[133] = 0;
432
-
433
- isoBandNextXBR[148] = isoBandNextXBR[22] = -1;
434
- isoBandNextYBR[148] = isoBandNextYBR[22] = 0;
435
- isoBandNextOBR[148] = isoBandNextOBR[22] = 0;
436
- isoBandNextXLB[148] = isoBandNextXLB[22] = 0;
437
- isoBandNextYLB[148] = isoBandNextYLB[22] = -1;
438
- isoBandNextOLB[148] = isoBandNextOLB[22] = 1;
439
- isoBandNextXLT[148] = isoBandNextXLT[22] = 0;
440
- isoBandNextYLT[148] = isoBandNextYLT[22] = 1;
441
- isoBandNextOLT[148] = isoBandNextOLT[22] = 1;
442
- isoBandNextXTR[148] = isoBandNextXTR[22] = -1;
443
- isoBandNextYTR[148] = isoBandNextYTR[22] = 0;
444
- isoBandNextOTR[148] = isoBandNextOTR[22] = 1;
445
-
446
- isoBandNextXRT[82] = isoBandNextXRT[88] = 0;
447
- isoBandNextYRT[82] = isoBandNextYRT[88] = -1;
448
- isoBandNextORT[82] = isoBandNextORT[88] = 1;
449
- isoBandNextXBR[82] = isoBandNextXBR[88] = 1;
450
- isoBandNextYBR[82] = isoBandNextYBR[88] = 0;
451
- isoBandNextOBR[82] = isoBandNextOBR[88] = 1;
452
- isoBandNextXBL[82] = isoBandNextXBL[88] = -1;
453
- isoBandNextYBL[82] = isoBandNextYBL[88] = 0;
454
- isoBandNextOBL[82] = isoBandNextOBL[88] = 1;
455
- isoBandNextXLT[82] = isoBandNextXLT[88] = 0;
456
- isoBandNextYLT[82] = isoBandNextYLT[88] = -1;
457
- isoBandNextOLT[82] = isoBandNextOLT[88] = 0;
458
-
459
- isoBandNextXRT[73] = isoBandNextXRT[97] = 0;
460
- isoBandNextYRT[73] = isoBandNextYRT[97] = 1;
461
- isoBandNextORT[73] = isoBandNextORT[97] = 0;
462
- isoBandNextXRB[73] = isoBandNextXRB[97] = 0;
463
- isoBandNextYRB[73] = isoBandNextYRB[97] = -1;
464
- isoBandNextORB[73] = isoBandNextORB[97] = 0;
465
- isoBandNextXBL[73] = isoBandNextXBL[97] = 1;
466
- isoBandNextYBL[73] = isoBandNextYBL[97] = 0;
467
- isoBandNextOBL[73] = isoBandNextOBL[97] = 0;
468
- isoBandNextXTL[73] = isoBandNextXTL[97] = 1;
469
- isoBandNextYTL[73] = isoBandNextYTL[97] = 0;
470
- isoBandNextOTL[73] = isoBandNextOTL[97] = 1;
471
-
472
- isoBandNextXRT[145] = isoBandNextXRT[25] = 0;
473
- isoBandNextYRT[145] = isoBandNextYRT[25] = -1;
474
- isoBandNextORT[145] = isoBandNextORT[25] = 0;
475
- isoBandNextXBL[145] = isoBandNextXBL[25] = 1;
476
- isoBandNextYBL[145] = isoBandNextYBL[25] = 0;
477
- isoBandNextOBL[145] = isoBandNextOBL[25] = 1;
478
- isoBandNextXLB[145] = isoBandNextXLB[25] = 0;
479
- isoBandNextYLB[145] = isoBandNextYLB[25] = 1;
480
- isoBandNextOLB[145] = isoBandNextOLB[25] = 1;
481
- isoBandNextXTR[145] = isoBandNextXTR[25] = -1;
482
- isoBandNextYTR[145] = isoBandNextYTR[25] = 0;
483
- isoBandNextOTR[145] = isoBandNextOTR[25] = 0;
484
-
485
- isoBandNextXRB[70] = isoBandNextXRB[100] = 0;
486
- isoBandNextYRB[70] = isoBandNextYRB[100] = 1;
487
- isoBandNextORB[70] = isoBandNextORB[100] = 0;
488
- isoBandNextXBR[70] = isoBandNextXBR[100] = -1;
489
- isoBandNextYBR[70] = isoBandNextYBR[100] = 0;
490
- isoBandNextOBR[70] = isoBandNextOBR[100] = 1;
491
- isoBandNextXLT[70] = isoBandNextXLT[100] = 0;
492
- isoBandNextYLT[70] = isoBandNextYLT[100] = -1;
493
- isoBandNextOLT[70] = isoBandNextOLT[100] = 1;
494
- isoBandNextXTL[70] = isoBandNextXTL[100] = 1;
495
- isoBandNextYTL[70] = isoBandNextYTL[100] = 0;
496
- isoBandNextOTL[70] = isoBandNextOTL[100] = 0;
497
-
498
- /* single pentagon cases */
499
- isoBandNextXRB[101] = isoBandNextXRB[69] = 0;
500
- isoBandNextYRB[101] = isoBandNextYRB[69] = 1;
501
- isoBandNextORB[101] = isoBandNextORB[69] = 0;
502
- isoBandNextXTL[101] = isoBandNextXTL[69] = 1;
503
- isoBandNextYTL[101] = isoBandNextYTL[69] = 0;
504
- isoBandNextOTL[101] = isoBandNextOTL[69] = 0;
505
-
506
- isoBandNextXLB[149] = isoBandNextXLB[21] = 0;
507
- isoBandNextYLB[149] = isoBandNextYLB[21] = 1;
508
- isoBandNextOLB[149] = isoBandNextOLB[21] = 1;
509
- isoBandNextXTR[149] = isoBandNextXTR[21] = -1;
510
- isoBandNextYTR[149] = isoBandNextYTR[21] = 0;
511
- isoBandNextOTR[149] = isoBandNextOTR[21] = 0;
512
-
513
- isoBandNextXBR[86] = isoBandNextXBR[84] = -1;
514
- isoBandNextYBR[86] = isoBandNextYBR[84] = 0;
515
- isoBandNextOBR[86] = isoBandNextOBR[84] = 1;
516
- isoBandNextXLT[86] = isoBandNextXLT[84] = 0;
517
- isoBandNextYLT[86] = isoBandNextYLT[84] = -1;
518
- isoBandNextOLT[86] = isoBandNextOLT[84] = 1;
519
-
520
- isoBandNextXRT[89] = isoBandNextXRT[81] = 0;
521
- isoBandNextYRT[89] = isoBandNextYRT[81] = -1;
522
- isoBandNextORT[89] = isoBandNextORT[81] = 0;
523
- isoBandNextXBL[89] = isoBandNextXBL[81] = 1;
524
- isoBandNextYBL[89] = isoBandNextYBL[81] = 0;
525
- isoBandNextOBL[89] = isoBandNextOBL[81] = 1;
526
-
527
- isoBandNextXRT[96] = isoBandNextXRT[74] = 0;
528
- isoBandNextYRT[96] = isoBandNextYRT[74] = 1;
529
- isoBandNextORT[96] = isoBandNextORT[74] = 0;
530
- isoBandNextXRB[96] = isoBandNextXRB[74] = -1;
531
- isoBandNextYRB[96] = isoBandNextYRB[74] = 0;
532
- isoBandNextORB[96] = isoBandNextORB[74] = 1;
533
- isoBandNextXLT[96] = isoBandNextXLT[74] = 1;
534
- isoBandNextYLT[96] = isoBandNextYLT[74] = 0;
535
- isoBandNextOLT[96] = isoBandNextOLT[74] = 0;
536
- isoBandNextXTL[96] = isoBandNextXTL[74] = 1;
537
- isoBandNextYTL[96] = isoBandNextYTL[74] = 0;
538
- isoBandNextOTL[96] = isoBandNextOTL[74] = 1;
539
-
540
- isoBandNextXRT[24] = isoBandNextXRT[146] = 0;
541
- isoBandNextYRT[24] = isoBandNextYRT[146] = -1;
542
- isoBandNextORT[24] = isoBandNextORT[146] = 1;
543
- isoBandNextXBR[24] = isoBandNextXBR[146] = 1;
544
- isoBandNextYBR[24] = isoBandNextYBR[146] = 0;
545
- isoBandNextOBR[24] = isoBandNextOBR[146] = 1;
546
- isoBandNextXBL[24] = isoBandNextXBL[146] = 0;
547
- isoBandNextYBL[24] = isoBandNextYBL[146] = 1;
548
- isoBandNextOBL[24] = isoBandNextOBL[146] = 1;
549
- isoBandNextXTR[24] = isoBandNextXTR[146] = 0;
550
- isoBandNextYTR[24] = isoBandNextYTR[146] = -1;
551
- isoBandNextOTR[24] = isoBandNextOTR[146] = 0;
552
-
553
- isoBandNextXRB[6] = isoBandNextXRB[164] = -1;
554
- isoBandNextYRB[6] = isoBandNextYRB[164] = 0;
555
- isoBandNextORB[6] = isoBandNextORB[164] = 1;
556
- isoBandNextXBR[6] = isoBandNextXBR[164] = -1;
557
- isoBandNextYBR[6] = isoBandNextYBR[164] = 0;
558
- isoBandNextOBR[6] = isoBandNextOBR[164] = 0;
559
- isoBandNextXLB[6] = isoBandNextXLB[164] = 0;
560
- isoBandNextYLB[6] = isoBandNextYLB[164] = -1;
561
- isoBandNextOLB[6] = isoBandNextOLB[164] = 1;
562
- isoBandNextXLT[6] = isoBandNextXLT[164] = 1;
563
- isoBandNextYLT[6] = isoBandNextYLT[164] = 0;
564
- isoBandNextOLT[6] = isoBandNextOLT[164] = 0;
565
-
566
- isoBandNextXBL[129] = isoBandNextXBL[41] = 0;
567
- isoBandNextYBL[129] = isoBandNextYBL[41] = 1;
568
- isoBandNextOBL[129] = isoBandNextOBL[41] = 1;
569
- isoBandNextXLB[129] = isoBandNextXLB[41] = 0;
570
- isoBandNextYLB[129] = isoBandNextYLB[41] = 1;
571
- isoBandNextOLB[129] = isoBandNextOLB[41] = 0;
572
- isoBandNextXTL[129] = isoBandNextXTL[41] = -1;
573
- isoBandNextYTL[129] = isoBandNextYTL[41] = 0;
574
- isoBandNextOTL[129] = isoBandNextOTL[41] = 0;
575
- isoBandNextXTR[129] = isoBandNextXTR[41] = 0;
576
- isoBandNextYTR[129] = isoBandNextYTR[41] = -1;
577
- isoBandNextOTR[129] = isoBandNextOTR[41] = 0;
578
-
579
- isoBandNextXBR[66] = isoBandNextXBR[104] = 0;
580
- isoBandNextYBR[66] = isoBandNextYBR[104] = 1;
581
- isoBandNextOBR[66] = isoBandNextOBR[104] = 0;
582
- isoBandNextXBL[66] = isoBandNextXBL[104] = -1;
583
- isoBandNextYBL[66] = isoBandNextYBL[104] = 0;
584
- isoBandNextOBL[66] = isoBandNextOBL[104] = 1;
585
- isoBandNextXLT[66] = isoBandNextXLT[104] = 0;
586
- isoBandNextYLT[66] = isoBandNextYLT[104] = -1;
587
- isoBandNextOLT[66] = isoBandNextOLT[104] = 0;
588
- isoBandNextXTL[66] = isoBandNextXTL[104] = 0;
589
- isoBandNextYTL[66] = isoBandNextYTL[104] = -1;
590
- isoBandNextOTL[66] = isoBandNextOTL[104] = 1;
591
-
592
- isoBandNextXRT[144] = isoBandNextXRT[26] = -1;
593
- isoBandNextYRT[144] = isoBandNextYRT[26] = 0;
594
- isoBandNextORT[144] = isoBandNextORT[26] = 0;
595
- isoBandNextXLB[144] = isoBandNextXLB[26] = 1;
596
- isoBandNextYLB[144] = isoBandNextYLB[26] = 0;
597
- isoBandNextOLB[144] = isoBandNextOLB[26] = 1;
598
- isoBandNextXLT[144] = isoBandNextXLT[26] = 0;
599
- isoBandNextYLT[144] = isoBandNextYLT[26] = 1;
600
- isoBandNextOLT[144] = isoBandNextOLT[26] = 1;
601
- isoBandNextXTR[144] = isoBandNextXTR[26] = -1;
602
- isoBandNextYTR[144] = isoBandNextYTR[26] = 0;
603
- isoBandNextOTR[144] = isoBandNextOTR[26] = 1;
604
-
605
- isoBandNextXRB[36] = isoBandNextXRB[134] = 0;
606
- isoBandNextYRB[36] = isoBandNextYRB[134] = 1;
607
- isoBandNextORB[36] = isoBandNextORB[134] = 1;
608
- isoBandNextXBR[36] = isoBandNextXBR[134] = 0;
609
- isoBandNextYBR[36] = isoBandNextYBR[134] = 1;
610
- isoBandNextOBR[36] = isoBandNextOBR[134] = 0;
611
- isoBandNextXTL[36] = isoBandNextXTL[134] = 0;
612
- isoBandNextYTL[36] = isoBandNextYTL[134] = -1;
613
- isoBandNextOTL[36] = isoBandNextOTL[134] = 1;
614
- isoBandNextXTR[36] = isoBandNextXTR[134] = 1;
615
- isoBandNextYTR[36] = isoBandNextYTR[134] = 0;
616
- isoBandNextOTR[36] = isoBandNextOTR[134] = 0;
617
-
618
- isoBandNextXRT[9] = isoBandNextXRT[161] = -1;
619
- isoBandNextYRT[9] = isoBandNextYRT[161] = 0;
620
- isoBandNextORT[9] = isoBandNextORT[161] = 0;
621
- isoBandNextXRB[9] = isoBandNextXRB[161] = 0;
622
- isoBandNextYRB[9] = isoBandNextYRB[161] = -1;
623
- isoBandNextORB[9] = isoBandNextORB[161] = 0;
624
- isoBandNextXBL[9] = isoBandNextXBL[161] = 1;
625
- isoBandNextYBL[9] = isoBandNextYBL[161] = 0;
626
- isoBandNextOBL[9] = isoBandNextOBL[161] = 0;
627
- isoBandNextXLB[9] = isoBandNextXLB[161] = 1;
628
- isoBandNextYLB[9] = isoBandNextYLB[161] = 0;
629
- isoBandNextOLB[9] = isoBandNextOLB[161] = 1;
630
-
631
- /* 8-sided cases */
632
- isoBandNextXRT[136] = 0;
633
- isoBandNextYRT[136] = 1;
634
- isoBandNextORT[136] = 1;
635
- isoBandNextXRB[136] = 0;
636
- isoBandNextYRB[136] = 1;
637
- isoBandNextORB[136] = 0;
638
- isoBandNextXBR[136] = -1;
639
- isoBandNextYBR[136] = 0;
640
- isoBandNextOBR[136] = 1;
641
- isoBandNextXBL[136] = -1;
642
- isoBandNextYBL[136] = 0;
643
- isoBandNextOBL[136] = 0;
644
- isoBandNextXLB[136] = 0;
645
- isoBandNextYLB[136] = -1;
646
- isoBandNextOLB[136] = 0;
647
- isoBandNextXLT[136] = 0;
648
- isoBandNextYLT[136] = -1;
649
- isoBandNextOLT[136] = 1;
650
- isoBandNextXTL[136] = 1;
651
- isoBandNextYTL[136] = 0;
652
- isoBandNextOTL[136] = 0;
653
- isoBandNextXTR[136] = 1;
654
- isoBandNextYTR[136] = 0;
655
- isoBandNextOTR[136] = 1;
656
-
657
- isoBandNextXRT[34] = 0;
658
- isoBandNextYRT[34] = -1;
659
- isoBandNextORT[34] = 0;
660
- isoBandNextXRB[34] = 0;
661
- isoBandNextYRB[34] = -1;
662
- isoBandNextORB[34] = 1;
663
- isoBandNextXBR[34] = 1;
664
- isoBandNextYBR[34] = 0;
665
- isoBandNextOBR[34] = 0;
666
- isoBandNextXBL[34] = 1;
667
- isoBandNextYBL[34] = 0;
668
- isoBandNextOBL[34] = 1;
669
- isoBandNextXLB[34] = 0;
670
- isoBandNextYLB[34] = 1;
671
- isoBandNextOLB[34] = 1;
672
- isoBandNextXLT[34] = 0;
673
- isoBandNextYLT[34] = 1;
674
- isoBandNextOLT[34] = 0;
675
- isoBandNextXTL[34] = -1;
676
- isoBandNextYTL[34] = 0;
677
- isoBandNextOTL[34] = 1;
678
- isoBandNextXTR[34] = -1;
679
- isoBandNextYTR[34] = 0;
680
- isoBandNextOTR[34] = 0;
681
-
682
- isoBandNextXRT[35] = 0;
683
- isoBandNextYRT[35] = 1;
684
- isoBandNextORT[35] = 1;
685
- isoBandNextXRB[35] = 0;
686
- isoBandNextYRB[35] = -1;
687
- isoBandNextORB[35] = 1;
688
- isoBandNextXBR[35] = 1;
689
- isoBandNextYBR[35] = 0;
690
- isoBandNextOBR[35] = 0;
691
- isoBandNextXBL[35] = -1;
692
- isoBandNextYBL[35] = 0;
693
- isoBandNextOBL[35] = 0;
694
- isoBandNextXLB[35] = 0;
695
- isoBandNextYLB[35] = -1;
696
- isoBandNextOLB[35] = 0;
697
- isoBandNextXLT[35] = 0;
698
- isoBandNextYLT[35] = 1;
699
- isoBandNextOLT[35] = 0;
700
- isoBandNextXTL[35] = -1;
701
- isoBandNextYTL[35] = 0;
702
- isoBandNextOTL[35] = 1;
703
- isoBandNextXTR[35] = 1;
704
- isoBandNextYTR[35] = 0;
705
- isoBandNextOTR[35] = 1;
706
-
707
- /* 6-sided cases */
708
- isoBandNextXRT[153] = 0;
709
- isoBandNextYRT[153] = 1;
710
- isoBandNextORT[153] = 1;
711
- isoBandNextXBL[153] = -1;
712
- isoBandNextYBL[153] = 0;
713
- isoBandNextOBL[153] = 0;
714
- isoBandNextXLB[153] = 0;
715
- isoBandNextYLB[153] = -1;
716
- isoBandNextOLB[153] = 0;
717
- isoBandNextXTR[153] = 1;
718
- isoBandNextYTR[153] = 0;
719
- isoBandNextOTR[153] = 1;
720
-
721
- isoBandNextXRB[102] = 0;
722
- isoBandNextYRB[102] = -1;
723
- isoBandNextORB[102] = 1;
724
- isoBandNextXBR[102] = 1;
725
- isoBandNextYBR[102] = 0;
726
- isoBandNextOBR[102] = 0;
727
- isoBandNextXLT[102] = 0;
728
- isoBandNextYLT[102] = 1;
729
- isoBandNextOLT[102] = 0;
730
- isoBandNextXTL[102] = -1;
731
- isoBandNextYTL[102] = 0;
732
- isoBandNextOTL[102] = 1;
733
-
734
- isoBandNextXRT[155] = 0;
735
- isoBandNextYRT[155] = -1;
736
- isoBandNextORT[155] = 0;
737
- isoBandNextXBL[155] = 1;
738
- isoBandNextYBL[155] = 0;
739
- isoBandNextOBL[155] = 1;
740
- isoBandNextXLB[155] = 0;
741
- isoBandNextYLB[155] = 1;
742
- isoBandNextOLB[155] = 1;
743
- isoBandNextXTR[155] = -1;
744
- isoBandNextYTR[155] = 0;
745
- isoBandNextOTR[155] = 0;
746
-
747
- isoBandNextXRB[103] = 0;
748
- isoBandNextYRB[103] = 1;
749
- isoBandNextORB[103] = 0;
750
- isoBandNextXBR[103] = -1;
751
- isoBandNextYBR[103] = 0;
752
- isoBandNextOBR[103] = 1;
753
- isoBandNextXLT[103] = 0;
754
- isoBandNextYLT[103] = -1;
755
- isoBandNextOLT[103] = 1;
756
- isoBandNextXTL[103] = 1;
757
- isoBandNextYTL[103] = 0;
758
- isoBandNextOTL[103] = 0;
759
-
760
- /* 7-sided cases */
761
- isoBandNextXRT[152] = 0;
762
- isoBandNextYRT[152] = 1;
763
- isoBandNextORT[152] = 1;
764
- isoBandNextXBR[152] = -1;
765
- isoBandNextYBR[152] = 0;
766
- isoBandNextOBR[152] = 1;
767
- isoBandNextXBL[152] = -1;
768
- isoBandNextYBL[152] = 0;
769
- isoBandNextOBL[152] = 0;
770
- isoBandNextXLB[152] = 0;
771
- isoBandNextYLB[152] = -1;
772
- isoBandNextOLB[152] = 0;
773
- isoBandNextXLT[152] = 0;
774
- isoBandNextYLT[152] = -1;
775
- isoBandNextOLT[152] = 1;
776
- isoBandNextXTR[152] = 1;
777
- isoBandNextYTR[152] = 0;
778
- isoBandNextOTR[152] = 1;
779
-
780
- isoBandNextXRT[156] = 0;
781
- isoBandNextYRT[156] = -1;
782
- isoBandNextORT[156] = 1;
783
- isoBandNextXBR[156] = 1;
784
- isoBandNextYBR[156] = 0;
785
- isoBandNextOBR[156] = 1;
786
- isoBandNextXBL[156] = -1;
787
- isoBandNextYBL[156] = 0;
788
- isoBandNextOBL[156] = 0;
789
- isoBandNextXLB[156] = 0;
790
- isoBandNextYLB[156] = -1;
791
- isoBandNextOLB[156] = 0;
792
- isoBandNextXLT[156] = 0;
793
- isoBandNextYLT[156] = 1;
794
- isoBandNextOLT[156] = 1;
795
- isoBandNextXTR[156] = -1;
796
- isoBandNextYTR[156] = 0;
797
- isoBandNextOTR[156] = 1;
798
-
799
- isoBandNextXRT[137] = 0;
800
- isoBandNextYRT[137] = 1;
801
- isoBandNextORT[137] = 1;
802
- isoBandNextXRB[137] = 0;
803
- isoBandNextYRB[137] = 1;
804
- isoBandNextORB[137] = 0;
805
- isoBandNextXBL[137] = -1;
806
- isoBandNextYBL[137] = 0;
807
- isoBandNextOBL[137] = 0;
808
- isoBandNextXLB[137] = 0;
809
- isoBandNextYLB[137] = -1;
810
- isoBandNextOLB[137] = 0;
811
- isoBandNextXTL[137] = 1;
812
- isoBandNextYTL[137] = 0;
813
- isoBandNextOTL[137] = 0;
814
- isoBandNextXTR[137] = 1;
815
- isoBandNextYTR[137] = 0;
816
- isoBandNextOTR[137] = 1;
817
-
818
- isoBandNextXRT[139] = 0;
819
- isoBandNextYRT[139] = 1;
820
- isoBandNextORT[139] = 1;
821
- isoBandNextXRB[139] = 0;
822
- isoBandNextYRB[139] = -1;
823
- isoBandNextORB[139] = 0;
824
- isoBandNextXBL[139] = 1;
825
- isoBandNextYBL[139] = 0;
826
- isoBandNextOBL[139] = 0;
827
- isoBandNextXLB[139] = 0;
828
- isoBandNextYLB[139] = 1;
829
- isoBandNextOLB[139] = 0;
830
- isoBandNextXTL[139] = -1;
831
- isoBandNextYTL[139] = 0;
832
- isoBandNextOTL[139] = 0;
833
- isoBandNextXTR[139] = 1;
834
- isoBandNextYTR[139] = 0;
835
- isoBandNextOTR[139] = 1;
836
-
837
- isoBandNextXRT[98] = 0;
838
- isoBandNextYRT[98] = -1;
839
- isoBandNextORT[98] = 0;
840
- isoBandNextXRB[98] = 0;
841
- isoBandNextYRB[98] = -1;
842
- isoBandNextORB[98] = 1;
843
- isoBandNextXBR[98] = 1;
844
- isoBandNextYBR[98] = 0;
845
- isoBandNextOBR[98] = 0;
846
- isoBandNextXBL[98] = 1;
847
- isoBandNextYBL[98] = 0;
848
- isoBandNextOBL[98] = 1;
849
- isoBandNextXLT[98] = 0;
850
- isoBandNextYLT[98] = 1;
851
- isoBandNextOLT[98] = 0;
852
- isoBandNextXTL[98] = -1;
853
- isoBandNextYTL[98] = 0;
854
- isoBandNextOTL[98] = 1;
855
-
856
- isoBandNextXRT[99] = 0;
857
- isoBandNextYRT[99] = 1;
858
- isoBandNextORT[99] = 0;
859
- isoBandNextXRB[99] = 0;
860
- isoBandNextYRB[99] = -1;
861
- isoBandNextORB[99] = 1;
862
- isoBandNextXBR[99] = 1;
863
- isoBandNextYBR[99] = 0;
864
- isoBandNextOBR[99] = 0;
865
- isoBandNextXBL[99] = -1;
866
- isoBandNextYBL[99] = 0;
867
- isoBandNextOBL[99] = 1;
868
- isoBandNextXLT[99] = 0;
869
- isoBandNextYLT[99] = -1;
870
- isoBandNextOLT[99] = 0;
871
- isoBandNextXTL[99] = 1;
872
- isoBandNextYTL[99] = 0;
873
- isoBandNextOTL[99] = 1;
874
-
875
- isoBandNextXRB[38] = 0;
876
- isoBandNextYRB[38] = -1;
877
- isoBandNextORB[38] = 1;
878
- isoBandNextXBR[38] = 1;
879
- isoBandNextYBR[38] = 0;
880
- isoBandNextOBR[38] = 0;
881
- isoBandNextXLB[38] = 0;
882
- isoBandNextYLB[38] = 1;
883
- isoBandNextOLB[38] = 1;
884
- isoBandNextXLT[38] = 0;
885
- isoBandNextYLT[38] = 1;
886
- isoBandNextOLT[38] = 0;
887
- isoBandNextXTL[38] = -1;
888
- isoBandNextYTL[38] = 0;
889
- isoBandNextOTL[38] = 1;
890
- isoBandNextXTR[38] = -1;
891
- isoBandNextYTR[38] = 0;
892
- isoBandNextOTR[38] = 0;
893
-
894
- isoBandNextXRB[39] = 0;
895
- isoBandNextYRB[39] = 1;
896
- isoBandNextORB[39] = 1;
897
- isoBandNextXBR[39] = -1;
898
- isoBandNextYBR[39] = 0;
899
- isoBandNextOBR[39] = 0;
900
- isoBandNextXLB[39] = 0;
901
- isoBandNextYLB[39] = -1;
902
- isoBandNextOLB[39] = 1;
903
- isoBandNextXLT[39] = 0;
904
- isoBandNextYLT[39] = 1;
905
- isoBandNextOLT[39] = 0;
906
- isoBandNextXTL[39] = -1;
907
- isoBandNextYTL[39] = 0;
908
- isoBandNextOTL[39] = 1;
909
- isoBandNextXTR[39] = 1;
910
- isoBandNextYTR[39] = 0;
911
- isoBandNextOTR[39] = 0;
912
-
913
- /*
914
- Define helper functions for the polygon_table
915
- */
916
-
917
- /* triangle cases */
918
- var p00 = function (cell) {
919
- return [
920
- [cell.bottomleft, 0],
921
- [0, 0],
922
- [0, cell.leftbottom],
923
- ];
924
- };
925
- var p01 = function (cell) {
926
- return [
927
- [1, cell.rightbottom],
928
- [1, 0],
929
- [cell.bottomright, 0],
930
- ];
931
- };
932
- var p02 = function (cell) {
933
- return [
934
- [cell.topright, 1],
935
- [1, 1],
936
- [1, cell.righttop],
937
- ];
938
- };
939
- var p03 = function (cell) {
940
- return [
941
- [0, cell.lefttop],
942
- [0, 1],
943
- [cell.topleft, 1],
944
- ];
945
- };
946
- /* trapezoid cases */
947
- var p04 = function (cell) {
948
- return [
949
- [cell.bottomright, 0],
950
- [cell.bottomleft, 0],
951
- [0, cell.leftbottom],
952
- [0, cell.lefttop],
953
- ];
954
- };
955
- var p05 = function (cell) {
956
- return [
957
- [cell.bottomright, 0],
958
- [cell.bottomleft, 0],
959
- [1, cell.righttop],
960
- [1, cell.rightbottom],
961
- ];
962
- };
963
- var p06 = function (cell) {
964
- return [
965
- [1, cell.righttop],
966
- [1, cell.rightbottom],
967
- [cell.topleft, 1],
968
- [cell.topright, 1],
969
- ];
970
- };
971
- var p07 = function (cell) {
972
- return [
973
- [0, cell.leftbottom],
974
- [0, cell.lefttop],
975
- [cell.topleft, 1],
976
- [cell.topright, 1],
977
- ];
978
- };
979
- /* rectangle cases */
980
- var p08 = function (cell) {
981
- return [
982
- [0, 0],
983
- [0, cell.leftbottom],
984
- [1, cell.rightbottom],
985
- [1, 0],
986
- ];
987
- };
988
- var p09 = function (cell) {
989
- return [
990
- [1, 0],
991
- [cell.bottomright, 0],
992
- [cell.topright, 1],
993
- [1, 1],
994
- ];
995
- };
996
- var p10 = function (cell) {
997
- return [
998
- [1, 1],
999
- [1, cell.righttop],
1000
- [0, cell.lefttop],
1001
- [0, 1],
1002
- ];
1003
- };
1004
- var p11 = function (cell) {
1005
- return [
1006
- [cell.bottomleft, 0],
1007
- [0, 0],
1008
- [0, 1],
1009
- [cell.topleft, 1],
1010
- ];
1011
- };
1012
- var p12 = function (cell) {
1013
- return [
1014
- [1, cell.righttop],
1015
- [1, cell.rightbottom],
1016
- [0, cell.leftbottom],
1017
- [0, cell.lefttop],
1018
- ];
1019
- };
1020
- var p13 = function (cell) {
1021
- return [
1022
- [cell.topleft, 1],
1023
- [cell.topright, 1],
1024
- [cell.bottomright, 0],
1025
- [cell.bottomleft, 0],
1026
- ];
1027
- };
1028
- /* square case */
1029
- var p14 = function () {
1030
- return [
1031
- [0, 0],
1032
- [0, 1],
1033
- [1, 1],
1034
- [1, 0],
1035
- ];
1036
- };
1037
- /* pentagon cases */
1038
- var p15 = function (cell) {
1039
- return [
1040
- [1, cell.rightbottom],
1041
- [1, 0],
1042
- [0, 0],
1043
- [0, 1],
1044
- [cell.topleft, 1],
1045
- ];
1046
- };
1047
- /* 1211 || 1011 */
1048
- var p16 = function (cell) {
1049
- return [
1050
- [cell.topright, 1],
1051
- [1, 1],
1052
- [1, 0],
1053
- [0, 0],
1054
- [0, cell.leftbottom],
1055
- ];
1056
- };
1057
- /* 2111 || 0111 */
1058
- var p17 = function (cell) {
1059
- return [
1060
- [1, 0],
1061
- [cell.bottomright, 0],
1062
- [0, cell.lefttop],
1063
- [0, 1],
1064
- [1, 1],
1065
- ];
1066
- };
1067
- /* 1112 || 1110 */
1068
- var p18 = function (cell) {
1069
- return [
1070
- [1, 1],
1071
- [1, cell.righttop],
1072
- [cell.bottomleft, 0],
1073
- [0, 0],
1074
- [0, 1],
1075
- ];
1076
- };
1077
- /* 1121 || 1101 */
1078
- var p19 = function (cell) {
1079
- return [
1080
- [1, cell.righttop],
1081
- [1, cell.rightbottom],
1082
- [0, cell.lefttop],
1083
- [0, 1],
1084
- [cell.topleft, 1],
1085
- ];
1086
- };
1087
- /* 1200 || 1022 */
1088
- var p20 = function (cell) {
1089
- return [
1090
- [1, 1],
1091
- [1, cell.righttop],
1092
- [cell.bottomright, 0],
1093
- [cell.bottomleft, 0],
1094
- [cell.topright, 1],
1095
- ];
1096
- };
1097
- /* 0120 || 2102 */
1098
- var p21 = function (cell) {
1099
- return [
1100
- [1, cell.rightbottom],
1101
- [1, 0],
1102
- [cell.bottomright, 0],
1103
- [0, cell.leftbottom],
1104
- [0, cell.lefttop],
1105
- ];
1106
- };
1107
- /* 0012 || 2210 */
1108
- var p22 = function (cell) {
1109
- return [
1110
- [cell.topright, 1],
1111
- [cell.bottomleft, 0],
1112
- [0, 0],
1113
- [0, cell.leftbottom],
1114
- [cell.topleft, 1],
1115
- ];
1116
- };
1117
- /* 2001 || 0221 */
1118
- var p23 = function (cell) {
1119
- return [
1120
- [cell.bottomright, 0],
1121
- [cell.bottomleft, 0],
1122
- [0, cell.lefttop],
1123
- [0, 1],
1124
- [cell.topleft, 1],
1125
- ];
1126
- };
1127
- /* 1002 || 1220 */
1128
- var p24 = function (cell) {
1129
- return [
1130
- [1, 1],
1131
- [1, cell.righttop],
1132
- [0, cell.leftbottom],
1133
- [0, cell.lefttop],
1134
- [cell.topright, 1],
1135
- ];
1136
- };
1137
- /* 2100 || 0122 */
1138
- var p25 = function (cell) {
1139
- return [
1140
- [1, cell.rightbottom],
1141
- [1, 0],
1142
- [cell.bottomright, 0],
1143
- [cell.topleft, 1],
1144
- [cell.topright, 1],
1145
- ];
1146
- };
1147
- /* 0210 || 2012 */
1148
- var p26 = function (cell) {
1149
- return [
1150
- [1, cell.righttop],
1151
- [1, cell.rightbottom],
1152
- [cell.bottomleft, 0],
1153
- [0, 0],
1154
- [0, cell.leftbottom],
1155
- ];
1156
- };
1157
- /* 0021 || 2201 */
1158
- /*hexagon cases */
1159
- var p27 = function (cell) {
1160
- return [
1161
- [1, cell.rightbottom],
1162
- [1, 0],
1163
- [0, 0],
1164
- [0, cell.leftbottom],
1165
- [cell.topleft, 1],
1166
- [cell.topright, 1],
1167
- ];
1168
- };
1169
- /* 0211 || 2011 */
1170
- var p28 = function (cell) {
1171
- return [
1172
- [1, 1],
1173
- [1, 0],
1174
- [cell.bottomright, 0],
1175
- [0, cell.leftbottom],
1176
- [0, cell.lefttop],
1177
- [cell.topright, 1],
1178
- ];
1179
- };
1180
- /* 2110 || 0112 */
1181
- var p29 = function (cell) {
1182
- return [
1183
- [1, 1],
1184
- [1, cell.righttop],
1185
- [cell.bottomright, 0],
1186
- [cell.bottomleft, 0],
1187
- [0, cell.lefttop],
1188
- [0, 1],
1189
- ];
1190
- };
1191
- /* 1102 || 1120 */
1192
- var p30 = function (cell) {
1193
- return [
1194
- [1, cell.righttop],
1195
- [1, cell.rightbottom],
1196
- [cell.bottomleft, 0],
1197
- [0, 0],
1198
- [0, 1],
1199
- [cell.topleft, 1],
1200
- ];
1201
- };
1202
- /* 1021 || 1201 */
1203
- var p31 = function (cell) {
1204
- return [
1205
- [1, 1],
1206
- [1, cell.righttop],
1207
- [cell.bottomleft, 0],
1208
- [0, 0],
1209
- [0, cell.leftbottom],
1210
- [cell.topright, 1],
1211
- ];
1212
- };
1213
- /* 2101 || 0121 */
1214
- var p32 = function (cell) {
1215
- return [
1216
- [1, cell.rightbottom],
1217
- [1, 0],
1218
- [cell.bottomright, 0],
1219
- [0, cell.lefttop],
1220
- [0, 1],
1221
- [cell.topleft, 1],
1222
- ];
1223
- };
1224
- /* 1012 || 1210 */
1225
- /* 8-sided cases */
1226
- var p33 = function (cell) {
1227
- return [
1228
- [1, cell.righttop],
1229
- [1, cell.rightbottom],
1230
- [cell.bottomright, 0],
1231
- [cell.bottomleft, 0],
1232
- [0, cell.leftbottom],
1233
- [0, cell.lefttop],
1234
- [cell.topleft, 1],
1235
- [cell.topright, 1],
1236
- ];
1237
- };
1238
- /* flipped == 1 state for 0202 and 2020 */
1239
- /* 6-sided cases */
1240
- var p34 = function (cell) {
1241
- return [
1242
- [1, 1],
1243
- [1, cell.righttop],
1244
- [cell.bottomleft, 0],
1245
- [0, 0],
1246
- [0, cell.leftbottom],
1247
- [cell.topright, 1],
1248
- ];
1249
- };
1250
- /* 0101 with flipped == 1 || 2121 with flipped == 1 */
1251
- var p35 = function (cell) {
1252
- return [
1253
- [1, cell.rightbottom],
1254
- [1, 0],
1255
- [cell.bottomright, 0],
1256
- [0, cell.lefttop],
1257
- [0, 1],
1258
- [cell.topleft, 1],
1259
- ];
1260
- };
1261
- /* 1010 with flipped == 1 || 1212 with flipped == 1 */
1262
- /* 7-sided cases */
1263
- var p36 = function (cell) {
1264
- return [
1265
- [1, 1],
1266
- [1, cell.righttop],
1267
- [cell.bottomright, 0],
1268
- [cell.bottomleft, 0],
1269
- [0, cell.leftbottom],
1270
- [0, cell.lefttop],
1271
- [cell.topright, 1],
1272
- ];
1273
- };
1274
- /* 2120 with flipped == 1 || 0102 with flipped == 1 */
1275
- var p37 = function (cell) {
1276
- return [
1277
- [1, cell.righttop],
1278
- [1, cell.rightbottom],
1279
- [cell.bottomleft, 0],
1280
- [0, 0],
1281
- [0, cell.leftbottom],
1282
- [cell.topleft, 1],
1283
- [cell.topright, 1],
1284
- ];
1285
- };
1286
- /* 2021 with flipped == 1 || 0201 with flipped == 1 */
1287
- var p38 = function (cell) {
1288
- return [
1289
- [1, cell.righttop],
1290
- [1, cell.rightbottom],
1291
- [cell.bottomright, 0],
1292
- [cell.bottomleft, 0],
1293
- [0, cell.lefttop],
1294
- [0, 1],
1295
- [cell.topleft, 1],
1296
- ];
1297
- };
1298
- /* 1202 with flipped == 1 || 1020 with flipped == 1 */
1299
- var p39 = function (cell) {
1300
- return [
1301
- [1, cell.rightbottom],
1302
- [1, 0],
1303
- [cell.bottomright, 0],
1304
- [0, cell.leftbottom],
1305
- [0, cell.lefttop],
1306
- [cell.topleft, 1],
1307
- [cell.topright, 1],
1308
- ];
1309
- };
1310
- /* 0212 with flipped == 1 || 2010 with flipped == 1 */
1311
-
1312
- /*
1313
- The lookup tables for edge number given the polygon
1314
- is entered at a specific location
1315
- */
1316
-
1317
- var isoBandEdgeRT = [];
1318
- var isoBandEdgeRB = [];
1319
- var isoBandEdgeBR = [];
1320
- var isoBandEdgeBL = [];
1321
- var isoBandEdgeLB = [];
1322
- var isoBandEdgeLT = [];
1323
- var isoBandEdgeTL = [];
1324
- var isoBandEdgeTR = [];
1325
-
1326
- /* triangle cases */
1327
- isoBandEdgeBL[1] = isoBandEdgeLB[1] = 18;
1328
- isoBandEdgeBL[169] = isoBandEdgeLB[169] = 18;
1329
- isoBandEdgeBR[4] = isoBandEdgeRB[4] = 12;
1330
- isoBandEdgeBR[166] = isoBandEdgeRB[166] = 12;
1331
- isoBandEdgeRT[16] = isoBandEdgeTR[16] = 4;
1332
- isoBandEdgeRT[154] = isoBandEdgeTR[154] = 4;
1333
- isoBandEdgeLT[64] = isoBandEdgeTL[64] = 22;
1334
- isoBandEdgeLT[106] = isoBandEdgeTL[106] = 22;
1335
-
1336
- /* trapezoid cases */
1337
- isoBandEdgeBR[2] = isoBandEdgeLT[2] = 17;
1338
- isoBandEdgeBL[2] = isoBandEdgeLB[2] = 18;
1339
- isoBandEdgeBR[168] = isoBandEdgeLT[168] = 17;
1340
- isoBandEdgeBL[168] = isoBandEdgeLB[168] = 18;
1341
- isoBandEdgeRT[8] = isoBandEdgeBL[8] = 9;
1342
- isoBandEdgeRB[8] = isoBandEdgeBR[8] = 12;
1343
- isoBandEdgeRT[162] = isoBandEdgeBL[162] = 9;
1344
- isoBandEdgeRB[162] = isoBandEdgeBR[162] = 12;
1345
- isoBandEdgeRT[32] = isoBandEdgeTR[32] = 4;
1346
- isoBandEdgeRB[32] = isoBandEdgeTL[32] = 1;
1347
- isoBandEdgeRT[138] = isoBandEdgeTR[138] = 4;
1348
- isoBandEdgeRB[138] = isoBandEdgeTL[138] = 1;
1349
- isoBandEdgeLB[128] = isoBandEdgeTR[128] = 21;
1350
- isoBandEdgeLT[128] = isoBandEdgeTL[128] = 22;
1351
- isoBandEdgeLB[42] = isoBandEdgeTR[42] = 21;
1352
- isoBandEdgeLT[42] = isoBandEdgeTL[42] = 22;
1353
-
1354
- /* rectangle cases */
1355
- isoBandEdgeRB[5] = isoBandEdgeLB[5] = 14;
1356
- isoBandEdgeRB[165] = isoBandEdgeLB[165] = 14;
1357
- isoBandEdgeBR[20] = isoBandEdgeTR[20] = 6;
1358
- isoBandEdgeBR[150] = isoBandEdgeTR[150] = 6;
1359
- isoBandEdgeRT[80] = isoBandEdgeLT[80] = 11;
1360
- isoBandEdgeRT[90] = isoBandEdgeLT[90] = 11;
1361
- isoBandEdgeBL[65] = isoBandEdgeTL[65] = 3;
1362
- isoBandEdgeBL[105] = isoBandEdgeTL[105] = 3;
1363
- isoBandEdgeRT[160] = isoBandEdgeLT[160] = 11;
1364
- isoBandEdgeRB[160] = isoBandEdgeLB[160] = 14;
1365
- isoBandEdgeRT[10] = isoBandEdgeLT[10] = 11;
1366
- isoBandEdgeRB[10] = isoBandEdgeLB[10] = 14;
1367
- isoBandEdgeBR[130] = isoBandEdgeTR[130] = 6;
1368
- isoBandEdgeBL[130] = isoBandEdgeTL[130] = 3;
1369
- isoBandEdgeBR[40] = isoBandEdgeTR[40] = 6;
1370
- isoBandEdgeBL[40] = isoBandEdgeTL[40] = 3;
1371
-
1372
- /* pentagon cases */
1373
- isoBandEdgeRB[101] = isoBandEdgeTL[101] = 1;
1374
- isoBandEdgeRB[69] = isoBandEdgeTL[69] = 1;
1375
- isoBandEdgeLB[149] = isoBandEdgeTR[149] = 21;
1376
- isoBandEdgeLB[21] = isoBandEdgeTR[21] = 21;
1377
- isoBandEdgeBR[86] = isoBandEdgeLT[86] = 17;
1378
- isoBandEdgeBR[84] = isoBandEdgeLT[84] = 17;
1379
- isoBandEdgeRT[89] = isoBandEdgeBL[89] = 9;
1380
- isoBandEdgeRT[81] = isoBandEdgeBL[81] = 9;
1381
- isoBandEdgeRT[96] = isoBandEdgeTL[96] = 0;
1382
- isoBandEdgeRB[96] = isoBandEdgeLT[96] = 15;
1383
- isoBandEdgeRT[74] = isoBandEdgeTL[74] = 0;
1384
- isoBandEdgeRB[74] = isoBandEdgeLT[74] = 15;
1385
- isoBandEdgeRT[24] = isoBandEdgeBR[24] = 8;
1386
- isoBandEdgeBL[24] = isoBandEdgeTR[24] = 7;
1387
- isoBandEdgeRT[146] = isoBandEdgeBR[146] = 8;
1388
- isoBandEdgeBL[146] = isoBandEdgeTR[146] = 7;
1389
- isoBandEdgeRB[6] = isoBandEdgeLT[6] = 15;
1390
- isoBandEdgeBR[6] = isoBandEdgeLB[6] = 16;
1391
- isoBandEdgeRB[164] = isoBandEdgeLT[164] = 15;
1392
- isoBandEdgeBR[164] = isoBandEdgeLB[164] = 16;
1393
- isoBandEdgeBL[129] = isoBandEdgeTR[129] = 7;
1394
- isoBandEdgeLB[129] = isoBandEdgeTL[129] = 20;
1395
- isoBandEdgeBL[41] = isoBandEdgeTR[41] = 7;
1396
- isoBandEdgeLB[41] = isoBandEdgeTL[41] = 20;
1397
- isoBandEdgeBR[66] = isoBandEdgeTL[66] = 2;
1398
- isoBandEdgeBL[66] = isoBandEdgeLT[66] = 19;
1399
- isoBandEdgeBR[104] = isoBandEdgeTL[104] = 2;
1400
- isoBandEdgeBL[104] = isoBandEdgeLT[104] = 19;
1401
- isoBandEdgeRT[144] = isoBandEdgeLB[144] = 10;
1402
- isoBandEdgeLT[144] = isoBandEdgeTR[144] = 23;
1403
- isoBandEdgeRT[26] = isoBandEdgeLB[26] = 10;
1404
- isoBandEdgeLT[26] = isoBandEdgeTR[26] = 23;
1405
- isoBandEdgeRB[36] = isoBandEdgeTR[36] = 5;
1406
- isoBandEdgeBR[36] = isoBandEdgeTL[36] = 2;
1407
- isoBandEdgeRB[134] = isoBandEdgeTR[134] = 5;
1408
- isoBandEdgeBR[134] = isoBandEdgeTL[134] = 2;
1409
- isoBandEdgeRT[9] = isoBandEdgeLB[9] = 10;
1410
- isoBandEdgeRB[9] = isoBandEdgeBL[9] = 13;
1411
- isoBandEdgeRT[161] = isoBandEdgeLB[161] = 10;
1412
- isoBandEdgeRB[161] = isoBandEdgeBL[161] = 13;
1413
-
1414
- /* hexagon cases */
1415
- isoBandEdgeRB[37] = isoBandEdgeTR[37] = 5;
1416
- isoBandEdgeLB[37] = isoBandEdgeTL[37] = 20;
1417
- isoBandEdgeRB[133] = isoBandEdgeTR[133] = 5;
1418
- isoBandEdgeLB[133] = isoBandEdgeTL[133] = 20;
1419
- isoBandEdgeBR[148] = isoBandEdgeLB[148] = 16;
1420
- isoBandEdgeLT[148] = isoBandEdgeTR[148] = 23;
1421
- isoBandEdgeBR[22] = isoBandEdgeLB[22] = 16;
1422
- isoBandEdgeLT[22] = isoBandEdgeTR[22] = 23;
1423
- isoBandEdgeRT[82] = isoBandEdgeBR[82] = 8;
1424
- isoBandEdgeBL[82] = isoBandEdgeLT[82] = 19;
1425
- isoBandEdgeRT[88] = isoBandEdgeBR[88] = 8;
1426
- isoBandEdgeBL[88] = isoBandEdgeLT[88] = 19;
1427
- isoBandEdgeRT[73] = isoBandEdgeTL[73] = 0;
1428
- isoBandEdgeRB[73] = isoBandEdgeBL[73] = 13;
1429
- isoBandEdgeRT[97] = isoBandEdgeTL[97] = 0;
1430
- isoBandEdgeRB[97] = isoBandEdgeBL[97] = 13;
1431
- isoBandEdgeRT[145] = isoBandEdgeBL[145] = 9;
1432
- isoBandEdgeLB[145] = isoBandEdgeTR[145] = 21;
1433
- isoBandEdgeRT[25] = isoBandEdgeBL[25] = 9;
1434
- isoBandEdgeLB[25] = isoBandEdgeTR[25] = 21;
1435
- isoBandEdgeRB[70] = isoBandEdgeTL[70] = 1;
1436
- isoBandEdgeBR[70] = isoBandEdgeLT[70] = 17;
1437
- isoBandEdgeRB[100] = isoBandEdgeTL[100] = 1;
1438
- isoBandEdgeBR[100] = isoBandEdgeLT[100] = 17;
1439
-
1440
- /* 8-sided cases */
1441
- isoBandEdgeRT[34] = isoBandEdgeBL[34] = 9;
1442
- isoBandEdgeRB[34] = isoBandEdgeBR[34] = 12;
1443
- isoBandEdgeLB[34] = isoBandEdgeTR[34] = 21;
1444
- isoBandEdgeLT[34] = isoBandEdgeTL[34] = 22;
1445
- isoBandEdgeRT[136] = isoBandEdgeTR[136] = 4;
1446
- isoBandEdgeRB[136] = isoBandEdgeTL[136] = 1;
1447
- isoBandEdgeBR[136] = isoBandEdgeLT[136] = 17;
1448
- isoBandEdgeBL[136] = isoBandEdgeLB[136] = 18;
1449
- isoBandEdgeRT[35] = isoBandEdgeTR[35] = 4;
1450
- isoBandEdgeRB[35] = isoBandEdgeBR[35] = 12;
1451
- isoBandEdgeBL[35] = isoBandEdgeLB[35] = 18;
1452
- isoBandEdgeLT[35] = isoBandEdgeTL[35] = 22;
1453
-
1454
- /* 6-sided cases */
1455
- isoBandEdgeRT[153] = isoBandEdgeTR[153] = 4;
1456
- isoBandEdgeBL[153] = isoBandEdgeLB[153] = 18;
1457
- isoBandEdgeRB[102] = isoBandEdgeBR[102] = 12;
1458
- isoBandEdgeLT[102] = isoBandEdgeTL[102] = 22;
1459
- isoBandEdgeRT[155] = isoBandEdgeBL[155] = 9;
1460
- isoBandEdgeLB[155] = isoBandEdgeTR[155] = 23;
1461
- isoBandEdgeRB[103] = isoBandEdgeTL[103] = 1;
1462
- isoBandEdgeBR[103] = isoBandEdgeLT[103] = 17;
1463
-
1464
- /* 7-sided cases */
1465
- isoBandEdgeRT[152] = isoBandEdgeTR[152] = 4;
1466
- isoBandEdgeBR[152] = isoBandEdgeLT[152] = 17;
1467
- isoBandEdgeBL[152] = isoBandEdgeLB[152] = 18;
1468
- isoBandEdgeRT[156] = isoBandEdgeBR[156] = 8;
1469
- isoBandEdgeBL[156] = isoBandEdgeLB[156] = 18;
1470
- isoBandEdgeLT[156] = isoBandEdgeTR[156] = 23;
1471
- isoBandEdgeRT[137] = isoBandEdgeTR[137] = 4;
1472
- isoBandEdgeRB[137] = isoBandEdgeTL[137] = 1;
1473
- isoBandEdgeBL[137] = isoBandEdgeLB[137] = 18;
1474
- isoBandEdgeRT[139] = isoBandEdgeTR[139] = 4;
1475
- isoBandEdgeRB[139] = isoBandEdgeBL[139] = 13;
1476
- isoBandEdgeLB[139] = isoBandEdgeTL[139] = 20;
1477
- isoBandEdgeRT[98] = isoBandEdgeBL[98] = 9;
1478
- isoBandEdgeRB[98] = isoBandEdgeBR[98] = 12;
1479
- isoBandEdgeLT[98] = isoBandEdgeTL[98] = 22;
1480
- isoBandEdgeRT[99] = isoBandEdgeTL[99] = 0;
1481
- isoBandEdgeRB[99] = isoBandEdgeBR[99] = 12;
1482
- isoBandEdgeBL[99] = isoBandEdgeLT[99] = 19;
1483
- isoBandEdgeRB[38] = isoBandEdgeBR[38] = 12;
1484
- isoBandEdgeLB[38] = isoBandEdgeTR[38] = 21;
1485
- isoBandEdgeLT[38] = isoBandEdgeTL[38] = 22;
1486
- isoBandEdgeRB[39] = isoBandEdgeTR[39] = 5;
1487
- isoBandEdgeBR[39] = isoBandEdgeLB[39] = 16;
1488
- isoBandEdgeLT[39] = isoBandEdgeTL[39] = 22;
1489
-
1490
- /*
1491
- The lookup tables for all different polygons that
1492
- may appear within a grid cell
1493
- */
1494
-
1495
- var polygon_table = [];
1496
-
1497
- /* triangle cases */
1498
- polygon_table[1] = polygon_table[169] = p00; /* 2221 || 0001 */
1499
- polygon_table[4] = polygon_table[166] = p01; /* 2212 || 0010 */
1500
- polygon_table[16] = polygon_table[154] = p02; /* 2122 || 0100 */
1501
- polygon_table[64] = polygon_table[106] = p03; /* 1222 || 1000 */
1502
-
1503
- /* trapezoid cases */
1504
- polygon_table[168] = polygon_table[2] = p04; /* 2220 || 0002 */
1505
- polygon_table[162] = polygon_table[8] = p05; /* 2202 || 0020 */
1506
- polygon_table[138] = polygon_table[32] = p06; /* 2022 || 0200 */
1507
- polygon_table[42] = polygon_table[128] = p07; /* 0222 || 2000 */
1508
-
1509
- /* rectangle cases */
1510
- polygon_table[5] = polygon_table[165] = p08; /* 0011 || 2211 */
1511
- polygon_table[20] = polygon_table[150] = p09; /* 0110 || 2112 */
1512
- polygon_table[80] = polygon_table[90] = p10; /* 1100 || 1122 */
1513
- polygon_table[65] = polygon_table[105] = p11; /* 1001 || 1221 */
1514
- polygon_table[160] = polygon_table[10] = p12; /* 2200 || 0022 */
1515
- polygon_table[130] = polygon_table[40] = p13; /* 2002 || 0220 */
1516
-
1517
- /* square case */
1518
- polygon_table[85] = p14; /* 1111 */
1519
-
1520
- /* pentagon cases */
1521
- polygon_table[101] = polygon_table[69] = p15; /* 1211 || 1011 */
1522
- polygon_table[149] = polygon_table[21] = p16; /* 2111 || 0111 */
1523
- polygon_table[86] = polygon_table[84] = p17; /* 1112 || 1110 */
1524
- polygon_table[89] = polygon_table[81] = p18; /* 1121 || 1101 */
1525
- polygon_table[96] = polygon_table[74] = p19; /* 1200 || 1022 */
1526
- polygon_table[24] = polygon_table[146] = p20; /* 0120 || 2102 */
1527
- polygon_table[6] = polygon_table[164] = p21; /* 0012 || 2210 */
1528
- polygon_table[129] = polygon_table[41] = p22; /* 2001 || 0221 */
1529
- polygon_table[66] = polygon_table[104] = p23; /* 1002 || 1220 */
1530
- polygon_table[144] = polygon_table[26] = p24; /* 2100 || 0122 */
1531
- polygon_table[36] = polygon_table[134] = p25; /* 0210 || 2012 */
1532
- polygon_table[9] = polygon_table[161] = p26; /* 0021 || 2201 */
1533
-
1534
- /* hexagon cases */
1535
- polygon_table[37] = polygon_table[133] = p27; /* 0211 || 2011 */
1536
- polygon_table[148] = polygon_table[22] = p28; /* 2110 || 0112 */
1537
- polygon_table[82] = polygon_table[88] = p29; /* 1102 || 1120 */
1538
- polygon_table[73] = polygon_table[97] = p30; /* 1021 || 1201 */
1539
- polygon_table[145] = polygon_table[25] = p31; /* 2101 || 0121 */
1540
- polygon_table[70] = polygon_table[100] = p32; /* 1012 || 1210 */
1541
-
1542
- /* 8-sided cases */
1543
- polygon_table[34] = function (c) {
1544
- return [p07(c), p05(c)];
1545
- }; /* 0202 || 2020 with flipped == 0 */
1546
- polygon_table[35] = p33; /* flipped == 1 state for 0202 and 2020 */
1547
- polygon_table[136] = function (c) {
1548
- return [p06(c), p04(c)];
1549
- }; /* 2020 || 0202 with flipped == 0 */
1550
-
1551
- /* 6-sided cases */
1552
- polygon_table[153] = function (c) {
1553
- return [p02(c), p00(c)];
1554
- }; /* 0101 with flipped == 0 || 2121 with flipped == 2 */
1555
- polygon_table[102] = function (c) {
1556
- return [p01(c), p03(c)];
1557
- }; /* 1010 with flipped == 0 || 1212 with flipped == 2 */
1558
- polygon_table[155] = p34; /* 0101 with flipped == 1 || 2121 with flipped == 1 */
1559
- polygon_table[103] = p35; /* 1010 with flipped == 1 || 1212 with flipped == 1 */
1560
-
1561
- /* 7-sided cases */
1562
- polygon_table[152] = function (c) {
1563
- return [p02(c), p04(c)];
1564
- }; /* 2120 with flipped == 2 || 0102 with flipped == 0 */
1565
- polygon_table[156] = p36; /* 2120 with flipped == 1 || 0102 with flipped == 1 */
1566
- polygon_table[137] = function (c) {
1567
- return [p06(c), p00(c)];
1568
- }; /* 2021 with flipped == 2 || 0201 with flipped == 0 */
1569
- polygon_table[139] = p37; /* 2021 with flipped == 1 || 0201 with flipped == 1 */
1570
- polygon_table[98] = function (c) {
1571
- return [p05(c), p03(c)];
1572
- }; /* 1202 with flipped == 2 || 1020 with flipped == 0 */
1573
- polygon_table[99] = p38; /* 1202 with flipped == 1 || 1020 with flipped == 1 */
1574
- polygon_table[38] = function (c) {
1575
- return [p01(c), p07(c)];
1576
- }; /* 0212 with flipped == 2 || 2010 with flipped == 0 */
1577
- polygon_table[39] = p39; /* 0212 with flipped == 1 || 2010 with flipped == 1 */
1578
-
1579
- /*
1580
- ####################################
1581
- Some small helper functions
1582
- ####################################
1583
- */
1584
-
1585
- /* assume that x1 == 1 && x0 == 0 */
1586
- function interpolateX(y, y0, y1) {
1587
- return (y - y0) / (y1 - y0);
1588
- }
1589
-
1590
- function isArray(myArray) {
1591
- return myArray.constructor.toString().indexOf("Array") > -1;
1592
- }
1593
-
1594
- /*
1595
- ####################################
1596
- Below is the actual Marching Squares implementation
1597
- ####################################
1598
- */
1599
-
1600
- function computeBandGrid(data, minV, bandwidth) {
1601
- var rows = data.length - 1;
1602
- var cols = data[0].length - 1;
1603
- var BandGrid = { rows: rows, cols: cols, cells: [] };
1604
-
1605
- var maxV = minV + Math.abs(bandwidth);
1606
-
1607
- for (var j = 0; j < rows; ++j) {
1608
- BandGrid.cells[j] = [];
1609
- for (var i = 0; i < cols; ++i) {
1610
- /* compose the 4-trit corner representation */
1611
- var cval = 0;
1612
-
1613
- var tl = data[j + 1][i];
1614
- var tr = data[j + 1][i + 1];
1615
- var br = data[j][i + 1];
1616
- var bl = data[j][i];
1617
-
1618
- if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
1619
- continue;
1620
- }
1621
-
1622
- cval |= tl < minV ? 0 : tl > maxV ? 128 : 64;
1623
- cval |= tr < minV ? 0 : tr > maxV ? 32 : 16;
1624
- cval |= br < minV ? 0 : br > maxV ? 8 : 4;
1625
- cval |= bl < minV ? 0 : bl > maxV ? 2 : 1;
1626
-
1627
- var cval_real = +cval;
1628
-
1629
- /* resolve ambiguity via averaging */
1630
- var flipped = 0;
1631
- if (
1632
- cval === 17 /* 0101 */ ||
1633
- cval === 18 /* 0102 */ ||
1634
- cval === 33 /* 0201 */ ||
1635
- cval === 34 /* 0202 */ ||
1636
- cval === 38 /* 0212 */ ||
1637
- cval === 68 /* 1010 */ ||
1638
- cval === 72 /* 1020 */ ||
1639
- cval === 98 /* 1202 */ ||
1640
- cval === 102 /* 1212 */ ||
1641
- cval === 132 /* 2010 */ ||
1642
- cval === 136 /* 2020 */ ||
1643
- cval === 137 /* 2021 */ ||
1644
- cval === 152 /* 2120 */ ||
1645
- cval === 153 /* 2121 */
1646
- ) {
1647
- var average = (tl + tr + br + bl) / 4;
1648
- /* set flipped state */
1649
- flipped = average > maxV ? 2 : average < minV ? 0 : 1;
1650
-
1651
- /* adjust cval for flipped cases */
1652
-
1653
- /* 8-sided cases */
1654
- if (cval === 34) {
1655
- if (flipped === 1) {
1656
- cval = 35;
1657
- } else if (flipped === 0) {
1658
- cval = 136;
1659
- }
1660
- } else if (cval === 136) {
1661
- if (flipped === 1) {
1662
- cval = 35;
1663
- flipped = 4;
1664
- } else if (flipped === 0) {
1665
- cval = 34;
1666
- }
1667
- } else if (cval === 17) {
1668
- /* 6-sided polygon cases */
1669
- if (flipped === 1) {
1670
- cval = 155;
1671
- flipped = 4;
1672
- } else if (flipped === 0) {
1673
- cval = 153;
1674
- }
1675
- } else if (cval === 68) {
1676
- if (flipped === 1) {
1677
- cval = 103;
1678
- flipped = 4;
1679
- } else if (flipped === 0) {
1680
- cval = 102;
1681
- }
1682
- } else if (cval === 153) {
1683
- if (flipped === 1) cval = 155;
1684
- } else if (cval === 102) {
1685
- if (flipped === 1) cval = 103;
1686
- } else if (cval === 152) {
1687
- /* 7-sided polygon cases */
1688
- if (flipped < 2) {
1689
- cval = 156;
1690
- flipped = 1;
1691
- }
1692
- } else if (cval === 137) {
1693
- if (flipped < 2) {
1694
- cval = 139;
1695
- flipped = 1;
1696
- }
1697
- } else if (cval === 98) {
1698
- if (flipped < 2) {
1699
- cval = 99;
1700
- flipped = 1;
1701
- }
1702
- } else if (cval === 38) {
1703
- if (flipped < 2) {
1704
- cval = 39;
1705
- flipped = 1;
1706
- }
1707
- } else if (cval === 18) {
1708
- if (flipped > 0) {
1709
- cval = 156;
1710
- flipped = 4;
1711
- } else {
1712
- cval = 152;
1713
- }
1714
- } else if (cval === 33) {
1715
- if (flipped > 0) {
1716
- cval = 139;
1717
- flipped = 4;
1718
- } else {
1719
- cval = 137;
1720
- }
1721
- } else if (cval === 72) {
1722
- if (flipped > 0) {
1723
- cval = 99;
1724
- flipped = 4;
1725
- } else {
1726
- cval = 98;
1727
- }
1728
- } else if (cval === 132) {
1729
- if (flipped > 0) {
1730
- cval = 39;
1731
- flipped = 4;
1732
- } else {
1733
- cval = 38;
1734
- }
1735
- }
1736
- }
1737
-
1738
- /* add cell to BandGrid if it contains at least one polygon-side */
1739
- if (cval != 0 && cval != 170) {
1740
- var topleft,
1741
- topright,
1742
- bottomleft,
1743
- bottomright,
1744
- righttop,
1745
- rightbottom,
1746
- lefttop,
1747
- leftbottom;
1748
-
1749
- topleft = topright = bottomleft = bottomright = righttop = rightbottom = lefttop = leftbottom = 0.5;
1750
-
1751
- var edges = [];
1752
-
1753
- /* do interpolation here */
1754
- /* 1st Triangles */
1755
- if (cval === 1) {
1756
- /* 0001 */
1757
- bottomleft = 1 - interpolateX(minV, br, bl);
1758
- leftbottom = 1 - interpolateX(minV, tl, bl);
1759
- edges.push(isoBandEdgeBL[cval]);
1760
- } else if (cval === 169) {
1761
- /* 2221 */
1762
- bottomleft = interpolateX(maxV, bl, br);
1763
- leftbottom = interpolateX(maxV, bl, tl);
1764
- edges.push(isoBandEdgeBL[cval]);
1765
- } else if (cval === 4) {
1766
- /* 0010 */
1767
- rightbottom = 1 - interpolateX(minV, tr, br);
1768
- bottomright = interpolateX(minV, bl, br);
1769
- edges.push(isoBandEdgeRB[cval]);
1770
- } else if (cval === 166) {
1771
- /* 2212 */
1772
- rightbottom = interpolateX(maxV, br, tr);
1773
- bottomright = 1 - interpolateX(maxV, br, bl);
1774
- edges.push(isoBandEdgeRB[cval]);
1775
- } else if (cval === 16) {
1776
- /* 0100 */
1777
- righttop = interpolateX(minV, br, tr);
1778
- topright = interpolateX(minV, tl, tr);
1779
- edges.push(isoBandEdgeRT[cval]);
1780
- } else if (cval === 154) {
1781
- /* 2122 */
1782
- righttop = 1 - interpolateX(maxV, tr, br);
1783
- topright = 1 - interpolateX(maxV, tr, tl);
1784
- edges.push(isoBandEdgeRT[cval]);
1785
- } else if (cval === 64) {
1786
- /* 1000 */
1787
- lefttop = interpolateX(minV, bl, tl);
1788
- topleft = 1 - interpolateX(minV, tr, tl);
1789
- edges.push(isoBandEdgeLT[cval]);
1790
- } else if (cval === 106) {
1791
- /* 1222 */
1792
- lefttop = 1 - interpolateX(maxV, tl, bl);
1793
- topleft = interpolateX(maxV, tl, tr);
1794
- edges.push(isoBandEdgeLT[cval]);
1795
- } else if (cval === 168) {
1796
- /* 2nd Trapezoids */
1797
- /* 2220 */
1798
- bottomright = interpolateX(maxV, bl, br);
1799
- bottomleft = interpolateX(minV, bl, br);
1800
- leftbottom = interpolateX(minV, bl, tl);
1801
- lefttop = interpolateX(maxV, bl, tl);
1802
- edges.push(isoBandEdgeBR[cval]);
1803
- edges.push(isoBandEdgeBL[cval]);
1804
- } else if (cval === 2) {
1805
- /* 0002 */
1806
- bottomright = 1 - interpolateX(minV, br, bl);
1807
- bottomleft = 1 - interpolateX(maxV, br, bl);
1808
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1809
- lefttop = 1 - interpolateX(minV, tl, bl);
1810
- edges.push(isoBandEdgeBR[cval]);
1811
- edges.push(isoBandEdgeBL[cval]);
1812
- } else if (cval === 162) {
1813
- /* 2202 */
1814
- righttop = interpolateX(maxV, br, tr);
1815
- rightbottom = interpolateX(minV, br, tr);
1816
- bottomright = 1 - interpolateX(minV, br, bl);
1817
- bottomleft = 1 - interpolateX(maxV, br, bl);
1818
- edges.push(isoBandEdgeBR[cval]);
1819
- edges.push(isoBandEdgeBL[cval]);
1820
- } else if (cval === 8) {
1821
- /* 0020 */
1822
- righttop = 1 - interpolateX(minV, tr, br);
1823
- rightbottom = 1 - interpolateX(maxV, tr, br);
1824
- bottomright = interpolateX(maxV, bl, br);
1825
- bottomleft = interpolateX(minV, bl, br);
1826
- edges.push(isoBandEdgeRT[cval]);
1827
- edges.push(isoBandEdgeRB[cval]);
1828
- } else if (cval === 138) {
1829
- /* 2022 */
1830
- righttop = 1 - interpolateX(minV, tr, br);
1831
- rightbottom = 1 - interpolateX(maxV, tr, br);
1832
- topleft = 1 - interpolateX(maxV, tr, tl);
1833
- topright = 1 - interpolateX(minV, tr, tl);
1834
- edges.push(isoBandEdgeRT[cval]);
1835
- edges.push(isoBandEdgeRB[cval]);
1836
- } else if (cval === 32) {
1837
- /* 0200 */
1838
- righttop = interpolateX(maxV, br, tr);
1839
- rightbottom = interpolateX(minV, br, tr);
1840
- topleft = interpolateX(minV, tl, tr);
1841
- topright = interpolateX(maxV, tl, tr);
1842
- edges.push(isoBandEdgeRT[cval]);
1843
- edges.push(isoBandEdgeRB[cval]);
1844
- } else if (cval === 42) {
1845
- /* 0222 */
1846
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1847
- lefttop = 1 - interpolateX(minV, tl, bl);
1848
- topleft = interpolateX(minV, tl, tr);
1849
- topright = interpolateX(maxV, tl, tr);
1850
- edges.push(isoBandEdgeLB[cval]);
1851
- edges.push(isoBandEdgeLT[cval]);
1852
- } else if (cval === 128) {
1853
- /* 2000 */
1854
- leftbottom = interpolateX(minV, bl, tl);
1855
- lefttop = interpolateX(maxV, bl, tl);
1856
- topleft = 1 - interpolateX(maxV, tr, tl);
1857
- topright = 1 - interpolateX(minV, tr, tl);
1858
- edges.push(isoBandEdgeLB[cval]);
1859
- edges.push(isoBandEdgeLT[cval]);
1860
- }
1861
-
1862
- /* 3rd rectangle cases */
1863
- if (cval === 5) {
1864
- /* 0011 */
1865
- rightbottom = 1 - interpolateX(minV, tr, br);
1866
- leftbottom = 1 - interpolateX(minV, tl, bl);
1867
- edges.push(isoBandEdgeRB[cval]);
1868
- } else if (cval === 165) {
1869
- /* 2211 */
1870
- rightbottom = interpolateX(maxV, br, tr);
1871
- leftbottom = interpolateX(maxV, bl, tl);
1872
- edges.push(isoBandEdgeRB[cval]);
1873
- } else if (cval === 20) {
1874
- /* 0110 */
1875
- bottomright = interpolateX(minV, bl, br);
1876
- topright = interpolateX(minV, tl, tr);
1877
- edges.push(isoBandEdgeBR[cval]);
1878
- } else if (cval === 150) {
1879
- /* 2112 */
1880
- bottomright = 1 - interpolateX(maxV, br, bl);
1881
- topright = 1 - interpolateX(maxV, tr, tl);
1882
- edges.push(isoBandEdgeBR[cval]);
1883
- } else if (cval === 80) {
1884
- /* 1100 */
1885
- righttop = interpolateX(minV, br, tr);
1886
- lefttop = interpolateX(minV, bl, tl);
1887
- edges.push(isoBandEdgeRT[cval]);
1888
- } else if (cval === 90) {
1889
- /* 1122 */
1890
- righttop = 1 - interpolateX(maxV, tr, br);
1891
- lefttop = 1 - interpolateX(maxV, tl, bl);
1892
- edges.push(isoBandEdgeRT[cval]);
1893
- } else if (cval === 65) {
1894
- /* 1001 */
1895
- bottomleft = 1 - interpolateX(minV, br, bl);
1896
- topleft = 1 - interpolateX(minV, tr, tl);
1897
- edges.push(isoBandEdgeBL[cval]);
1898
- } else if (cval === 105) {
1899
- /* 1221 */
1900
- bottomleft = interpolateX(maxV, bl, br);
1901
- topleft = interpolateX(maxV, tl, tr);
1902
- edges.push(isoBandEdgeBL[cval]);
1903
- } else if (cval === 160) {
1904
- /* 2200 */
1905
- righttop = interpolateX(maxV, br, tr);
1906
- rightbottom = interpolateX(minV, br, tr);
1907
- leftbottom = interpolateX(minV, bl, tl);
1908
- lefttop = interpolateX(maxV, bl, tl);
1909
- edges.push(isoBandEdgeRT[cval]);
1910
- edges.push(isoBandEdgeRB[cval]);
1911
- } else if (cval === 10) {
1912
- /* 0022 */
1913
- righttop = 1 - interpolateX(minV, tr, br);
1914
- rightbottom = 1 - interpolateX(maxV, tr, br);
1915
- leftbottom = 1 - interpolateX(maxV, tl, bl);
1916
- lefttop = 1 - interpolateX(minV, tl, bl);
1917
- edges.push(isoBandEdgeRT[cval]);
1918
- edges.push(isoBandEdgeRB[cval]);
1919
- } else if (cval === 130) {
1920
- /* 2002 */
1921
- bottomright = 1 - interpolateX(minV, br, bl);
1922
- bottomleft = 1 - interpolateX(maxV, br, bl);
1923
- topleft = 1 - interpolateX(maxV, tr, tl);
1924
- topright = 1 - interpolateX(minV, tr, tl);
1925
- edges.push(isoBandEdgeBR[cval]);
1926
- edges.push(isoBandEdgeBL[cval]);
1927
- } else if (cval === 40) {
1928
- /* 0220 */
1929
- bottomright = interpolateX(maxV, bl, br);
1930
- bottomleft = interpolateX(minV, bl, br);
1931
- topleft = interpolateX(minV, tl, tr);
1932
- topright = interpolateX(maxV, tl, tr);
1933
- edges.push(isoBandEdgeBR[cval]);
1934
- edges.push(isoBandEdgeBL[cval]);
1935
- } else if (cval === 101) {
1936
- /* 4th single pentagon cases */
1937
- /* 1211 */
1938
- rightbottom = interpolateX(maxV, br, tr);
1939
- topleft = interpolateX(maxV, tl, tr);
1940
- edges.push(isoBandEdgeRB[cval]);
1941
- } else if (cval === 69) {
1942
- /* 1011 */
1943
- rightbottom = 1 - interpolateX(minV, tr, br);
1944
- topleft = 1 - interpolateX(minV, tr, tl);
1945
- edges.push(isoBandEdgeRB[cval]);
1946
- } else if (cval === 149) {
1947
- /* 2111 */
1948
- leftbottom = interpolateX(maxV, bl, tl);
1949
- topright = 1 - interpolateX(maxV, tr, tl);
1950
- edges.push(isoBandEdgeLB[cval]);
1951
- } else if (cval === 21) {
1952
- /* 0111 */
1953
- leftbottom = 1 - interpolateX(minV, tl, bl);
1954
- topright = interpolateX(minV, tl, tr);
1955
- edges.push(isoBandEdgeLB[cval]);
1956
- } else if (cval === 86) {
1957
- /* 1112 */
1958
- bottomright = 1 - interpolateX(maxV, br, bl);
1959
- lefttop = 1 - interpolateX(maxV, tl, bl);
1960
- edges.push(isoBandEdgeBR[cval]);
1961
- } else if (cval === 84) {
1962
- /* 1110 */
1963
- bottomright = interpolateX(minV, bl, br);
1964
- lefttop = interpolateX(minV, bl, tl);
1965
- edges.push(isoBandEdgeBR[cval]);
1966
- } else if (cval === 89) {
1967
- /* 1121 */
1968
- righttop = 1 - interpolateX(maxV, tr, br);
1969
- bottomleft = interpolateX(maxV, bl, br);
1970
- edges.push(isoBandEdgeBL[cval]);
1971
- } else if (cval === 81) {
1972
- /* 1101 */
1973
- righttop = interpolateX(minV, br, tr);
1974
- bottomleft = 1 - interpolateX(minV, br, bl);
1975
- edges.push(isoBandEdgeBL[cval]);
1976
- } else if (cval === 96) {
1977
- /* 1200 */
1978
- righttop = interpolateX(maxV, br, tr);
1979
- rightbottom = interpolateX(minV, br, tr);
1980
- lefttop = interpolateX(minV, bl, tl);
1981
- topleft = interpolateX(maxV, tl, tr);
1982
- edges.push(isoBandEdgeRT[cval]);
1983
- edges.push(isoBandEdgeRB[cval]);
1984
- } else if (cval === 74) {
1985
- /* 1022 */
1986
- righttop = 1 - interpolateX(minV, tr, br);
1987
- rightbottom = 1 - interpolateX(maxV, tr, br);
1988
- lefttop = 1 - interpolateX(maxV, tl, bl);
1989
- topleft = 1 - interpolateX(minV, tr, tl);
1990
- edges.push(isoBandEdgeRT[cval]);
1991
- edges.push(isoBandEdgeRB[cval]);
1992
- } else if (cval === 24) {
1993
- /* 0120 */
1994
- righttop = 1 - interpolateX(maxV, tr, br);
1995
- bottomright = interpolateX(maxV, bl, br);
1996
- bottomleft = interpolateX(minV, bl, br);
1997
- topright = interpolateX(minV, tl, tr);
1998
- edges.push(isoBandEdgeRT[cval]);
1999
- edges.push(isoBandEdgeBL[cval]);
2000
- } else if (cval === 146) {
2001
- /* 2102 */
2002
- righttop = interpolateX(minV, br, tr);
2003
- bottomright = 1 - interpolateX(minV, br, bl);
2004
- bottomleft = 1 - interpolateX(maxV, br, bl);
2005
- topright = 1 - interpolateX(maxV, tr, tl);
2006
- edges.push(isoBandEdgeRT[cval]);
2007
- edges.push(isoBandEdgeBL[cval]);
2008
- } else if (cval === 6) {
2009
- /* 0012 */
2010
- rightbottom = 1 - interpolateX(minV, tr, br);
2011
- bottomright = 1 - interpolateX(maxV, br, bl);
2012
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2013
- lefttop = 1 - interpolateX(minV, tl, bl);
2014
- edges.push(isoBandEdgeRB[cval]);
2015
- edges.push(isoBandEdgeBR[cval]);
2016
- } else if (cval === 164) {
2017
- /* 2210 */
2018
- rightbottom = interpolateX(maxV, br, tr);
2019
- bottomright = interpolateX(minV, bl, br);
2020
- leftbottom = interpolateX(minV, bl, tl);
2021
- lefttop = interpolateX(maxV, bl, tl);
2022
- edges.push(isoBandEdgeRB[cval]);
2023
- edges.push(isoBandEdgeBR[cval]);
2024
- } else if (cval === 129) {
2025
- /* 2001 */
2026
- bottomleft = 1 - interpolateX(minV, br, bl);
2027
- leftbottom = interpolateX(maxV, bl, tl);
2028
- topleft = 1 - interpolateX(maxV, tr, tl);
2029
- topright = 1 - interpolateX(minV, tr, tl);
2030
- edges.push(isoBandEdgeBL[cval]);
2031
- edges.push(isoBandEdgeLB[cval]);
2032
- } else if (cval === 41) {
2033
- /* 0221 */
2034
- bottomleft = interpolateX(maxV, bl, br);
2035
- leftbottom = 1 - interpolateX(minV, tl, bl);
2036
- topleft = interpolateX(minV, tl, tr);
2037
- topright = interpolateX(maxV, tl, tr);
2038
- edges.push(isoBandEdgeBL[cval]);
2039
- edges.push(isoBandEdgeLB[cval]);
2040
- } else if (cval === 66) {
2041
- /* 1002 */
2042
- bottomright = 1 - interpolateX(minV, br, bl);
2043
- bottomleft = 1 - interpolateX(maxV, br, bl);
2044
- lefttop = 1 - interpolateX(maxV, tl, bl);
2045
- topleft = 1 - interpolateX(minV, tr, tl);
2046
- edges.push(isoBandEdgeBR[cval]);
2047
- edges.push(isoBandEdgeBL[cval]);
2048
- } else if (cval === 104) {
2049
- /* 1220 */
2050
- bottomright = interpolateX(maxV, bl, br);
2051
- bottomleft = interpolateX(minV, bl, br);
2052
- lefttop = interpolateX(minV, bl, tl);
2053
- topleft = interpolateX(maxV, tl, tr);
2054
- edges.push(isoBandEdgeBL[cval]);
2055
- edges.push(isoBandEdgeTL[cval]);
2056
- } else if (cval === 144) {
2057
- /* 2100 */
2058
- righttop = interpolateX(minV, br, tr);
2059
- leftbottom = interpolateX(minV, bl, tl);
2060
- lefttop = interpolateX(maxV, bl, tl);
2061
- topright = 1 - interpolateX(maxV, tr, tl);
2062
- edges.push(isoBandEdgeRT[cval]);
2063
- edges.push(isoBandEdgeLT[cval]);
2064
- } else if (cval === 26) {
2065
- /* 0122 */
2066
- righttop = 1 - interpolateX(maxV, tr, br);
2067
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2068
- lefttop = 1 - interpolateX(minV, tl, bl);
2069
- topright = interpolateX(minV, tl, tr);
2070
- edges.push(isoBandEdgeRT[cval]);
2071
- edges.push(isoBandEdgeLT[cval]);
2072
- } else if (cval === 36) {
2073
- /* 0210 */
2074
- rightbottom = interpolateX(maxV, br, tr);
2075
- bottomright = interpolateX(minV, bl, br);
2076
- topleft = interpolateX(minV, tl, tr);
2077
- topright = interpolateX(maxV, tl, tr);
2078
- edges.push(isoBandEdgeRB[cval]);
2079
- edges.push(isoBandEdgeBR[cval]);
2080
- } else if (cval === 134) {
2081
- /* 2012 */
2082
- rightbottom = 1 - interpolateX(minV, tr, br);
2083
- bottomright = 1 - interpolateX(maxV, br, bl);
2084
- topleft = 1 - interpolateX(maxV, tr, tl);
2085
- topright = 1 - interpolateX(minV, tr, tl);
2086
- edges.push(isoBandEdgeRB[cval]);
2087
- edges.push(isoBandEdgeBR[cval]);
2088
- } else if (cval === 9) {
2089
- /* 0021 */
2090
- righttop = 1 - interpolateX(minV, tr, br);
2091
- rightbottom = 1 - interpolateX(maxV, tr, br);
2092
- bottomleft = interpolateX(maxV, bl, br);
2093
- leftbottom = 1 - interpolateX(minV, tl, bl);
2094
- edges.push(isoBandEdgeRT[cval]);
2095
- edges.push(isoBandEdgeRB[cval]);
2096
- } else if (cval === 161) {
2097
- /* 2201 */
2098
- righttop = interpolateX(maxV, br, tr);
2099
- rightbottom = interpolateX(minV, br, tr);
2100
- bottomleft = 1 - interpolateX(minV, br, bl);
2101
- leftbottom = interpolateX(maxV, bl, tl);
2102
- edges.push(isoBandEdgeRT[cval]);
2103
- edges.push(isoBandEdgeRB[cval]);
2104
- } else if (cval === 37) {
2105
- /* 5th single hexagon cases */
2106
- /* 0211 */
2107
- rightbottom = interpolateX(maxV, br, tr);
2108
- leftbottom = 1 - interpolateX(minV, tl, bl);
2109
- topleft = interpolateX(minV, tl, tr);
2110
- topright = interpolateX(maxV, tl, tr);
2111
- edges.push(isoBandEdgeRB[cval]);
2112
- edges.push(isoBandEdgeLB[cval]);
2113
- } else if (cval === 133) {
2114
- /* 2011 */
2115
- rightbottom = 1 - interpolateX(minV, tr, br);
2116
- leftbottom = interpolateX(maxV, bl, tl);
2117
- topleft = 1 - interpolateX(maxV, tr, tl);
2118
- topright = 1 - interpolateX(minV, tr, tl);
2119
- edges.push(isoBandEdgeRB[cval]);
2120
- edges.push(isoBandEdgeLB[cval]);
2121
- } else if (cval === 148) {
2122
- /* 2110 */
2123
- bottomright = interpolateX(minV, bl, br);
2124
- leftbottom = interpolateX(minV, bl, tl);
2125
- lefttop = interpolateX(maxV, bl, tl);
2126
- topright = 1 - interpolateX(maxV, tr, tl);
2127
- edges.push(isoBandEdgeBR[cval]);
2128
- edges.push(isoBandEdgeLT[cval]);
2129
- } else if (cval === 22) {
2130
- /* 0112 */
2131
- bottomright = 1 - interpolateX(maxV, br, bl);
2132
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2133
- lefttop = 1 - interpolateX(minV, tl, bl);
2134
- topright = interpolateX(minV, tl, tr);
2135
- edges.push(isoBandEdgeBR[cval]);
2136
- edges.push(isoBandEdgeLT[cval]);
2137
- } else if (cval === 82) {
2138
- /* 1102 */
2139
- righttop = interpolateX(minV, br, tr);
2140
- bottomright = 1 - interpolateX(minV, br, bl);
2141
- bottomleft = 1 - interpolateX(maxV, br, bl);
2142
- lefttop = 1 - interpolateX(maxV, tl, bl);
2143
- edges.push(isoBandEdgeRT[cval]);
2144
- edges.push(isoBandEdgeBL[cval]);
2145
- } else if (cval === 88) {
2146
- /* 1120 */
2147
- righttop = 1 - interpolateX(maxV, tr, br);
2148
- bottomright = interpolateX(maxV, bl, br);
2149
- bottomleft = interpolateX(minV, bl, br);
2150
- lefttop = interpolateX(minV, bl, tl);
2151
- edges.push(isoBandEdgeRT[cval]);
2152
- edges.push(isoBandEdgeBL[cval]);
2153
- } else if (cval === 73) {
2154
- /* 1021 */
2155
- righttop = 1 - interpolateX(minV, tr, br);
2156
- rightbottom = 1 - interpolateX(maxV, tr, br);
2157
- bottomleft = interpolateX(maxV, bl, br);
2158
- topleft = 1 - interpolateX(minV, tr, tl);
2159
- edges.push(isoBandEdgeRT[cval]);
2160
- edges.push(isoBandEdgeRB[cval]);
2161
- } else if (cval === 97) {
2162
- /* 1201 */
2163
- righttop = interpolateX(maxV, br, tr);
2164
- rightbottom = interpolateX(minV, br, tr);
2165
- bottomleft = 1 - interpolateX(minV, br, bl);
2166
- topleft = interpolateX(maxV, tl, tr);
2167
- edges.push(isoBandEdgeRT[cval]);
2168
- edges.push(isoBandEdgeRB[cval]);
2169
- } else if (cval === 145) {
2170
- /* 2101 */
2171
- righttop = interpolateX(minV, br, tr);
2172
- bottomleft = 1 - interpolateX(minV, br, bl);
2173
- leftbottom = interpolateX(maxV, bl, tl);
2174
- topright = 1 - interpolateX(maxV, tr, tl);
2175
- edges.push(isoBandEdgeRT[cval]);
2176
- edges.push(isoBandEdgeLB[cval]);
2177
- } else if (cval === 25) {
2178
- /* 0121 */
2179
- righttop = 1 - interpolateX(maxV, tr, br);
2180
- bottomleft = interpolateX(maxV, bl, br);
2181
- leftbottom = 1 - interpolateX(minV, tl, bl);
2182
- topright = interpolateX(minV, tl, tr);
2183
- edges.push(isoBandEdgeRT[cval]);
2184
- edges.push(isoBandEdgeLB[cval]);
2185
- } else if (cval === 70) {
2186
- /* 1012 */
2187
- rightbottom = 1 - interpolateX(minV, tr, br);
2188
- bottomright = 1 - interpolateX(maxV, br, bl);
2189
- lefttop = 1 - interpolateX(maxV, tl, bl);
2190
- topleft = 1 - interpolateX(minV, tr, tl);
2191
- edges.push(isoBandEdgeRB[cval]);
2192
- edges.push(isoBandEdgeBR[cval]);
2193
- } else if (cval === 100) {
2194
- /* 1210 */
2195
- rightbottom = interpolateX(maxV, br, tr);
2196
- bottomright = interpolateX(minV, bl, br);
2197
- lefttop = interpolateX(minV, bl, tl);
2198
- topleft = interpolateX(maxV, tl, tr);
2199
- edges.push(isoBandEdgeRB[cval]);
2200
- edges.push(isoBandEdgeBR[cval]);
2201
- } else if (cval === 34) {
2202
- /* 8-sided cases */
2203
- /* 0202 || 2020 with flipped == 0 */
2204
- if (flipped === 0) {
2205
- righttop = 1 - interpolateX(minV, tr, br);
2206
- rightbottom = 1 - interpolateX(maxV, tr, br);
2207
- bottomright = interpolateX(maxV, bl, br);
2208
- bottomleft = interpolateX(minV, bl, br);
2209
- leftbottom = interpolateX(minV, bl, tl);
2210
- lefttop = interpolateX(maxV, bl, tl);
2211
- topleft = 1 - interpolateX(maxV, tr, tl);
2212
- topright = 1 - interpolateX(minV, tr, tl);
2213
- } else {
2214
- righttop = interpolateX(maxV, br, tr);
2215
- rightbottom = interpolateX(minV, br, tr);
2216
- bottomright = 1 - interpolateX(minV, br, bl);
2217
- bottomleft = 1 - interpolateX(maxV, br, bl);
2218
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2219
- lefttop = 1 - interpolateX(minV, tl, bl);
2220
- topleft = interpolateX(minV, tl, tr);
2221
- topright = interpolateX(maxV, tl, tr);
2222
- }
2223
- edges.push(isoBandEdgeRT[cval]);
2224
- edges.push(isoBandEdgeRB[cval]);
2225
- edges.push(isoBandEdgeLB[cval]);
2226
- edges.push(isoBandEdgeLT[cval]);
2227
- } else if (cval === 35) {
2228
- /* flipped == 1 state for 0202, and 2020 with flipped == 4*/
2229
- if (flipped === 4) {
2230
- righttop = 1 - interpolateX(minV, tr, br);
2231
- rightbottom = 1 - interpolateX(maxV, tr, br);
2232
- bottomright = interpolateX(maxV, bl, br);
2233
- bottomleft = interpolateX(minV, bl, br);
2234
- leftbottom = interpolateX(minV, bl, tl);
2235
- lefttop = interpolateX(maxV, bl, tl);
2236
- topleft = 1 - interpolateX(maxV, tr, tl);
2237
- topright = 1 - interpolateX(minV, tr, tl);
2238
- } else {
2239
- righttop = interpolateX(maxV, br, tr);
2240
- rightbottom = interpolateX(minV, br, tr);
2241
- bottomright = 1 - interpolateX(minV, br, bl);
2242
- bottomleft = 1 - interpolateX(maxV, br, bl);
2243
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2244
- lefttop = 1 - interpolateX(minV, tl, bl);
2245
- topleft = interpolateX(minV, tl, tr);
2246
- topright = interpolateX(maxV, tl, tr);
2247
- }
2248
- edges.push(isoBandEdgeRT[cval]);
2249
- edges.push(isoBandEdgeRB[cval]);
2250
- edges.push(isoBandEdgeBL[cval]);
2251
- edges.push(isoBandEdgeLT[cval]);
2252
- } else if (cval === 136) {
2253
- /* 2020 || 0202 with flipped == 0 */
2254
- if (flipped === 0) {
2255
- righttop = interpolateX(maxV, br, tr);
2256
- rightbottom = interpolateX(minV, br, tr);
2257
- bottomright = 1 - interpolateX(minV, br, bl);
2258
- bottomleft = 1 - interpolateX(maxV, br, bl);
2259
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2260
- lefttop = 1 - interpolateX(minV, tl, bl);
2261
- topleft = interpolateX(minV, tl, tr);
2262
- topright = interpolateX(maxV, tl, tr);
2263
- } else {
2264
- righttop = 1 - interpolateX(minV, tr, br);
2265
- rightbottom = 1 - interpolateX(maxV, tr, br);
2266
- bottomright = interpolateX(maxV, bl, br);
2267
- bottomleft = interpolateX(minV, bl, br);
2268
- leftbottom = interpolateX(minV, bl, tl);
2269
- lefttop = interpolateX(maxV, bl, tl);
2270
- topleft = 1 - interpolateX(maxV, tr, tl);
2271
- topright = 1 - interpolateX(minV, tr, tl);
2272
- }
2273
- edges.push(isoBandEdgeRT[cval]);
2274
- edges.push(isoBandEdgeRB[cval]);
2275
- edges.push(isoBandEdgeLB[cval]);
2276
- edges.push(isoBandEdgeLT[cval]);
2277
- } else if (cval === 153) {
2278
- /* 6-sided polygon cases */
2279
- /* 0101 with flipped == 0 || 2121 with flipped == 2 */
2280
- if (flipped === 0) {
2281
- righttop = interpolateX(minV, br, tr);
2282
- bottomleft = 1 - interpolateX(minV, br, bl);
2283
- leftbottom = 1 - interpolateX(minV, tl, bl);
2284
- topright = interpolateX(minV, tl, tr);
2285
- } else {
2286
- righttop = 1 - interpolateX(maxV, tr, br);
2287
- bottomleft = interpolateX(maxV, bl, br);
2288
- leftbottom = interpolateX(maxV, bl, tl);
2289
- topright = 1 - interpolateX(maxV, tr, tl);
2290
- }
2291
- edges.push(isoBandEdgeRT[cval]);
2292
- edges.push(isoBandEdgeBL[cval]);
2293
- } else if (cval === 102) {
2294
- /* 1010 with flipped == 0 || 1212 with flipped == 2 */
2295
- if (flipped === 0) {
2296
- rightbottom = 1 - interpolateX(minV, tr, br);
2297
- bottomright = interpolateX(minV, bl, br);
2298
- lefttop = interpolateX(minV, bl, tl);
2299
- topleft = 1 - interpolateX(minV, tr, tl);
2300
- } else {
2301
- rightbottom = interpolateX(maxV, br, tr);
2302
- bottomright = 1 - interpolateX(maxV, br, bl);
2303
- lefttop = 1 - interpolateX(maxV, tl, bl);
2304
- topleft = interpolateX(maxV, tl, tr);
2305
- }
2306
- edges.push(isoBandEdgeRB[cval]);
2307
- edges.push(isoBandEdgeLT[cval]);
2308
- } else if (cval === 155) {
2309
- /* 0101 with flipped == 4 || 2121 with flipped == 1 */
2310
- if (flipped === 4) {
2311
- righttop = interpolateX(minV, br, tr);
2312
- bottomleft = 1 - interpolateX(minV, br, bl);
2313
- leftbottom = 1 - interpolateX(minV, tl, bl);
2314
- topright = interpolateX(minV, tl, tr);
2315
- } else {
2316
- righttop = 1 - interpolateX(maxV, tr, br);
2317
- bottomleft = interpolateX(maxV, bl, br);
2318
- leftbottom = interpolateX(maxV, bl, tl);
2319
- topright = 1 - interpolateX(maxV, tr, tl);
2320
- }
2321
- edges.push(isoBandEdgeRT[cval]);
2322
- edges.push(isoBandEdgeLB[cval]);
2323
- } else if (cval === 103) {
2324
- /* 1010 with flipped == 4 || 1212 with flipped == 1 */
2325
- if (flipped === 4) {
2326
- rightbottom = 1 - interpolateX(minV, tr, br);
2327
- bottomright = interpolateX(minV, bl, br);
2328
- lefttop = interpolateX(minV, bl, tl);
2329
- topleft = 1 - interpolateX(minV, tr, tl);
2330
- } else {
2331
- rightbottom = interpolateX(maxV, br, tr);
2332
- bottomright = 1 - interpolateX(maxV, br, bl);
2333
- lefttop = 1 - interpolateX(maxV, tl, bl);
2334
- topleft = interpolateX(maxV, tl, tr);
2335
- }
2336
- edges.push(isoBandEdgeRB[cval]);
2337
- edges.push(isoBandEdgeBR[cval]);
2338
- } else if (cval === 152) {
2339
- /* 7-sided polygon cases */
2340
- /* 2120 with flipped == 2 || 0102 with flipped == 0 */
2341
- if (flipped === 0) {
2342
- righttop = interpolateX(minV, br, tr);
2343
- bottomright = 1 - interpolateX(minV, br, bl);
2344
- bottomleft = 1 - interpolateX(maxV, br, bl);
2345
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2346
- lefttop = 1 - interpolateX(minV, tl, bl);
2347
- topright = interpolateX(minV, tl, tr);
2348
- } else {
2349
- righttop = 1 - interpolateX(maxV, tr, br);
2350
- bottomright = interpolateX(maxV, bl, br);
2351
- bottomleft = interpolateX(minV, bl, br);
2352
- leftbottom = interpolateX(minV, bl, tl);
2353
- lefttop = interpolateX(maxV, bl, tl);
2354
- topright = 1 - interpolateX(maxV, tr, tl);
2355
- }
2356
- edges.push(isoBandEdgeRT[cval]);
2357
- edges.push(isoBandEdgeBR[cval]);
2358
- edges.push(isoBandEdgeBL[cval]);
2359
- } else if (cval === 156) {
2360
- /* 2120 with flipped == 1 || 0102 with flipped == 4 */
2361
- if (flipped === 4) {
2362
- righttop = interpolateX(minV, br, tr);
2363
- bottomright = 1 - interpolateX(minV, br, bl);
2364
- bottomleft = 1 - interpolateX(maxV, br, bl);
2365
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2366
- lefttop = 1 - interpolateX(minV, tl, bl);
2367
- topright = interpolateX(minV, tl, tr);
2368
- } else {
2369
- righttop = 1 - interpolateX(maxV, tr, br);
2370
- bottomright = interpolateX(maxV, bl, br);
2371
- bottomleft = interpolateX(minV, bl, br);
2372
- leftbottom = interpolateX(minV, bl, tl);
2373
- lefttop = interpolateX(maxV, bl, tl);
2374
- topright = 1 - interpolateX(maxV, tr, tl);
2375
- }
2376
- edges.push(isoBandEdgeRT[cval]);
2377
- edges.push(isoBandEdgeBL[cval]);
2378
- edges.push(isoBandEdgeLT[cval]);
2379
- } else if (cval === 137) {
2380
- /* 2021 with flipped == 2 || 0201 with flipped == 0 */
2381
- if (flipped === 0) {
2382
- righttop = interpolateX(maxV, br, tr);
2383
- rightbottom = interpolateX(minV, br, tr);
2384
- bottomleft = 1 - interpolateX(minV, br, bl);
2385
- leftbottom = 1 - interpolateX(minV, tl, bl);
2386
- topleft = interpolateX(minV, tl, tr);
2387
- topright = interpolateX(maxV, tl, tr);
2388
- } else {
2389
- righttop = 1 - interpolateX(minV, tr, br);
2390
- rightbottom = 1 - interpolateX(maxV, tr, br);
2391
- bottomleft = interpolateX(maxV, bl, br);
2392
- leftbottom = interpolateX(maxV, bl, tl);
2393
- topleft = 1 - interpolateX(maxV, tr, tl);
2394
- topright = 1 - interpolateX(minV, tr, tl);
2395
- }
2396
- edges.push(isoBandEdgeRT[cval]);
2397
- edges.push(isoBandEdgeRB[cval]);
2398
- edges.push(isoBandEdgeBL[cval]);
2399
- } else if (cval === 139) {
2400
- /* 2021 with flipped == 1 || 0201 with flipped == 4 */
2401
- if (flipped === 4) {
2402
- righttop = interpolateX(maxV, br, tr);
2403
- rightbottom = interpolateX(minV, br, tr);
2404
- bottomleft = 1 - interpolateX(minV, br, bl);
2405
- leftbottom = 1 - interpolateX(minV, tl, bl);
2406
- topleft = interpolateX(minV, tl, tr);
2407
- topright = interpolateX(maxV, tl, tr);
2408
- } else {
2409
- righttop = 1 - interpolateX(minV, tr, br);
2410
- rightbottom = 1 - interpolateX(maxV, tr, br);
2411
- bottomleft = interpolateX(maxV, bl, br);
2412
- leftbottom = interpolateX(maxV, bl, tl);
2413
- topleft = 1 - interpolateX(maxV, tr, tl);
2414
- topright = 1 - interpolateX(minV, tr, tl);
2415
- }
2416
- edges.push(isoBandEdgeRT[cval]);
2417
- edges.push(isoBandEdgeRB[cval]);
2418
- edges.push(isoBandEdgeLB[cval]);
2419
- } else if (cval === 98) {
2420
- /* 1202 with flipped == 2 || 1020 with flipped == 0 */
2421
- if (flipped === 0) {
2422
- righttop = 1 - interpolateX(minV, tr, br);
2423
- rightbottom = 1 - interpolateX(maxV, tr, br);
2424
- bottomright = interpolateX(maxV, bl, br);
2425
- bottomleft = interpolateX(minV, bl, br);
2426
- lefttop = interpolateX(minV, bl, tl);
2427
- topleft = 1 - interpolateX(minV, tr, tl);
2428
- } else {
2429
- righttop = interpolateX(maxV, br, tr);
2430
- rightbottom = interpolateX(minV, br, tr);
2431
- bottomright = 1 - interpolateX(minV, br, bl);
2432
- bottomleft = 1 - interpolateX(maxV, br, bl);
2433
- lefttop = 1 - interpolateX(maxV, tl, bl);
2434
- topleft = interpolateX(maxV, tl, tr);
2435
- }
2436
- edges.push(isoBandEdgeRT[cval]);
2437
- edges.push(isoBandEdgeRB[cval]);
2438
- edges.push(isoBandEdgeLT[cval]);
2439
- } else if (cval === 99) {
2440
- /* 1202 with flipped == 1 || 1020 with flipped == 4 */
2441
- if (flipped === 4) {
2442
- righttop = 1 - interpolateX(minV, tr, br);
2443
- rightbottom = 1 - interpolateX(maxV, tr, br);
2444
- bottomright = interpolateX(maxV, bl, br);
2445
- bottomleft = interpolateX(minV, bl, br);
2446
- lefttop = interpolateX(minV, bl, tl);
2447
- topleft = 1 - interpolateX(minV, tr, tl);
2448
- } else {
2449
- righttop = interpolateX(maxV, br, tr);
2450
- rightbottom = interpolateX(minV, br, tr);
2451
- bottomright = 1 - interpolateX(minV, br, bl);
2452
- bottomleft = 1 - interpolateX(maxV, br, bl);
2453
- lefttop = 1 - interpolateX(maxV, tl, bl);
2454
- topleft = interpolateX(maxV, tl, tr);
2455
- }
2456
- edges.push(isoBandEdgeRT[cval]);
2457
- edges.push(isoBandEdgeRB[cval]);
2458
- edges.push(isoBandEdgeBL[cval]);
2459
- } else if (cval === 38) {
2460
- /* 0212 with flipped == 2 || 2010 with flipped == 0 */
2461
- if (flipped === 0) {
2462
- rightbottom = 1 - interpolateX(minV, tr, br);
2463
- bottomright = interpolateX(minV, bl, br);
2464
- leftbottom = interpolateX(minV, bl, tl);
2465
- lefttop = interpolateX(maxV, bl, tl);
2466
- topleft = 1 - interpolateX(maxV, tr, tl);
2467
- topright = 1 - interpolateX(minV, tr, tl);
2468
- } else {
2469
- rightbottom = interpolateX(maxV, br, tr);
2470
- bottomright = 1 - interpolateX(maxV, br, bl);
2471
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2472
- lefttop = 1 - interpolateX(minV, tl, bl);
2473
- topleft = interpolateX(minV, tl, tr);
2474
- topright = interpolateX(maxV, tl, tr);
2475
- }
2476
- edges.push(isoBandEdgeRB[cval]);
2477
- edges.push(isoBandEdgeLB[cval]);
2478
- edges.push(isoBandEdgeLT[cval]);
2479
- } else if (cval === 39) {
2480
- /* 0212 with flipped == 1 || 2010 with flipped == 4 */
2481
- if (flipped === 4) {
2482
- rightbottom = 1 - interpolateX(minV, tr, br);
2483
- bottomright = interpolateX(minV, bl, br);
2484
- leftbottom = interpolateX(minV, bl, tl);
2485
- lefttop = interpolateX(maxV, bl, tl);
2486
- topleft = 1 - interpolateX(maxV, tr, tl);
2487
- topright = 1 - interpolateX(minV, tr, tl);
2488
- } else {
2489
- rightbottom = interpolateX(maxV, br, tr);
2490
- bottomright = 1 - interpolateX(maxV, br, bl);
2491
- leftbottom = 1 - interpolateX(maxV, tl, bl);
2492
- lefttop = 1 - interpolateX(minV, tl, bl);
2493
- topleft = interpolateX(minV, tl, tr);
2494
- topright = interpolateX(maxV, tl, tr);
2495
- }
2496
- edges.push(isoBandEdgeRB[cval]);
2497
- edges.push(isoBandEdgeBR[cval]);
2498
- edges.push(isoBandEdgeLT[cval]);
2499
- } else if (cval === 85) {
2500
- righttop = 1;
2501
- rightbottom = 0;
2502
- bottomright = 1;
2503
- bottomleft = 0;
2504
- leftbottom = 0;
2505
- lefttop = 1;
2506
- topleft = 0;
2507
- topright = 1;
2508
- }
2509
-
2510
- if (
2511
- topleft < 0 ||
2512
- topleft > 1 ||
2513
- topright < 0 ||
2514
- topright > 1 ||
2515
- righttop < 0 ||
2516
- righttop > 1 ||
2517
- bottomright < 0 ||
2518
- bottomright > 1 ||
2519
- leftbottom < 0 ||
2520
- leftbottom > 1 ||
2521
- lefttop < 0 ||
2522
- lefttop > 1
2523
- ) {
2524
- console.log(
2525
- "MarchingSquaresJS-isoBands: " +
2526
- cval +
2527
- " " +
2528
- cval_real +
2529
- " " +
2530
- tl +
2531
- "," +
2532
- tr +
2533
- "," +
2534
- br +
2535
- "," +
2536
- bl +
2537
- " " +
2538
- flipped +
2539
- " " +
2540
- topleft +
2541
- " " +
2542
- topright +
2543
- " " +
2544
- righttop +
2545
- " " +
2546
- rightbottom +
2547
- " " +
2548
- bottomright +
2549
- " " +
2550
- bottomleft +
2551
- " " +
2552
- leftbottom +
2553
- " " +
2554
- lefttop
2555
- );
2556
- }
2557
-
2558
- BandGrid.cells[j][i] = {
2559
- cval: cval,
2560
- cval_real: cval_real,
2561
- flipped: flipped,
2562
- topleft: topleft,
2563
- topright: topright,
2564
- righttop: righttop,
2565
- rightbottom: rightbottom,
2566
- bottomright: bottomright,
2567
- bottomleft: bottomleft,
2568
- leftbottom: leftbottom,
2569
- lefttop: lefttop,
2570
- edges: edges,
2571
- };
2572
- }
2573
- }
2574
- }
2575
-
2576
- return BandGrid;
2577
- }
2578
-
2579
- function BandGrid2AreaPaths(grid) {
2580
- var areas = [];
2581
- var rows = grid.rows;
2582
- var cols = grid.cols;
2583
- var currentPolygon = [];
2584
-
2585
- for (var j = 0; j < rows; j++) {
2586
- for (var i = 0; i < cols; i++) {
2587
- if (
2588
- typeof grid.cells[j][i] !== "undefined" &&
2589
- grid.cells[j][i].edges.length > 0
2590
- ) {
2591
- /* trace back polygon path starting from this cell */
2592
-
2593
- var cell = grid.cells[j][i];
2594
-
2595
- /* get start coordinates */
2596
-
2597
- var prev = getStartXY(cell),
2598
- next = null,
2599
- p = i,
2600
- q = j;
2601
-
2602
- if (prev !== null) {
2603
- currentPolygon.push([prev.p[0] + p, prev.p[1] + q]);
2604
- //console.log(cell);
2605
- //console.log("coords: " + (prev.p[0] + p) + " " + (prev.p[1] + q));
2606
- }
2607
-
2608
- do {
2609
- //console.log(p + "," + q);
2610
- //console.log(grid.cells[q][p]);
2611
- //console.log(grid.cells[q][p].edges);
2612
- //console.log("from : " + prev.x + " " + prev.y + " " + prev.o);
2613
-
2614
- next = getExitXY(grid.cells[q][p], prev.x, prev.y, prev.o);
2615
- if (next !== null) {
2616
- //console.log("coords: " + (next.p[0] + p) + " " + (next.p[1] + q));
2617
- currentPolygon.push([next.p[0] + p, next.p[1] + q]);
2618
- p += next.x;
2619
- q += next.y;
2620
- prev = next;
2621
- } else {
2622
- //console.log("getExitXY() returned null!");
2623
- break;
2624
- }
2625
- //console.log("to : " + next.x + " " + next.y + " " + next.o);
2626
- /* special case, where we've reached the grid boundaries */
2627
- if (
2628
- q < 0 ||
2629
- q >= rows ||
2630
- p < 0 ||
2631
- p >= cols ||
2632
- typeof grid.cells[q][p] === "undefined"
2633
- ) {
2634
- /* to create a closed path, we need to trace our way
2635
- arround the missing data, until we find an entry
2636
- point again
2637
- */
2638
-
2639
- /* set back coordinates of current cell */
2640
- p -= next.x;
2641
- q -= next.y;
2642
-
2643
- //console.log("reached boundary at " + p + " " + q);
2644
-
2645
- var missing = traceOutOfGridPath(
2646
- grid,
2647
- p,
2648
- q,
2649
- next.x,
2650
- next.y,
2651
- next.o
2652
- );
2653
- if (missing !== null) {
2654
- missing.path.forEach(function (pp) {
2655
- //console.log("coords: " + (pp[0]) + " " + (pp[1]));
2656
- currentPolygon.push(pp);
2657
- });
2658
- p = missing.i;
2659
- q = missing.j;
2660
- prev = missing;
2661
- } else {
2662
- break;
2663
- }
2664
- //console.log(grid.cells[q][p]);
2665
- }
2666
- } while (
2667
- typeof grid.cells[q][p] !== "undefined" &&
2668
- grid.cells[q][p].edges.length > 0
2669
- );
2670
-
2671
- areas.push(currentPolygon);
2672
- //console.log("next polygon");
2673
- //console.log(currentPolygon);
2674
- currentPolygon = [];
2675
- if (grid.cells[j][i].edges.length > 0) i--;
2676
- }
2677
- }
2678
- }
2679
- return areas;
2680
- }
2681
-
2682
- function traceOutOfGridPath(grid, i, j, d_x, d_y, d_o) {
2683
- var cell = grid.cells[j][i];
2684
- var cval = cell.cval_real;
2685
- var p = i + d_x,
2686
- q = j + d_y;
2687
- var path = [];
2688
- var closed = false;
2689
-
2690
- while (!closed) {
2691
- //console.log("processing cell " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
2692
- if (
2693
- typeof grid.cells[q] === "undefined" ||
2694
- typeof grid.cells[q][p] === "undefined"
2695
- ) {
2696
- //console.log("which is undefined");
2697
- /* we can't move on, so we have to change direction to proceed further */
2698
-
2699
- /* go back to previous cell */
2700
- q -= d_y;
2701
- p -= d_x;
2702
- cell = grid.cells[q][p];
2703
- cval = cell.cval_real;
2704
-
2705
- /* check where we've left defined cells of the grid... */
2706
- if (d_y === -1) {
2707
- /* we came from top */
2708
- if (d_o === 0) {
2709
- /* exit left */
2710
- if (cval & Node3) {
2711
- /* lower left node is within range, so we move left */
2712
- path.push([p, q]);
2713
- d_x = -1;
2714
- d_y = 0;
2715
- d_o = 0;
2716
- } else if (cval & Node2) {
2717
- /* lower right node is within range, so we move right */
2718
- path.push([p + 1, q]);
2719
- d_x = 1;
2720
- d_y = 0;
2721
- d_o = 0;
2722
- } else {
2723
- /* close the path */
2724
- path.push([p + cell.bottomright, q]);
2725
- d_x = 0;
2726
- d_y = 1;
2727
- d_o = 1;
2728
- closed = true;
2729
- break;
2730
- }
2731
- } else if (cval & Node3) {
2732
- path.push([p, q]);
2733
- d_x = -1;
2734
- d_y = 0;
2735
- d_o = 0;
2736
- } else if (cval & Node2) {
2737
- path.push([p + cell.bottomright, q]);
2738
- d_x = 0;
2739
- d_y = 1;
2740
- d_o = 1;
2741
- closed = true;
2742
- break;
2743
- } else {
2744
- path.push([p + cell.bottomleft, q]);
2745
- d_x = 0;
2746
- d_y = 1;
2747
- d_o = 0;
2748
- closed = true;
2749
- break;
2750
- }
2751
- } else if (d_y === 1) {
2752
- /* we came from bottom */
2753
- //console.log("we came from bottom and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
2754
- if (d_o === 0) {
2755
- /* exit left */
2756
- if (cval & Node1) {
2757
- /* top right node is within range, so we move right */
2758
- path.push([p + 1, q + 1]);
2759
- d_x = 1;
2760
- d_y = 0;
2761
- d_o = 1;
2762
- } else if (!(cval & Node0)) {
2763
- /* found entry within same cell */
2764
- path.push([p + cell.topright, q + 1]);
2765
- d_x = 0;
2766
- d_y = -1;
2767
- d_o = 1;
2768
- closed = true;
2769
- //console.log("found entry from bottom at " + p + "," + q);
2770
- break;
2771
- } else {
2772
- path.push([p + cell.topleft, q + 1]);
2773
- d_x = 0;
2774
- d_y = -1;
2775
- d_o = 0;
2776
- closed = true;
2777
- break;
2778
- }
2779
- } else if (cval & Node1) {
2780
- path.push([p + 1, q + 1]);
2781
- d_x = 1;
2782
- d_y = 0;
2783
- d_o = 1;
2784
- } else {
2785
- /* move right */
2786
- path.push([p + 1, q + 1]);
2787
- d_x = 1;
2788
- d_y = 0;
2789
- d_o = 1;
2790
- //console.log("wtf");
2791
- //break;
2792
- }
2793
- } else if (d_x === -1) {
2794
- /* we came from right */
2795
- //console.log("we came from right and hit a non-existing cell at " + (p + d_x) + "," + (q + d_y) + "!");
2796
- if (d_o === 0) {
2797
- //console.log("continue at bottom");
2798
- if (cval & Node0) {
2799
- path.push([p, q + 1]);
2800
- d_x = 0;
2801
- d_y = 1;
2802
- d_o = 0;
2803
- //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
2804
- } else if (!(cval & Node3)) {
2805
- /* there has to be an entry into the regular grid again! */
2806
- //console.log("exiting top");
2807
- path.push([p, q + cell.lefttop]);
2808
- d_x = 1;
2809
- d_y = 0;
2810
- d_o = 1;
2811
- closed = true;
2812
- break;
2813
- } else {
2814
- //console.log("exiting bottom");
2815
- path.push([p, q + cell.leftbottom]);
2816
- d_x = 1;
2817
- d_y = 0;
2818
- d_o = 0;
2819
- closed = true;
2820
- break;
2821
- }
2822
- } else {
2823
- //console.log("continue at top");
2824
- if (cval & Node0) {
2825
- path.push([p, q + 1]);
2826
- d_x = 0;
2827
- d_y = 1;
2828
- d_o = 0;
2829
- //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
2830
- } else {
2831
- /* */
2832
- console.log("MarchingSquaresJS-isoBands: wtf");
2833
- break;
2834
- }
2835
- }
2836
- } else if (d_x === 1) {
2837
- /* we came from left */
2838
- //console.log("we came from left and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
2839
- if (d_o === 0) {
2840
- /* exit bottom */
2841
- if (cval & Node2) {
2842
- path.push([p + 1, q]);
2843
- d_x = 0;
2844
- d_y = -1;
2845
- d_o = 1;
2846
- } else {
2847
- path.push([p + 1, q + cell.rightbottom]);
2848
- d_x = -1;
2849
- d_y = 0;
2850
- d_o = 0;
2851
- closed = true;
2852
- break;
2853
- }
2854
- } else {
2855
- /* exit top */
2856
- if (cval & Node2) {
2857
- path.push([p + 1, q]);
2858
- d_x = 0;
2859
- d_y = -1;
2860
- d_o = 1;
2861
- } else if (!(cval & Node1)) {
2862
- path.push([p + 1, q + cell.rightbottom]);
2863
- d_x = -1;
2864
- d_y = 0;
2865
- d_o = 0;
2866
- closed = true;
2867
- break;
2868
- } else {
2869
- path.push([p + 1, q + cell.righttop]);
2870
- d_x = -1;
2871
- d_y = 0;
2872
- d_o = 1;
2873
- break;
2874
- }
2875
- }
2876
- } else {
2877
- /* we came from the same cell */
2878
- console.log("MarchingSquaresJS-isoBands: we came from nowhere!");
2879
- break;
2880
- }
2881
- } else {
2882
- /* try to find an entry into the regular grid again! */
2883
- cell = grid.cells[q][p];
2884
- cval = cell.cval_real;
2885
- //console.log("which is defined");
2886
-
2887
- if (d_x === -1) {
2888
- if (d_o === 0) {
2889
- /* try to go downwards */
2890
- if (
2891
- typeof grid.cells[q - 1] !== "undefined" &&
2892
- typeof grid.cells[q - 1][p] !== "undefined"
2893
- ) {
2894
- d_x = 0;
2895
- d_y = -1;
2896
- d_o = 1;
2897
- } else if (cval & Node3) {
2898
- /* proceed searching in x-direction */
2899
- //console.log("proceeding in x-direction!");
2900
- path.push([p, q]);
2901
- } else {
2902
- /* we must have found an entry into the regular grid */
2903
- path.push([p + cell.bottomright, q]);
2904
- d_x = 0;
2905
- d_y = 1;
2906
- d_o = 1;
2907
- closed = true;
2908
- //console.log("found entry from bottom at " + p + "," + q);
2909
- break;
2910
- }
2911
- } else if (cval & Node0) {
2912
- /* proceed searchin in x-direction */
2913
- console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!");
2914
- } else {
2915
- /* we must have found an entry into the regular grid */
2916
- console.log(
2917
- "MarchingSquaresJS-isoBands: found entry from top at " + p + "," + q
2918
- );
2919
- break;
2920
- }
2921
- } else if (d_x === 1) {
2922
- if (d_o === 0) {
2923
- console.log("MarchingSquaresJS-isoBands: wtf");
2924
- break;
2925
- } else {
2926
- /* try to go upwards */
2927
- if (
2928
- typeof grid.cells[q + 1] !== "undefined" &&
2929
- typeof grid.cells[q + 1][p] !== "undefined"
2930
- ) {
2931
- d_x = 0;
2932
- d_y = 1;
2933
- d_o = 0;
2934
- } else if (cval & Node1) {
2935
- path.push([p + 1, q + 1]);
2936
- d_x = 1;
2937
- d_y = 0;
2938
- d_o = 1;
2939
- } else {
2940
- /* found an entry point into regular grid! */
2941
- path.push([p + cell.topleft, q + 1]);
2942
- d_x = 0;
2943
- d_y = -1;
2944
- d_o = 0;
2945
- closed = true;
2946
- //console.log("found entry from bottom at " + p + "," + q);
2947
- break;
2948
- }
2949
- }
2950
- } else if (d_y === -1) {
2951
- if (d_o === 1) {
2952
- /* try to go right */
2953
- if (typeof grid.cells[q][p + 1] !== "undefined") {
2954
- d_x = 1;
2955
- d_y = 0;
2956
- d_o = 1;
2957
- } else if (cval & Node2) {
2958
- path.push([p + 1, q]);
2959
- d_x = 0;
2960
- d_y = -1;
2961
- d_o = 1;
2962
- } else {
2963
- /* found entry into regular grid! */
2964
- path.push([p + 1, q + cell.righttop]);
2965
- d_x = -1;
2966
- d_y = 0;
2967
- d_o = 1;
2968
- closed = true;
2969
- //console.log("found entry from top at " + p + "," + q);
2970
- break;
2971
- }
2972
- } else {
2973
- console.log("MarchingSquaresJS-isoBands: wtf");
2974
- break;
2975
- }
2976
- } else if (d_y === 1) {
2977
- if (d_o === 0) {
2978
- //console.log("we came from bottom left and proceed to the left");
2979
- /* try to go left */
2980
- if (typeof grid.cells[q][p - 1] !== "undefined") {
2981
- d_x = -1;
2982
- d_y = 0;
2983
- d_o = 0;
2984
- } else if (cval & Node0) {
2985
- path.push([p, q + 1]);
2986
- d_x = 0;
2987
- d_y = 1;
2988
- d_o = 0;
2989
- } else {
2990
- /* found an entry point into regular grid! */
2991
- path.push([p, q + cell.leftbottom]);
2992
- d_x = 1;
2993
- d_y = 0;
2994
- d_o = 0;
2995
- closed = true;
2996
- //console.log("found entry from bottom at " + p + "," + q);
2997
- break;
2998
- }
2999
- } else {
3000
- //console.log("we came from bottom right and proceed to the right");
3001
- console.log("MarchingSquaresJS-isoBands: wtf");
3002
- break;
3003
- }
3004
- } else {
3005
- console.log("MarchingSquaresJS-isoBands: where did we came from???");
3006
- break;
3007
- }
3008
- }
3009
-
3010
- p += d_x;
3011
- q += d_y;
3012
- //console.log("going on to " + p + "," + q + " via " + d_x + " " + d_y + " " + d_o);
3013
-
3014
- if (p === i && q === j) {
3015
- /* bail out, once we've closed a circle path */
3016
- break;
3017
- }
3018
- }
3019
-
3020
- //console.log("exit with " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
3021
- return { path: path, i: p, j: q, x: d_x, y: d_y, o: d_o };
3022
- }
3023
-
3024
- function deleteEdge(cell, edgeIdx) {
3025
- delete cell.edges[edgeIdx];
3026
- for (var k = edgeIdx + 1; k < cell.edges.length; k++) {
3027
- cell.edges[k - 1] = cell.edges[k];
3028
- }
3029
- cell.edges.pop();
3030
- }
3031
-
3032
- function getStartXY(cell) {
3033
- if (cell.edges.length > 0) {
3034
- var e = cell.edges[cell.edges.length - 1];
3035
- //console.log("starting with edge " + e);
3036
- var cval = cell.cval_real;
3037
- switch (e) {
3038
- case 0:
3039
- if (cval & Node1) {
3040
- /* node 1 within range */
3041
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3042
- } else {
3043
- /* node 1 below or above threshold */
3044
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3045
- }
3046
- case 1:
3047
- if (cval & Node2) {
3048
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3049
- } else {
3050
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3051
- }
3052
- case 2:
3053
- if (cval & Node2) {
3054
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3055
- } else {
3056
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3057
- }
3058
- case 3:
3059
- if (cval & Node3) {
3060
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3061
- } else {
3062
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3063
- }
3064
- case 4:
3065
- if (cval & Node1) {
3066
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3067
- } else {
3068
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3069
- }
3070
- case 5:
3071
- if (cval & Node2) {
3072
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3073
- } else {
3074
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3075
- }
3076
- case 6:
3077
- if (cval & Node2) {
3078
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3079
- } else {
3080
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3081
- }
3082
- case 7:
3083
- if (cval & Node3) {
3084
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3085
- } else {
3086
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3087
- }
3088
- case 8:
3089
- if (cval & Node2) {
3090
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3091
- } else {
3092
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3093
- }
3094
- case 9:
3095
- if (cval & Node3) {
3096
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3097
- } else {
3098
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3099
- }
3100
- case 10:
3101
- if (cval & Node3) {
3102
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3103
- } else {
3104
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3105
- }
3106
- case 11:
3107
- if (cval & Node0) {
3108
- return { p: [1, cell.righttop], x: -1, y: 0, o: 1 };
3109
- } else {
3110
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3111
- }
3112
- case 12:
3113
- if (cval & Node2) {
3114
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3115
- } else {
3116
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3117
- }
3118
- case 13:
3119
- if (cval & Node3) {
3120
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3121
- } else {
3122
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3123
- }
3124
- case 14:
3125
- if (cval & Node3) {
3126
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3127
- } else {
3128
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3129
- }
3130
- case 15:
3131
- if (cval & Node0) {
3132
- return { p: [1, cell.rightbottom], x: -1, y: 0, o: 0 };
3133
- } else {
3134
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3135
- }
3136
- case 16:
3137
- if (cval & Node2) {
3138
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3139
- } else {
3140
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3141
- }
3142
- case 17:
3143
- if (cval & Node0) {
3144
- return { p: [cell.bottomright, 0], x: 0, y: 1, o: 1 };
3145
- } else {
3146
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3147
- }
3148
- case 18:
3149
- if (cval & Node3) {
3150
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3151
- } else {
3152
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3153
- }
3154
- case 19:
3155
- if (cval & Node0) {
3156
- return { p: [cell.bottomleft, 0], x: 0, y: 1, o: 0 };
3157
- } else {
3158
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3159
- }
3160
- case 20:
3161
- if (cval & Node0) {
3162
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3163
- } else {
3164
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3165
- }
3166
- case 21:
3167
- if (cval & Node1) {
3168
- return { p: [0, cell.leftbottom], x: 1, y: 0, o: 0 };
3169
- } else {
3170
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3171
- }
3172
- case 22:
3173
- if (cval & Node0) {
3174
- return { p: [cell.topleft, 1], x: 0, y: -1, o: 0 };
3175
- } else {
3176
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3177
- }
3178
- case 23:
3179
- if (cval & Node1) {
3180
- return { p: [0, cell.lefttop], x: 1, y: 0, o: 1 };
3181
- } else {
3182
- return { p: [cell.topright, 1], x: 0, y: -1, o: 1 };
3183
- }
3184
- default:
3185
- console.log("MarchingSquaresJS-isoBands: edge index out of range!");
3186
- console.log(cell);
3187
- break;
3188
- }
3189
- }
3190
-
3191
- return null;
3192
- }
3193
-
3194
- function getExitXY(cell, x, y, o) {
3195
- var e,
3196
- id_x,
3197
- d_x,
3198
- d_y,
3199
- cval = cell.cval;
3200
- var d_o;
3201
-
3202
- switch (x) {
3203
- case -1:
3204
- switch (o) {
3205
- case 0:
3206
- e = isoBandEdgeRB[cval];
3207
- d_x = isoBandNextXRB[cval];
3208
- d_y = isoBandNextYRB[cval];
3209
- d_o = isoBandNextORB[cval];
3210
- break;
3211
- default:
3212
- e = isoBandEdgeRT[cval];
3213
- d_x = isoBandNextXRT[cval];
3214
- d_y = isoBandNextYRT[cval];
3215
- d_o = isoBandNextORT[cval];
3216
- break;
3217
- }
3218
- break;
3219
- case 1:
3220
- switch (o) {
3221
- case 0:
3222
- e = isoBandEdgeLB[cval];
3223
- d_x = isoBandNextXLB[cval];
3224
- d_y = isoBandNextYLB[cval];
3225
- d_o = isoBandNextOLB[cval];
3226
- break;
3227
- default:
3228
- e = isoBandEdgeLT[cval];
3229
- d_x = isoBandNextXLT[cval];
3230
- d_y = isoBandNextYLT[cval];
3231
- d_o = isoBandNextOLT[cval];
3232
- break;
3233
- }
3234
- break;
3235
- default:
3236
- switch (y) {
3237
- case -1:
3238
- switch (o) {
3239
- case 0:
3240
- e = isoBandEdgeTL[cval];
3241
- d_x = isoBandNextXTL[cval];
3242
- d_y = isoBandNextYTL[cval];
3243
- d_o = isoBandNextOTL[cval];
3244
- break;
3245
- default:
3246
- e = isoBandEdgeTR[cval];
3247
- d_x = isoBandNextXTR[cval];
3248
- d_y = isoBandNextYTR[cval];
3249
- d_o = isoBandNextOTR[cval];
3250
- break;
3251
- }
3252
- break;
3253
- case 1:
3254
- switch (o) {
3255
- case 0:
3256
- e = isoBandEdgeBL[cval];
3257
- d_x = isoBandNextXBL[cval];
3258
- d_y = isoBandNextYBL[cval];
3259
- d_o = isoBandNextOBL[cval];
3260
- break;
3261
- default:
3262
- e = isoBandEdgeBR[cval];
3263
- d_x = isoBandNextXBR[cval];
3264
- d_y = isoBandNextYBR[cval];
3265
- d_o = isoBandNextOBR[cval];
3266
- break;
3267
- }
3268
- break;
3269
- }
3270
- break;
3271
- }
3272
-
3273
- id_x = cell.edges.indexOf(e);
3274
- if (typeof cell.edges[id_x] !== "undefined") {
3275
- deleteEdge(cell, id_x);
3276
- } else {
3277
- //console.log("wrong edges...");
3278
- //console.log(x + " " + y + " " + o);
3279
- //console.log(cell);
3280
- return null;
3281
- }
3282
-
3283
- cval = cell.cval_real;
3284
-
3285
- switch (e) {
3286
- case 0:
3287
- if (cval & Node1) {
3288
- /* node 1 within range */
3289
- x = cell.topleft;
3290
- y = 1;
3291
- } else {
3292
- /* node 1 below or above threshold */
3293
- x = 1;
3294
- y = cell.righttop;
3295
- }
3296
- break;
3297
- case 1:
3298
- if (cval & Node2) {
3299
- x = 1;
3300
- y = cell.rightbottom;
3301
- } else {
3302
- x = cell.topleft;
3303
- y = 1;
3304
- }
3305
- break;
3306
- case 2:
3307
- if (cval & Node2) {
3308
- x = cell.topleft;
3309
- y = 1;
3310
- } else {
3311
- x = cell.bottomright;
3312
- y = 0;
3313
- }
3314
- break;
3315
- case 3:
3316
- if (cval & Node3) {
3317
- x = cell.bottomleft;
3318
- y = 0;
3319
- } else {
3320
- x = cell.topleft;
3321
- y = 1;
3322
- }
3323
- break;
3324
- case 4:
3325
- if (cval & Node1) {
3326
- x = cell.topright;
3327
- y = 1;
3328
- } else {
3329
- x = 1;
3330
- y = cell.righttop;
3331
- }
3332
- break;
3333
- case 5:
3334
- if (cval & Node2) {
3335
- x = 1;
3336
- y = cell.rightbottom;
3337
- } else {
3338
- x = cell.topright;
3339
- y = 1;
3340
- }
3341
- break;
3342
- case 6:
3343
- if (cval & Node2) {
3344
- x = cell.topright;
3345
- y = 1;
3346
- } else {
3347
- x = cell.bottomright;
3348
- y = 0;
3349
- }
3350
- break;
3351
- case 7:
3352
- if (cval & Node3) {
3353
- x = cell.bottomleft;
3354
- y = 0;
3355
- } else {
3356
- x = cell.topright;
3357
- y = 1;
3358
- }
3359
- break;
3360
- case 8:
3361
- if (cval & Node2) {
3362
- x = 1;
3363
- y = cell.righttop;
3364
- } else {
3365
- x = cell.bottomright;
3366
- y = 0;
3367
- }
3368
- break;
3369
- case 9:
3370
- if (cval & Node3) {
3371
- x = cell.bottomleft;
3372
- y = 0;
3373
- } else {
3374
- x = 1;
3375
- y = cell.righttop;
3376
- }
3377
- break;
3378
- case 10:
3379
- if (cval & Node3) {
3380
- x = 1;
3381
- y = cell.righttop;
3382
- } else {
3383
- x = 0;
3384
- y = cell.leftbottom;
3385
- }
3386
- break;
3387
- case 11:
3388
- if (cval & Node0) {
3389
- x = 0;
3390
- y = cell.lefttop;
3391
- } else {
3392
- x = 1;
3393
- y = cell.righttop;
3394
- }
3395
- break;
3396
- case 12:
3397
- if (cval & Node2) {
3398
- x = 1;
3399
- y = cell.rightbottom;
3400
- } else {
3401
- x = cell.bottomright;
3402
- y = 0;
3403
- }
3404
- break;
3405
- case 13:
3406
- if (cval & Node3) {
3407
- x = cell.bottomleft;
3408
- y = 0;
3409
- } else {
3410
- x = 1;
3411
- y = cell.rightbottom;
3412
- }
3413
- break;
3414
- case 14:
3415
- if (cval & Node3) {
3416
- x = 1;
3417
- y = cell.rightbottom;
3418
- } else {
3419
- x = 0;
3420
- y = cell.leftbottom;
3421
- }
3422
- break;
3423
- case 15:
3424
- if (cval & Node0) {
3425
- x = 0;
3426
- y = cell.lefttop;
3427
- } else {
3428
- x = 1;
3429
- y = cell.rightbottom;
3430
- }
3431
- break;
3432
- case 16:
3433
- if (cval & Node2) {
3434
- x = 0;
3435
- y = cell.leftbottom;
3436
- } else {
3437
- x = cell.bottomright;
3438
- y = 0;
3439
- }
3440
- break;
3441
- case 17:
3442
- if (cval & Node0) {
3443
- x = 0;
3444
- y = cell.lefttop;
3445
- } else {
3446
- x = cell.bottomright;
3447
- y = 0;
3448
- }
3449
- break;
3450
- case 18:
3451
- if (cval & Node3) {
3452
- x = cell.bottomleft;
3453
- y = 0;
3454
- } else {
3455
- x = 0;
3456
- y = cell.leftbottom;
3457
- }
3458
- break;
3459
- case 19:
3460
- if (cval & Node0) {
3461
- x = 0;
3462
- y = cell.lefttop;
3463
- } else {
3464
- x = cell.bottomleft;
3465
- y = 0;
3466
- }
3467
- break;
3468
- case 20:
3469
- if (cval & Node0) {
3470
- x = 0;
3471
- y = cell.leftbottom;
3472
- } else {
3473
- x = cell.topleft;
3474
- y = 1;
3475
- }
3476
- break;
3477
- case 21:
3478
- if (cval & Node1) {
3479
- x = cell.topright;
3480
- y = 1;
3481
- } else {
3482
- x = 0;
3483
- y = cell.leftbottom;
3484
- }
3485
- break;
3486
- case 22:
3487
- if (cval & Node0) {
3488
- x = 0;
3489
- y = cell.lefttop;
3490
- } else {
3491
- x = cell.topleft;
3492
- y = 1;
3493
- }
3494
- break;
3495
- case 23:
3496
- if (cval & Node1) {
3497
- x = cell.topright;
3498
- y = 1;
3499
- } else {
3500
- x = 0;
3501
- y = cell.lefttop;
3502
- }
3503
- break;
3504
- default:
3505
- console.log("MarchingSquaresJS-isoBands: edge index out of range!");
3506
- console.log(cell);
3507
- return null;
3508
- }
3509
-
3510
- if (
3511
- typeof x === "undefined" ||
3512
- typeof y === "undefined" ||
3513
- typeof d_x === "undefined" ||
3514
- typeof d_y === "undefined" ||
3515
- typeof d_o === "undefined"
3516
- ) {
3517
- console.log("MarchingSquaresJS-isoBands: undefined value!");
3518
- console.log(cell);
3519
- console.log(x + " " + y + " " + d_x + " " + d_y + " " + d_o);
3520
- }
3521
- return { p: [x, y], x: d_x, y: d_y, o: d_o };
3522
- }
3523
-
3524
- function BandGrid2Areas(grid) {
3525
- var areas = [];
3526
- var area_idx = 0;
3527
-
3528
- grid.cells.forEach(function (g, j) {
3529
- g.forEach(function (gg, i) {
3530
- if (typeof gg !== "undefined") {
3531
- var a = polygon_table[gg.cval](gg);
3532
- if (typeof a === "object" && isArray(a)) {
3533
- if (typeof a[0] === "object" && isArray(a[0])) {
3534
- if (typeof a[0][0] === "object" && isArray(a[0][0])) {
3535
- a.forEach(function (aa) {
3536
- aa.forEach(function (aaa) {
3537
- aaa[0] += i;
3538
- aaa[1] += j;
3539
- });
3540
- areas[area_idx++] = aa;
3541
- });
3542
- } else {
3543
- a.forEach(function (aa) {
3544
- aa[0] += i;
3545
- aa[1] += j;
3546
- });
3547
- areas[area_idx++] = a;
3548
- }
3549
- } else {
3550
- console.log(
3551
- "MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"
3552
- );
3553
- }
3554
- } else {
3555
- console.log(
3556
- "MarchingSquaresJS-isoBands: bandcell polygon with null coordinates"
3557
- );
3558
- }
3559
- }
3560
- });
3561
- });
3562
-
3563
- return areas;
3564
- }
3565
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const bbox_1 = tslib_1.__importDefault(require("@turf/bbox"));
5
+ const area_1 = tslib_1.__importDefault(require("@turf/area"));
6
+ const boolean_point_in_polygon_1 = tslib_1.__importDefault(require("@turf/boolean-point-in-polygon"));
7
+ const explode_1 = tslib_1.__importDefault(require("@turf/explode"));
8
+ const invariant_1 = require("@turf/invariant");
9
+ const helpers_1 = require("@turf/helpers");
10
+ const grid_to_matrix_1 = tslib_1.__importDefault(require("./lib/grid-to-matrix"));
11
+ const marchingsquares_isobands_1 = tslib_1.__importDefault(require("./lib/marchingsquares-isobands"));
3566
12
  /**
3567
13
  * Takes a square or rectangular grid {@link FeatureCollection} of {@link Point} features with z-values and an array of
3568
14
  * value breaks and generates filled contour isobands.
@@ -3577,45 +23,39 @@ function BandGrid2Areas(grid) {
3577
23
  * @returns {FeatureCollection<MultiPolygon>} a FeatureCollection of {@link MultiPolygon} features representing isobands
3578
24
  */
3579
25
  function isobands(pointGrid, breaks, options) {
3580
- // Optional parameters
3581
- options = options || {};
3582
- if (!helpers.isObject(options)) throw new Error("options is invalid");
3583
- var zProperty = options.zProperty || "elevation";
3584
- var commonProperties = options.commonProperties || {};
3585
- var breaksProperties = options.breaksProperties || [];
3586
-
3587
- // Validation
3588
- invariant.collectionOf(pointGrid, "Point", "Input must contain Points");
3589
- if (!breaks) throw new Error("breaks is required");
3590
- if (!Array.isArray(breaks)) throw new Error("breaks is not an Array");
3591
- if (!helpers.isObject(commonProperties))
3592
- throw new Error("commonProperties is not an Object");
3593
- if (!Array.isArray(breaksProperties))
3594
- throw new Error("breaksProperties is not an Array");
3595
-
3596
- // Isoband methods
3597
- var matrix = gridToMatrix(pointGrid, { zProperty: zProperty, flip: true });
3598
- var contours = createContourLines(matrix, breaks, zProperty);
3599
- contours = rescaleContours(contours, matrix, pointGrid);
3600
-
3601
- var multipolygons = contours.map(function (contour, index) {
3602
- if (breaksProperties[index] && !helpers.isObject(breaksProperties[index])) {
3603
- throw new Error("Each mappedProperty is required to be an Object");
3604
- }
3605
- // collect all properties
3606
- var contourProperties = objectAssign__default['default'](
3607
- {},
3608
- commonProperties,
3609
- breaksProperties[index]
3610
- );
3611
- contourProperties[zProperty] = contour[zProperty];
3612
- var multiP = helpers.multiPolygon(contour.groupedRings, contourProperties);
3613
- return multiP;
3614
- });
3615
-
3616
- return helpers.featureCollection(multipolygons);
26
+ // Optional parameters
27
+ options = options || {};
28
+ if (!helpers_1.isObject(options))
29
+ throw new Error("options is invalid");
30
+ const zProperty = options.zProperty || "elevation";
31
+ const commonProperties = options.commonProperties || {};
32
+ const breaksProperties = options.breaksProperties || [];
33
+ // Validation
34
+ invariant_1.collectionOf(pointGrid, "Point", "Input must contain Points");
35
+ if (!breaks)
36
+ throw new Error("breaks is required");
37
+ if (!Array.isArray(breaks))
38
+ throw new Error("breaks is not an Array");
39
+ if (!helpers_1.isObject(commonProperties))
40
+ throw new Error("commonProperties is not an Object");
41
+ if (!Array.isArray(breaksProperties))
42
+ throw new Error("breaksProperties is not an Array");
43
+ // Isoband methods
44
+ const matrix = grid_to_matrix_1.default(pointGrid, { zProperty: zProperty, flip: true });
45
+ let contours = createContourLines(matrix, breaks, zProperty);
46
+ contours = rescaleContours(contours, matrix, pointGrid);
47
+ const multipolygons = contours.map((contour, index) => {
48
+ if (breaksProperties[index] && !helpers_1.isObject(breaksProperties[index])) {
49
+ throw new Error("Each mappedProperty is required to be an Object");
50
+ }
51
+ // collect all properties
52
+ const contourProperties = Object.assign(Object.assign({}, commonProperties), breaksProperties[index]);
53
+ contourProperties[zProperty] = contour[zProperty];
54
+ const multiP = helpers_1.multiPolygon(contour.groupedRings, contourProperties);
55
+ return multiP;
56
+ });
57
+ return helpers_1.featureCollection(multipolygons);
3617
58
  }
3618
-
3619
59
  /**
3620
60
  * Creates the contours lines (featuresCollection of polygon features) from the 2D data grid
3621
61
  *
@@ -3630,26 +70,24 @@ function isobands(pointGrid, breaks, options) {
3630
70
  * @returns {Array<any>} contours
3631
71
  */
3632
72
  function createContourLines(matrix, breaks, property) {
3633
- var contours = [];
3634
- for (var i = 1; i < breaks.length; i++) {
3635
- var lowerBand = +breaks[i - 1]; // make sure the breaks value is a number
3636
- var upperBand = +breaks[i];
3637
-
3638
- var isobandsCoords = isoBands(matrix, lowerBand, upperBand - lowerBand);
3639
- // as per GeoJson rules for creating a Polygon, make sure the first element
3640
- // in the array of LinearRings represents the exterior ring (i.e. biggest area),
3641
- // and any subsequent elements represent interior rings (i.e. smaller area);
3642
- // this avoids rendering issues of the MultiPolygons on the map
3643
- var nestedRings = orderByArea(isobandsCoords);
3644
- var groupedRings = groupNestedRings(nestedRings);
3645
- var obj = {};
3646
- obj["groupedRings"] = groupedRings;
3647
- obj[property] = lowerBand + "-" + upperBand;
3648
- contours.push(obj);
3649
- }
3650
- return contours;
73
+ const contours = [];
74
+ for (let i = 1; i < breaks.length; i++) {
75
+ const lowerBand = +breaks[i - 1]; // make sure the breaks value is a number
76
+ const upperBand = +breaks[i];
77
+ const isobandsCoords = marchingsquares_isobands_1.default(matrix, lowerBand, upperBand - lowerBand);
78
+ // as per GeoJson rules for creating a Polygon, make sure the first element
79
+ // in the array of LinearRings represents the exterior ring (i.e. biggest area),
80
+ // and any subsequent elements represent interior rings (i.e. smaller area);
81
+ // this avoids rendering issues of the MultiPolygons on the map
82
+ const nestedRings = orderByArea(isobandsCoords);
83
+ const groupedRings = groupNestedRings(nestedRings);
84
+ contours.push({
85
+ groupedRings: groupedRings,
86
+ [property]: lowerBand + "-" + upperBand,
87
+ });
88
+ }
89
+ return contours;
3651
90
  }
3652
-
3653
91
  /**
3654
92
  * Transform isobands of 2D grid to polygons for the map
3655
93
  *
@@ -3660,39 +98,34 @@ function createContourLines(matrix, breaks, property) {
3660
98
  * @returns {Array<any>} contours
3661
99
  */
3662
100
  function rescaleContours(contours, matrix, points) {
3663
- // get dimensions (on the map) of the original grid
3664
- var gridBbox = bbox__default['default'](points); // [ minX, minY, maxX, maxY ]
3665
- var originalWidth = gridBbox[2] - gridBbox[0];
3666
- var originalHeigth = gridBbox[3] - gridBbox[1];
3667
-
3668
- // get origin, which is the first point of the last row on the rectangular data on the map
3669
- var x0 = gridBbox[0];
3670
- var y0 = gridBbox[1];
3671
- // get number of cells per side
3672
- var matrixWidth = matrix[0].length - 1;
3673
- var matrixHeight = matrix.length - 1;
3674
- // calculate the scaling factor between matrix and rectangular grid on the map
3675
- var scaleX = originalWidth / matrixWidth;
3676
- var scaleY = originalHeigth / matrixHeight;
3677
-
3678
- var resize = function (point) {
3679
- point[0] = point[0] * scaleX + x0;
3680
- point[1] = point[1] * scaleY + y0;
3681
- };
3682
-
3683
- // resize and shift each point/line of the isobands
3684
- contours.forEach(function (contour) {
3685
- contour.groupedRings.forEach(function (lineRingSet) {
3686
- lineRingSet.forEach(function (lineRing) {
3687
- lineRing.forEach(resize);
3688
- });
101
+ // get dimensions (on the map) of the original grid
102
+ const gridBbox = bbox_1.default(points); // [ minX, minY, maxX, maxY ]
103
+ const originalWidth = gridBbox[2] - gridBbox[0];
104
+ const originalHeigth = gridBbox[3] - gridBbox[1];
105
+ // get origin, which is the first point of the last row on the rectangular data on the map
106
+ const x0 = gridBbox[0];
107
+ const y0 = gridBbox[1];
108
+ // get number of cells per side
109
+ const matrixWidth = matrix[0].length - 1;
110
+ const matrixHeight = matrix.length - 1;
111
+ // calculate the scaling factor between matrix and rectangular grid on the map
112
+ const scaleX = originalWidth / matrixWidth;
113
+ const scaleY = originalHeigth / matrixHeight;
114
+ const resize = (point) => {
115
+ point[0] = point[0] * scaleX + x0;
116
+ point[1] = point[1] * scaleY + y0;
117
+ };
118
+ // resize and shift each point/line of the isobands
119
+ contours.forEach(function (contour) {
120
+ contour.groupedRings.forEach(function (lineRingSet) {
121
+ lineRingSet.forEach(function (lineRing) {
122
+ lineRing.forEach(resize);
123
+ });
124
+ });
3689
125
  });
3690
- });
3691
- return contours;
126
+ return contours;
3692
127
  }
3693
-
3694
128
  /* utility functions */
3695
-
3696
129
  /**
3697
130
  * Returns an array of coordinates (of LinearRings) in descending order by area
3698
131
  *
@@ -3701,34 +134,33 @@ function rescaleContours(contours, matrix, points) {
3701
134
  * @returns {Array} array of the input LineString ordered by area
3702
135
  */
3703
136
  function orderByArea(ringsCoords) {
3704
- var ringsWithArea = [];
3705
- var areas = [];
3706
- ringsCoords.forEach(function (coords) {
3707
- // var poly = polygon([points]);
3708
- var ringArea = area__default['default'](helpers.polygon([coords]));
3709
- // create an array of areas value
3710
- areas.push(ringArea);
3711
- // associate each lineRing with its area
3712
- ringsWithArea.push({ ring: coords, area: ringArea });
3713
- });
3714
- areas.sort(function (a, b) {
3715
- // bigger --> smaller
3716
- return b - a;
3717
- });
3718
- // create a new array of linearRings coordinates ordered by their area
3719
- var orderedByArea = [];
3720
- areas.forEach(function (area) {
3721
- for (var lr = 0; lr < ringsWithArea.length; lr++) {
3722
- if (ringsWithArea[lr].area === area) {
3723
- orderedByArea.push(ringsWithArea[lr].ring);
3724
- ringsWithArea.splice(lr, 1);
3725
- break;
3726
- }
3727
- }
3728
- });
3729
- return orderedByArea;
137
+ const ringsWithArea = [];
138
+ const areas = [];
139
+ ringsCoords.forEach(function (coords) {
140
+ // const poly = polygon([points]);
141
+ const ringArea = area_1.default(helpers_1.polygon([coords]));
142
+ // create an array of areas value
143
+ areas.push(ringArea);
144
+ // associate each lineRing with its area
145
+ ringsWithArea.push({ ring: coords, area: ringArea });
146
+ });
147
+ areas.sort(function (a, b) {
148
+ // bigger --> smaller
149
+ return b - a;
150
+ });
151
+ // create a new array of linearRings coordinates ordered by their area
152
+ const orderedByArea = [];
153
+ areas.forEach(function (area) {
154
+ for (let lr = 0; lr < ringsWithArea.length; lr++) {
155
+ if (ringsWithArea[lr].area === area) {
156
+ orderedByArea.push(ringsWithArea[lr].ring);
157
+ ringsWithArea.splice(lr, 1);
158
+ break;
159
+ }
160
+ }
161
+ });
162
+ return orderedByArea;
3730
163
  }
3731
-
3732
164
  /**
3733
165
  * Returns an array of arrays of coordinates, each representing
3734
166
  * a set of (coordinates of) nested LinearRings,
@@ -3739,37 +171,36 @@ function orderByArea(ringsCoords) {
3739
171
  * @returns {Array<Array>} Array of coordinates of nested LinearRings
3740
172
  */
3741
173
  function groupNestedRings(orderedLinearRings) {
3742
- // create a list of the (coordinates of) LinearRings
3743
- var lrList = orderedLinearRings.map(function (lr) {
3744
- return { lrCoordinates: lr, grouped: false };
3745
- });
3746
- var groupedLinearRingsCoords = [];
3747
- while (!allGrouped(lrList)) {
3748
- for (var i = 0; i < lrList.length; i++) {
3749
- if (!lrList[i].grouped) {
3750
- // create new group starting with the larger not already grouped ring
3751
- var group = [];
3752
- group.push(lrList[i].lrCoordinates);
3753
- lrList[i].grouped = true;
3754
- var outerMostPoly = helpers.polygon([lrList[i].lrCoordinates]);
3755
- // group all the rings contained by the outermost ring
3756
- for (var j = i + 1; j < lrList.length; j++) {
3757
- if (!lrList[j].grouped) {
3758
- var lrPoly = helpers.polygon([lrList[j].lrCoordinates]);
3759
- if (isInside(lrPoly, outerMostPoly)) {
3760
- group.push(lrList[j].lrCoordinates);
3761
- lrList[j].grouped = true;
174
+ // create a list of the (coordinates of) LinearRings
175
+ const lrList = orderedLinearRings.map((lr) => {
176
+ return { lrCoordinates: lr, grouped: false };
177
+ });
178
+ const groupedLinearRingsCoords = [];
179
+ while (!allGrouped(lrList)) {
180
+ for (let i = 0; i < lrList.length; i++) {
181
+ if (!lrList[i].grouped) {
182
+ // create new group starting with the larger not already grouped ring
183
+ const group = [];
184
+ group.push(lrList[i].lrCoordinates);
185
+ lrList[i].grouped = true;
186
+ const outerMostPoly = helpers_1.polygon([lrList[i].lrCoordinates]);
187
+ // group all the rings contained by the outermost ring
188
+ for (let j = i + 1; j < lrList.length; j++) {
189
+ if (!lrList[j].grouped) {
190
+ const lrPoly = helpers_1.polygon([lrList[j].lrCoordinates]);
191
+ if (isInside(lrPoly, outerMostPoly)) {
192
+ group.push(lrList[j].lrCoordinates);
193
+ lrList[j].grouped = true;
194
+ }
195
+ }
196
+ }
197
+ // insert the new group
198
+ groupedLinearRingsCoords.push(group);
3762
199
  }
3763
- }
3764
200
  }
3765
- // insert the new group
3766
- groupedLinearRingsCoords.push(group);
3767
- }
3768
201
  }
3769
- }
3770
- return groupedLinearRingsCoords;
202
+ return groupedLinearRingsCoords;
3771
203
  }
3772
-
3773
204
  /**
3774
205
  * @private
3775
206
  * @param {Polygon} testPolygon polygon of interest
@@ -3777,28 +208,25 @@ function groupNestedRings(orderedLinearRings) {
3777
208
  * @returns {boolean} true if test-Polygon is inside target-Polygon
3778
209
  */
3779
210
  function isInside(testPolygon, targetPolygon) {
3780
- var points = explode__default['default'](testPolygon);
3781
- for (var i = 0; i < points.features.length; i++) {
3782
- if (!booleanPointInPolygon__default['default'](points.features[i], targetPolygon)) {
3783
- return false;
211
+ const points = explode_1.default(testPolygon);
212
+ for (let i = 0; i < points.features.length; i++) {
213
+ if (!boolean_point_in_polygon_1.default(points.features[i], targetPolygon)) {
214
+ return false;
215
+ }
3784
216
  }
3785
- }
3786
- return true;
217
+ return true;
3787
218
  }
3788
-
3789
219
  /**
3790
220
  * @private
3791
221
  * @param {Array<Object>} list list of objects which might contain the 'group' attribute
3792
222
  * @returns {boolean} true if all the objects in the list are marked as grouped
3793
223
  */
3794
224
  function allGrouped(list) {
3795
- for (var i = 0; i < list.length; i++) {
3796
- if (list[i].grouped === false) {
3797
- return false;
225
+ for (let i = 0; i < list.length; i++) {
226
+ if (list[i].grouped === false) {
227
+ return false;
228
+ }
3798
229
  }
3799
- }
3800
- return true;
230
+ return true;
3801
231
  }
3802
-
3803
- module.exports = isobands;
3804
- module.exports.default = isobands;
232
+ exports.default = isobands;