esri-gl 1.0.0 → 1.0.2

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/index.umd.js CHANGED
@@ -1,27 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@mapbox/tilebelt'), require('arcgis-pbf-parser')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@mapbox/tilebelt', 'arcgis-pbf-parser'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.esrigl = {}, global.tilebelt, global.arcgisPbfParser));
5
- })(this, (function (exports, tilebelt, tileDecode) { 'use strict';
6
-
7
- function _interopNamespaceDefault(e) {
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var tilebelt__namespace = /*#__PURE__*/_interopNamespaceDefault(tilebelt);
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.esrigl = {}));
5
+ })(this, (function (exports) { 'use strict';
25
6
 
26
7
  function cleanTrailingSlash(url) {
27
8
  return url.replace(/\/$/, '');
@@ -631,6 +612,7 @@
631
612
  bboxSR: '3857',
632
613
  imageSR: '3857',
633
614
  format: this.options.format,
615
+ dpi: this.options.dpi.toString(),
634
616
  layers: this._layersStr || '',
635
617
  transparent: this.options.transparent.toString(),
636
618
  size: `${tileSize},${tileSize}`,
@@ -924,7 +906,7 @@
924
906
  }),
925
907
  tolerance: '3',
926
908
  returnGeometry: returnGeometry.toString(),
927
- imageDisplay: `${canvas.width},${canvas.height},96`,
909
+ imageDisplay: `${canvas.width},${canvas.height},${this.options.dpi}`,
928
910
  mapExtent: `${bounds[0][0]},${bounds[0][1]},${bounds[1][0]},${bounds[1][1]}`,
929
911
  layers: this._layersStrIdentify || '',
930
912
  f: 'json'
@@ -1572,6 +1554,7 @@
1572
1554
  bboxSR: '3857',
1573
1555
  imageSR: '3857',
1574
1556
  format: this.options.format,
1557
+ dpi: this.options.dpi.toString(),
1575
1558
  size: `${tileSize},${tileSize}`,
1576
1559
  f: 'image'
1577
1560
  });
@@ -1669,7 +1652,7 @@
1669
1652
  }),
1670
1653
  tolerance: '3',
1671
1654
  returnGeometry: returnGeometry.toString(),
1672
- imageDisplay: `${canvas.width},${canvas.height},96`,
1655
+ imageDisplay: `${canvas.width},${canvas.height},${this.options.dpi}`,
1673
1656
  mapExtent: `${bounds[0][0]},${bounds[0][1]},${bounds[1][0]},${bounds[1][1]}`,
1674
1657
  f: 'json'
1675
1658
  });
@@ -2094,6 +2077,1642 @@
2094
2077
  }
2095
2078
  }
2096
2079
 
2080
+ const d2r = Math.PI / 180;
2081
+ const r2d = 180 / Math.PI;
2082
+ function tile2lon(x, z) {
2083
+ return (x / Math.pow(2, z)) * 360 - 180;
2084
+ }
2085
+ function tile2lat(y, z) {
2086
+ const n = Math.PI - (2 * Math.PI * y) / Math.pow(2, z);
2087
+ return r2d * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
2088
+ }
2089
+ /**
2090
+ * Get the bbox of a tile
2091
+ *
2092
+ * const bbox = tileToBBOX([5, 10, 10])
2093
+ * //=bbox
2094
+ */
2095
+ function tileToBBOX(tile) {
2096
+ const e = tile2lon(tile[0] + 1, tile[2]);
2097
+ const w = tile2lon(tile[0], tile[2]);
2098
+ const s = tile2lat(tile[1] + 1, tile[2]);
2099
+ const n = tile2lat(tile[1], tile[2]);
2100
+ return [w, s, e, n];
2101
+ }
2102
+ /**
2103
+ * Get the tile for a point at a specified zoom level
2104
+ *
2105
+ * const tile = pointToTile(1, 1, 20)
2106
+ * //=tile
2107
+ */
2108
+ function pointToTile(lon, lat, z) {
2109
+ const tile = pointToTileFraction(lon, lat, z);
2110
+ tile[0] = Math.floor(tile[0]);
2111
+ tile[1] = Math.floor(tile[1]);
2112
+ return tile;
2113
+ }
2114
+ /**
2115
+ * Get the precise fractional tile location for a point at a zoom level
2116
+ *
2117
+ * const tile = pointToTileFraction(30.5, 50.5, 15)
2118
+ * //=tile
2119
+ */
2120
+ function pointToTileFraction(lon, lat, z) {
2121
+ const sin = Math.sin(lat * d2r);
2122
+ const z2 = Math.pow(2, z);
2123
+ let x = z2 * (lon / 360 + 0.5);
2124
+ const y = z2 * (0.5 - (0.25 * Math.log((1 + sin) / (1 - sin))) / Math.PI);
2125
+ // Wrap Tile X
2126
+ x = x % z2;
2127
+ if (x < 0)
2128
+ x = x + z2;
2129
+ return [x, y, z];
2130
+ }
2131
+ /**
2132
+ * Get the 4 tiles one zoom level higher
2133
+ *
2134
+ * const tiles = getChildren([5, 10, 10])
2135
+ * //=tiles
2136
+ */
2137
+ function getChildren(tile) {
2138
+ return [
2139
+ [tile[0] * 2, tile[1] * 2, tile[2] + 1],
2140
+ [tile[0] * 2 + 1, tile[1] * 2, tile[2] + 1],
2141
+ [tile[0] * 2 + 1, tile[1] * 2 + 1, tile[2] + 1],
2142
+ [tile[0] * 2, tile[1] * 2 + 1, tile[2] + 1],
2143
+ ];
2144
+ }
2145
+ /**
2146
+ * Get the quadkey for a tile
2147
+ *
2148
+ * const quadkey = tileToQuadkey([0, 1, 5])
2149
+ * //=quadkey
2150
+ */
2151
+ function tileToQuadkey(tile) {
2152
+ let index = '';
2153
+ for (let z = tile[2]; z > 0; z--) {
2154
+ let b = 0;
2155
+ const mask = 1 << (z - 1);
2156
+ if ((tile[0] & mask) !== 0)
2157
+ b++;
2158
+ if ((tile[1] & mask) !== 0)
2159
+ b += 2;
2160
+ index += b.toString();
2161
+ }
2162
+ return index;
2163
+ }
2164
+ function getBboxZoom(bbox) {
2165
+ const MAX_ZOOM = 28;
2166
+ for (let z = 0; z < MAX_ZOOM; z++) {
2167
+ const mask = 1 << (32 - (z + 1));
2168
+ if ((bbox[0] & mask) !== (bbox[2] & mask) ||
2169
+ (bbox[1] & mask) !== (bbox[3] & mask)) {
2170
+ return z;
2171
+ }
2172
+ }
2173
+ return MAX_ZOOM;
2174
+ }
2175
+ /**
2176
+ * Get the smallest tile to cover a bbox
2177
+ *
2178
+ * const tile = bboxToTile([ -178, 84, -177, 85 ])
2179
+ * //=tile
2180
+ */
2181
+ function bboxToTile(bboxCoords) {
2182
+ const min = pointToTile(bboxCoords[0], bboxCoords[1], 32);
2183
+ const max = pointToTile(bboxCoords[2], bboxCoords[3], 32);
2184
+ const bbox = [min[0], min[1], max[0], max[1]];
2185
+ const z = getBboxZoom(bbox);
2186
+ if (z === 0)
2187
+ return [0, 0, 0];
2188
+ const x = bbox[0] >>> (32 - z);
2189
+ const y = bbox[1] >>> (32 - z);
2190
+ return [x, y, z];
2191
+ }
2192
+
2193
+ function getDefaultExportFromCjs (x) {
2194
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
2195
+ }
2196
+
2197
+ var ieee754 = {};
2198
+
2199
+ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
2200
+
2201
+ var hasRequiredIeee754;
2202
+
2203
+ function requireIeee754 () {
2204
+ if (hasRequiredIeee754) return ieee754;
2205
+ hasRequiredIeee754 = 1;
2206
+ ieee754.read = function (buffer, offset, isLE, mLen, nBytes) {
2207
+ var e, m;
2208
+ var eLen = (nBytes * 8) - mLen - 1;
2209
+ var eMax = (1 << eLen) - 1;
2210
+ var eBias = eMax >> 1;
2211
+ var nBits = -7;
2212
+ var i = isLE ? (nBytes - 1) : 0;
2213
+ var d = isLE ? -1 : 1;
2214
+ var s = buffer[offset + i];
2215
+
2216
+ i += d;
2217
+
2218
+ e = s & ((1 << (-nBits)) - 1);
2219
+ s >>= (-nBits);
2220
+ nBits += eLen;
2221
+ for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2222
+
2223
+ m = e & ((1 << (-nBits)) - 1);
2224
+ e >>= (-nBits);
2225
+ nBits += mLen;
2226
+ for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
2227
+
2228
+ if (e === 0) {
2229
+ e = 1 - eBias;
2230
+ } else if (e === eMax) {
2231
+ return m ? NaN : ((s ? -1 : 1) * Infinity)
2232
+ } else {
2233
+ m = m + Math.pow(2, mLen);
2234
+ e = e - eBias;
2235
+ }
2236
+ return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
2237
+ };
2238
+
2239
+ ieee754.write = function (buffer, value, offset, isLE, mLen, nBytes) {
2240
+ var e, m, c;
2241
+ var eLen = (nBytes * 8) - mLen - 1;
2242
+ var eMax = (1 << eLen) - 1;
2243
+ var eBias = eMax >> 1;
2244
+ var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0);
2245
+ var i = isLE ? 0 : (nBytes - 1);
2246
+ var d = isLE ? 1 : -1;
2247
+ var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
2248
+
2249
+ value = Math.abs(value);
2250
+
2251
+ if (isNaN(value) || value === Infinity) {
2252
+ m = isNaN(value) ? 1 : 0;
2253
+ e = eMax;
2254
+ } else {
2255
+ e = Math.floor(Math.log(value) / Math.LN2);
2256
+ if (value * (c = Math.pow(2, -e)) < 1) {
2257
+ e--;
2258
+ c *= 2;
2259
+ }
2260
+ if (e + eBias >= 1) {
2261
+ value += rt / c;
2262
+ } else {
2263
+ value += rt * Math.pow(2, 1 - eBias);
2264
+ }
2265
+ if (value * c >= 2) {
2266
+ e++;
2267
+ c /= 2;
2268
+ }
2269
+
2270
+ if (e + eBias >= eMax) {
2271
+ m = 0;
2272
+ e = eMax;
2273
+ } else if (e + eBias >= 1) {
2274
+ m = ((value * c) - 1) * Math.pow(2, mLen);
2275
+ e = e + eBias;
2276
+ } else {
2277
+ m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
2278
+ e = 0;
2279
+ }
2280
+ }
2281
+
2282
+ for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
2283
+
2284
+ e = (e << mLen) | m;
2285
+ eLen += mLen;
2286
+ for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
2287
+
2288
+ buffer[offset + i - d] |= s * 128;
2289
+ };
2290
+ return ieee754;
2291
+ }
2292
+
2293
+ var pbf;
2294
+ var hasRequiredPbf;
2295
+
2296
+ function requirePbf () {
2297
+ if (hasRequiredPbf) return pbf;
2298
+ hasRequiredPbf = 1;
2299
+
2300
+ pbf = Pbf;
2301
+
2302
+ var ieee754 = requireIeee754();
2303
+
2304
+ function Pbf(buf) {
2305
+ this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
2306
+ this.pos = 0;
2307
+ this.type = 0;
2308
+ this.length = this.buf.length;
2309
+ }
2310
+
2311
+ Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
2312
+ Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
2313
+ Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
2314
+ Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32
2315
+
2316
+ var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
2317
+ SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
2318
+
2319
+ // Threshold chosen based on both benchmarking and knowledge about browser string
2320
+ // data structures (which currently switch structure types at 12 bytes or more)
2321
+ var TEXT_DECODER_MIN_LENGTH = 12;
2322
+ var utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8');
2323
+
2324
+ Pbf.prototype = {
2325
+
2326
+ destroy: function() {
2327
+ this.buf = null;
2328
+ },
2329
+
2330
+ // === READING =================================================================
2331
+
2332
+ readFields: function(readField, result, end) {
2333
+ end = end || this.length;
2334
+
2335
+ while (this.pos < end) {
2336
+ var val = this.readVarint(),
2337
+ tag = val >> 3,
2338
+ startPos = this.pos;
2339
+
2340
+ this.type = val & 0x7;
2341
+ readField(tag, result, this);
2342
+
2343
+ if (this.pos === startPos) this.skip(val);
2344
+ }
2345
+ return result;
2346
+ },
2347
+
2348
+ readMessage: function(readField, result) {
2349
+ return this.readFields(readField, result, this.readVarint() + this.pos);
2350
+ },
2351
+
2352
+ readFixed32: function() {
2353
+ var val = readUInt32(this.buf, this.pos);
2354
+ this.pos += 4;
2355
+ return val;
2356
+ },
2357
+
2358
+ readSFixed32: function() {
2359
+ var val = readInt32(this.buf, this.pos);
2360
+ this.pos += 4;
2361
+ return val;
2362
+ },
2363
+
2364
+ // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
2365
+
2366
+ readFixed64: function() {
2367
+ var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
2368
+ this.pos += 8;
2369
+ return val;
2370
+ },
2371
+
2372
+ readSFixed64: function() {
2373
+ var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
2374
+ this.pos += 8;
2375
+ return val;
2376
+ },
2377
+
2378
+ readFloat: function() {
2379
+ var val = ieee754.read(this.buf, this.pos, true, 23, 4);
2380
+ this.pos += 4;
2381
+ return val;
2382
+ },
2383
+
2384
+ readDouble: function() {
2385
+ var val = ieee754.read(this.buf, this.pos, true, 52, 8);
2386
+ this.pos += 8;
2387
+ return val;
2388
+ },
2389
+
2390
+ readVarint: function(isSigned) {
2391
+ var buf = this.buf,
2392
+ val, b;
2393
+
2394
+ b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;
2395
+ b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;
2396
+ b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;
2397
+ b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;
2398
+ b = buf[this.pos]; val |= (b & 0x0f) << 28;
2399
+
2400
+ return readVarintRemainder(val, isSigned, this);
2401
+ },
2402
+
2403
+ readVarint64: function() { // for compatibility with v2.0.1
2404
+ return this.readVarint(true);
2405
+ },
2406
+
2407
+ readSVarint: function() {
2408
+ var num = this.readVarint();
2409
+ return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
2410
+ },
2411
+
2412
+ readBoolean: function() {
2413
+ return Boolean(this.readVarint());
2414
+ },
2415
+
2416
+ readString: function() {
2417
+ var end = this.readVarint() + this.pos;
2418
+ var pos = this.pos;
2419
+ this.pos = end;
2420
+
2421
+ if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
2422
+ // longer strings are fast with the built-in browser TextDecoder API
2423
+ return readUtf8TextDecoder(this.buf, pos, end);
2424
+ }
2425
+ // short strings are fast with our custom implementation
2426
+ return readUtf8(this.buf, pos, end);
2427
+ },
2428
+
2429
+ readBytes: function() {
2430
+ var end = this.readVarint() + this.pos,
2431
+ buffer = this.buf.subarray(this.pos, end);
2432
+ this.pos = end;
2433
+ return buffer;
2434
+ },
2435
+
2436
+ // verbose for performance reasons; doesn't affect gzipped size
2437
+
2438
+ readPackedVarint: function(arr, isSigned) {
2439
+ if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));
2440
+ var end = readPackedEnd(this);
2441
+ arr = arr || [];
2442
+ while (this.pos < end) arr.push(this.readVarint(isSigned));
2443
+ return arr;
2444
+ },
2445
+ readPackedSVarint: function(arr) {
2446
+ if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());
2447
+ var end = readPackedEnd(this);
2448
+ arr = arr || [];
2449
+ while (this.pos < end) arr.push(this.readSVarint());
2450
+ return arr;
2451
+ },
2452
+ readPackedBoolean: function(arr) {
2453
+ if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());
2454
+ var end = readPackedEnd(this);
2455
+ arr = arr || [];
2456
+ while (this.pos < end) arr.push(this.readBoolean());
2457
+ return arr;
2458
+ },
2459
+ readPackedFloat: function(arr) {
2460
+ if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());
2461
+ var end = readPackedEnd(this);
2462
+ arr = arr || [];
2463
+ while (this.pos < end) arr.push(this.readFloat());
2464
+ return arr;
2465
+ },
2466
+ readPackedDouble: function(arr) {
2467
+ if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());
2468
+ var end = readPackedEnd(this);
2469
+ arr = arr || [];
2470
+ while (this.pos < end) arr.push(this.readDouble());
2471
+ return arr;
2472
+ },
2473
+ readPackedFixed32: function(arr) {
2474
+ if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());
2475
+ var end = readPackedEnd(this);
2476
+ arr = arr || [];
2477
+ while (this.pos < end) arr.push(this.readFixed32());
2478
+ return arr;
2479
+ },
2480
+ readPackedSFixed32: function(arr) {
2481
+ if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());
2482
+ var end = readPackedEnd(this);
2483
+ arr = arr || [];
2484
+ while (this.pos < end) arr.push(this.readSFixed32());
2485
+ return arr;
2486
+ },
2487
+ readPackedFixed64: function(arr) {
2488
+ if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());
2489
+ var end = readPackedEnd(this);
2490
+ arr = arr || [];
2491
+ while (this.pos < end) arr.push(this.readFixed64());
2492
+ return arr;
2493
+ },
2494
+ readPackedSFixed64: function(arr) {
2495
+ if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());
2496
+ var end = readPackedEnd(this);
2497
+ arr = arr || [];
2498
+ while (this.pos < end) arr.push(this.readSFixed64());
2499
+ return arr;
2500
+ },
2501
+
2502
+ skip: function(val) {
2503
+ var type = val & 0x7;
2504
+ if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}
2505
+ else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
2506
+ else if (type === Pbf.Fixed32) this.pos += 4;
2507
+ else if (type === Pbf.Fixed64) this.pos += 8;
2508
+ else throw new Error('Unimplemented type: ' + type);
2509
+ },
2510
+
2511
+ // === WRITING =================================================================
2512
+
2513
+ writeTag: function(tag, type) {
2514
+ this.writeVarint((tag << 3) | type);
2515
+ },
2516
+
2517
+ realloc: function(min) {
2518
+ var length = this.length || 16;
2519
+
2520
+ while (length < this.pos + min) length *= 2;
2521
+
2522
+ if (length !== this.length) {
2523
+ var buf = new Uint8Array(length);
2524
+ buf.set(this.buf);
2525
+ this.buf = buf;
2526
+ this.length = length;
2527
+ }
2528
+ },
2529
+
2530
+ finish: function() {
2531
+ this.length = this.pos;
2532
+ this.pos = 0;
2533
+ return this.buf.subarray(0, this.length);
2534
+ },
2535
+
2536
+ writeFixed32: function(val) {
2537
+ this.realloc(4);
2538
+ writeInt32(this.buf, val, this.pos);
2539
+ this.pos += 4;
2540
+ },
2541
+
2542
+ writeSFixed32: function(val) {
2543
+ this.realloc(4);
2544
+ writeInt32(this.buf, val, this.pos);
2545
+ this.pos += 4;
2546
+ },
2547
+
2548
+ writeFixed64: function(val) {
2549
+ this.realloc(8);
2550
+ writeInt32(this.buf, val & -1, this.pos);
2551
+ writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
2552
+ this.pos += 8;
2553
+ },
2554
+
2555
+ writeSFixed64: function(val) {
2556
+ this.realloc(8);
2557
+ writeInt32(this.buf, val & -1, this.pos);
2558
+ writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
2559
+ this.pos += 8;
2560
+ },
2561
+
2562
+ writeVarint: function(val) {
2563
+ val = +val || 0;
2564
+
2565
+ if (val > 0xfffffff || val < 0) {
2566
+ writeBigVarint(val, this);
2567
+ return;
2568
+ }
2569
+
2570
+ this.realloc(4);
2571
+
2572
+ this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
2573
+ this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
2574
+ this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;
2575
+ this.buf[this.pos++] = (val >>> 7) & 0x7f;
2576
+ },
2577
+
2578
+ writeSVarint: function(val) {
2579
+ this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
2580
+ },
2581
+
2582
+ writeBoolean: function(val) {
2583
+ this.writeVarint(Boolean(val));
2584
+ },
2585
+
2586
+ writeString: function(str) {
2587
+ str = String(str);
2588
+ this.realloc(str.length * 4);
2589
+
2590
+ this.pos++; // reserve 1 byte for short string length
2591
+
2592
+ var startPos = this.pos;
2593
+ // write the string directly to the buffer and see how much was written
2594
+ this.pos = writeUtf8(this.buf, str, this.pos);
2595
+ var len = this.pos - startPos;
2596
+
2597
+ if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
2598
+
2599
+ // finally, write the message length in the reserved place and restore the position
2600
+ this.pos = startPos - 1;
2601
+ this.writeVarint(len);
2602
+ this.pos += len;
2603
+ },
2604
+
2605
+ writeFloat: function(val) {
2606
+ this.realloc(4);
2607
+ ieee754.write(this.buf, val, this.pos, true, 23, 4);
2608
+ this.pos += 4;
2609
+ },
2610
+
2611
+ writeDouble: function(val) {
2612
+ this.realloc(8);
2613
+ ieee754.write(this.buf, val, this.pos, true, 52, 8);
2614
+ this.pos += 8;
2615
+ },
2616
+
2617
+ writeBytes: function(buffer) {
2618
+ var len = buffer.length;
2619
+ this.writeVarint(len);
2620
+ this.realloc(len);
2621
+ for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
2622
+ },
2623
+
2624
+ writeRawMessage: function(fn, obj) {
2625
+ this.pos++; // reserve 1 byte for short message length
2626
+
2627
+ // write the message directly to the buffer and see how much was written
2628
+ var startPos = this.pos;
2629
+ fn(obj, this);
2630
+ var len = this.pos - startPos;
2631
+
2632
+ if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);
2633
+
2634
+ // finally, write the message length in the reserved place and restore the position
2635
+ this.pos = startPos - 1;
2636
+ this.writeVarint(len);
2637
+ this.pos += len;
2638
+ },
2639
+
2640
+ writeMessage: function(tag, fn, obj) {
2641
+ this.writeTag(tag, Pbf.Bytes);
2642
+ this.writeRawMessage(fn, obj);
2643
+ },
2644
+
2645
+ writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },
2646
+ writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },
2647
+ writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },
2648
+ writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },
2649
+ writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },
2650
+ writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },
2651
+ writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },
2652
+ writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },
2653
+ writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },
2654
+
2655
+ writeBytesField: function(tag, buffer) {
2656
+ this.writeTag(tag, Pbf.Bytes);
2657
+ this.writeBytes(buffer);
2658
+ },
2659
+ writeFixed32Field: function(tag, val) {
2660
+ this.writeTag(tag, Pbf.Fixed32);
2661
+ this.writeFixed32(val);
2662
+ },
2663
+ writeSFixed32Field: function(tag, val) {
2664
+ this.writeTag(tag, Pbf.Fixed32);
2665
+ this.writeSFixed32(val);
2666
+ },
2667
+ writeFixed64Field: function(tag, val) {
2668
+ this.writeTag(tag, Pbf.Fixed64);
2669
+ this.writeFixed64(val);
2670
+ },
2671
+ writeSFixed64Field: function(tag, val) {
2672
+ this.writeTag(tag, Pbf.Fixed64);
2673
+ this.writeSFixed64(val);
2674
+ },
2675
+ writeVarintField: function(tag, val) {
2676
+ this.writeTag(tag, Pbf.Varint);
2677
+ this.writeVarint(val);
2678
+ },
2679
+ writeSVarintField: function(tag, val) {
2680
+ this.writeTag(tag, Pbf.Varint);
2681
+ this.writeSVarint(val);
2682
+ },
2683
+ writeStringField: function(tag, str) {
2684
+ this.writeTag(tag, Pbf.Bytes);
2685
+ this.writeString(str);
2686
+ },
2687
+ writeFloatField: function(tag, val) {
2688
+ this.writeTag(tag, Pbf.Fixed32);
2689
+ this.writeFloat(val);
2690
+ },
2691
+ writeDoubleField: function(tag, val) {
2692
+ this.writeTag(tag, Pbf.Fixed64);
2693
+ this.writeDouble(val);
2694
+ },
2695
+ writeBooleanField: function(tag, val) {
2696
+ this.writeVarintField(tag, Boolean(val));
2697
+ }
2698
+ };
2699
+
2700
+ function readVarintRemainder(l, s, p) {
2701
+ var buf = p.buf,
2702
+ h, b;
2703
+
2704
+ b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);
2705
+ b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);
2706
+ b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);
2707
+ b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);
2708
+ b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);
2709
+ b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);
2710
+
2711
+ throw new Error('Expected varint not more than 10 bytes');
2712
+ }
2713
+
2714
+ function readPackedEnd(pbf) {
2715
+ return pbf.type === Pbf.Bytes ?
2716
+ pbf.readVarint() + pbf.pos : pbf.pos + 1;
2717
+ }
2718
+
2719
+ function toNum(low, high, isSigned) {
2720
+ if (isSigned) {
2721
+ return high * 0x100000000 + (low >>> 0);
2722
+ }
2723
+
2724
+ return ((high >>> 0) * 0x100000000) + (low >>> 0);
2725
+ }
2726
+
2727
+ function writeBigVarint(val, pbf) {
2728
+ var low, high;
2729
+
2730
+ if (val >= 0) {
2731
+ low = (val % 0x100000000) | 0;
2732
+ high = (val / 0x100000000) | 0;
2733
+ } else {
2734
+ low = ~(-val % 0x100000000);
2735
+ high = ~(-val / 0x100000000);
2736
+
2737
+ if (low ^ 0xffffffff) {
2738
+ low = (low + 1) | 0;
2739
+ } else {
2740
+ low = 0;
2741
+ high = (high + 1) | 0;
2742
+ }
2743
+ }
2744
+
2745
+ if (val >= 0x10000000000000000 || val < -18446744073709552e3) {
2746
+ throw new Error('Given varint doesn\'t fit into 10 bytes');
2747
+ }
2748
+
2749
+ pbf.realloc(10);
2750
+
2751
+ writeBigVarintLow(low, high, pbf);
2752
+ writeBigVarintHigh(high, pbf);
2753
+ }
2754
+
2755
+ function writeBigVarintLow(low, high, pbf) {
2756
+ pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
2757
+ pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
2758
+ pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
2759
+ pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;
2760
+ pbf.buf[pbf.pos] = low & 0x7f;
2761
+ }
2762
+
2763
+ function writeBigVarintHigh(high, pbf) {
2764
+ var lsb = (high & 0x07) << 4;
2765
+
2766
+ pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;
2767
+ pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
2768
+ pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
2769
+ pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
2770
+ pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;
2771
+ pbf.buf[pbf.pos++] = high & 0x7f;
2772
+ }
2773
+
2774
+ function makeRoomForExtraLength(startPos, len, pbf) {
2775
+ var extraLen =
2776
+ len <= 0x3fff ? 1 :
2777
+ len <= 0x1fffff ? 2 :
2778
+ len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
2779
+
2780
+ // if 1 byte isn't enough for encoding message length, shift the data to the right
2781
+ pbf.realloc(extraLen);
2782
+ for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
2783
+ }
2784
+
2785
+ function writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }
2786
+ function writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }
2787
+ function writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }
2788
+ function writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }
2789
+ function writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }
2790
+ function writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }
2791
+ function writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }
2792
+ function writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }
2793
+ function writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }
2794
+
2795
+ // Buffer code below from https://github.com/feross/buffer, MIT-licensed
2796
+
2797
+ function readUInt32(buf, pos) {
2798
+ return ((buf[pos]) |
2799
+ (buf[pos + 1] << 8) |
2800
+ (buf[pos + 2] << 16)) +
2801
+ (buf[pos + 3] * 0x1000000);
2802
+ }
2803
+
2804
+ function writeInt32(buf, val, pos) {
2805
+ buf[pos] = val;
2806
+ buf[pos + 1] = (val >>> 8);
2807
+ buf[pos + 2] = (val >>> 16);
2808
+ buf[pos + 3] = (val >>> 24);
2809
+ }
2810
+
2811
+ function readInt32(buf, pos) {
2812
+ return ((buf[pos]) |
2813
+ (buf[pos + 1] << 8) |
2814
+ (buf[pos + 2] << 16)) +
2815
+ (buf[pos + 3] << 24);
2816
+ }
2817
+
2818
+ function readUtf8(buf, pos, end) {
2819
+ var str = '';
2820
+ var i = pos;
2821
+
2822
+ while (i < end) {
2823
+ var b0 = buf[i];
2824
+ var c = null; // codepoint
2825
+ var bytesPerSequence =
2826
+ b0 > 0xEF ? 4 :
2827
+ b0 > 0xDF ? 3 :
2828
+ b0 > 0xBF ? 2 : 1;
2829
+
2830
+ if (i + bytesPerSequence > end) break;
2831
+
2832
+ var b1, b2, b3;
2833
+
2834
+ if (bytesPerSequence === 1) {
2835
+ if (b0 < 0x80) {
2836
+ c = b0;
2837
+ }
2838
+ } else if (bytesPerSequence === 2) {
2839
+ b1 = buf[i + 1];
2840
+ if ((b1 & 0xC0) === 0x80) {
2841
+ c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
2842
+ if (c <= 0x7F) {
2843
+ c = null;
2844
+ }
2845
+ }
2846
+ } else if (bytesPerSequence === 3) {
2847
+ b1 = buf[i + 1];
2848
+ b2 = buf[i + 2];
2849
+ if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
2850
+ c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
2851
+ if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
2852
+ c = null;
2853
+ }
2854
+ }
2855
+ } else if (bytesPerSequence === 4) {
2856
+ b1 = buf[i + 1];
2857
+ b2 = buf[i + 2];
2858
+ b3 = buf[i + 3];
2859
+ if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
2860
+ c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
2861
+ if (c <= 0xFFFF || c >= 0x110000) {
2862
+ c = null;
2863
+ }
2864
+ }
2865
+ }
2866
+
2867
+ if (c === null) {
2868
+ c = 0xFFFD;
2869
+ bytesPerSequence = 1;
2870
+
2871
+ } else if (c > 0xFFFF) {
2872
+ c -= 0x10000;
2873
+ str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
2874
+ c = 0xDC00 | c & 0x3FF;
2875
+ }
2876
+
2877
+ str += String.fromCharCode(c);
2878
+ i += bytesPerSequence;
2879
+ }
2880
+
2881
+ return str;
2882
+ }
2883
+
2884
+ function readUtf8TextDecoder(buf, pos, end) {
2885
+ return utf8TextDecoder.decode(buf.subarray(pos, end));
2886
+ }
2887
+
2888
+ function writeUtf8(buf, str, pos) {
2889
+ for (var i = 0, c, lead; i < str.length; i++) {
2890
+ c = str.charCodeAt(i); // code point
2891
+
2892
+ if (c > 0xD7FF && c < 0xE000) {
2893
+ if (lead) {
2894
+ if (c < 0xDC00) {
2895
+ buf[pos++] = 0xEF;
2896
+ buf[pos++] = 0xBF;
2897
+ buf[pos++] = 0xBD;
2898
+ lead = c;
2899
+ continue;
2900
+ } else {
2901
+ c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
2902
+ lead = null;
2903
+ }
2904
+ } else {
2905
+ if (c > 0xDBFF || (i + 1 === str.length)) {
2906
+ buf[pos++] = 0xEF;
2907
+ buf[pos++] = 0xBF;
2908
+ buf[pos++] = 0xBD;
2909
+ } else {
2910
+ lead = c;
2911
+ }
2912
+ continue;
2913
+ }
2914
+ } else if (lead) {
2915
+ buf[pos++] = 0xEF;
2916
+ buf[pos++] = 0xBF;
2917
+ buf[pos++] = 0xBD;
2918
+ lead = null;
2919
+ }
2920
+
2921
+ if (c < 0x80) {
2922
+ buf[pos++] = c;
2923
+ } else {
2924
+ if (c < 0x800) {
2925
+ buf[pos++] = c >> 0x6 | 0xC0;
2926
+ } else {
2927
+ if (c < 0x10000) {
2928
+ buf[pos++] = c >> 0xC | 0xE0;
2929
+ } else {
2930
+ buf[pos++] = c >> 0x12 | 0xF0;
2931
+ buf[pos++] = c >> 0xC & 0x3F | 0x80;
2932
+ }
2933
+ buf[pos++] = c >> 0x6 & 0x3F | 0x80;
2934
+ }
2935
+ buf[pos++] = c & 0x3F | 0x80;
2936
+ }
2937
+ }
2938
+ return pos;
2939
+ }
2940
+ return pbf;
2941
+ }
2942
+
2943
+ var pbfExports = requirePbf();
2944
+ var Pbf = /*@__PURE__*/getDefaultExportFromCjs(pbfExports);
2945
+
2946
+ // FeatureCollectionPBuffer ========================================
2947
+
2948
+ const FeatureCollectionPBuffer = {};
2949
+
2950
+ FeatureCollectionPBuffer.read = function (pbf, end) {
2951
+ return pbf.readFields(FeatureCollectionPBuffer._readField, {version: '', queryResult: null}, end);
2952
+ };
2953
+ FeatureCollectionPBuffer._readField = function (tag, obj, pbf) {
2954
+ if (tag === 1) obj.version = pbf.readString();
2955
+ else if (tag === 2) obj.queryResult = FeatureCollectionPBuffer.QueryResult.read(pbf, pbf.readVarint() + pbf.pos);
2956
+ };
2957
+ FeatureCollectionPBuffer.write = function (obj, pbf) {
2958
+ if (obj.version) pbf.writeStringField(1, obj.version);
2959
+ if (obj.queryResult) pbf.writeMessage(2, FeatureCollectionPBuffer.QueryResult.write, obj.queryResult);
2960
+ };
2961
+
2962
+ FeatureCollectionPBuffer.GeometryType = {
2963
+ 'esriGeometryTypePoint': {
2964
+ 'value': 0,
2965
+ 'options': {}
2966
+ },
2967
+ 'esriGeometryTypeMultipoint': {
2968
+ 'value': 1,
2969
+ 'options': {}
2970
+ },
2971
+ 'esriGeometryTypePolyline': {
2972
+ 'value': 2,
2973
+ 'options': {}
2974
+ },
2975
+ 'esriGeometryTypePolygon': {
2976
+ 'value': 3,
2977
+ 'options': {}
2978
+ },
2979
+ 'esriGeometryTypeMultipatch': {
2980
+ 'value': 4,
2981
+ 'options': {}
2982
+ },
2983
+ 'esriGeometryTypeNone': {
2984
+ 'value': 127,
2985
+ 'options': {}
2986
+ }
2987
+ };
2988
+
2989
+ FeatureCollectionPBuffer.FieldType = {
2990
+ 'esriFieldTypeSmallInteger': {
2991
+ 'value': 0,
2992
+ 'options': {}
2993
+ },
2994
+ 'esriFieldTypeInteger': {
2995
+ 'value': 1,
2996
+ 'options': {}
2997
+ },
2998
+ 'esriFieldTypeSingle': {
2999
+ 'value': 2,
3000
+ 'options': {}
3001
+ },
3002
+ 'esriFieldTypeDouble': {
3003
+ 'value': 3,
3004
+ 'options': {}
3005
+ },
3006
+ 'esriFieldTypeString': {
3007
+ 'value': 4,
3008
+ 'options': {}
3009
+ },
3010
+ 'esriFieldTypeDate': {
3011
+ 'value': 5,
3012
+ 'options': {}
3013
+ },
3014
+ 'esriFieldTypeOID': {
3015
+ 'value': 6,
3016
+ 'options': {}
3017
+ },
3018
+ 'esriFieldTypeGeometry': {
3019
+ 'value': 7,
3020
+ 'options': {}
3021
+ },
3022
+ 'esriFieldTypeBlob': {
3023
+ 'value': 8,
3024
+ 'options': {}
3025
+ },
3026
+ 'esriFieldTypeRaster': {
3027
+ 'value': 9,
3028
+ 'options': {}
3029
+ },
3030
+ 'esriFieldTypeGUID': {
3031
+ 'value': 10,
3032
+ 'options': {}
3033
+ },
3034
+ 'esriFieldTypeGlobalID': {
3035
+ 'value': 11,
3036
+ 'options': {}
3037
+ },
3038
+ 'esriFieldTypeXML': {
3039
+ 'value': 12,
3040
+ 'options': {}
3041
+ }
3042
+ };
3043
+
3044
+ FeatureCollectionPBuffer.SQLType = {
3045
+ 'sqlTypeBigInt': {
3046
+ 'value': 0,
3047
+ 'options': {}
3048
+ },
3049
+ 'sqlTypeBinary': {
3050
+ 'value': 1,
3051
+ 'options': {}
3052
+ },
3053
+ 'sqlTypeBit': {
3054
+ 'value': 2,
3055
+ 'options': {}
3056
+ },
3057
+ 'sqlTypeChar': {
3058
+ 'value': 3,
3059
+ 'options': {}
3060
+ },
3061
+ 'sqlTypeDate': {
3062
+ 'value': 4,
3063
+ 'options': {}
3064
+ },
3065
+ 'sqlTypeDecimal': {
3066
+ 'value': 5,
3067
+ 'options': {}
3068
+ },
3069
+ 'sqlTypeDouble': {
3070
+ 'value': 6,
3071
+ 'options': {}
3072
+ },
3073
+ 'sqlTypeFloat': {
3074
+ 'value': 7,
3075
+ 'options': {}
3076
+ },
3077
+ 'sqlTypeGeometry': {
3078
+ 'value': 8,
3079
+ 'options': {}
3080
+ },
3081
+ 'sqlTypeGUID': {
3082
+ 'value': 9,
3083
+ 'options': {}
3084
+ },
3085
+ 'sqlTypeInteger': {
3086
+ 'value': 10,
3087
+ 'options': {}
3088
+ },
3089
+ 'sqlTypeLongNVarchar': {
3090
+ 'value': 11,
3091
+ 'options': {}
3092
+ },
3093
+ 'sqlTypeLongVarbinary': {
3094
+ 'value': 12,
3095
+ 'options': {}
3096
+ },
3097
+ 'sqlTypeLongVarchar': {
3098
+ 'value': 13,
3099
+ 'options': {}
3100
+ },
3101
+ 'sqlTypeNChar': {
3102
+ 'value': 14,
3103
+ 'options': {}
3104
+ },
3105
+ 'sqlTypeNVarchar': {
3106
+ 'value': 15,
3107
+ 'options': {}
3108
+ },
3109
+ 'sqlTypeOther': {
3110
+ 'value': 16,
3111
+ 'options': {}
3112
+ },
3113
+ 'sqlTypeReal': {
3114
+ 'value': 17,
3115
+ 'options': {}
3116
+ },
3117
+ 'sqlTypeSmallInt': {
3118
+ 'value': 18,
3119
+ 'options': {}
3120
+ },
3121
+ 'sqlTypeSqlXml': {
3122
+ 'value': 19,
3123
+ 'options': {}
3124
+ },
3125
+ 'sqlTypeTime': {
3126
+ 'value': 20,
3127
+ 'options': {}
3128
+ },
3129
+ 'sqlTypeTimestamp': {
3130
+ 'value': 21,
3131
+ 'options': {}
3132
+ },
3133
+ 'sqlTypeTimestamp2': {
3134
+ 'value': 22,
3135
+ 'options': {}
3136
+ },
3137
+ 'sqlTypeTinyInt': {
3138
+ 'value': 23,
3139
+ 'options': {}
3140
+ },
3141
+ 'sqlTypeVarbinary': {
3142
+ 'value': 24,
3143
+ 'options': {}
3144
+ },
3145
+ 'sqlTypeVarchar': {
3146
+ 'value': 25,
3147
+ 'options': {}
3148
+ }
3149
+ };
3150
+
3151
+ FeatureCollectionPBuffer.QuantizeOriginPostion = {
3152
+ 'upperLeft': {
3153
+ 'value': 0,
3154
+ 'options': {}
3155
+ },
3156
+ 'lowerLeft': {
3157
+ 'value': 1,
3158
+ 'options': {}
3159
+ }
3160
+ };
3161
+
3162
+ // FeatureCollectionPBuffer.SpatialReference ========================================
3163
+
3164
+ FeatureCollectionPBuffer.SpatialReference = {};
3165
+
3166
+ FeatureCollectionPBuffer.SpatialReference.read = function (pbf, end) {
3167
+ return pbf.readFields(FeatureCollectionPBuffer.SpatialReference._readField, {wkid: 0, lastestWkid: 0, vcsWkid: 0, latestVcsWkid: 0, wkt: ''}, end);
3168
+ };
3169
+ FeatureCollectionPBuffer.SpatialReference._readField = function (tag, obj, pbf) {
3170
+ if (tag === 1) obj.wkid = pbf.readVarint();
3171
+ else if (tag === 2) obj.lastestWkid = pbf.readVarint();
3172
+ else if (tag === 3) obj.vcsWkid = pbf.readVarint();
3173
+ else if (tag === 4) obj.latestVcsWkid = pbf.readVarint();
3174
+ else if (tag === 5) obj.wkt = pbf.readString();
3175
+ };
3176
+ FeatureCollectionPBuffer.SpatialReference.write = function (obj, pbf) {
3177
+ if (obj.wkid) pbf.writeVarintField(1, obj.wkid);
3178
+ if (obj.lastestWkid) pbf.writeVarintField(2, obj.lastestWkid);
3179
+ if (obj.vcsWkid) pbf.writeVarintField(3, obj.vcsWkid);
3180
+ if (obj.latestVcsWkid) pbf.writeVarintField(4, obj.latestVcsWkid);
3181
+ if (obj.wkt) pbf.writeStringField(5, obj.wkt);
3182
+ };
3183
+
3184
+ // FeatureCollectionPBuffer.Field ========================================
3185
+
3186
+ FeatureCollectionPBuffer.Field = {};
3187
+
3188
+ FeatureCollectionPBuffer.Field.read = function (pbf, end) {
3189
+ return pbf.readFields(FeatureCollectionPBuffer.Field._readField, {name: '', fieldType: 0, alias: '', sqlType: 0, domain: '', defaultValue: ''}, end);
3190
+ };
3191
+ FeatureCollectionPBuffer.Field._readField = function (tag, obj, pbf) {
3192
+ if (tag === 1) obj.name = pbf.readString();
3193
+ else if (tag === 2) obj.fieldType = pbf.readVarint();
3194
+ else if (tag === 3) obj.alias = pbf.readString();
3195
+ else if (tag === 4) obj.sqlType = pbf.readVarint();
3196
+ else if (tag === 5) obj.domain = pbf.readString();
3197
+ else if (tag === 6) obj.defaultValue = pbf.readString();
3198
+ };
3199
+ FeatureCollectionPBuffer.Field.write = function (obj, pbf) {
3200
+ if (obj.name) pbf.writeStringField(1, obj.name);
3201
+ if (obj.fieldType) pbf.writeVarintField(2, obj.fieldType);
3202
+ if (obj.alias) pbf.writeStringField(3, obj.alias);
3203
+ if (obj.sqlType) pbf.writeVarintField(4, obj.sqlType);
3204
+ if (obj.domain) pbf.writeStringField(5, obj.domain);
3205
+ if (obj.defaultValue) pbf.writeStringField(6, obj.defaultValue);
3206
+ };
3207
+
3208
+ // FeatureCollectionPBuffer.Value ========================================
3209
+
3210
+ FeatureCollectionPBuffer.Value = {};
3211
+
3212
+ FeatureCollectionPBuffer.Value.read = function (pbf, end) {
3213
+ return pbf.readFields(FeatureCollectionPBuffer.Value._readField, {string_value: '', value_type: null, float_value: 0, double_value: 0, sint_value: 0, uint_value: 0, int64_value: 0, uint64_value: 0, sint64_value: 0, bool_value: false}, end);
3214
+ };
3215
+ FeatureCollectionPBuffer.Value._readField = function (tag, obj, pbf) {
3216
+ if (tag === 1) obj.string_value = pbf.readString(), obj.value_type = 'string_value';
3217
+ else if (tag === 2) obj.float_value = pbf.readFloat(), obj.value_type = 'float_value';
3218
+ else if (tag === 3) obj.double_value = pbf.readDouble(), obj.value_type = 'double_value';
3219
+ else if (tag === 4) obj.sint_value = pbf.readSVarint(), obj.value_type = 'sint_value';
3220
+ else if (tag === 5) obj.uint_value = pbf.readVarint(), obj.value_type = 'uint_value';
3221
+ else if (tag === 6) obj.int64_value = pbf.readVarint(true), obj.value_type = 'int64_value';
3222
+ else if (tag === 7) obj.uint64_value = pbf.readVarint(), obj.value_type = 'uint64_value';
3223
+ else if (tag === 8) obj.sint64_value = pbf.readSVarint(), obj.value_type = 'sint64_value';
3224
+ else if (tag === 9) obj.bool_value = pbf.readBoolean(), obj.value_type = 'bool_value';
3225
+ };
3226
+ FeatureCollectionPBuffer.Value.write = function (obj, pbf) {
3227
+ if (obj.string_value) pbf.writeStringField(1, obj.string_value);
3228
+ if (obj.float_value) pbf.writeFloatField(2, obj.float_value);
3229
+ if (obj.double_value) pbf.writeDoubleField(3, obj.double_value);
3230
+ if (obj.sint_value) pbf.writeSVarintField(4, obj.sint_value);
3231
+ if (obj.uint_value) pbf.writeVarintField(5, obj.uint_value);
3232
+ if (obj.int64_value) pbf.writeVarintField(6, obj.int64_value);
3233
+ if (obj.uint64_value) pbf.writeVarintField(7, obj.uint64_value);
3234
+ if (obj.sint64_value) pbf.writeSVarintField(8, obj.sint64_value);
3235
+ if (obj.bool_value) pbf.writeBooleanField(9, obj.bool_value);
3236
+ };
3237
+
3238
+ // FeatureCollectionPBuffer.Geometry ========================================
3239
+
3240
+ FeatureCollectionPBuffer.Geometry = {};
3241
+
3242
+ FeatureCollectionPBuffer.Geometry.read = function (pbf, end) {
3243
+ return pbf.readFields(FeatureCollectionPBuffer.Geometry._readField, {lengths: [], coords: []}, end);
3244
+ };
3245
+ FeatureCollectionPBuffer.Geometry._readField = function (tag, obj, pbf) {
3246
+ if (tag === 2) pbf.readPackedVarint(obj.lengths);
3247
+ else if (tag === 3) pbf.readPackedSVarint(obj.coords);
3248
+ };
3249
+ FeatureCollectionPBuffer.Geometry.write = function (obj, pbf) {
3250
+ if (obj.lengths) pbf.writePackedVarint(2, obj.lengths);
3251
+ if (obj.coords) pbf.writePackedSVarint(3, obj.coords);
3252
+ };
3253
+
3254
+ // FeatureCollectionPBuffer.esriShapeBuffer ========================================
3255
+
3256
+ FeatureCollectionPBuffer.esriShapeBuffer = {};
3257
+
3258
+ FeatureCollectionPBuffer.esriShapeBuffer.read = function (pbf, end) {
3259
+ return pbf.readFields(FeatureCollectionPBuffer.esriShapeBuffer._readField, {bytes: null}, end);
3260
+ };
3261
+ FeatureCollectionPBuffer.esriShapeBuffer._readField = function (tag, obj, pbf) {
3262
+ if (tag === 1) obj.bytes = pbf.readBytes();
3263
+ };
3264
+ FeatureCollectionPBuffer.esriShapeBuffer.write = function (obj, pbf) {
3265
+ if (obj.bytes) pbf.writeBytesField(1, obj.bytes);
3266
+ };
3267
+
3268
+ // FeatureCollectionPBuffer.Feature ========================================
3269
+
3270
+ FeatureCollectionPBuffer.Feature = {};
3271
+
3272
+ FeatureCollectionPBuffer.Feature.read = function (pbf, end) {
3273
+ return pbf.readFields(FeatureCollectionPBuffer.Feature._readField, {attributes: [], geometry: null, compressed_geometry: null, shapeBuffer: null, centroid: null}, end);
3274
+ };
3275
+ FeatureCollectionPBuffer.Feature._readField = function (tag, obj, pbf) {
3276
+ if (tag === 1) obj.attributes.push(FeatureCollectionPBuffer.Value.read(pbf, pbf.readVarint() + pbf.pos));
3277
+ else if (tag === 2) obj.geometry = FeatureCollectionPBuffer.Geometry.read(pbf, pbf.readVarint() + pbf.pos), obj.compressed_geometry = 'geometry';
3278
+ else if (tag === 3) obj.shapeBuffer = FeatureCollectionPBuffer.esriShapeBuffer.read(pbf, pbf.readVarint() + pbf.pos), obj.compressed_geometry = 'shapeBuffer';
3279
+ else if (tag === 4) obj.centroid = FeatureCollectionPBuffer.Geometry.read(pbf, pbf.readVarint() + pbf.pos);
3280
+ };
3281
+ FeatureCollectionPBuffer.Feature.write = function (obj, pbf) {
3282
+ if (obj.attributes) for (let i = 0; i < obj.attributes.length; i++) pbf.writeMessage(1, FeatureCollectionPBuffer.Value.write, obj.attributes[i]);
3283
+ if (obj.geometry) pbf.writeMessage(2, FeatureCollectionPBuffer.Geometry.write, obj.geometry);
3284
+ if (obj.shapeBuffer) pbf.writeMessage(3, FeatureCollectionPBuffer.esriShapeBuffer.write, obj.shapeBuffer);
3285
+ if (obj.centroid) pbf.writeMessage(4, FeatureCollectionPBuffer.Geometry.write, obj.centroid);
3286
+ };
3287
+
3288
+ // FeatureCollectionPBuffer.UniqueIdField ========================================
3289
+
3290
+ FeatureCollectionPBuffer.UniqueIdField = {};
3291
+
3292
+ FeatureCollectionPBuffer.UniqueIdField.read = function (pbf, end) {
3293
+ return pbf.readFields(FeatureCollectionPBuffer.UniqueIdField._readField, {name: '', isSystemMaintained: false}, end);
3294
+ };
3295
+ FeatureCollectionPBuffer.UniqueIdField._readField = function (tag, obj, pbf) {
3296
+ if (tag === 1) obj.name = pbf.readString();
3297
+ else if (tag === 2) obj.isSystemMaintained = pbf.readBoolean();
3298
+ };
3299
+ FeatureCollectionPBuffer.UniqueIdField.write = function (obj, pbf) {
3300
+ if (obj.name) pbf.writeStringField(1, obj.name);
3301
+ if (obj.isSystemMaintained) pbf.writeBooleanField(2, obj.isSystemMaintained);
3302
+ };
3303
+
3304
+ // FeatureCollectionPBuffer.GeometryProperties ========================================
3305
+
3306
+ FeatureCollectionPBuffer.GeometryProperties = {};
3307
+
3308
+ FeatureCollectionPBuffer.GeometryProperties.read = function (pbf, end) {
3309
+ return pbf.readFields(FeatureCollectionPBuffer.GeometryProperties._readField, {shapeAreaFieldName: '', shapeLengthFieldName: '', units: ''}, end);
3310
+ };
3311
+ FeatureCollectionPBuffer.GeometryProperties._readField = function (tag, obj, pbf) {
3312
+ if (tag === 1) obj.shapeAreaFieldName = pbf.readString();
3313
+ else if (tag === 2) obj.shapeLengthFieldName = pbf.readString();
3314
+ else if (tag === 3) obj.units = pbf.readString();
3315
+ };
3316
+ FeatureCollectionPBuffer.GeometryProperties.write = function (obj, pbf) {
3317
+ if (obj.shapeAreaFieldName) pbf.writeStringField(1, obj.shapeAreaFieldName);
3318
+ if (obj.shapeLengthFieldName) pbf.writeStringField(2, obj.shapeLengthFieldName);
3319
+ if (obj.units) pbf.writeStringField(3, obj.units);
3320
+ };
3321
+
3322
+ // FeatureCollectionPBuffer.ServerGens ========================================
3323
+
3324
+ FeatureCollectionPBuffer.ServerGens = {};
3325
+
3326
+ FeatureCollectionPBuffer.ServerGens.read = function (pbf, end) {
3327
+ return pbf.readFields(FeatureCollectionPBuffer.ServerGens._readField, {minServerGen: 0, serverGen: 0}, end);
3328
+ };
3329
+ FeatureCollectionPBuffer.ServerGens._readField = function (tag, obj, pbf) {
3330
+ if (tag === 1) obj.minServerGen = pbf.readVarint();
3331
+ else if (tag === 2) obj.serverGen = pbf.readVarint();
3332
+ };
3333
+ FeatureCollectionPBuffer.ServerGens.write = function (obj, pbf) {
3334
+ if (obj.minServerGen) pbf.writeVarintField(1, obj.minServerGen);
3335
+ if (obj.serverGen) pbf.writeVarintField(2, obj.serverGen);
3336
+ };
3337
+
3338
+ // FeatureCollectionPBuffer.Scale ========================================
3339
+
3340
+ FeatureCollectionPBuffer.Scale = {};
3341
+
3342
+ FeatureCollectionPBuffer.Scale.read = function (pbf, end) {
3343
+ return pbf.readFields(FeatureCollectionPBuffer.Scale._readField, {xScale: 0, yScale: 0, mScale: 0, zScale: 0}, end);
3344
+ };
3345
+ FeatureCollectionPBuffer.Scale._readField = function (tag, obj, pbf) {
3346
+ if (tag === 1) obj.xScale = pbf.readDouble();
3347
+ else if (tag === 2) obj.yScale = pbf.readDouble();
3348
+ else if (tag === 3) obj.mScale = pbf.readDouble();
3349
+ else if (tag === 4) obj.zScale = pbf.readDouble();
3350
+ };
3351
+ FeatureCollectionPBuffer.Scale.write = function (obj, pbf) {
3352
+ if (obj.xScale) pbf.writeDoubleField(1, obj.xScale);
3353
+ if (obj.yScale) pbf.writeDoubleField(2, obj.yScale);
3354
+ if (obj.mScale) pbf.writeDoubleField(3, obj.mScale);
3355
+ if (obj.zScale) pbf.writeDoubleField(4, obj.zScale);
3356
+ };
3357
+
3358
+ // FeatureCollectionPBuffer.Translate ========================================
3359
+
3360
+ FeatureCollectionPBuffer.Translate = {};
3361
+
3362
+ FeatureCollectionPBuffer.Translate.read = function (pbf, end) {
3363
+ return pbf.readFields(FeatureCollectionPBuffer.Translate._readField, {xTranslate: 0, yTranslate: 0, mTranslate: 0, zTranslate: 0}, end);
3364
+ };
3365
+ FeatureCollectionPBuffer.Translate._readField = function (tag, obj, pbf) {
3366
+ if (tag === 1) obj.xTranslate = pbf.readDouble();
3367
+ else if (tag === 2) obj.yTranslate = pbf.readDouble();
3368
+ else if (tag === 3) obj.mTranslate = pbf.readDouble();
3369
+ else if (tag === 4) obj.zTranslate = pbf.readDouble();
3370
+ };
3371
+ FeatureCollectionPBuffer.Translate.write = function (obj, pbf) {
3372
+ if (obj.xTranslate) pbf.writeDoubleField(1, obj.xTranslate);
3373
+ if (obj.yTranslate) pbf.writeDoubleField(2, obj.yTranslate);
3374
+ if (obj.mTranslate) pbf.writeDoubleField(3, obj.mTranslate);
3375
+ if (obj.zTranslate) pbf.writeDoubleField(4, obj.zTranslate);
3376
+ };
3377
+
3378
+ // FeatureCollectionPBuffer.Transform ========================================
3379
+
3380
+ FeatureCollectionPBuffer.Transform = {};
3381
+
3382
+ FeatureCollectionPBuffer.Transform.read = function (pbf, end) {
3383
+ return pbf.readFields(FeatureCollectionPBuffer.Transform._readField, {quantizeOriginPostion: 0, scale: null, translate: null}, end);
3384
+ };
3385
+ FeatureCollectionPBuffer.Transform._readField = function (tag, obj, pbf) {
3386
+ if (tag === 1) obj.quantizeOriginPostion = pbf.readVarint();
3387
+ else if (tag === 2) obj.scale = FeatureCollectionPBuffer.Scale.read(pbf, pbf.readVarint() + pbf.pos);
3388
+ else if (tag === 3) obj.translate = FeatureCollectionPBuffer.Translate.read(pbf, pbf.readVarint() + pbf.pos);
3389
+ };
3390
+ FeatureCollectionPBuffer.Transform.write = function (obj, pbf) {
3391
+ if (obj.quantizeOriginPostion) pbf.writeVarintField(1, obj.quantizeOriginPostion);
3392
+ if (obj.scale) pbf.writeMessage(2, FeatureCollectionPBuffer.Scale.write, obj.scale);
3393
+ if (obj.translate) pbf.writeMessage(3, FeatureCollectionPBuffer.Translate.write, obj.translate);
3394
+ };
3395
+
3396
+ // FeatureCollectionPBuffer.FeatureResult ========================================
3397
+
3398
+ FeatureCollectionPBuffer.FeatureResult = {};
3399
+
3400
+ FeatureCollectionPBuffer.FeatureResult.read = function (pbf, end) {
3401
+ return pbf.readFields(FeatureCollectionPBuffer.FeatureResult._readField, {objectIdFieldName: '', uniqueIdField: null, globalIdFieldName: '', geohashFieldName: '', geometryProperties: null, serverGens: null, geometryType: 0, spatialReference: null, exceededTransferLimit: false, hasZ: false, hasM: false, transform: null, fields: [], values: [], features: []}, end);
3402
+ };
3403
+ FeatureCollectionPBuffer.FeatureResult._readField = function (tag, obj, pbf) {
3404
+ if (tag === 1) obj.objectIdFieldName = pbf.readString();
3405
+ else if (tag === 2) obj.uniqueIdField = FeatureCollectionPBuffer.UniqueIdField.read(pbf, pbf.readVarint() + pbf.pos);
3406
+ else if (tag === 3) obj.globalIdFieldName = pbf.readString();
3407
+ else if (tag === 4) obj.geohashFieldName = pbf.readString();
3408
+ else if (tag === 5) obj.geometryProperties = FeatureCollectionPBuffer.GeometryProperties.read(pbf, pbf.readVarint() + pbf.pos);
3409
+ else if (tag === 6) obj.serverGens = FeatureCollectionPBuffer.ServerGens.read(pbf, pbf.readVarint() + pbf.pos);
3410
+ else if (tag === 7) obj.geometryType = pbf.readVarint();
3411
+ else if (tag === 8) obj.spatialReference = FeatureCollectionPBuffer.SpatialReference.read(pbf, pbf.readVarint() + pbf.pos);
3412
+ else if (tag === 9) obj.exceededTransferLimit = pbf.readBoolean();
3413
+ else if (tag === 10) obj.hasZ = pbf.readBoolean();
3414
+ else if (tag === 11) obj.hasM = pbf.readBoolean();
3415
+ else if (tag === 12) obj.transform = FeatureCollectionPBuffer.Transform.read(pbf, pbf.readVarint() + pbf.pos);
3416
+ else if (tag === 13) obj.fields.push(FeatureCollectionPBuffer.Field.read(pbf, pbf.readVarint() + pbf.pos));
3417
+ else if (tag === 14) obj.values.push(FeatureCollectionPBuffer.Value.read(pbf, pbf.readVarint() + pbf.pos));
3418
+ else if (tag === 15) obj.features.push(FeatureCollectionPBuffer.Feature.read(pbf, pbf.readVarint() + pbf.pos));
3419
+ };
3420
+ FeatureCollectionPBuffer.FeatureResult.write = function (obj, pbf) {
3421
+ if (obj.objectIdFieldName) pbf.writeStringField(1, obj.objectIdFieldName);
3422
+ if (obj.uniqueIdField) pbf.writeMessage(2, FeatureCollectionPBuffer.UniqueIdField.write, obj.uniqueIdField);
3423
+ if (obj.globalIdFieldName) pbf.writeStringField(3, obj.globalIdFieldName);
3424
+ if (obj.geohashFieldName) pbf.writeStringField(4, obj.geohashFieldName);
3425
+ if (obj.geometryProperties) pbf.writeMessage(5, FeatureCollectionPBuffer.GeometryProperties.write, obj.geometryProperties);
3426
+ if (obj.serverGens) pbf.writeMessage(6, FeatureCollectionPBuffer.ServerGens.write, obj.serverGens);
3427
+ if (obj.geometryType) pbf.writeVarintField(7, obj.geometryType);
3428
+ if (obj.spatialReference) pbf.writeMessage(8, FeatureCollectionPBuffer.SpatialReference.write, obj.spatialReference);
3429
+ if (obj.exceededTransferLimit) pbf.writeBooleanField(9, obj.exceededTransferLimit);
3430
+ if (obj.hasZ) pbf.writeBooleanField(10, obj.hasZ);
3431
+ if (obj.hasM) pbf.writeBooleanField(11, obj.hasM);
3432
+ if (obj.transform) pbf.writeMessage(12, FeatureCollectionPBuffer.Transform.write, obj.transform);
3433
+ if (obj.fields) for (var i = 0; i < obj.fields.length; i++) pbf.writeMessage(13, FeatureCollectionPBuffer.Field.write, obj.fields[i]);
3434
+ if (obj.values) for (i = 0; i < obj.values.length; i++) pbf.writeMessage(14, FeatureCollectionPBuffer.Value.write, obj.values[i]);
3435
+ if (obj.features) for (i = 0; i < obj.features.length; i++) pbf.writeMessage(15, FeatureCollectionPBuffer.Feature.write, obj.features[i]);
3436
+ };
3437
+
3438
+ // FeatureCollectionPBuffer.CountResult ========================================
3439
+
3440
+ FeatureCollectionPBuffer.CountResult = {};
3441
+
3442
+ FeatureCollectionPBuffer.CountResult.read = function (pbf, end) {
3443
+ return pbf.readFields(FeatureCollectionPBuffer.CountResult._readField, {count: 0}, end);
3444
+ };
3445
+ FeatureCollectionPBuffer.CountResult._readField = function (tag, obj, pbf) {
3446
+ if (tag === 1) obj.count = pbf.readVarint();
3447
+ };
3448
+ FeatureCollectionPBuffer.CountResult.write = function (obj, pbf) {
3449
+ if (obj.count) pbf.writeVarintField(1, obj.count);
3450
+ };
3451
+
3452
+ // FeatureCollectionPBuffer.ObjectIdsResult ========================================
3453
+
3454
+ FeatureCollectionPBuffer.ObjectIdsResult = {};
3455
+
3456
+ FeatureCollectionPBuffer.ObjectIdsResult.read = function (pbf, end) {
3457
+ return pbf.readFields(FeatureCollectionPBuffer.ObjectIdsResult._readField, {objectIdFieldName: '', serverGens: null, objectIds: []}, end);
3458
+ };
3459
+ FeatureCollectionPBuffer.ObjectIdsResult._readField = function (tag, obj, pbf) {
3460
+ if (tag === 1) obj.objectIdFieldName = pbf.readString();
3461
+ else if (tag === 2) obj.serverGens = FeatureCollectionPBuffer.ServerGens.read(pbf, pbf.readVarint() + pbf.pos);
3462
+ else if (tag === 3) pbf.readPackedVarint(obj.objectIds);
3463
+ };
3464
+ FeatureCollectionPBuffer.ObjectIdsResult.write = function (obj, pbf) {
3465
+ if (obj.objectIdFieldName) pbf.writeStringField(1, obj.objectIdFieldName);
3466
+ if (obj.serverGens) pbf.writeMessage(2, FeatureCollectionPBuffer.ServerGens.write, obj.serverGens);
3467
+ if (obj.objectIds) pbf.writePackedVarint(3, obj.objectIds);
3468
+ };
3469
+
3470
+ // FeatureCollectionPBuffer.QueryResult ========================================
3471
+
3472
+ FeatureCollectionPBuffer.QueryResult = {};
3473
+
3474
+ FeatureCollectionPBuffer.QueryResult.read = function (pbf, end) {
3475
+ return pbf.readFields(FeatureCollectionPBuffer.QueryResult._readField, {featureResult: null, Results: null, countResult: null, idsResult: null}, end);
3476
+ };
3477
+ FeatureCollectionPBuffer.QueryResult._readField = function (tag, obj, pbf) {
3478
+ if (tag === 1) obj.featureResult = FeatureCollectionPBuffer.FeatureResult.read(pbf, pbf.readVarint() + pbf.pos), obj.Results = 'featureResult';
3479
+ else if (tag === 2) obj.countResult = FeatureCollectionPBuffer.CountResult.read(pbf, pbf.readVarint() + pbf.pos), obj.Results = 'countResult';
3480
+ else if (tag === 3) obj.idsResult = FeatureCollectionPBuffer.ObjectIdsResult.read(pbf, pbf.readVarint() + pbf.pos), obj.Results = 'idsResult';
3481
+ };
3482
+ FeatureCollectionPBuffer.QueryResult.write = function (obj, pbf) {
3483
+ if (obj.featureResult) pbf.writeMessage(1, FeatureCollectionPBuffer.FeatureResult.write, obj.featureResult);
3484
+ if (obj.countResult) pbf.writeMessage(2, FeatureCollectionPBuffer.CountResult.write, obj.countResult);
3485
+ if (obj.idsResult) pbf.writeMessage(3, FeatureCollectionPBuffer.ObjectIdsResult.write, obj.idsResult);
3486
+ };
3487
+
3488
+ function decode(featureCollectionBuffer) {
3489
+ let decodedObject;
3490
+ try {
3491
+ decodedObject = FeatureCollectionPBuffer.read(new Pbf(featureCollectionBuffer));
3492
+ } catch (error) {
3493
+ throw new Error('Could not parse arcgis-pbf buffer')
3494
+ }
3495
+ const featureResult = decodedObject.queryResult.featureResult;
3496
+ const transform = featureResult.transform;
3497
+ const geometryType = featureResult.geometryType;
3498
+ const objectIdField = featureResult.objectIdFieldName;
3499
+
3500
+ // Wires up the field keynames
3501
+ const fields = featureResult.fields;
3502
+ for (let index = 0; index < fields.length; index++) {
3503
+ const field = fields[index];
3504
+ field.keyName = getKeyName(field);
3505
+ }
3506
+
3507
+ const out = {
3508
+ type: 'FeatureCollection',
3509
+ features: []
3510
+ };
3511
+
3512
+ const geometryParser = getGeometryParser(geometryType);
3513
+
3514
+ const featureLen = featureResult.features.length;
3515
+ for (let index = 0; index < featureLen; index++) {
3516
+ const f = featureResult.features[index];
3517
+ out.features.push({
3518
+ type: 'Feature',
3519
+ id: getFeatureId(fields, f.attributes, objectIdField),
3520
+ properties: collectAttributes(fields, f.attributes),
3521
+ geometry: f.geometry && geometryParser(f, transform)
3522
+ });
3523
+ }
3524
+
3525
+ return {
3526
+ featureCollection: out,
3527
+ exceededTransferLimit: featureResult.exceededTransferLimit
3528
+ }
3529
+ }
3530
+
3531
+ // * @property {number} esriGeometryTypePoint=0 esriGeometryTypePoint value
3532
+ // * @property {number} esriGeometryTypeMultipoint=1 esriGeometryTypeMultipoint value
3533
+ // * @property {number} esriGeometryTypePolyline=2 esriGeometryTypePolyline value
3534
+ // * @property {number} esriGeometryTypePolygon=3 esriGeometryTypePolygon value
3535
+ // * @property {number} esriGeometryTypeMultipatch=4 esriGeometryTypeMultipatch value
3536
+ // * @property {number} esriGeometryTypeNone=127 esriGeometryTypeNone value
3537
+ function getGeometryParser (featureType) {
3538
+ switch (featureType) {
3539
+ case 3:
3540
+ return createPolygon
3541
+ case 2:
3542
+ return createLine
3543
+ case 0:
3544
+ return createPoint
3545
+ default:
3546
+ return createPolygon
3547
+ }
3548
+ }
3549
+
3550
+ function createPoint (f, transform) {
3551
+ const p = {
3552
+ type: 'Point',
3553
+ coordinates: transformTuple(f.geometry.coords, transform)
3554
+ };
3555
+ return p
3556
+ }
3557
+
3558
+ function createLine (f, transform) {
3559
+ let l = null;
3560
+ const lengths = f.geometry.lengths.length;
3561
+
3562
+ if (lengths === 1) {
3563
+ l = {
3564
+ type: 'LineString',
3565
+ coordinates: createLinearRing(f.geometry.coords, transform, 0, f.geometry.lengths[0] * 2)
3566
+ };
3567
+ } else if (lengths > 1) {
3568
+ l = {
3569
+ type: 'MultiLineString',
3570
+ coordinates: []
3571
+ };
3572
+ let startPoint = 0;
3573
+ for (let index = 0; index < lengths; index++) {
3574
+ const stopPoint = startPoint + (f.geometry.lengths[index] * 2);
3575
+ const line = createLinearRing(f.geometry.coords, transform, startPoint, stopPoint);
3576
+ l.coordinates.push(line);
3577
+ startPoint = stopPoint;
3578
+ }
3579
+ }
3580
+ return l
3581
+ }
3582
+
3583
+ function createPolygon (f, transform) {
3584
+ const lengths = f.geometry.lengths.length;
3585
+
3586
+ const p = {
3587
+ type: 'Polygon',
3588
+ coordinates: []
3589
+ };
3590
+
3591
+ if (lengths === 1) {
3592
+ p.coordinates.push(createLinearRing(f.geometry.coords, transform, 0, f.geometry.lengths[0] * 2));
3593
+ } else {
3594
+ p.type = 'MultiPolygon';
3595
+
3596
+ let startPoint = 0;
3597
+ for (let index = 0; index < lengths; index++) {
3598
+ const stopPoint = startPoint + (f.geometry.lengths[index] * 2);
3599
+ const ring = createLinearRing(f.geometry.coords, transform, startPoint, stopPoint);
3600
+
3601
+ // Check if the ring is clockwise, if so it's an outer ring
3602
+ // If it's counter-clockwise its a hole and so push it to the prev outer ring
3603
+ // This is perhaps a bit naive
3604
+ // see https://github.com/terraformer-js/terraformer/blob/master/packages/arcgis/src/geojson.js
3605
+ // for a fuller example of doing this
3606
+ if (ringIsClockwise(ring)) {
3607
+ p.coordinates.push([ring]);
3608
+ } else if (p.coordinates.length > 0) {
3609
+ p.coordinates[p.coordinates.length - 1].push(ring);
3610
+ }
3611
+ startPoint = stopPoint;
3612
+ }
3613
+ }
3614
+ return p
3615
+ }
3616
+
3617
+ function ringIsClockwise (ringToTest) {
3618
+ let total = 0;
3619
+ let i = 0;
3620
+ const rLength = ringToTest.length;
3621
+ let pt1 = ringToTest[i];
3622
+ let pt2;
3623
+ for (i; i < rLength - 1; i++) {
3624
+ pt2 = ringToTest[i + 1];
3625
+ total += (pt2[0] - pt1[0]) * (pt2[1] + pt1[1]);
3626
+ pt1 = pt2;
3627
+ }
3628
+ return (total >= 0)
3629
+ }
3630
+
3631
+ function createLinearRing (arr, transform, startPoint, stopPoint) {
3632
+ const out = [];
3633
+ if (arr.length === 0) return out
3634
+
3635
+
3636
+ const initialX = arr[startPoint];
3637
+ const initialY = arr[startPoint + 1];
3638
+ out.push(transformTuple([initialX, initialY], transform));
3639
+ let prevX = initialX;
3640
+ let prevY = initialY;
3641
+ for (let i = startPoint + 2; i < stopPoint; i = i + 2) {
3642
+ const x = difference(prevX, arr[i]);
3643
+ const y = difference(prevY, arr[i + 1]);
3644
+ const transformed = transformTuple([x, y], transform);
3645
+ out.push(transformed);
3646
+ prevX = x;
3647
+ prevY = y;
3648
+ }
3649
+ return out
3650
+ }
3651
+
3652
+ function collectAttributes(fields, featureAttributes) {
3653
+ const out = {};
3654
+ for (let i = 0; i < fields.length; i++) {
3655
+ const f = fields[i];
3656
+ if (featureAttributes[i][featureAttributes[i].value_type] !== undefined) out[f.name] = featureAttributes[i][featureAttributes[i].value_type];
3657
+ else out[f.name] = null;
3658
+ }
3659
+ return out
3660
+ }
3661
+
3662
+ function getFeatureId(fields, featureAttributes, featureIdField) {
3663
+ for (let index = 0; index < fields.length; index++) {
3664
+ const field = fields[index];
3665
+ if (field.name === featureIdField) {
3666
+ return featureAttributes[index][featureAttributes[index].value_type]
3667
+ }
3668
+ }
3669
+ return null
3670
+ }
3671
+
3672
+ function getKeyName (fields) {
3673
+ switch (fields.fieldType) {
3674
+ case 1:
3675
+ return 'sintValue'
3676
+ case 2:
3677
+ return 'floatValue'
3678
+ case 3:
3679
+ return 'doubleValue'
3680
+ case 4:
3681
+ return 'stringValue'
3682
+ case 5:
3683
+ return 'sint64Value'
3684
+ case 6:
3685
+ return 'uintValue'
3686
+ default:
3687
+ return null
3688
+ }
3689
+ }
3690
+
3691
+ function transformTuple(coords, transform) {
3692
+
3693
+ let x = coords[0];
3694
+ let y = coords[1];
3695
+
3696
+ let z = coords[2] ? coords[2] : undefined;
3697
+ if (transform.scale) {
3698
+ x *= transform.scale.xScale;
3699
+ y *= -transform.scale.yScale;
3700
+ if (undefined !== z) { z *= transform.scale.zScale; }
3701
+ }
3702
+ if (transform.translate) {
3703
+ x += transform.translate.xTranslate;
3704
+ y += transform.translate.yTranslate;
3705
+ if (undefined !== z) { z += transform.translate.zTranslate; }
3706
+ }
3707
+ const ret = [x, y];
3708
+ if (undefined !== z) { ret.push(z); }
3709
+ return ret;
3710
+ }
3711
+
3712
+ function difference(a, b) {
3713
+ return a + b
3714
+ }
3715
+
2097
3716
  /**
2098
3717
  * FeatureService - Tile-based feature loading from ArcGIS FeatureServers
2099
3718
  *
@@ -2512,7 +4131,7 @@
2512
4131
  const bounds = this._map.getBounds();
2513
4132
  if (!bounds) return;
2514
4133
  const boundsArray = bounds.toArray();
2515
- const primaryTile = tilebelt__namespace.bboxToTile([boundsArray[0][0], boundsArray[0][1], boundsArray[1][0], boundsArray[1][1]]);
4134
+ const primaryTile = bboxToTile([boundsArray[0][0], boundsArray[0][1], boundsArray[1][0], boundsArray[1][1]]);
2516
4135
  if (this._esriServiceOptions.useServiceBounds) {
2517
4136
  if (this._maxExtent[0] !== -Infinity && !this._doesTileOverlapBbox(this._maxExtent, boundsArray)) {
2518
4137
  return;
@@ -2525,12 +4144,12 @@
2525
4144
  const fc = this._createOrGetFeatureCollection(zoomLevel);
2526
4145
  let tilesToRequest = [];
2527
4146
  if (primaryTile[2] < zoomLevel) {
2528
- let candidateTiles = tilebelt__namespace.getChildren(primaryTile);
4147
+ let candidateTiles = getChildren(primaryTile);
2529
4148
  let minZoomOfCandidates = candidateTiles[0][2];
2530
4149
  while (minZoomOfCandidates < zoomLevel) {
2531
4150
  const newCandidateTiles = [];
2532
4151
  candidateTiles.forEach(t => {
2533
- newCandidateTiles.push(...tilebelt__namespace.getChildren(t));
4152
+ newCandidateTiles.push(...getChildren(t));
2534
4153
  });
2535
4154
  candidateTiles = newCandidateTiles;
2536
4155
  minZoomOfCandidates = candidateTiles[0][2];
@@ -2545,7 +4164,7 @@
2545
4164
  }
2546
4165
  // Filter out already fetched tiles
2547
4166
  tilesToRequest = tilesToRequest.filter(tile => {
2548
- const quadKey = tilebelt__namespace.tileToQuadkey(tile);
4167
+ const quadKey = tileToQuadkey(tile);
2549
4168
  if (zoomLevelIndex.has(quadKey)) {
2550
4169
  return false;
2551
4170
  }
@@ -2592,7 +4211,7 @@
2592
4211
  return `${from ?? ''},${to}`;
2593
4212
  }
2594
4213
  async _getTile(tile, tolerance) {
2595
- const tileBounds = tilebelt__namespace.tileToBBOX(tile);
4214
+ const tileBounds = tileToBBOX(tile);
2596
4215
  const extent = {
2597
4216
  spatialReference: {
2598
4217
  latestWkid: 4326,
@@ -2635,7 +4254,7 @@
2635
4254
  if (this._format === 'pbf') {
2636
4255
  const buffer = await response.arrayBuffer();
2637
4256
  try {
2638
- const decoded = tileDecode(new Uint8Array(buffer));
4257
+ const decoded = decode(new Uint8Array(buffer));
2639
4258
  return decoded.featureCollection;
2640
4259
  } catch {
2641
4260
  console.error('Could not parse arcgis buffer. Please check the url you requested.');
@@ -2659,7 +4278,7 @@
2659
4278
  }
2660
4279
  }
2661
4280
  _doesTileOverlapBbox(tile, bbox) {
2662
- const tileBounds = tile.length === 4 ? tile : tilebelt__namespace.tileToBBOX(tile);
4281
+ const tileBounds = tile.length === 4 ? tile : tileToBBOX(tile);
2663
4282
  if (tileBounds[2] < bbox[0][0]) return false;
2664
4283
  if (tileBounds[0] > bbox[1][0]) return false;
2665
4284
  if (tileBounds[3] < bbox[0][1]) return false;
@@ -3987,7 +5606,8 @@
3987
5606
  const bounds = map.getBounds().toArray();
3988
5607
  this.params.mapExtent = [bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]].join(',');
3989
5608
  const canvas = map.getCanvas();
3990
- this.params.imageDisplay = [canvas.width, canvas.height, 96].join(',');
5609
+ const dpi = this.options?.dpi ?? 96;
5610
+ this.params.imageDisplay = [canvas.width, canvas.height, dpi].join(',');
3991
5611
  } catch (error) {
3992
5612
  console.warn('Could not extract map extent and display info:', error);
3993
5613
  }