diff --git a/DESCRIPTION b/DESCRIPTION index 70e7eea..457dd60 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -6,7 +6,7 @@ Description: Client for 'Turfjs' () for measuring aspects of 'GeoJSON', and combining, transforming, and creating random 'GeoJSON' data objects. Type: Package -Version: 0.3.3.9150 +Version: 0.3.5.9110 License: MIT + file LICENSE Authors@R: c( person("Scott", "Chamberlain", role = c("aut", "cre"), email = "myrmecocystus@gmail.com"), diff --git a/R/onLoad.R b/R/onLoad.R index 5802b8f..48fcc26 100644 --- a/R/onLoad.R +++ b/R/onLoad.R @@ -5,7 +5,7 @@ ht <- NULL .onLoad <- function(libname, pkgname){ ct <<- V8::v8(); - ct$source(system.file("js/turf3104.js", package = pkgname)) + ct$source(system.file("js/turf440.js", package = pkgname)) ct$source(system.file("js/turf-meta.js", package = pkgname)) ct$source(system.file("js/turf-invariant.js", package = pkgname)) ct$source(system.file("js/cloner.js", package = pkgname)) @@ -15,5 +15,5 @@ ht <- NULL rand$source(system.file("js/geojson_random.js", package = pkgname)) ht <<- V8::v8(); - ht$source(system.file("js/geojsonhint-v2beta.js", package = pkgname)) + ht$source(system.file("js/geojsonhint-v201.js", package = pkgname)) } diff --git a/data/lawn_data.rda b/data/lawn_data.rda index e227cf2..e1bc8ca 100644 Binary files a/data/lawn_data.rda and b/data/lawn_data.rda differ diff --git a/inst/js/README.md b/inst/js/README.md index 1006250..3b31e2b 100644 --- a/inst/js/README.md +++ b/inst/js/README.md @@ -2,18 +2,18 @@ ## turf -Currently (as of 2017-02-28) using `turf` `v3.10.4` +Currently (as of 2017-06-13) using `turf` `v4.4.0` -To recreate `inst/js/turf3104.js`: +To recreate `inst/js/turf440.js`: -Download the minified file from +Download the minified file from to `inst/js` directory in the `lawn` package ## @turf/meta -Currently (as of 2017-02-28) using `turf/meta` `v3.10.4` +Currently (as of 2017-06-13) using `turf/meta` `v4.4.0` To recreate `inst/js/turf-meta.js`: @@ -38,7 +38,7 @@ cp turf-meta.js lawn/inst/js/ ## @turf/invariant -Currently (as of 2017-02-28) using `turf/invariant` `v3.10.4` +Currently (as of 2017-06-13) using `turf/invariant` `v4.4.0` To recreate `inst/js/turf-invariant.js`: @@ -74,32 +74,34 @@ to `inst/js` directory in the `lawn` package ## geojsonhint -Currently (as of 2016-10-12) using `geojsonhint` `v2.0.0-beta2` +Currently (as of 2017-06-13) using `geojsonhint` `v2.0.1` -To recreate `inst/js/geojsohint-v2beta.js`: +To recreate `inst/js/geojsohint-v201.js`: Install `geojsonhint` from NPM ``` -npm install geojsonhint +npm i @mapbox/geojsonhint ``` Browserify ``` -echo "global.geojsonhint = require('geojsonhint');" > in.js -browserify in.js -o geojsohint-v2beta.js +echo "global.geojsonhint = require('@mapbox/geojsonhint');" > in.js +browserify in.js -o geojsohint-v201.js ``` Copy js file into the `inst/js` directory in the `lawn` package ``` -cp geojsohint-v2beta.js lawn/inst/js +cp geojsohint-v201.js lawn/inst/js ``` + + ## clone -Currently (as of 2016-10-12) using `clone` `v2.0.0-beta2` +Currently (as of 2017-06-13) using `clone` `v2.1.1` To recreate `inst/js/cloner.js`: @@ -122,9 +124,11 @@ Copy js file into the `inst/js` directory in the `lawn` package cp cloner.js lawn/inst/js ``` + + ## geojson-random -Currently (as of 2016-10-12) using `geojson-random` `v0.2.2` +Currently (as of 2017-06-13) using `geojson-random` `v0.4.0` To recreate `inst/js/geojson_random.js`: diff --git a/inst/js/cloner.js b/inst/js/cloner.js index 4dfc38d..d42331d 100644 --- a/inst/js/cloner.js +++ b/inst/js/cloner.js @@ -8,6 +8,33 @@ global.clone = require('clone'); var clone = (function() { 'use strict'; +function _instanceof(obj, type) { + return type != null && obj instanceof type; +} + +var nativeMap; +try { + nativeMap = Map; +} catch(_) { + // maybe a reference error because no `Map`. Give it a dummy value that no + // value will ever be an instanceof. + nativeMap = function() {}; +} + +var nativeSet; +try { + nativeSet = Set; +} catch(_) { + nativeSet = function() {}; +} + +var nativePromise; +try { + nativePromise = Promise; +} catch(_) { + nativePromise = function() {}; +} + /** * Clones (copies) an Object using deep copying. * @@ -25,14 +52,16 @@ var clone = (function() { * a particular depth. (optional - defaults to Infinity) * @param `prototype` - sets the prototype to be used when cloning an object. * (optional - defaults to parent prototype). + * @param `includeNonEnumerable` - set to true if the non-enumerable properties + * should be cloned as well. Non-enumerable properties on the prototype + * chain will be ignored. (optional - false by default) */ -function clone(parent, circular, depth, prototype) { - var filter; +function clone(parent, circular, depth, prototype, includeNonEnumerable) { if (typeof circular === 'object') { depth = circular.depth; prototype = circular.prototype; - filter = circular.filter; - circular = circular.circular + includeNonEnumerable = circular.includeNonEnumerable; + circular = circular.circular; } // maintain two arrays for circular references, where corresponding parents // and children have the same index @@ -53,7 +82,7 @@ function clone(parent, circular, depth, prototype) { if (parent === null) return null; - if (depth == 0) + if (depth === 0) return parent; var child; @@ -62,7 +91,19 @@ function clone(parent, circular, depth, prototype) { return parent; } - if (clone.__isArray(parent)) { + if (_instanceof(parent, nativeMap)) { + child = new nativeMap(); + } else if (_instanceof(parent, nativeSet)) { + child = new nativeSet(); + } else if (_instanceof(parent, nativePromise)) { + child = new nativePromise(function (resolve, reject) { + parent.then(function(value) { + resolve(_clone(value, depth - 1)); + }, function(err) { + reject(_clone(err, depth - 1)); + }); + }); + } else if (clone.__isArray(parent)) { child = []; } else if (clone.__isRegExp(parent)) { child = new RegExp(parent.source, __getRegExpFlags(parent)); @@ -73,6 +114,8 @@ function clone(parent, circular, depth, prototype) { child = new Buffer(parent.length); parent.copy(child); return child; + } else if (_instanceof(parent, Error)) { + child = Object.create(parent); } else { if (typeof prototype == 'undefined') { proto = Object.getPrototypeOf(parent); @@ -94,6 +137,20 @@ function clone(parent, circular, depth, prototype) { allChildren.push(child); } + if (_instanceof(parent, nativeMap)) { + parent.forEach(function(value, key) { + var keyChild = _clone(key, depth - 1); + var valueChild = _clone(value, depth - 1); + child.set(keyChild, valueChild); + }); + } + if (_instanceof(parent, nativeSet)) { + parent.forEach(function(value) { + var entryChild = _clone(value, depth - 1); + child.add(entryChild); + }); + } + for (var i in parent) { var attrs; if (proto) { @@ -106,6 +163,40 @@ function clone(parent, circular, depth, prototype) { child[i] = _clone(parent[i], depth - 1); } + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(parent); + for (var i = 0; i < symbols.length; i++) { + // Don't need to worry about cloning a symbol because it is a primitive, + // like a number or string. + var symbol = symbols[i]; + var descriptor = Object.getOwnPropertyDescriptor(parent, symbol); + if (descriptor && !descriptor.enumerable && !includeNonEnumerable) { + continue; + } + child[symbol] = _clone(parent[symbol], depth - 1); + if (!descriptor.enumerable) { + Object.defineProperty(child, symbol, { + enumerable: false + }); + } + } + } + + if (includeNonEnumerable) { + var allPropertyNames = Object.getOwnPropertyNames(parent); + for (var i = 0; i < allPropertyNames.length; i++) { + var propertyName = allPropertyNames[i]; + var descriptor = Object.getOwnPropertyDescriptor(parent, propertyName); + if (descriptor && descriptor.enumerable) { + continue; + } + child[propertyName] = _clone(parent[propertyName], depth - 1); + Object.defineProperty(child, propertyName, { + enumerable: false + }); + } + } + return child; } @@ -132,22 +223,22 @@ clone.clonePrototype = function clonePrototype(parent) { function __objToStr(o) { return Object.prototype.toString.call(o); -}; +} clone.__objToStr = __objToStr; function __isDate(o) { return typeof o === 'object' && __objToStr(o) === '[object Date]'; -}; +} clone.__isDate = __isDate; function __isArray(o) { return typeof o === 'object' && __objToStr(o) === '[object Array]'; -}; +} clone.__isArray = __isArray; function __isRegExp(o) { return typeof o === 'object' && __objToStr(o) === '[object RegExp]'; -}; +} clone.__isRegExp = __isRegExp; function __getRegExpFlags(re) { @@ -156,7 +247,7 @@ function __getRegExpFlags(re) { if (re.ignoreCase) flags += 'i'; if (re.multiline) flags += 'm'; return flags; -}; +} clone.__getRegExpFlags = __getRegExpFlags; return clone; @@ -167,25 +258,141 @@ if (typeof module === 'object' && module.exports) { } }).call(this,require("buffer").Buffer) -},{"buffer":3}],3:[function(require,module,exports){ +},{"buffer":4}],3:[function(require,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return b64.length * 3 / 4 - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr(len * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],4:[function(require,module,exports){ +(function (global){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ +/* eslint-disable no-proto */ + +'use strict' var base64 = require('base64-js') var ieee754 = require('ieee754') -var isArray = require('is-array') +var isArray = require('isarray') exports.Buffer = Buffer exports.SlowBuffer = SlowBuffer exports.INSPECT_MAX_BYTES = 50 -Buffer.poolSize = 8192 // not used by this implementation - -var kMaxLength = 0x3fffffff -var rootParent = {} /** * If `Buffer.TYPED_ARRAY_SUPPORT`: @@ -195,144 +402,346 @@ var rootParent = {} * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, * Opera 11.6+, iOS 4.2+. * - * Note: + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. * - * - Implementation must support adding new properties to `Uint8Array` instances. - * Firefox 4-29 lacked support, fixed in Firefox 30+. - * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * Note: * - * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. * - * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of - * incorrect length in some situations. + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. * - * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they will - * get the Object implementation, which is slower but will work correctly. + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. */ -Buffer.TYPED_ARRAY_SUPPORT = (function () { +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { try { - var buf = new ArrayBuffer(0) - var arr = new Uint8Array(buf) - arr.foo = function () { return 42 } - return 42 === arr.foo() && // typed array instances can be augmented + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` - new Uint8Array(1).subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` } catch (e) { return false } -})() +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} /** - * Class: Buffer - * ============= - * - * The Buffer constructor returns instances of `Uint8Array` that are augmented - * with function properties for all the node `Buffer` API functions. We use - * `Uint8Array` so that square bracket notation works as expected -- it returns - * a single octet. + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. * - * By augmenting the instances, we can avoid modifying the `Uint8Array` - * prototype. + * The `Uint8Array` prototype remains unmodified. */ -function Buffer (subject, encoding, noZero) { - if (!(this instanceof Buffer)) - return new Buffer(subject, encoding, noZero) - - var type = typeof subject - - // Find the length - var length - if (type === 'number') - length = subject > 0 ? subject >>> 0 : 0 - else if (type === 'string') { - length = Buffer.byteLength(subject, encoding) - } else if (type === 'object' && subject !== null) { // assume object is array-like - if (subject.type === 'Buffer' && isArray(subject.data)) - subject = subject.data - length = +subject.length > 0 ? Math.floor(+subject.length) : 0 - } else - throw new TypeError('must start with number, buffer, array or string') - - if (length > kMaxLength) - throw new RangeError('Attempt to allocate Buffer larger than maximum ' + - 'size: 0x' + kMaxLength.toString(16) + ' bytes') - var buf +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + if (Buffer.TYPED_ARRAY_SUPPORT) { - // Preferred: Return an augmented `Uint8Array` instance for best performance - buf = Buffer._augment(new Uint8Array(length)) + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype } else { - // Fallback: Return THIS instance of Buffer (created by `new`) - buf = this - buf.length = length - buf._isBuffer = true + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) } + return that +} - var i - if (Buffer.TYPED_ARRAY_SUPPORT && typeof subject.byteLength === 'number') { - // Speed optimization -- use set if we're copying from a typed array - buf._set(subject) - } else if (isArrayish(subject)) { - // Treat array-ish objects as a byte array - if (Buffer.isBuffer(subject)) { - for (i = 0; i < length; i++) - buf[i] = subject.readUInt8(i) - } else { - for (i = 0; i < length; i++) - buf[i] = ((subject[i] % 256) + 256) % 256 - } - } else if (type === 'string') { - buf.write(subject, 0, encoding) - } else if (type === 'number' && !Buffer.TYPED_ARRAY_SUPPORT && !noZero) { - for (i = 0; i < length; i++) { - buf[i] = 0 +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that } + + obj.copy(that, 0, 0, len) + return that } - if (length > 0 && length <= Buffer.poolSize) - buf.parent = rootParent + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } - return buf + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') } -function SlowBuffer(subject, encoding, noZero) { - if (!(this instanceof SlowBuffer)) - return new SlowBuffer(subject, encoding, noZero) +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} - var buf = new Buffer(subject, encoding, noZero) - delete buf.parent - return buf +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) } -Buffer.isBuffer = function (b) { +Buffer.isBuffer = function isBuffer (b) { return !!(b != null && b._isBuffer) } -Buffer.compare = function (a, b) { - if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 var x = a.length var y = b.length - for (var i = 0, len = Math.min(x, y); i < len && a[i] === b[i]; i++) {} - if (i !== len) { - x = a[i] - y = b[i] + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } } + if (x < y) return -1 if (y < x) return 1 return 0 } -Buffer.isEncoding = function (encoding) { +Buffer.isEncoding = function isEncoding (encoding) { switch (String(encoding).toLowerCase()) { case 'hex': case 'utf8': case 'utf-8': case 'ascii': + case 'latin1': case 'binary': case 'base64': - case 'raw': case 'ucs2': case 'ucs-2': case 'utf16le': @@ -343,79 +752,117 @@ Buffer.isEncoding = function (encoding) { } } -Buffer.concat = function (list, totalLength) { - if (!isArray(list)) throw new TypeError('Usage: Buffer.concat(list[, length])') +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } if (list.length === 0) { - return new Buffer(0) - } else if (list.length === 1) { - return list[0] + return Buffer.alloc(0) } var i - if (totalLength === undefined) { - totalLength = 0 - for (i = 0; i < list.length; i++) { - totalLength += list[i].length + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length } } - var buf = new Buffer(totalLength) + var buffer = Buffer.allocUnsafe(length) var pos = 0 - for (i = 0; i < list.length; i++) { - var item = list[i] - item.copy(buf, pos) - pos += item.length + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length } - return buf + return buffer } -Buffer.byteLength = function (str, encoding) { - var ret - str = str + '' - switch (encoding || 'utf8') { - case 'ascii': - case 'binary': - case 'raw': - ret = str.length - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = str.length * 2 - break - case 'hex': - ret = str.length >>> 1 - break - case 'utf8': - case 'utf-8': - ret = utf8ToBytes(str).length - break - case 'base64': - ret = base64ToBytes(str).length - break - default: - ret = str.length +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length } - return ret -} + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 -// pre-set for values that may exist in the future -Buffer.prototype.length = undefined -Buffer.prototype.parent = undefined + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength -// toString(encoding, start=0, end=buffer.length) -Buffer.prototype.toString = function (encoding, start, end) { +function slowToString (encoding, start, end) { var loweredCase = false - start = start >>> 0 - end = end === undefined || end === Infinity ? this.length : end >>> 0 + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } if (!encoding) encoding = 'utf8' - if (start < 0) start = 0 - if (end > this.length) end = this.length - if (end <= start) return '' while (true) { switch (encoding) { @@ -426,61 +873,291 @@ Buffer.prototype.toString = function (encoding, start, end) { case 'utf-8': return utf8Slice(this, start, end) - case 'ascii': - return asciiSlice(this, start, end) + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} - case 'binary': - return binarySlice(this, start, end) +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } - case 'base64': - return base64Slice(this, start, end) + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - return utf16leSlice(this, start, end) + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } - default: - if (loweredCase) - throw new TypeError('Unknown encoding: ' + encoding) - encoding = (encoding + '').toLowerCase() - loweredCase = true + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) } -} -Buffer.prototype.equals = function (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - return Buffer.compare(this, b) === 0 + throw new TypeError('val must be string, number or Buffer') } -Buffer.prototype.inspect = function () { - var str = '' - var max = exports.INSPECT_MAX_BYTES - if (this.length > 0) { - str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') - if (this.length > max) - str += ' ... ' +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } } - return '' + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 } -Buffer.prototype.compare = function (b) { - if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') - return Buffer.compare(this, b) +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 } -// `get` will be removed in Node 0.13+ -Buffer.prototype.get = function (offset) { - console.log('.get() is deprecated. Access using array indexes instead.') - return this.readUInt8(offset) +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) } -// `set` will be removed in Node 0.13+ -Buffer.prototype.set = function (v, offset) { - console.log('.set() is deprecated. Access using array indexes instead.') - return this.writeUInt8(v, offset) +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) } function hexWrite (buf, string, offset, length) { @@ -497,105 +1174,112 @@ function hexWrite (buf, string, offset, length) { // must be an even number of digits var strLen = string.length - if (strLen % 2 !== 0) throw new Error('Invalid hex string') + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') if (length > strLen / 2) { length = strLen / 2 } - for (var i = 0; i < length; i++) { - var byte = parseInt(string.substr(i * 2, 2), 16) - if (isNaN(byte)) throw new Error('Invalid hex string') - buf[offset + i] = byte + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed } return i } function utf8Write (buf, string, offset, length) { - var charsWritten = blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) - return charsWritten + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) } function asciiWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(asciiToBytes(string), buf, offset, length) - return charsWritten + return blitBuffer(asciiToBytes(string), buf, offset, length) } -function binaryWrite (buf, string, offset, length) { +function latin1Write (buf, string, offset, length) { return asciiWrite(buf, string, offset, length) } function base64Write (buf, string, offset, length) { - var charsWritten = blitBuffer(base64ToBytes(string), buf, offset, length) - return charsWritten + return blitBuffer(base64ToBytes(string), buf, offset, length) } -function utf16leWrite (buf, string, offset, length) { - var charsWritten = blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length, 2) - return charsWritten +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) } -Buffer.prototype.write = function (string, offset, length, encoding) { - // Support both (string, offset, length, encoding) - // and the legacy (string, encoding, offset, length) - if (isFinite(offset)) { - if (!isFinite(length)) { +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { encoding = length length = undefined } - } else { // legacy - var swap = encoding - encoding = offset - offset = length - length = swap + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) } - offset = Number(offset) || 0 - - if (length < 0 || offset < 0 || offset > this.length) - throw new RangeError('attempt to write outside buffer bounds'); - var remaining = this.length - offset - if (!length) { - length = remaining - } else { - length = Number(length) - if (length > remaining) { - length = remaining - } + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') } - encoding = String(encoding || 'utf8').toLowerCase() - var ret - switch (encoding) { - case 'hex': - ret = hexWrite(this, string, offset, length) - break - case 'utf8': - case 'utf-8': - ret = utf8Write(this, string, offset, length) - break - case 'ascii': - ret = asciiWrite(this, string, offset, length) - break - case 'binary': - ret = binaryWrite(this, string, offset, length) - break - case 'base64': - ret = base64Write(this, string, offset, length) - break - case 'ucs2': - case 'ucs-2': - case 'utf16le': - case 'utf-16le': - ret = utf16leWrite(this, string, offset, length) - break - default: - throw new TypeError('Unknown encoding: ' + encoding) + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } } - return ret } -Buffer.prototype.toJSON = function () { +Buffer.prototype.toJSON = function toJSON () { return { type: 'Buffer', data: Array.prototype.slice.call(this._arr || this, 0) @@ -611,37 +1295,116 @@ function base64Slice (buf, start, end) { } function utf8Slice (buf, start, end) { - var res = '' - var tmp = '' end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } - for (var i = start; i < end; i++) { - if (buf[i] <= 0x7F) { - res += decodeUtf8Char(tmp) + String.fromCharCode(buf[i]) - tmp = '' - } else { - tmp += '%' + buf[i].toString(16) + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() } - return res + decodeUtf8Char(tmp) + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res } function asciiSlice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i] & 0x7F) } return ret } -function binarySlice (buf, start, end) { +function latin1Slice (buf, start, end) { var ret = '' end = Math.min(buf.length, end) - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { ret += String.fromCharCode(buf[i]) } return ret @@ -654,7 +1417,7 @@ function hexSlice (buf, start, end) { if (!end || end < 0 || end > len) end = len var out = '' - for (var i = start; i < end; i++) { + for (var i = start; i < end; ++i) { out += toHex(buf[i]) } return out @@ -669,44 +1432,39 @@ function utf16leSlice (buf, start, end) { return res } -Buffer.prototype.slice = function (start, end) { +Buffer.prototype.slice = function slice (start, end) { var len = this.length start = ~~start end = end === undefined ? len : ~~end if (start < 0) { - start += len; - if (start < 0) - start = 0 + start += len + if (start < 0) start = 0 } else if (start > len) { start = len } if (end < 0) { end += len - if (end < 0) - end = 0 + if (end < 0) end = 0 } else if (end > len) { end = len } - if (end < start) - end = start + if (end < start) end = start var newBuf if (Buffer.TYPED_ARRAY_SUPPORT) { - newBuf = Buffer._augment(this.subarray(start, end)) + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype } else { var sliceLen = end - start - newBuf = new Buffer(sliceLen, undefined, true) - for (var i = 0; i < sliceLen; i++) { + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { newBuf[i] = this[i + start] } } - if (newBuf.length) - newBuf.parent = this.parent || this - return newBuf } @@ -714,62 +1472,58 @@ Buffer.prototype.slice = function (start, end) { * Need to make sure that buffer isn't trying to write out of bounds. */ function checkOffset (offset, ext, length) { - if ((offset % 1) !== 0 || offset < 0) - throw new RangeError('offset is not uint') - if (offset + ext > length) - throw new RangeError('Trying to access beyond buffer length') + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') } -Buffer.prototype.readUIntLE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul + } return val } -Buffer.prototype.readUIntBE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { checkOffset(offset, byteLength, this.length) + } var val = this[offset + --byteLength] var mul = 1 - while (byteLength > 0 && (mul *= 0x100)) - val += this[offset + --byteLength] * mul; + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } return val } -Buffer.prototype.readUInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) return this[offset] } -Buffer.prototype.readUInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) return this[offset] | (this[offset + 1] << 8) } -Buffer.prototype.readUInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) return (this[offset] << 8) | this[offset + 1] } -Buffer.prototype.readUInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ((this[offset]) | (this[offset + 1] << 8) | @@ -777,541 +1531,497 @@ Buffer.prototype.readUInt32LE = function (offset, noAssert) { (this[offset + 3] * 0x1000000) } -Buffer.prototype.readUInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] * 0x1000000) + - ((this[offset + 1] << 16) | - (this[offset + 2] << 8) | - this[offset + 3]) + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) } -Buffer.prototype.readIntLE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var val = this[offset] var mul = 1 var i = 0 - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { val += this[offset + i] * mul + } mul *= 0x80 - if (val >= mul) - val -= Math.pow(2, 8 * byteLength) + if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } -Buffer.prototype.readIntBE = function (offset, byteLength, noAssert) { - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkOffset(offset, byteLength, this.length) +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) var i = byteLength var mul = 1 var val = this[offset + --i] - while (i > 0 && (mul *= 0x100)) + while (i > 0 && (mul *= 0x100)) { val += this[offset + --i] * mul + } mul *= 0x80 - if (val >= mul) - val -= Math.pow(2, 8 * byteLength) + if (val >= mul) val -= Math.pow(2, 8 * byteLength) return val } -Buffer.prototype.readInt8 = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 1, this.length) - if (!(this[offset] & 0x80)) - return (this[offset]) +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) return ((0xff - this[offset] + 1) * -1) } -Buffer.prototype.readInt16LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset] | (this[offset + 1] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } -Buffer.prototype.readInt16BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 2, this.length) +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) var val = this[offset + 1] | (this[offset] << 8) return (val & 0x8000) ? val | 0xFFFF0000 : val } -Buffer.prototype.readInt32LE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset]) | - (this[offset + 1] << 8) | - (this[offset + 2] << 16) | - (this[offset + 3] << 24) + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) } -Buffer.prototype.readInt32BE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return (this[offset] << 24) | - (this[offset + 1] << 16) | - (this[offset + 2] << 8) | - (this[offset + 3]) + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) } -Buffer.prototype.readFloatLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, true, 23, 4) } -Buffer.prototype.readFloatBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 4, this.length) +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) return ieee754.read(this, offset, false, 23, 4) } -Buffer.prototype.readDoubleLE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, true, 52, 8) } -Buffer.prototype.readDoubleBE = function (offset, noAssert) { - if (!noAssert) - checkOffset(offset, 8, this.length) +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) return ieee754.read(this, offset, false, 52, 8) } function checkInt (buf, value, offset, ext, max, min) { - if (!Buffer.isBuffer(buf)) throw new TypeError('buffer must be a Buffer instance') - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') } -Buffer.prototype.writeUIntLE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var mul = 1 var i = 0 this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) - this[offset + i] = (value / mul) >>> 0 & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } return offset + byteLength } -Buffer.prototype.writeUIntBE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 - byteLength = byteLength >>> 0 - if (!noAssert) - checkInt(this, value, offset, byteLength, Math.pow(2, 8 * byteLength), 0) + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } var i = byteLength - 1 var mul = 1 this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) - this[offset + i] = (value / mul) >>> 0 & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } return offset + byteLength } -Buffer.prototype.writeUInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0xff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) - this[offset] = value + this[offset] = (value & 0xff) return offset + 1 } function objectWriteUInt16 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> (littleEndian ? i : 1 - i) * 8 } } -Buffer.prototype.writeUInt16LE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) + } else { + objectWriteUInt16(this, value, offset, true) + } return offset + 2 } -Buffer.prototype.writeUInt16BE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0xffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) - this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } return offset + 2 } function objectWriteUInt32 (buf, value, offset, littleEndian) { if (value < 0) value = 0xffffffff + value + 1 - for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; i++) { + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff } } -Buffer.prototype.writeUInt32LE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset + 3] = (value >>> 24) this[offset + 2] = (value >>> 16) this[offset + 1] = (value >>> 8) - this[offset] = value - } else objectWriteUInt32(this, value, offset, true) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } return offset + 4 } -Buffer.prototype.writeUInt32BE = function (value, offset, noAssert) { +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0xffffffff, 0) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } return offset + 4 } -Buffer.prototype.writeIntLE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 + offset = offset | 0 if (!noAssert) { - checkInt(this, - value, - offset, - byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1)) + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = 0 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset] = value & 0xFF - while (++i < byteLength && (mul *= 0x100)) + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } return offset + byteLength } -Buffer.prototype.writeIntBE = function (value, offset, byteLength, noAssert) { +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { value = +value - offset = offset >>> 0 + offset = offset | 0 if (!noAssert) { - checkInt(this, - value, - offset, - byteLength, - Math.pow(2, 8 * byteLength - 1) - 1, - -Math.pow(2, 8 * byteLength - 1)) + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) } var i = byteLength - 1 var mul = 1 - var sub = value < 0 ? 1 : 0 + var sub = 0 this[offset + i] = value & 0xFF - while (--i >= 0 && (mul *= 0x100)) + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } return offset + byteLength } -Buffer.prototype.writeInt8 = function (value, offset, noAssert) { +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 1, 0x7f, -0x80) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) if (value < 0) value = 0xff + value + 1 - this[offset] = value + this[offset] = (value & 0xff) return offset + 1 } -Buffer.prototype.writeInt16LE = function (value, offset, noAssert) { +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) - } else objectWriteUInt16(this, value, offset, true) + } else { + objectWriteUInt16(this, value, offset, true) + } return offset + 2 } -Buffer.prototype.writeInt16BE = function (value, offset, noAssert) { +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 2, 0x7fff, -0x8000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 8) - this[offset + 1] = value - } else objectWriteUInt16(this, value, offset, false) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } return offset + 2 } -Buffer.prototype.writeInt32LE = function (value, offset, noAssert) { +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (Buffer.TYPED_ARRAY_SUPPORT) { - this[offset] = value + this[offset] = (value & 0xff) this[offset + 1] = (value >>> 8) this[offset + 2] = (value >>> 16) this[offset + 3] = (value >>> 24) - } else objectWriteUInt32(this, value, offset, true) + } else { + objectWriteUInt32(this, value, offset, true) + } return offset + 4 } -Buffer.prototype.writeInt32BE = function (value, offset, noAssert) { +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { value = +value - offset = offset >>> 0 - if (!noAssert) - checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) if (value < 0) value = 0xffffffff + value + 1 if (Buffer.TYPED_ARRAY_SUPPORT) { this[offset] = (value >>> 24) this[offset + 1] = (value >>> 16) this[offset + 2] = (value >>> 8) - this[offset + 3] = value - } else objectWriteUInt32(this, value, offset, false) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } return offset + 4 } function checkIEEE754 (buf, value, offset, ext, max, min) { - if (value > max || value < min) throw new RangeError('value is out of bounds') - if (offset + ext > buf.length) throw new RangeError('index out of range') - if (offset < 0) throw new RangeError('index out of range') + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') } function writeFloat (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) + if (!noAssert) { checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } ieee754.write(buf, value, offset, littleEndian, 23, 4) return offset + 4 } -Buffer.prototype.writeFloatLE = function (value, offset, noAssert) { +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { return writeFloat(this, value, offset, true, noAssert) } -Buffer.prototype.writeFloatBE = function (value, offset, noAssert) { +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { return writeFloat(this, value, offset, false, noAssert) } function writeDouble (buf, value, offset, littleEndian, noAssert) { - if (!noAssert) + if (!noAssert) { checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } ieee754.write(buf, value, offset, littleEndian, 52, 8) return offset + 8 } -Buffer.prototype.writeDoubleLE = function (value, offset, noAssert) { +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { return writeDouble(this, value, offset, true, noAssert) } -Buffer.prototype.writeDoubleBE = function (value, offset, noAssert) { +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { return writeDouble(this, value, offset, false, noAssert) } // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) -Buffer.prototype.copy = function (target, target_start, start, end) { - var source = this - +Buffer.prototype.copy = function copy (target, targetStart, start, end) { if (!start) start = 0 if (!end && end !== 0) end = this.length - if (target_start >= target.length) target_start = target.length - if (!target_start) target_start = 0 + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 if (end > 0 && end < start) end = start // Copy 0 bytes; we're done if (end === start) return 0 - if (target.length === 0 || source.length === 0) return 0 + if (target.length === 0 || this.length === 0) return 0 // Fatal error conditions - if (target_start < 0) + if (targetStart < 0) { throw new RangeError('targetStart out of bounds') - if (start < 0 || start >= source.length) throw new RangeError('sourceStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') if (end < 0) throw new RangeError('sourceEnd out of bounds') // Are we oob? - if (end > this.length) - end = this.length - if (target.length - target_start < end - start) - end = target.length - target_start + start + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } var len = end - start + var i - if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { - for (var i = 0; i < len; i++) { - target[i + target_start] = this[i + start] + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] } } else { - target._set(this.subarray(start, start + len), target_start) + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) } return len } -// fill(value, start=0, end=buffer.length) -Buffer.prototype.fill = function (value, start, end) { - if (!value) value = 0 - if (!start) start = 0 - if (!end) end = this.length +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } - if (end < start) throw new RangeError('end < start') + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } - // Fill 0 bytes; we're done - if (end === start) return - if (this.length === 0) return + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 - if (start < 0 || start >= this.length) throw new RangeError('start out of bounds') - if (end < 0 || end > this.length) throw new RangeError('end out of bounds') + if (!val) val = 0 var i - if (typeof value === 'number') { - for (i = start; i < end; i++) { - this[i] = value + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val } } else { - var bytes = utf8ToBytes(value.toString()) + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) var len = bytes.length - for (i = start; i < end; i++) { - this[i] = bytes[i % len] + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] } } return this } -/** - * Creates a new `ArrayBuffer` with the *copied* memory of the buffer instance. - * Added in Node 0.12. Only available in browsers that support ArrayBuffer. - */ -Buffer.prototype.toArrayBuffer = function () { - if (typeof Uint8Array !== 'undefined') { - if (Buffer.TYPED_ARRAY_SUPPORT) { - return (new Buffer(this)).buffer - } else { - var buf = new Uint8Array(this.length) - for (var i = 0, len = buf.length; i < len; i += 1) { - buf[i] = this[i] - } - return buf.buffer - } - } else { - throw new TypeError('Buffer.toArrayBuffer not supported in this browser') - } -} - // HELPER FUNCTIONS // ================ -var BP = Buffer.prototype - -/** - * Augment a Uint8Array *instance* (not the Uint8Array class!) with Buffer methods - */ -Buffer._augment = function (arr) { - arr.constructor = Buffer - arr._isBuffer = true - - // save reference to original Uint8Array get/set methods before overwriting - arr._get = arr.get - arr._set = arr.set - - // deprecated, will be removed in node 0.13+ - arr.get = BP.get - arr.set = BP.set - - arr.write = BP.write - arr.toString = BP.toString - arr.toLocaleString = BP.toString - arr.toJSON = BP.toJSON - arr.equals = BP.equals - arr.compare = BP.compare - arr.copy = BP.copy - arr.slice = BP.slice - arr.readUIntLE = BP.readUIntLE - arr.readUIntBE = BP.readUIntBE - arr.readUInt8 = BP.readUInt8 - arr.readUInt16LE = BP.readUInt16LE - arr.readUInt16BE = BP.readUInt16BE - arr.readUInt32LE = BP.readUInt32LE - arr.readUInt32BE = BP.readUInt32BE - arr.readIntLE = BP.readIntLE - arr.readIntBE = BP.readIntBE - arr.readInt8 = BP.readInt8 - arr.readInt16LE = BP.readInt16LE - arr.readInt16BE = BP.readInt16BE - arr.readInt32LE = BP.readInt32LE - arr.readInt32BE = BP.readInt32BE - arr.readFloatLE = BP.readFloatLE - arr.readFloatBE = BP.readFloatBE - arr.readDoubleLE = BP.readDoubleLE - arr.readDoubleBE = BP.readDoubleBE - arr.writeUInt8 = BP.writeUInt8 - arr.writeUIntLE = BP.writeUIntLE - arr.writeUIntBE = BP.writeUIntBE - arr.writeUInt16LE = BP.writeUInt16LE - arr.writeUInt16BE = BP.writeUInt16BE - arr.writeUInt32LE = BP.writeUInt32LE - arr.writeUInt32BE = BP.writeUInt32BE - arr.writeIntLE = BP.writeIntLE - arr.writeIntBE = BP.writeIntBE - arr.writeInt8 = BP.writeInt8 - arr.writeInt16LE = BP.writeInt16LE - arr.writeInt16BE = BP.writeInt16BE - arr.writeInt32LE = BP.writeInt32LE - arr.writeInt32BE = BP.writeInt32BE - arr.writeFloatLE = BP.writeFloatLE - arr.writeFloatBE = BP.writeFloatBE - arr.writeDoubleLE = BP.writeDoubleLE - arr.writeDoubleBE = BP.writeDoubleBE - arr.fill = BP.fill - arr.inspect = BP.inspect - arr.toArrayBuffer = BP.toArrayBuffer - - return arr -} - -var INVALID_BASE64_RE = /[^+\/0-9A-z\-]/g +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g function base64clean (str) { // Node strips out invalid characters like \n and \t from the string, base64-js does not @@ -1330,106 +2040,84 @@ function stringtrim (str) { return str.replace(/^\s+|\s+$/g, '') } -function isArrayish (subject) { - return isArray(subject) || Buffer.isBuffer(subject) || - subject && typeof subject === 'object' && - typeof subject.length === 'number' -} - function toHex (n) { if (n < 16) return '0' + n.toString(16) return n.toString(16) } -function utf8ToBytes(string, units) { - var codePoint, length = string.length - var leadSurrogate = null +function utf8ToBytes (string, units) { units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null var bytes = [] - var i = 0 - for (; i 0xD7FF && codePoint < 0xE000) { - // last char was a lead - if (leadSurrogate) { - - // 2 leads in a row - if (codePoint < 0xDC00) { - if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = codePoint - continue - } - - // valid surrogate pair - else { - codePoint = leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00 | 0x10000 - leadSurrogate = null - } - } - - // no lead yet - else { - - // unexpected trail + if (!leadSurrogate) { + // no lead yet if (codePoint > 0xDBFF) { + // unexpected trail if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue - } - - // unpaired lead - else if (i + 1 === length) { + } else if (i + 1 === length) { + // unpaired lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) continue } // valid lead - else { - leadSurrogate = codePoint - continue - } + leadSurrogate = codePoint + + continue } - } - // valid bmp char, but last char was a lead - else if (leadSurrogate) { + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) - leadSurrogate = null } + leadSurrogate = null + // encode utf8 if (codePoint < 0x80) { if ((units -= 1) < 0) break bytes.push(codePoint) - } - else if (codePoint < 0x800) { + } else if (codePoint < 0x800) { if ((units -= 2) < 0) break bytes.push( codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x10000) { + ) + } else if (codePoint < 0x10000) { if ((units -= 3) < 0) break bytes.push( codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else if (codePoint < 0x200000) { + ) + } else if (codePoint < 0x110000) { if ((units -= 4) < 0) break bytes.push( codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80 - ); - } - else { + ) + } else { throw new Error('Invalid code point') } } @@ -1439,7 +2127,7 @@ function utf8ToBytes(string, units) { function asciiToBytes (str) { var byteArray = [] - for (var i = 0; i < str.length; i++) { + for (var i = 0; i < str.length; ++i) { // Node's code seems to be doing this and not & 0x7F.. byteArray.push(str.charCodeAt(i) & 0xFF) } @@ -1449,8 +2137,7 @@ function asciiToBytes (str) { function utf16leToBytes (str, units) { var c, hi, lo var byteArray = [] - for (var i = 0; i < str.length; i++) { - + for (var i = 0; i < str.length; ++i) { if ((units -= 2) < 0) break c = str.charCodeAt(i) @@ -1467,269 +2154,110 @@ function base64ToBytes (str) { return base64.toByteArray(base64clean(str)) } -function blitBuffer (src, dst, offset, length, unitSize) { - if (unitSize) length -= length % unitSize; - for (var i = 0; i < length; i++) { - if ((i + offset >= dst.length) || (i >= src.length)) - break +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break dst[i + offset] = src[i] } return i } -function decodeUtf8Char (str) { - try { - return decodeURIComponent(str) - } catch (err) { - return String.fromCharCode(0xFFFD) // UTF 8 invalid char - } -} - -},{"base64-js":4,"ieee754":5,"is-array":6}],4:[function(require,module,exports){ -var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; - -;(function (exports) { - 'use strict'; - - var Arr = (typeof Uint8Array !== 'undefined') - ? Uint8Array - : Array - - var PLUS = '+'.charCodeAt(0) - var SLASH = '/'.charCodeAt(0) - var NUMBER = '0'.charCodeAt(0) - var LOWER = 'a'.charCodeAt(0) - var UPPER = 'A'.charCodeAt(0) - var PLUS_URL_SAFE = '-'.charCodeAt(0) - var SLASH_URL_SAFE = '_'.charCodeAt(0) - - function decode (elt) { - var code = elt.charCodeAt(0) - if (code === PLUS || - code === PLUS_URL_SAFE) - return 62 // '+' - if (code === SLASH || - code === SLASH_URL_SAFE) - return 63 // '/' - if (code < NUMBER) - return -1 //no match - if (code < NUMBER + 10) - return code - NUMBER + 26 + 26 - if (code < UPPER + 26) - return code - UPPER - if (code < LOWER + 26) - return code - LOWER + 26 - } - - function b64ToByteArray (b64) { - var i, j, l, tmp, placeHolders, arr - - if (b64.length % 4 > 0) { - throw new Error('Invalid string. Length must be a multiple of 4') - } - - // the number of equal signs (place holders) - // if there are two placeholders, than the two characters before it - // represent one byte - // if there is only one, then the three characters before it represent 2 bytes - // this is just a cheap hack to not do indexOf twice - var len = b64.length - placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0 - - // base64 is 4/3 + up to two characters of the original data - arr = new Arr(b64.length * 3 / 4 - placeHolders) - - // if there are placeholders, only get up to the last complete 4 chars - l = placeHolders > 0 ? b64.length - 4 : b64.length - - var L = 0 - - function push (v) { - arr[L++] = v - } - - for (i = 0, j = 0; i < l; i += 4, j += 3) { - tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3)) - push((tmp & 0xFF0000) >> 16) - push((tmp & 0xFF00) >> 8) - push(tmp & 0xFF) - } - - if (placeHolders === 2) { - tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4) - push(tmp & 0xFF) - } else if (placeHolders === 1) { - tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2) - push((tmp >> 8) & 0xFF) - push(tmp & 0xFF) - } - - return arr - } - - function uint8ToBase64 (uint8) { - var i, - extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes - output = "", - temp, length - - function encode (num) { - return lookup.charAt(num) - } - - function tripletToBase64 (num) { - return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) - } - - // go through the array every three bytes, we'll deal with trailing stuff later - for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) { - temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) - output += tripletToBase64(temp) - } - - // pad the end with zeros, but make sure to not forget the extra bytes - switch (extraBytes) { - case 1: - temp = uint8[uint8.length - 1] - output += encode(temp >> 2) - output += encode((temp << 4) & 0x3F) - output += '==' - break - case 2: - temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) - output += encode(temp >> 10) - output += encode((temp >> 4) & 0x3F) - output += encode((temp << 2) & 0x3F) - output += '=' - break - } - - return output - } - - exports.toByteArray = b64ToByteArray - exports.fromByteArray = uint8ToBase64 -}(typeof exports === 'undefined' ? (this.base64js = {}) : exports)) - -},{}],5:[function(require,module,exports){ -exports.read = function(buffer, offset, isLE, mLen, nBytes) { - var e, m, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - nBits = -7, - i = isLE ? (nBytes - 1) : 0, - d = isLE ? -1 : 1, - s = buffer[offset + i]; - - i += d; - - e = s & ((1 << (-nBits)) - 1); - s >>= (-nBits); - nBits += eLen; - for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8); - - m = e & ((1 << (-nBits)) - 1); - e >>= (-nBits); - nBits += mLen; - for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8); +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"base64-js":3,"ieee754":5,"isarray":6}],5:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} if (e === 0) { - e = 1 - eBias; + e = 1 - eBias } else if (e === eMax) { - return m ? NaN : ((s ? -1 : 1) * Infinity); + return m ? NaN : ((s ? -1 : 1) * Infinity) } else { - m = m + Math.pow(2, mLen); - e = e - eBias; + m = m + Math.pow(2, mLen) + e = e - eBias } - return (s ? -1 : 1) * m * Math.pow(2, e - mLen); -}; + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} -exports.write = function(buffer, value, offset, isLE, mLen, nBytes) { - var e, m, c, - eLen = nBytes * 8 - mLen - 1, - eMax = (1 << eLen) - 1, - eBias = eMax >> 1, - rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0), - i = isLE ? 0 : (nBytes - 1), - d = isLE ? 1 : -1, - s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0; +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 - value = Math.abs(value); + value = Math.abs(value) if (isNaN(value) || value === Infinity) { - m = isNaN(value) ? 1 : 0; - e = eMax; + m = isNaN(value) ? 1 : 0 + e = eMax } else { - e = Math.floor(Math.log(value) / Math.LN2); + e = Math.floor(Math.log(value) / Math.LN2) if (value * (c = Math.pow(2, -e)) < 1) { - e--; - c *= 2; + e-- + c *= 2 } if (e + eBias >= 1) { - value += rt / c; + value += rt / c } else { - value += rt * Math.pow(2, 1 - eBias); + value += rt * Math.pow(2, 1 - eBias) } if (value * c >= 2) { - e++; - c /= 2; + e++ + c /= 2 } if (e + eBias >= eMax) { - m = 0; - e = eMax; + m = 0 + e = eMax } else if (e + eBias >= 1) { - m = (value * c - 1) * Math.pow(2, mLen); - e = e + eBias; + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias } else { - m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen); - e = 0; + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 } } - for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8); + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} - e = (e << mLen) | m; - eLen += mLen; - for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8); + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} - buffer[offset + i - d] |= s * 128; -}; + buffer[offset + i - d] |= s * 128 +} },{}],6:[function(require,module,exports){ +var toString = {}.toString; -/** - * isArray - */ - -var isArray = Array.isArray; - -/** - * toString - */ - -var str = Object.prototype.toString; - -/** - * Whether or not the given `val` - * is an array. - * - * example: - * - * isArray([]); - * // > true - * isArray(arguments); - * // > false - * isArray(''); - * // > false - * - * @param {mixed} val - * @return {bool} - */ - -module.exports = isArray || function (val) { - return !! val && '[object Array]' == str.call(val); +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; }; },{}]},{},[1]); diff --git a/inst/js/geojson_random.js b/inst/js/geojson_random.js index 8bd270c..34ebcb5 100644 --- a/inst/js/geojson_random.js +++ b/inst/js/geojson_random.js @@ -3,9 +3,229 @@ global.georandom = require('geojson-random'); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"geojson-random":2}],2:[function(require,module,exports){ +},{"geojson-random":4}],2:[function(require,module,exports){ +(function (Buffer){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. + +function isArray(arg) { + if (Array.isArray) { + return Array.isArray(arg); + } + return objectToString(arg) === '[object Array]'; +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; + +function isError(e) { + return (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = Buffer.isBuffer; + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + +}).call(this,{"isBuffer":require("../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js")}) +},{"../../../../../usr/local/lib/node_modules/browserify/node_modules/is-buffer/index.js":21}],3:[function(require,module,exports){ +(function (process){ +var Readable = require('readable-stream').Readable +var inherits = require('inherits') + +module.exports = from2 + +from2.ctor = ctor +from2.obj = obj + +var Proto = ctor() + +function toFunction(list) { + list = list.slice() + return function (_, cb) { + var err = null + var item = list.length ? list.shift() : null + if (item instanceof Error) { + err = item + item = null + } + + cb(err, item) + } +} + +function from2(opts, read) { + if (typeof opts !== 'object' || Array.isArray(opts)) { + read = opts + opts = {} + } + + var rs = new Proto(opts) + rs._from = Array.isArray(read) ? toFunction(read) : (read || noop) + return rs +} + +function ctor(opts, read) { + if (typeof opts === 'function') { + read = opts + opts = {} + } + + opts = defaults(opts) + + inherits(Class, Readable) + function Class(override) { + if (!(this instanceof Class)) return new Class(override) + this._reading = false + this._callback = check + this.destroyed = false + Readable.call(this, override || opts) + + var self = this + var hwm = this._readableState.highWaterMark + + function check(err, data) { + if (self.destroyed) return + if (err) return self.destroy(err) + if (data === null) return self.push(null) + self._reading = false + if (self.push(data)) self._read(hwm) + } + } + + Class.prototype._from = read || noop + Class.prototype._read = function(size) { + if (this._reading || this.destroyed) return + this._reading = true + this._from(size, this._callback) + } + + Class.prototype.destroy = function(err) { + if (this.destroyed) return + this.destroyed = true + + var self = this + process.nextTick(function() { + if (err) self.emit('error', err) + self.emit('close') + }) + } + + return Class +} + +function obj(opts, read) { + if (typeof opts === 'function' || Array.isArray(opts)) { + read = opts + opts = {} + } + + opts = defaults(opts) + opts.objectMode = true + opts.highWaterMark = 16 + + return from2(opts, read) +} + +function noop () {} + +function defaults(opts) { + opts = opts || {} + return opts +} + +}).call(this,require('_process')) +},{"_process":23,"inherits":5,"readable-stream":13}],4:[function(require,module,exports){ +var from = require('from2'); + module.exports = function() { - throw new Error('call .point() or .polygon() instead'); + throw new Error('call .point(), .lineString(), or .polygon() instead'); }; function position(bbox) { @@ -17,12 +237,22 @@ module.exports.position = position; module.exports.point = function(count, bbox) { var features = []; - for (i = 0; i < count; i++) { + for (var i = 0; i < count; i++) { features.push(feature(bbox ? point(position(bbox)) : point())); } return collection(features); }; +module.exports.pointStream = function(count, bbox) { + return from.obj(function(size, next) { + if (--count) { + next(null, feature(bbox ? point(position(bbox)) : point())); + } else { + next(null, null); + } + }); +}; + module.exports.polygon = function(count, num_vertices, max_radial_length, bbox) { if (typeof num_vertices !== 'number') num_vertices = 10; if (typeof max_radial_length !== 'number') max_radial_length = 10; @@ -57,6 +287,35 @@ module.exports.polygon = function(count, num_vertices, max_radial_length, bbox) return collection(features); }; +module.exports.lineString = function(count, num_vertices, max_length, max_rotation, bbox) { + if (typeof num_vertices !== 'number' || num_vertices < 2) num_vertices = 10; + if (typeof max_length !== 'number') max_length = 0.0001; + if (typeof max_rotation !== 'number') max_rotation = Math.PI / 8; + + var features = []; + for (i = 0; i < count; i++) { + var startingPoint = position(bbox); + var vertices = [startingPoint]; + for (var j = 0; j < num_vertices - 1; j++) { + var priorAngle = (j === 0) + ? Math.random() * 2 * Math.PI + : Math.tan( + (vertices[j][1] - vertices[j - 1][1]) / + (vertices[j][0] - vertices[j - 1][0]) + ) + var angle = priorAngle + (Math.random() - 0.5) * max_rotation * 2; + var distance = Math.random() * max_length; + vertices.push([ + vertices[j][0] + distance * Math.cos(angle), + vertices[j][1] + distance * Math.sin(angle) + ]); + } + features.push(feature(lineString(vertices))); + } + + return collection(features); +}; + function vertexToCoordinate(hub) { return function(cur, index) { return [cur[0] + hub[0], cur[1] + hub[1]]; }; @@ -108,4 +367,4592 @@ function collection(f) { }; } +function lineString(coordinates) { + return { + type: 'LineString', + coordinates: coordinates + }; +} + +},{"from2":3}],5:[function(require,module,exports){ +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } +} + +},{}],6:[function(require,module,exports){ +var toString = {}.toString; + +module.exports = Array.isArray || function (arr) { + return toString.call(arr) == '[object Array]'; +}; + +},{}],7:[function(require,module,exports){ +(function (process){ +'use strict'; + +if (!process.version || + process.version.indexOf('v0.') === 0 || + process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) { + module.exports = nextTick; +} else { + module.exports = process.nextTick; +} + +function nextTick(fn, arg1, arg2, arg3) { + if (typeof fn !== 'function') { + throw new TypeError('"callback" argument must be a function'); + } + var len = arguments.length; + var args, i; + switch (len) { + case 0: + case 1: + return process.nextTick(fn); + case 2: + return process.nextTick(function afterTickOne() { + fn.call(null, arg1); + }); + case 3: + return process.nextTick(function afterTickTwo() { + fn.call(null, arg1, arg2); + }); + case 4: + return process.nextTick(function afterTickThree() { + fn.call(null, arg1, arg2, arg3); + }); + default: + args = new Array(len - 1); + i = 0; + while (i < args.length) { + args[i++] = arguments[i]; + } + return process.nextTick(function afterTick() { + fn.apply(null, args); + }); + } +} + +}).call(this,require('_process')) +},{"_process":23}],8:[function(require,module,exports){ +// a duplex stream is just a stream that is both readable and writable. +// Since JS doesn't have multiple prototypal inheritance, this class +// prototypally inherits from Readable, and then parasitically from +// Writable. + +'use strict'; + +/**/ + +var objectKeys = Object.keys || function (obj) { + var keys = []; + for (var key in obj) { + keys.push(key); + }return keys; +}; +/**/ + +module.exports = Duplex; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +var Readable = require('./_stream_readable'); +var Writable = require('./_stream_writable'); + +util.inherits(Duplex, Readable); + +var keys = objectKeys(Writable.prototype); +for (var v = 0; v < keys.length; v++) { + var method = keys[v]; + if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method]; +} + +function Duplex(options) { + if (!(this instanceof Duplex)) return new Duplex(options); + + Readable.call(this, options); + Writable.call(this, options); + + if (options && options.readable === false) this.readable = false; + + if (options && options.writable === false) this.writable = false; + + this.allowHalfOpen = true; + if (options && options.allowHalfOpen === false) this.allowHalfOpen = false; + + this.once('end', onend); +} + +// the no-half-open enforcer +function onend() { + // if we allow half-open state, or if the writable side ended, + // then we're ok. + if (this.allowHalfOpen || this._writableState.ended) return; + + // no more data can be written. + // But allow more writes to happen in this tick. + processNextTick(onEndNT, this); +} + +function onEndNT(self) { + self.end(); +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} +},{"./_stream_readable":10,"./_stream_writable":12,"core-util-is":2,"inherits":5,"process-nextick-args":7}],9:[function(require,module,exports){ +// a passthrough stream. +// basically just the most minimal sort of Transform stream. +// Every written chunk gets output as-is. + +'use strict'; + +module.exports = PassThrough; + +var Transform = require('./_stream_transform'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(PassThrough, Transform); + +function PassThrough(options) { + if (!(this instanceof PassThrough)) return new PassThrough(options); + + Transform.call(this, options); +} + +PassThrough.prototype._transform = function (chunk, encoding, cb) { + cb(null, chunk); +}; +},{"./_stream_transform":11,"core-util-is":2,"inherits":5}],10:[function(require,module,exports){ +(function (process){ +'use strict'; + +module.exports = Readable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var isArray = require('isarray'); +/**/ + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Readable.ReadableState = ReadableState; + +var EE = require('events'); + +/**/ +var EElistenerCount = function (emitter, type) { + return emitter.listeners(type).length; +}; +/**/ + +/**/ +var Stream; +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); +/**/ + +var Buffer = require('buffer').Buffer; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var debugUtil = require('util'); +var debug = undefined; +if (debugUtil && debugUtil.debuglog) { + debug = debugUtil.debuglog('stream'); +} else { + debug = function () {}; +} +/**/ + +var StringDecoder; + +util.inherits(Readable, Stream); + +var Duplex; +function ReadableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag. Used to make read(n) ignore n and to + // make all the buffer merging and length checks go away + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode; + + // the point at which it stops calling _read() to fill the buffer + // Note: 0 is a valid value, means "don't call _read preemptively ever" + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.buffer = []; + this.length = 0; + this.pipes = null; + this.pipesCount = 0; + this.flowing = null; + this.ended = false; + this.endEmitted = false; + this.reading = false; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // whenever we return null, then we set a flag to say + // that we're awaiting a 'readable' event emission. + this.needReadable = false; + this.emittedReadable = false; + this.readableListening = false; + this.resumeScheduled = false; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // when piping, we only care about 'readable' events that happen + // after read()ing all the bytes and not getting any pushback. + this.ranOut = false; + + // the number of writers that are awaiting a drain event in .pipe()s + this.awaitDrain = 0; + + // if true, a maybeReadMore has been scheduled + this.readingMore = false; + + this.decoder = null; + this.encoding = null; + if (options.encoding) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this.decoder = new StringDecoder(options.encoding); + this.encoding = options.encoding; + } +} + +var Duplex; +function Readable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + if (!(this instanceof Readable)) return new Readable(options); + + this._readableState = new ReadableState(options, this); + + // legacy + this.readable = true; + + if (options && typeof options.read === 'function') this._read = options.read; + + Stream.call(this); +} + +// Manually shove something into the read() buffer. +// This returns true if the highWaterMark has not been hit yet, +// similar to how Writable.write() returns true if you should +// write() some more. +Readable.prototype.push = function (chunk, encoding) { + var state = this._readableState; + + if (!state.objectMode && typeof chunk === 'string') { + encoding = encoding || state.defaultEncoding; + if (encoding !== state.encoding) { + chunk = new Buffer(chunk, encoding); + encoding = ''; + } + } + + return readableAddChunk(this, state, chunk, encoding, false); +}; + +// Unshift should *always* be something directly out of read() +Readable.prototype.unshift = function (chunk) { + var state = this._readableState; + return readableAddChunk(this, state, chunk, '', true); +}; + +Readable.prototype.isPaused = function () { + return this._readableState.flowing === false; +}; + +function readableAddChunk(stream, state, chunk, encoding, addToFront) { + var er = chunkInvalid(state, chunk); + if (er) { + stream.emit('error', er); + } else if (chunk === null) { + state.reading = false; + onEofChunk(stream, state); + } else if (state.objectMode || chunk && chunk.length > 0) { + if (state.ended && !addToFront) { + var e = new Error('stream.push() after EOF'); + stream.emit('error', e); + } else if (state.endEmitted && addToFront) { + var e = new Error('stream.unshift() after end event'); + stream.emit('error', e); + } else { + var skipAdd; + if (state.decoder && !addToFront && !encoding) { + chunk = state.decoder.write(chunk); + skipAdd = !state.objectMode && chunk.length === 0; + } + + if (!addToFront) state.reading = false; + + // Don't add to the buffer if we've decoded to an empty string chunk and + // we're not in object mode + if (!skipAdd) { + // if we want the data now, just emit it. + if (state.flowing && state.length === 0 && !state.sync) { + stream.emit('data', chunk); + stream.read(0); + } else { + // update the buffer info. + state.length += state.objectMode ? 1 : chunk.length; + if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk); + + if (state.needReadable) emitReadable(stream); + } + } + + maybeReadMore(stream, state); + } + } else if (!addToFront) { + state.reading = false; + } + + return needMoreData(state); +} + +// if it's past the high water mark, we can push in some more. +// Also, if we have no data yet, we can stand some +// more bytes. This is to work around cases where hwm=0, +// such as the repl. Also, if the push() triggered a +// readable event, and the user called read(largeNumber) such that +// needReadable was set, then we ought to push more, so that another +// 'readable' event will be triggered. +function needMoreData(state) { + return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0); +} + +// backwards compatibility. +Readable.prototype.setEncoding = function (enc) { + if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder; + this._readableState.decoder = new StringDecoder(enc); + this._readableState.encoding = enc; + return this; +}; + +// Don't raise the hwm > 8MB +var MAX_HWM = 0x800000; +function computeNewHighWaterMark(n) { + if (n >= MAX_HWM) { + n = MAX_HWM; + } else { + // Get the next highest power of 2 + n--; + n |= n >>> 1; + n |= n >>> 2; + n |= n >>> 4; + n |= n >>> 8; + n |= n >>> 16; + n++; + } + return n; +} + +function howMuchToRead(n, state) { + if (state.length === 0 && state.ended) return 0; + + if (state.objectMode) return n === 0 ? 0 : 1; + + if (n === null || isNaN(n)) { + // only flow one buffer at a time + if (state.flowing && state.buffer.length) return state.buffer[0].length;else return state.length; + } + + if (n <= 0) return 0; + + // If we're asking for more than the target buffer level, + // then raise the water mark. Bump up to the next highest + // power of 2, to prevent increasing it excessively in tiny + // amounts. + if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n); + + // don't have that much. return null, unless we've ended. + if (n > state.length) { + if (!state.ended) { + state.needReadable = true; + return 0; + } else { + return state.length; + } + } + + return n; +} + +// you can override either this method, or the async _read(n) below. +Readable.prototype.read = function (n) { + debug('read', n); + var state = this._readableState; + var nOrig = n; + + if (typeof n !== 'number' || n > 0) state.emittedReadable = false; + + // if we're doing read(0) to trigger a readable event, but we + // already have a bunch of data in the buffer, then just trigger + // the 'readable' event and move on. + if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) { + debug('read: emitReadable', state.length, state.ended); + if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this); + return null; + } + + n = howMuchToRead(n, state); + + // if we've ended, and we're now clear, then finish it up. + if (n === 0 && state.ended) { + if (state.length === 0) endReadable(this); + return null; + } + + // All the actual chunk generation logic needs to be + // *below* the call to _read. The reason is that in certain + // synthetic stream cases, such as passthrough streams, _read + // may be a completely synchronous operation which may change + // the state of the read buffer, providing enough data when + // before there was *not* enough. + // + // So, the steps are: + // 1. Figure out what the state of things will be after we do + // a read from the buffer. + // + // 2. If that resulting state will trigger a _read, then call _read. + // Note that this may be asynchronous, or synchronous. Yes, it is + // deeply ugly to write APIs this way, but that still doesn't mean + // that the Readable class should behave improperly, as streams are + // designed to be sync/async agnostic. + // Take note if the _read call is sync or async (ie, if the read call + // has returned yet), so that we know whether or not it's safe to emit + // 'readable' etc. + // + // 3. Actually pull the requested chunks out of the buffer and return. + + // if we need a readable event, then we need to do some reading. + var doRead = state.needReadable; + debug('need readable', doRead); + + // if we currently have less than the highWaterMark, then also read some + if (state.length === 0 || state.length - n < state.highWaterMark) { + doRead = true; + debug('length less than watermark', doRead); + } + + // however, if we've ended, then there's no point, and if we're already + // reading, then it's unnecessary. + if (state.ended || state.reading) { + doRead = false; + debug('reading or ended', doRead); + } + + if (doRead) { + debug('do read'); + state.reading = true; + state.sync = true; + // if the length is currently zero, then we *need* a readable event. + if (state.length === 0) state.needReadable = true; + // call internal read method + this._read(state.highWaterMark); + state.sync = false; + } + + // If _read pushed data synchronously, then `reading` will be false, + // and we need to re-evaluate how much data we can return to the user. + if (doRead && !state.reading) n = howMuchToRead(nOrig, state); + + var ret; + if (n > 0) ret = fromList(n, state);else ret = null; + + if (ret === null) { + state.needReadable = true; + n = 0; + } + + state.length -= n; + + // If we have nothing in the buffer, then we want to know + // as soon as we *do* get something into the buffer. + if (state.length === 0 && !state.ended) state.needReadable = true; + + // If we tried to read() past the EOF, then emit end on the next tick. + if (nOrig !== n && state.ended && state.length === 0) endReadable(this); + + if (ret !== null) this.emit('data', ret); + + return ret; +}; + +function chunkInvalid(state, chunk) { + var er = null; + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + er = new TypeError('Invalid non-string/buffer chunk'); + } + return er; +} + +function onEofChunk(stream, state) { + if (state.ended) return; + if (state.decoder) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) { + state.buffer.push(chunk); + state.length += state.objectMode ? 1 : chunk.length; + } + } + state.ended = true; + + // emit 'readable' now to make sure it gets picked up. + emitReadable(stream); +} + +// Don't emit readable right away in sync mode, because this can trigger +// another read() call => stack overflow. This way, it might trigger +// a nextTick recursion warning, but that's not so bad. +function emitReadable(stream) { + var state = stream._readableState; + state.needReadable = false; + if (!state.emittedReadable) { + debug('emitReadable', state.flowing); + state.emittedReadable = true; + if (state.sync) processNextTick(emitReadable_, stream);else emitReadable_(stream); + } +} + +function emitReadable_(stream) { + debug('emit readable'); + stream.emit('readable'); + flow(stream); +} + +// at this point, the user has presumably seen the 'readable' event, +// and called read() to consume some data. that may have triggered +// in turn another _read(n) call, in which case reading = true if +// it's in progress. +// However, if we're not ended, or reading, and the length < hwm, +// then go ahead and try to read some more preemptively. +function maybeReadMore(stream, state) { + if (!state.readingMore) { + state.readingMore = true; + processNextTick(maybeReadMore_, stream, state); + } +} + +function maybeReadMore_(stream, state) { + var len = state.length; + while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) { + debug('maybeReadMore read 0'); + stream.read(0); + if (len === state.length) + // didn't get any data, stop spinning. + break;else len = state.length; + } + state.readingMore = false; +} + +// abstract method. to be overridden in specific implementation classes. +// call cb(er, data) where data is <= n in length. +// for virtual (non-string, non-buffer) streams, "length" is somewhat +// arbitrary, and perhaps not very meaningful. +Readable.prototype._read = function (n) { + this.emit('error', new Error('not implemented')); +}; + +Readable.prototype.pipe = function (dest, pipeOpts) { + var src = this; + var state = this._readableState; + + switch (state.pipesCount) { + case 0: + state.pipes = dest; + break; + case 1: + state.pipes = [state.pipes, dest]; + break; + default: + state.pipes.push(dest); + break; + } + state.pipesCount += 1; + debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts); + + var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr; + + var endFn = doEnd ? onend : cleanup; + if (state.endEmitted) processNextTick(endFn);else src.once('end', endFn); + + dest.on('unpipe', onunpipe); + function onunpipe(readable) { + debug('onunpipe'); + if (readable === src) { + cleanup(); + } + } + + function onend() { + debug('onend'); + dest.end(); + } + + // when the dest drains, it reduces the awaitDrain counter + // on the source. This would be more elegant with a .once() + // handler in flow(), but adding and removing repeatedly is + // too slow. + var ondrain = pipeOnDrain(src); + dest.on('drain', ondrain); + + var cleanedUp = false; + function cleanup() { + debug('cleanup'); + // cleanup event handlers once the pipe is broken + dest.removeListener('close', onclose); + dest.removeListener('finish', onfinish); + dest.removeListener('drain', ondrain); + dest.removeListener('error', onerror); + dest.removeListener('unpipe', onunpipe); + src.removeListener('end', onend); + src.removeListener('end', cleanup); + src.removeListener('data', ondata); + + cleanedUp = true; + + // if the reader is waiting for a drain event from this + // specific writer, then it would cause it to never start + // flowing again. + // So, if this is awaiting a drain, then we just call it now. + // If we don't know, then assume that we are waiting for one. + if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain(); + } + + src.on('data', ondata); + function ondata(chunk) { + debug('ondata'); + var ret = dest.write(chunk); + if (false === ret) { + // If the user unpiped during `dest.write()`, it is possible + // to get stuck in a permanently paused state if that write + // also returned false. + if (state.pipesCount === 1 && state.pipes[0] === dest && src.listenerCount('data') === 1 && !cleanedUp) { + debug('false write response, pause', src._readableState.awaitDrain); + src._readableState.awaitDrain++; + } + src.pause(); + } + } + + // if the dest has an error, then stop piping into it. + // however, don't suppress the throwing behavior for this. + function onerror(er) { + debug('onerror', er); + unpipe(); + dest.removeListener('error', onerror); + if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er); + } + // This is a brutally ugly hack to make sure that our error handler + // is attached before any userland ones. NEVER DO THIS. + if (!dest._events || !dest._events.error) dest.on('error', onerror);else if (isArray(dest._events.error)) dest._events.error.unshift(onerror);else dest._events.error = [onerror, dest._events.error]; + + // Both close and finish should trigger unpipe, but only once. + function onclose() { + dest.removeListener('finish', onfinish); + unpipe(); + } + dest.once('close', onclose); + function onfinish() { + debug('onfinish'); + dest.removeListener('close', onclose); + unpipe(); + } + dest.once('finish', onfinish); + + function unpipe() { + debug('unpipe'); + src.unpipe(dest); + } + + // tell the dest that it's being piped to + dest.emit('pipe', src); + + // start the flow if it hasn't been started already. + if (!state.flowing) { + debug('pipe resume'); + src.resume(); + } + + return dest; +}; + +function pipeOnDrain(src) { + return function () { + var state = src._readableState; + debug('pipeOnDrain', state.awaitDrain); + if (state.awaitDrain) state.awaitDrain--; + if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) { + state.flowing = true; + flow(src); + } + }; +} + +Readable.prototype.unpipe = function (dest) { + var state = this._readableState; + + // if we're not piping anywhere, then do nothing. + if (state.pipesCount === 0) return this; + + // just one destination. most common case. + if (state.pipesCount === 1) { + // passed in one, but it's not the right one. + if (dest && dest !== state.pipes) return this; + + if (!dest) dest = state.pipes; + + // got a match. + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + if (dest) dest.emit('unpipe', this); + return this; + } + + // slow case. multiple pipe destinations. + + if (!dest) { + // remove all. + var dests = state.pipes; + var len = state.pipesCount; + state.pipes = null; + state.pipesCount = 0; + state.flowing = false; + + for (var _i = 0; _i < len; _i++) { + dests[_i].emit('unpipe', this); + }return this; + } + + // try to find the right one. + var i = indexOf(state.pipes, dest); + if (i === -1) return this; + + state.pipes.splice(i, 1); + state.pipesCount -= 1; + if (state.pipesCount === 1) state.pipes = state.pipes[0]; + + dest.emit('unpipe', this); + + return this; +}; + +// set up data events if they are asked for +// Ensure readable listeners eventually get something +Readable.prototype.on = function (ev, fn) { + var res = Stream.prototype.on.call(this, ev, fn); + + // If listening to data, and it has not explicitly been paused, + // then call resume to start the flow of data on the next tick. + if (ev === 'data' && false !== this._readableState.flowing) { + this.resume(); + } + + if (ev === 'readable' && !this._readableState.endEmitted) { + var state = this._readableState; + if (!state.readableListening) { + state.readableListening = true; + state.emittedReadable = false; + state.needReadable = true; + if (!state.reading) { + processNextTick(nReadingNextTick, this); + } else if (state.length) { + emitReadable(this, state); + } + } + } + + return res; +}; +Readable.prototype.addListener = Readable.prototype.on; + +function nReadingNextTick(self) { + debug('readable nexttick read 0'); + self.read(0); +} + +// pause() and resume() are remnants of the legacy readable stream API +// If the user uses them, then switch into old mode. +Readable.prototype.resume = function () { + var state = this._readableState; + if (!state.flowing) { + debug('resume'); + state.flowing = true; + resume(this, state); + } + return this; +}; + +function resume(stream, state) { + if (!state.resumeScheduled) { + state.resumeScheduled = true; + processNextTick(resume_, stream, state); + } +} + +function resume_(stream, state) { + if (!state.reading) { + debug('resume read 0'); + stream.read(0); + } + + state.resumeScheduled = false; + stream.emit('resume'); + flow(stream); + if (state.flowing && !state.reading) stream.read(0); +} + +Readable.prototype.pause = function () { + debug('call pause flowing=%j', this._readableState.flowing); + if (false !== this._readableState.flowing) { + debug('pause'); + this._readableState.flowing = false; + this.emit('pause'); + } + return this; +}; + +function flow(stream) { + var state = stream._readableState; + debug('flow', state.flowing); + if (state.flowing) { + do { + var chunk = stream.read(); + } while (null !== chunk && state.flowing); + } +} + +// wrap an old-style stream as the async data source. +// This is *not* part of the readable stream interface. +// It is an ugly unfortunate mess of history. +Readable.prototype.wrap = function (stream) { + var state = this._readableState; + var paused = false; + + var self = this; + stream.on('end', function () { + debug('wrapped end'); + if (state.decoder && !state.ended) { + var chunk = state.decoder.end(); + if (chunk && chunk.length) self.push(chunk); + } + + self.push(null); + }); + + stream.on('data', function (chunk) { + debug('wrapped data'); + if (state.decoder) chunk = state.decoder.write(chunk); + + // don't skip over falsy values in objectMode + if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return; + + var ret = self.push(chunk); + if (!ret) { + paused = true; + stream.pause(); + } + }); + + // proxy all the other methods. + // important when wrapping filters and duplexes. + for (var i in stream) { + if (this[i] === undefined && typeof stream[i] === 'function') { + this[i] = function (method) { + return function () { + return stream[method].apply(stream, arguments); + }; + }(i); + } + } + + // proxy certain important events. + var events = ['error', 'close', 'destroy', 'pause', 'resume']; + forEach(events, function (ev) { + stream.on(ev, self.emit.bind(self, ev)); + }); + + // when we try to consume some more bytes, simply unpause the + // underlying stream. + self._read = function (n) { + debug('wrapped _read', n); + if (paused) { + paused = false; + stream.resume(); + } + }; + + return self; +}; + +// exposed for testing purposes only. +Readable._fromList = fromList; + +// Pluck off n bytes from an array of buffers. +// Length is the combined lengths of all the buffers in the list. +function fromList(n, state) { + var list = state.buffer; + var length = state.length; + var stringMode = !!state.decoder; + var objectMode = !!state.objectMode; + var ret; + + // nothing in the list, definitely empty. + if (list.length === 0) return null; + + if (length === 0) ret = null;else if (objectMode) ret = list.shift();else if (!n || n >= length) { + // read it all, truncate the array. + if (stringMode) ret = list.join('');else if (list.length === 1) ret = list[0];else ret = Buffer.concat(list, length); + list.length = 0; + } else { + // read just some of it. + if (n < list[0].length) { + // just take a part of the first list item. + // slice is the same for buffers and strings. + var buf = list[0]; + ret = buf.slice(0, n); + list[0] = buf.slice(n); + } else if (n === list[0].length) { + // first list is a perfect match + ret = list.shift(); + } else { + // complex case. + // we have enough to cover it, but it spans past the first buffer. + if (stringMode) ret = '';else ret = new Buffer(n); + + var c = 0; + for (var i = 0, l = list.length; i < l && c < n; i++) { + var buf = list[0]; + var cpy = Math.min(n - c, buf.length); + + if (stringMode) ret += buf.slice(0, cpy);else buf.copy(ret, c, 0, cpy); + + if (cpy < buf.length) list[0] = buf.slice(cpy);else list.shift(); + + c += cpy; + } + } + } + + return ret; +} + +function endReadable(stream) { + var state = stream._readableState; + + // If we get here before consuming all the bytes, then that is a + // bug in node. Should never happen. + if (state.length > 0) throw new Error('endReadable called on non-empty stream'); + + if (!state.endEmitted) { + state.ended = true; + processNextTick(endReadableNT, state, stream); + } +} + +function endReadableNT(state, stream) { + // Check that we didn't get one last unshift. + if (!state.endEmitted && state.length === 0) { + state.endEmitted = true; + stream.readable = false; + stream.emit('end'); + } +} + +function forEach(xs, f) { + for (var i = 0, l = xs.length; i < l; i++) { + f(xs[i], i); + } +} + +function indexOf(xs, x) { + for (var i = 0, l = xs.length; i < l; i++) { + if (xs[i] === x) return i; + } + return -1; +} +}).call(this,require('_process')) +},{"./_stream_duplex":8,"_process":23,"buffer":18,"core-util-is":2,"events":19,"inherits":5,"isarray":6,"process-nextick-args":7,"string_decoder/":14,"util":17}],11:[function(require,module,exports){ +// a transform stream is a readable/writable stream where you do +// something with the data. Sometimes it's called a "filter", +// but that's not a great name for it, since that implies a thing where +// some bits pass through, and others are simply ignored. (That would +// be a valid example of a transform, of course.) +// +// While the output is causally related to the input, it's not a +// necessarily symmetric or synchronous transformation. For example, +// a zlib stream might take multiple plain-text writes(), and then +// emit a single compressed chunk some time in the future. +// +// Here's how this works: +// +// The Transform stream has all the aspects of the readable and writable +// stream classes. When you write(chunk), that calls _write(chunk,cb) +// internally, and returns false if there's a lot of pending writes +// buffered up. When you call read(), that calls _read(n) until +// there's enough pending readable data buffered up. +// +// In a transform stream, the written data is placed in a buffer. When +// _read(n) is called, it transforms the queued up data, calling the +// buffered _write cb's as it consumes chunks. If consuming a single +// written chunk would result in multiple output chunks, then the first +// outputted bit calls the readcb, and subsequent chunks just go into +// the read buffer, and will cause it to emit 'readable' if necessary. +// +// This way, back-pressure is actually determined by the reading side, +// since _read has to be called to start processing a new chunk. However, +// a pathological inflate type of transform can cause excessive buffering +// here. For example, imagine a stream where every byte of input is +// interpreted as an integer from 0-255, and then results in that many +// bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in +// 1kb of data being output. In this case, you could write a very small +// amount of input, and end up with a very large amount of output. In +// such a pathological inflating mechanism, there'd be no way to tell +// the system to stop doing the transform. A single 4MB write could +// cause the system to run out of memory. +// +// However, even in such a pathological case, only a single written chunk +// would be consumed, and then the rest would wait (un-transformed) until +// the results of the previous transformed chunk were consumed. + +'use strict'; + +module.exports = Transform; + +var Duplex = require('./_stream_duplex'); + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +util.inherits(Transform, Duplex); + +function TransformState(stream) { + this.afterTransform = function (er, data) { + return afterTransform(stream, er, data); + }; + + this.needTransform = false; + this.transforming = false; + this.writecb = null; + this.writechunk = null; + this.writeencoding = null; +} + +function afterTransform(stream, er, data) { + var ts = stream._transformState; + ts.transforming = false; + + var cb = ts.writecb; + + if (!cb) return stream.emit('error', new Error('no writecb in Transform class')); + + ts.writechunk = null; + ts.writecb = null; + + if (data !== null && data !== undefined) stream.push(data); + + cb(er); + + var rs = stream._readableState; + rs.reading = false; + if (rs.needReadable || rs.length < rs.highWaterMark) { + stream._read(rs.highWaterMark); + } +} + +function Transform(options) { + if (!(this instanceof Transform)) return new Transform(options); + + Duplex.call(this, options); + + this._transformState = new TransformState(this); + + // when the writable side finishes, then flush out anything remaining. + var stream = this; + + // start out asking for a readable event once data is transformed. + this._readableState.needReadable = true; + + // we have implemented the _read method, and done the other things + // that Readable wants before the first _read call, so unset the + // sync guard flag. + this._readableState.sync = false; + + if (options) { + if (typeof options.transform === 'function') this._transform = options.transform; + + if (typeof options.flush === 'function') this._flush = options.flush; + } + + this.once('prefinish', function () { + if (typeof this._flush === 'function') this._flush(function (er) { + done(stream, er); + });else done(stream); + }); +} + +Transform.prototype.push = function (chunk, encoding) { + this._transformState.needTransform = false; + return Duplex.prototype.push.call(this, chunk, encoding); +}; + +// This is the part where you do stuff! +// override this function in implementation classes. +// 'chunk' is an input chunk. +// +// Call `push(newChunk)` to pass along transformed output +// to the readable side. You may call 'push' zero or more times. +// +// Call `cb(err)` when you are done with this chunk. If you pass +// an error, then that'll put the hurt on the whole operation. If you +// never call cb(), then you'll never get another chunk. +Transform.prototype._transform = function (chunk, encoding, cb) { + throw new Error('not implemented'); +}; + +Transform.prototype._write = function (chunk, encoding, cb) { + var ts = this._transformState; + ts.writecb = cb; + ts.writechunk = chunk; + ts.writeencoding = encoding; + if (!ts.transforming) { + var rs = this._readableState; + if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark); + } +}; + +// Doesn't matter what the args are here. +// _transform does all the work. +// That we got here means that the readable side wants more data. +Transform.prototype._read = function (n) { + var ts = this._transformState; + + if (ts.writechunk !== null && ts.writecb && !ts.transforming) { + ts.transforming = true; + this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform); + } else { + // mark that we need a transform, so that any data that comes in + // will get processed, now that we've asked for it. + ts.needTransform = true; + } +}; + +function done(stream, er) { + if (er) return stream.emit('error', er); + + // if there's nothing in the write buffer, then that means + // that nothing more will ever be provided + var ws = stream._writableState; + var ts = stream._transformState; + + if (ws.length) throw new Error('calling transform done when ws.length != 0'); + + if (ts.transforming) throw new Error('calling transform done when still transforming'); + + return stream.push(null); +} +},{"./_stream_duplex":8,"core-util-is":2,"inherits":5}],12:[function(require,module,exports){ +(function (process){ +// A bit simpler than readable streams. +// Implement an async ._write(chunk, encoding, cb), and it'll handle all +// the drain event emission and buffering. + +'use strict'; + +module.exports = Writable; + +/**/ +var processNextTick = require('process-nextick-args'); +/**/ + +/**/ +var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick; +/**/ + +/**/ +var Buffer = require('buffer').Buffer; +/**/ + +Writable.WritableState = WritableState; + +/**/ +var util = require('core-util-is'); +util.inherits = require('inherits'); +/**/ + +/**/ +var internalUtil = { + deprecate: require('util-deprecate') +}; +/**/ + +/**/ +var Stream; +(function () { + try { + Stream = require('st' + 'ream'); + } catch (_) {} finally { + if (!Stream) Stream = require('events').EventEmitter; + } +})(); +/**/ + +var Buffer = require('buffer').Buffer; + +util.inherits(Writable, Stream); + +function nop() {} + +function WriteReq(chunk, encoding, cb) { + this.chunk = chunk; + this.encoding = encoding; + this.callback = cb; + this.next = null; +} + +var Duplex; +function WritableState(options, stream) { + Duplex = Duplex || require('./_stream_duplex'); + + options = options || {}; + + // object stream flag to indicate whether or not this stream + // contains buffers or objects. + this.objectMode = !!options.objectMode; + + if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.writableObjectMode; + + // the point at which write() starts returning false + // Note: 0 is a valid value, means that we always return false if + // the entire buffer is not flushed immediately on write() + var hwm = options.highWaterMark; + var defaultHwm = this.objectMode ? 16 : 16 * 1024; + this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm; + + // cast to ints. + this.highWaterMark = ~ ~this.highWaterMark; + + this.needDrain = false; + // at the start of calling end() + this.ending = false; + // when end() has been called, and returned + this.ended = false; + // when 'finish' is emitted + this.finished = false; + + // should we decode strings into buffers before passing to _write? + // this is here so that some node-core streams can optimize string + // handling at a lower level. + var noDecode = options.decodeStrings === false; + this.decodeStrings = !noDecode; + + // Crypto is kind of old and crusty. Historically, its default string + // encoding is 'binary' so we have to make this configurable. + // Everything else in the universe uses 'utf8', though. + this.defaultEncoding = options.defaultEncoding || 'utf8'; + + // not an actual buffer we keep track of, but a measurement + // of how much we're waiting to get pushed to some underlying + // socket or file. + this.length = 0; + + // a flag to see when we're in the middle of a write. + this.writing = false; + + // when true all writes will be buffered until .uncork() call + this.corked = 0; + + // a flag to be able to tell if the onwrite cb is called immediately, + // or on a later tick. We set this to true at first, because any + // actions that shouldn't happen until "later" should generally also + // not happen before the first write call. + this.sync = true; + + // a flag to know if we're processing previously buffered items, which + // may call the _write() callback in the same tick, so that we don't + // end up in an overlapped onwrite situation. + this.bufferProcessing = false; + + // the callback that's passed to _write(chunk,cb) + this.onwrite = function (er) { + onwrite(stream, er); + }; + + // the callback that the user supplies to write(chunk,encoding,cb) + this.writecb = null; + + // the amount that is being written when _write is called. + this.writelen = 0; + + this.bufferedRequest = null; + this.lastBufferedRequest = null; + + // number of pending user-supplied write callbacks + // this must be 0 before 'finish' can be emitted + this.pendingcb = 0; + + // emit prefinish if the only thing we're waiting for is _write cbs + // This is relevant for synchronous Transform streams + this.prefinished = false; + + // True if the error was already emitted and should not be thrown again + this.errorEmitted = false; + + // count buffered requests + this.bufferedRequestCount = 0; + + // create the two objects needed to store the corked requests + // they are not a linked list, as no new elements are inserted in there + this.corkedRequestsFree = new CorkedRequest(this); + this.corkedRequestsFree.next = new CorkedRequest(this); +} + +WritableState.prototype.getBuffer = function writableStateGetBuffer() { + var current = this.bufferedRequest; + var out = []; + while (current) { + out.push(current); + current = current.next; + } + return out; +}; + +(function () { + try { + Object.defineProperty(WritableState.prototype, 'buffer', { + get: internalUtil.deprecate(function () { + return this.getBuffer(); + }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.') + }); + } catch (_) {} +})(); + +var Duplex; +function Writable(options) { + Duplex = Duplex || require('./_stream_duplex'); + + // Writable ctor is applied to Duplexes, though they're not + // instanceof Writable, they're instanceof Readable. + if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); + + this._writableState = new WritableState(options, this); + + // legacy. + this.writable = true; + + if (options) { + if (typeof options.write === 'function') this._write = options.write; + + if (typeof options.writev === 'function') this._writev = options.writev; + } + + Stream.call(this); +} + +// Otherwise people can pipe Writable streams, which is just wrong. +Writable.prototype.pipe = function () { + this.emit('error', new Error('Cannot pipe. Not readable.')); +}; + +function writeAfterEnd(stream, cb) { + var er = new Error('write after end'); + // TODO: defer error events consistently everywhere, not just the cb + stream.emit('error', er); + processNextTick(cb, er); +} + +// If we get something that is not a buffer, string, null, or undefined, +// and we're not in objectMode, then that's an error. +// Otherwise stream chunks are all considered to be of length=1, and the +// watermarks determine how many objects to keep in the buffer, rather than +// how many bytes or characters. +function validChunk(stream, state, chunk, cb) { + var valid = true; + + if (!Buffer.isBuffer(chunk) && typeof chunk !== 'string' && chunk !== null && chunk !== undefined && !state.objectMode) { + var er = new TypeError('Invalid non-string/buffer chunk'); + stream.emit('error', er); + processNextTick(cb, er); + valid = false; + } + return valid; +} + +Writable.prototype.write = function (chunk, encoding, cb) { + var state = this._writableState; + var ret = false; + + if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (Buffer.isBuffer(chunk)) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding; + + if (typeof cb !== 'function') cb = nop; + + if (state.ended) writeAfterEnd(this, cb);else if (validChunk(this, state, chunk, cb)) { + state.pendingcb++; + ret = writeOrBuffer(this, state, chunk, encoding, cb); + } + + return ret; +}; + +Writable.prototype.cork = function () { + var state = this._writableState; + + state.corked++; +}; + +Writable.prototype.uncork = function () { + var state = this._writableState; + + if (state.corked) { + state.corked--; + + if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state); + } +}; + +Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) { + // node::ParseEncoding() requires lower case. + if (typeof encoding === 'string') encoding = encoding.toLowerCase(); + if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding); + this._writableState.defaultEncoding = encoding; +}; + +function decodeChunk(state, chunk, encoding) { + if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') { + chunk = new Buffer(chunk, encoding); + } + return chunk; +} + +// if we're already writing something, then just put this +// in the queue, and wait our turn. Otherwise, call _write +// If we return false, then we need a drain event, so set that flag. +function writeOrBuffer(stream, state, chunk, encoding, cb) { + chunk = decodeChunk(state, chunk, encoding); + + if (Buffer.isBuffer(chunk)) encoding = 'buffer'; + var len = state.objectMode ? 1 : chunk.length; + + state.length += len; + + var ret = state.length < state.highWaterMark; + // we must ensure that previous needDrain will not be reset to false. + if (!ret) state.needDrain = true; + + if (state.writing || state.corked) { + var last = state.lastBufferedRequest; + state.lastBufferedRequest = new WriteReq(chunk, encoding, cb); + if (last) { + last.next = state.lastBufferedRequest; + } else { + state.bufferedRequest = state.lastBufferedRequest; + } + state.bufferedRequestCount += 1; + } else { + doWrite(stream, state, false, len, chunk, encoding, cb); + } + + return ret; +} + +function doWrite(stream, state, writev, len, chunk, encoding, cb) { + state.writelen = len; + state.writecb = cb; + state.writing = true; + state.sync = true; + if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite); + state.sync = false; +} + +function onwriteError(stream, state, sync, er, cb) { + --state.pendingcb; + if (sync) processNextTick(cb, er);else cb(er); + + stream._writableState.errorEmitted = true; + stream.emit('error', er); +} + +function onwriteStateUpdate(state) { + state.writing = false; + state.writecb = null; + state.length -= state.writelen; + state.writelen = 0; +} + +function onwrite(stream, er) { + var state = stream._writableState; + var sync = state.sync; + var cb = state.writecb; + + onwriteStateUpdate(state); + + if (er) onwriteError(stream, state, sync, er, cb);else { + // Check if we're actually ready to finish, but don't emit yet + var finished = needFinish(state); + + if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) { + clearBuffer(stream, state); + } + + if (sync) { + /**/ + asyncWrite(afterWrite, stream, state, finished, cb); + /**/ + } else { + afterWrite(stream, state, finished, cb); + } + } +} + +function afterWrite(stream, state, finished, cb) { + if (!finished) onwriteDrain(stream, state); + state.pendingcb--; + cb(); + finishMaybe(stream, state); +} + +// Must force callback to be called on nextTick, so that we don't +// emit 'drain' before the write() consumer gets the 'false' return +// value, and has a chance to attach a 'drain' listener. +function onwriteDrain(stream, state) { + if (state.length === 0 && state.needDrain) { + state.needDrain = false; + stream.emit('drain'); + } +} + +// if there's something in the buffer waiting, then process it +function clearBuffer(stream, state) { + state.bufferProcessing = true; + var entry = state.bufferedRequest; + + if (stream._writev && entry && entry.next) { + // Fast case, write everything using _writev() + var l = state.bufferedRequestCount; + var buffer = new Array(l); + var holder = state.corkedRequestsFree; + holder.entry = entry; + + var count = 0; + while (entry) { + buffer[count] = entry; + entry = entry.next; + count += 1; + } + + doWrite(stream, state, true, state.length, buffer, '', holder.finish); + + // doWrite is always async, defer these to save a bit of time + // as the hot path ends with doWrite + state.pendingcb++; + state.lastBufferedRequest = null; + state.corkedRequestsFree = holder.next; + holder.next = null; + } else { + // Slow case, write chunks one-by-one + while (entry) { + var chunk = entry.chunk; + var encoding = entry.encoding; + var cb = entry.callback; + var len = state.objectMode ? 1 : chunk.length; + + doWrite(stream, state, false, len, chunk, encoding, cb); + entry = entry.next; + // if we didn't call the onwrite immediately, then + // it means that we need to wait until it does. + // also, that means that the chunk and cb are currently + // being processed, so move the buffer counter past them. + if (state.writing) { + break; + } + } + + if (entry === null) state.lastBufferedRequest = null; + } + + state.bufferedRequestCount = 0; + state.bufferedRequest = entry; + state.bufferProcessing = false; +} + +Writable.prototype._write = function (chunk, encoding, cb) { + cb(new Error('not implemented')); +}; + +Writable.prototype._writev = null; + +Writable.prototype.end = function (chunk, encoding, cb) { + var state = this._writableState; + + if (typeof chunk === 'function') { + cb = chunk; + chunk = null; + encoding = null; + } else if (typeof encoding === 'function') { + cb = encoding; + encoding = null; + } + + if (chunk !== null && chunk !== undefined) this.write(chunk, encoding); + + // .end() fully uncorks + if (state.corked) { + state.corked = 1; + this.uncork(); + } + + // ignore unnecessary end() calls. + if (!state.ending && !state.finished) endWritable(this, state, cb); +}; + +function needFinish(state) { + return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing; +} + +function prefinish(stream, state) { + if (!state.prefinished) { + state.prefinished = true; + stream.emit('prefinish'); + } +} + +function finishMaybe(stream, state) { + var need = needFinish(state); + if (need) { + if (state.pendingcb === 0) { + prefinish(stream, state); + state.finished = true; + stream.emit('finish'); + } else { + prefinish(stream, state); + } + } + return need; +} + +function endWritable(stream, state, cb) { + state.ending = true; + finishMaybe(stream, state); + if (cb) { + if (state.finished) processNextTick(cb);else stream.once('finish', cb); + } + state.ended = true; + stream.writable = false; +} + +// It seems a linked list but it is not +// there will be only 2 of these for each stream +function CorkedRequest(state) { + var _this = this; + + this.next = null; + this.entry = null; + + this.finish = function (err) { + var entry = _this.entry; + _this.entry = null; + while (entry) { + var cb = entry.callback; + state.pendingcb--; + cb(err); + entry = entry.next; + } + if (state.corkedRequestsFree) { + state.corkedRequestsFree.next = _this; + } else { + state.corkedRequestsFree = _this; + } + }; +} +}).call(this,require('_process')) +},{"./_stream_duplex":8,"_process":23,"buffer":18,"core-util-is":2,"events":19,"inherits":5,"process-nextick-args":7,"util-deprecate":15}],13:[function(require,module,exports){ +var Stream = (function (){ + try { + return require('st' + 'ream'); // hack to fix a circular dependency issue when used with browserify + } catch(_){} +}()); +exports = module.exports = require('./lib/_stream_readable.js'); +exports.Stream = Stream || exports; +exports.Readable = exports; +exports.Writable = require('./lib/_stream_writable.js'); +exports.Duplex = require('./lib/_stream_duplex.js'); +exports.Transform = require('./lib/_stream_transform.js'); +exports.PassThrough = require('./lib/_stream_passthrough.js'); + +},{"./lib/_stream_duplex.js":8,"./lib/_stream_passthrough.js":9,"./lib/_stream_readable.js":10,"./lib/_stream_transform.js":11,"./lib/_stream_writable.js":12}],14:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var Buffer = require('buffer').Buffer; + +var isBufferEncoding = Buffer.isEncoding + || function(encoding) { + switch (encoding && encoding.toLowerCase()) { + case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true; + default: return false; + } + } + + +function assertEncoding(encoding) { + if (encoding && !isBufferEncoding(encoding)) { + throw new Error('Unknown encoding: ' + encoding); + } +} + +// StringDecoder provides an interface for efficiently splitting a series of +// buffers into a series of JS strings without breaking apart multi-byte +// characters. CESU-8 is handled as part of the UTF-8 encoding. +// +// @TODO Handling all encodings inside a single object makes it very difficult +// to reason about this code, so it should be split up in the future. +// @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code +// points as used by CESU-8. +var StringDecoder = exports.StringDecoder = function(encoding) { + this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, ''); + assertEncoding(encoding); + switch (this.encoding) { + case 'utf8': + // CESU-8 represents each of Surrogate Pair by 3-bytes + this.surrogateSize = 3; + break; + case 'ucs2': + case 'utf16le': + // UTF-16 represents each of Surrogate Pair by 2-bytes + this.surrogateSize = 2; + this.detectIncompleteChar = utf16DetectIncompleteChar; + break; + case 'base64': + // Base-64 stores 3 bytes in 4 chars, and pads the remainder. + this.surrogateSize = 3; + this.detectIncompleteChar = base64DetectIncompleteChar; + break; + default: + this.write = passThroughWrite; + return; + } + + // Enough space to store all bytes of a single character. UTF-8 needs 4 + // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate). + this.charBuffer = new Buffer(6); + // Number of bytes received for the current incomplete multi-byte character. + this.charReceived = 0; + // Number of bytes expected for the current incomplete multi-byte character. + this.charLength = 0; +}; + + +// write decodes the given buffer and returns it as JS string that is +// guaranteed to not contain any partial multi-byte characters. Any partial +// character found at the end of the buffer is buffered up, and will be +// returned when calling write again with the remaining bytes. +// +// Note: Converting a Buffer containing an orphan surrogate to a String +// currently works, but converting a String to a Buffer (via `new Buffer`, or +// Buffer#write) will replace incomplete surrogates with the unicode +// replacement character. See https://codereview.chromium.org/121173009/ . +StringDecoder.prototype.write = function(buffer) { + var charStr = ''; + // if our last write ended with an incomplete multibyte character + while (this.charLength) { + // determine how many remaining bytes this buffer has to offer for this char + var available = (buffer.length >= this.charLength - this.charReceived) ? + this.charLength - this.charReceived : + buffer.length; + + // add the new bytes to the char buffer + buffer.copy(this.charBuffer, this.charReceived, 0, available); + this.charReceived += available; + + if (this.charReceived < this.charLength) { + // still not enough chars in this buffer? wait for more ... + return ''; + } + + // remove bytes belonging to the current character from the buffer + buffer = buffer.slice(available, buffer.length); + + // get the character that was split + charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding); + + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + var charCode = charStr.charCodeAt(charStr.length - 1); + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + this.charLength += this.surrogateSize; + charStr = ''; + continue; + } + this.charReceived = this.charLength = 0; + + // if there are no more bytes in this buffer, just emit our char + if (buffer.length === 0) { + return charStr; + } + break; + } + + // determine and set charLength / charReceived + this.detectIncompleteChar(buffer); + + var end = buffer.length; + if (this.charLength) { + // buffer the incomplete character bytes we got + buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end); + end -= this.charReceived; + } + + charStr += buffer.toString(this.encoding, 0, end); + + var end = charStr.length - 1; + var charCode = charStr.charCodeAt(end); + // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character + if (charCode >= 0xD800 && charCode <= 0xDBFF) { + var size = this.surrogateSize; + this.charLength += size; + this.charReceived += size; + this.charBuffer.copy(this.charBuffer, size, 0, size); + buffer.copy(this.charBuffer, 0, 0, size); + return charStr.substring(0, end); + } + + // or just emit the charStr + return charStr; +}; + +// detectIncompleteChar determines if there is an incomplete UTF-8 character at +// the end of the given buffer. If so, it sets this.charLength to the byte +// length that character, and sets this.charReceived to the number of bytes +// that are available for this character. +StringDecoder.prototype.detectIncompleteChar = function(buffer) { + // determine how many bytes we have to check at the end of this buffer + var i = (buffer.length >= 3) ? 3 : buffer.length; + + // Figure out if one of the last i bytes of our buffer announces an + // incomplete char. + for (; i > 0; i--) { + var c = buffer[buffer.length - i]; + + // See http://en.wikipedia.org/wiki/UTF-8#Description + + // 110XXXXX + if (i == 1 && c >> 5 == 0x06) { + this.charLength = 2; + break; + } + + // 1110XXXX + if (i <= 2 && c >> 4 == 0x0E) { + this.charLength = 3; + break; + } + + // 11110XXX + if (i <= 3 && c >> 3 == 0x1E) { + this.charLength = 4; + break; + } + } + this.charReceived = i; +}; + +StringDecoder.prototype.end = function(buffer) { + var res = ''; + if (buffer && buffer.length) + res = this.write(buffer); + + if (this.charReceived) { + var cr = this.charReceived; + var buf = this.charBuffer; + var enc = this.encoding; + res += buf.slice(0, cr).toString(enc); + } + + return res; +}; + +function passThroughWrite(buffer) { + return buffer.toString(this.encoding); +} + +function utf16DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 2; + this.charLength = this.charReceived ? 2 : 0; +} + +function base64DetectIncompleteChar(buffer) { + this.charReceived = buffer.length % 3; + this.charLength = this.charReceived ? 3 : 0; +} + +},{"buffer":18}],15:[function(require,module,exports){ +(function (global){ + +/** + * Module exports. + */ + +module.exports = deprecate; + +/** + * Mark that a method should not be used. + * Returns a modified function which warns once by default. + * + * If `localStorage.noDeprecation = true` is set, then it is a no-op. + * + * If `localStorage.throwDeprecation = true` is set, then deprecated functions + * will throw an Error when invoked. + * + * If `localStorage.traceDeprecation = true` is set, then deprecated functions + * will invoke `console.trace()` instead of `console.error()`. + * + * @param {Function} fn - the function to deprecate + * @param {String} msg - the string to print to the console when `fn` is invoked + * @returns {Function} a new "deprecated" version of `fn` + * @api public + */ + +function deprecate (fn, msg) { + if (config('noDeprecation')) { + return fn; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (config('throwDeprecation')) { + throw new Error(msg); + } else if (config('traceDeprecation')) { + console.trace(msg); + } else { + console.warn(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +} + +/** + * Checks `localStorage` for boolean values for the given `name`. + * + * @param {String} name + * @returns {Boolean} + * @api private + */ + +function config (name) { + // accessing global.localStorage can trigger a DOMException in sandboxed iframes + try { + if (!global.localStorage) return false; + } catch (_) { + return false; + } + var val = global.localStorage[name]; + if (null == val) return false; + return String(val).toLowerCase() === 'true'; +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],16:[function(require,module,exports){ +'use strict' + +exports.byteLength = byteLength +exports.toByteArray = toByteArray +exports.fromByteArray = fromByteArray + +var lookup = [] +var revLookup = [] +var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array + +var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' +for (var i = 0, len = code.length; i < len; ++i) { + lookup[i] = code[i] + revLookup[code.charCodeAt(i)] = i +} + +revLookup['-'.charCodeAt(0)] = 62 +revLookup['_'.charCodeAt(0)] = 63 + +function placeHoldersCount (b64) { + var len = b64.length + if (len % 4 > 0) { + throw new Error('Invalid string. Length must be a multiple of 4') + } + + // the number of equal signs (place holders) + // if there are two placeholders, than the two characters before it + // represent one byte + // if there is only one, then the three characters before it represent 2 bytes + // this is just a cheap hack to not do indexOf twice + return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0 +} + +function byteLength (b64) { + // base64 is 4/3 + up to two characters of the original data + return b64.length * 3 / 4 - placeHoldersCount(b64) +} + +function toByteArray (b64) { + var i, j, l, tmp, placeHolders, arr + var len = b64.length + placeHolders = placeHoldersCount(b64) + + arr = new Arr(len * 3 / 4 - placeHolders) + + // if there are placeholders, only get up to the last complete 4 chars + l = placeHolders > 0 ? len - 4 : len + + var L = 0 + + for (i = 0, j = 0; i < l; i += 4, j += 3) { + tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)] + arr[L++] = (tmp >> 16) & 0xFF + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + if (placeHolders === 2) { + tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4) + arr[L++] = tmp & 0xFF + } else if (placeHolders === 1) { + tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2) + arr[L++] = (tmp >> 8) & 0xFF + arr[L++] = tmp & 0xFF + } + + return arr +} + +function tripletToBase64 (num) { + return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] +} + +function encodeChunk (uint8, start, end) { + var tmp + var output = [] + for (var i = start; i < end; i += 3) { + tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2]) + output.push(tripletToBase64(tmp)) + } + return output.join('') +} + +function fromByteArray (uint8) { + var tmp + var len = uint8.length + var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes + var output = '' + var parts = [] + var maxChunkLength = 16383 // must be multiple of 3 + + // go through the array every three bytes, we'll deal with trailing stuff later + for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) { + parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength))) + } + + // pad the end with zeros, but make sure to not forget the extra bytes + if (extraBytes === 1) { + tmp = uint8[len - 1] + output += lookup[tmp >> 2] + output += lookup[(tmp << 4) & 0x3F] + output += '==' + } else if (extraBytes === 2) { + tmp = (uint8[len - 2] << 8) + (uint8[len - 1]) + output += lookup[tmp >> 10] + output += lookup[(tmp >> 4) & 0x3F] + output += lookup[(tmp << 2) & 0x3F] + output += '=' + } + + parts.push(output) + + return parts.join('') +} + +},{}],17:[function(require,module,exports){ + +},{}],18:[function(require,module,exports){ +(function (global){ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +/* eslint-disable no-proto */ + +'use strict' + +var base64 = require('base64-js') +var ieee754 = require('ieee754') +var isArray = require('isarray') + +exports.Buffer = Buffer +exports.SlowBuffer = SlowBuffer +exports.INSPECT_MAX_BYTES = 50 + +/** + * If `Buffer.TYPED_ARRAY_SUPPORT`: + * === true Use Uint8Array implementation (fastest) + * === false Use Object implementation (most compatible, even IE6) + * + * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+, + * Opera 11.6+, iOS 4.2+. + * + * Due to various browser bugs, sometimes the Object implementation will be used even + * when the browser supports typed arrays. + * + * Note: + * + * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances, + * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438. + * + * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function. + * + * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of + * incorrect length in some situations. + + * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they + * get the Object implementation, which is slower but behaves correctly. + */ +Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined + ? global.TYPED_ARRAY_SUPPORT + : typedArraySupport() + +/* + * Export kMaxLength after typed array support is determined. + */ +exports.kMaxLength = kMaxLength() + +function typedArraySupport () { + try { + var arr = new Uint8Array(1) + arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }} + return arr.foo() === 42 && // typed array instances can be augmented + typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray` + arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray` + } catch (e) { + return false + } +} + +function kMaxLength () { + return Buffer.TYPED_ARRAY_SUPPORT + ? 0x7fffffff + : 0x3fffffff +} + +function createBuffer (that, length) { + if (kMaxLength() < length) { + throw new RangeError('Invalid typed array length') + } + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = new Uint8Array(length) + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + if (that === null) { + that = new Buffer(length) + } + that.length = length + } + + return that +} + +/** + * The Buffer constructor returns instances of `Uint8Array` that have their + * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of + * `Uint8Array`, so the returned instances will have all the node `Buffer` methods + * and the `Uint8Array` methods. Square bracket notation works as expected -- it + * returns a single octet. + * + * The `Uint8Array` prototype remains unmodified. + */ + +function Buffer (arg, encodingOrOffset, length) { + if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) { + return new Buffer(arg, encodingOrOffset, length) + } + + // Common case. + if (typeof arg === 'number') { + if (typeof encodingOrOffset === 'string') { + throw new Error( + 'If encoding is specified then the first argument must be a string' + ) + } + return allocUnsafe(this, arg) + } + return from(this, arg, encodingOrOffset, length) +} + +Buffer.poolSize = 8192 // not used by this implementation + +// TODO: Legacy, not needed anymore. Remove in next major version. +Buffer._augment = function (arr) { + arr.__proto__ = Buffer.prototype + return arr +} + +function from (that, value, encodingOrOffset, length) { + if (typeof value === 'number') { + throw new TypeError('"value" argument must not be a number') + } + + if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) { + return fromArrayBuffer(that, value, encodingOrOffset, length) + } + + if (typeof value === 'string') { + return fromString(that, value, encodingOrOffset) + } + + return fromObject(that, value) +} + +/** + * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError + * if value is a number. + * Buffer.from(str[, encoding]) + * Buffer.from(array) + * Buffer.from(buffer) + * Buffer.from(arrayBuffer[, byteOffset[, length]]) + **/ +Buffer.from = function (value, encodingOrOffset, length) { + return from(null, value, encodingOrOffset, length) +} + +if (Buffer.TYPED_ARRAY_SUPPORT) { + Buffer.prototype.__proto__ = Uint8Array.prototype + Buffer.__proto__ = Uint8Array + if (typeof Symbol !== 'undefined' && Symbol.species && + Buffer[Symbol.species] === Buffer) { + // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97 + Object.defineProperty(Buffer, Symbol.species, { + value: null, + configurable: true + }) + } +} + +function assertSize (size) { + if (typeof size !== 'number') { + throw new TypeError('"size" argument must be a number') + } else if (size < 0) { + throw new RangeError('"size" argument must not be negative') + } +} + +function alloc (that, size, fill, encoding) { + assertSize(size) + if (size <= 0) { + return createBuffer(that, size) + } + if (fill !== undefined) { + // Only pay attention to encoding if it's a string. This + // prevents accidentally sending in a number that would + // be interpretted as a start offset. + return typeof encoding === 'string' + ? createBuffer(that, size).fill(fill, encoding) + : createBuffer(that, size).fill(fill) + } + return createBuffer(that, size) +} + +/** + * Creates a new filled Buffer instance. + * alloc(size[, fill[, encoding]]) + **/ +Buffer.alloc = function (size, fill, encoding) { + return alloc(null, size, fill, encoding) +} + +function allocUnsafe (that, size) { + assertSize(size) + that = createBuffer(that, size < 0 ? 0 : checked(size) | 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) { + for (var i = 0; i < size; ++i) { + that[i] = 0 + } + } + return that +} + +/** + * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance. + * */ +Buffer.allocUnsafe = function (size) { + return allocUnsafe(null, size) +} +/** + * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance. + */ +Buffer.allocUnsafeSlow = function (size) { + return allocUnsafe(null, size) +} + +function fromString (that, string, encoding) { + if (typeof encoding !== 'string' || encoding === '') { + encoding = 'utf8' + } + + if (!Buffer.isEncoding(encoding)) { + throw new TypeError('"encoding" must be a valid string encoding') + } + + var length = byteLength(string, encoding) | 0 + that = createBuffer(that, length) + + var actual = that.write(string, encoding) + + if (actual !== length) { + // Writing a hex string, for example, that contains invalid characters will + // cause everything after the first invalid character to be ignored. (e.g. + // 'abxxcd' will be treated as 'ab') + that = that.slice(0, actual) + } + + return that +} + +function fromArrayLike (that, array) { + var length = array.length < 0 ? 0 : checked(array.length) | 0 + that = createBuffer(that, length) + for (var i = 0; i < length; i += 1) { + that[i] = array[i] & 255 + } + return that +} + +function fromArrayBuffer (that, array, byteOffset, length) { + array.byteLength // this throws if `array` is not a valid ArrayBuffer + + if (byteOffset < 0 || array.byteLength < byteOffset) { + throw new RangeError('\'offset\' is out of bounds') + } + + if (array.byteLength < byteOffset + (length || 0)) { + throw new RangeError('\'length\' is out of bounds') + } + + if (byteOffset === undefined && length === undefined) { + array = new Uint8Array(array) + } else if (length === undefined) { + array = new Uint8Array(array, byteOffset) + } else { + array = new Uint8Array(array, byteOffset, length) + } + + if (Buffer.TYPED_ARRAY_SUPPORT) { + // Return an augmented `Uint8Array` instance, for best performance + that = array + that.__proto__ = Buffer.prototype + } else { + // Fallback: Return an object instance of the Buffer class + that = fromArrayLike(that, array) + } + return that +} + +function fromObject (that, obj) { + if (Buffer.isBuffer(obj)) { + var len = checked(obj.length) | 0 + that = createBuffer(that, len) + + if (that.length === 0) { + return that + } + + obj.copy(that, 0, 0, len) + return that + } + + if (obj) { + if ((typeof ArrayBuffer !== 'undefined' && + obj.buffer instanceof ArrayBuffer) || 'length' in obj) { + if (typeof obj.length !== 'number' || isnan(obj.length)) { + return createBuffer(that, 0) + } + return fromArrayLike(that, obj) + } + + if (obj.type === 'Buffer' && isArray(obj.data)) { + return fromArrayLike(that, obj.data) + } + } + + throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.') +} + +function checked (length) { + // Note: cannot use `length < kMaxLength()` here because that fails when + // length is NaN (which is otherwise coerced to zero.) + if (length >= kMaxLength()) { + throw new RangeError('Attempt to allocate Buffer larger than maximum ' + + 'size: 0x' + kMaxLength().toString(16) + ' bytes') + } + return length | 0 +} + +function SlowBuffer (length) { + if (+length != length) { // eslint-disable-line eqeqeq + length = 0 + } + return Buffer.alloc(+length) +} + +Buffer.isBuffer = function isBuffer (b) { + return !!(b != null && b._isBuffer) +} + +Buffer.compare = function compare (a, b) { + if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) { + throw new TypeError('Arguments must be Buffers') + } + + if (a === b) return 0 + + var x = a.length + var y = b.length + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i] + y = b[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +Buffer.isEncoding = function isEncoding (encoding) { + switch (String(encoding).toLowerCase()) { + case 'hex': + case 'utf8': + case 'utf-8': + case 'ascii': + case 'latin1': + case 'binary': + case 'base64': + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return true + default: + return false + } +} + +Buffer.concat = function concat (list, length) { + if (!isArray(list)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + + if (list.length === 0) { + return Buffer.alloc(0) + } + + var i + if (length === undefined) { + length = 0 + for (i = 0; i < list.length; ++i) { + length += list[i].length + } + } + + var buffer = Buffer.allocUnsafe(length) + var pos = 0 + for (i = 0; i < list.length; ++i) { + var buf = list[i] + if (!Buffer.isBuffer(buf)) { + throw new TypeError('"list" argument must be an Array of Buffers') + } + buf.copy(buffer, pos) + pos += buf.length + } + return buffer +} + +function byteLength (string, encoding) { + if (Buffer.isBuffer(string)) { + return string.length + } + if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' && + (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) { + return string.byteLength + } + if (typeof string !== 'string') { + string = '' + string + } + + var len = string.length + if (len === 0) return 0 + + // Use a for loop to avoid recursion + var loweredCase = false + for (;;) { + switch (encoding) { + case 'ascii': + case 'latin1': + case 'binary': + return len + case 'utf8': + case 'utf-8': + case undefined: + return utf8ToBytes(string).length + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return len * 2 + case 'hex': + return len >>> 1 + case 'base64': + return base64ToBytes(string).length + default: + if (loweredCase) return utf8ToBytes(string).length // assume utf8 + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} +Buffer.byteLength = byteLength + +function slowToString (encoding, start, end) { + var loweredCase = false + + // No need to verify that "this.length <= MAX_UINT32" since it's a read-only + // property of a typed array. + + // This behaves neither like String nor Uint8Array in that we set start/end + // to their upper/lower bounds if the value passed is out of range. + // undefined is handled specially as per ECMA-262 6th Edition, + // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization. + if (start === undefined || start < 0) { + start = 0 + } + // Return early if start > this.length. Done here to prevent potential uint32 + // coercion fail below. + if (start > this.length) { + return '' + } + + if (end === undefined || end > this.length) { + end = this.length + } + + if (end <= 0) { + return '' + } + + // Force coersion to uint32. This will also coerce falsey/NaN values to 0. + end >>>= 0 + start >>>= 0 + + if (end <= start) { + return '' + } + + if (!encoding) encoding = 'utf8' + + while (true) { + switch (encoding) { + case 'hex': + return hexSlice(this, start, end) + + case 'utf8': + case 'utf-8': + return utf8Slice(this, start, end) + + case 'ascii': + return asciiSlice(this, start, end) + + case 'latin1': + case 'binary': + return latin1Slice(this, start, end) + + case 'base64': + return base64Slice(this, start, end) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return utf16leSlice(this, start, end) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = (encoding + '').toLowerCase() + loweredCase = true + } + } +} + +// The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect +// Buffer instances. +Buffer.prototype._isBuffer = true + +function swap (b, n, m) { + var i = b[n] + b[n] = b[m] + b[m] = i +} + +Buffer.prototype.swap16 = function swap16 () { + var len = this.length + if (len % 2 !== 0) { + throw new RangeError('Buffer size must be a multiple of 16-bits') + } + for (var i = 0; i < len; i += 2) { + swap(this, i, i + 1) + } + return this +} + +Buffer.prototype.swap32 = function swap32 () { + var len = this.length + if (len % 4 !== 0) { + throw new RangeError('Buffer size must be a multiple of 32-bits') + } + for (var i = 0; i < len; i += 4) { + swap(this, i, i + 3) + swap(this, i + 1, i + 2) + } + return this +} + +Buffer.prototype.swap64 = function swap64 () { + var len = this.length + if (len % 8 !== 0) { + throw new RangeError('Buffer size must be a multiple of 64-bits') + } + for (var i = 0; i < len; i += 8) { + swap(this, i, i + 7) + swap(this, i + 1, i + 6) + swap(this, i + 2, i + 5) + swap(this, i + 3, i + 4) + } + return this +} + +Buffer.prototype.toString = function toString () { + var length = this.length | 0 + if (length === 0) return '' + if (arguments.length === 0) return utf8Slice(this, 0, length) + return slowToString.apply(this, arguments) +} + +Buffer.prototype.equals = function equals (b) { + if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer') + if (this === b) return true + return Buffer.compare(this, b) === 0 +} + +Buffer.prototype.inspect = function inspect () { + var str = '' + var max = exports.INSPECT_MAX_BYTES + if (this.length > 0) { + str = this.toString('hex', 0, max).match(/.{2}/g).join(' ') + if (this.length > max) str += ' ... ' + } + return '' +} + +Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) { + if (!Buffer.isBuffer(target)) { + throw new TypeError('Argument must be a Buffer') + } + + if (start === undefined) { + start = 0 + } + if (end === undefined) { + end = target ? target.length : 0 + } + if (thisStart === undefined) { + thisStart = 0 + } + if (thisEnd === undefined) { + thisEnd = this.length + } + + if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) { + throw new RangeError('out of range index') + } + + if (thisStart >= thisEnd && start >= end) { + return 0 + } + if (thisStart >= thisEnd) { + return -1 + } + if (start >= end) { + return 1 + } + + start >>>= 0 + end >>>= 0 + thisStart >>>= 0 + thisEnd >>>= 0 + + if (this === target) return 0 + + var x = thisEnd - thisStart + var y = end - start + var len = Math.min(x, y) + + var thisCopy = this.slice(thisStart, thisEnd) + var targetCopy = target.slice(start, end) + + for (var i = 0; i < len; ++i) { + if (thisCopy[i] !== targetCopy[i]) { + x = thisCopy[i] + y = targetCopy[i] + break + } + } + + if (x < y) return -1 + if (y < x) return 1 + return 0 +} + +// Finds either the first index of `val` in `buffer` at offset >= `byteOffset`, +// OR the last index of `val` in `buffer` at offset <= `byteOffset`. +// +// Arguments: +// - buffer - a Buffer to search +// - val - a string, Buffer, or number +// - byteOffset - an index into `buffer`; will be clamped to an int32 +// - encoding - an optional encoding, relevant is val is a string +// - dir - true for indexOf, false for lastIndexOf +function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) { + // Empty buffer means no match + if (buffer.length === 0) return -1 + + // Normalize byteOffset + if (typeof byteOffset === 'string') { + encoding = byteOffset + byteOffset = 0 + } else if (byteOffset > 0x7fffffff) { + byteOffset = 0x7fffffff + } else if (byteOffset < -0x80000000) { + byteOffset = -0x80000000 + } + byteOffset = +byteOffset // Coerce to Number. + if (isNaN(byteOffset)) { + // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer + byteOffset = dir ? 0 : (buffer.length - 1) + } + + // Normalize byteOffset: negative offsets start from the end of the buffer + if (byteOffset < 0) byteOffset = buffer.length + byteOffset + if (byteOffset >= buffer.length) { + if (dir) return -1 + else byteOffset = buffer.length - 1 + } else if (byteOffset < 0) { + if (dir) byteOffset = 0 + else return -1 + } + + // Normalize val + if (typeof val === 'string') { + val = Buffer.from(val, encoding) + } + + // Finally, search either indexOf (if dir is true) or lastIndexOf + if (Buffer.isBuffer(val)) { + // Special case: looking for empty string/buffer always fails + if (val.length === 0) { + return -1 + } + return arrayIndexOf(buffer, val, byteOffset, encoding, dir) + } else if (typeof val === 'number') { + val = val & 0xFF // Search for a byte value [0-255] + if (Buffer.TYPED_ARRAY_SUPPORT && + typeof Uint8Array.prototype.indexOf === 'function') { + if (dir) { + return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset) + } else { + return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset) + } + } + return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir) + } + + throw new TypeError('val must be string, number or Buffer') +} + +function arrayIndexOf (arr, val, byteOffset, encoding, dir) { + var indexSize = 1 + var arrLength = arr.length + var valLength = val.length + + if (encoding !== undefined) { + encoding = String(encoding).toLowerCase() + if (encoding === 'ucs2' || encoding === 'ucs-2' || + encoding === 'utf16le' || encoding === 'utf-16le') { + if (arr.length < 2 || val.length < 2) { + return -1 + } + indexSize = 2 + arrLength /= 2 + valLength /= 2 + byteOffset /= 2 + } + } + + function read (buf, i) { + if (indexSize === 1) { + return buf[i] + } else { + return buf.readUInt16BE(i * indexSize) + } + } + + var i + if (dir) { + var foundIndex = -1 + for (i = byteOffset; i < arrLength; i++) { + if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) { + if (foundIndex === -1) foundIndex = i + if (i - foundIndex + 1 === valLength) return foundIndex * indexSize + } else { + if (foundIndex !== -1) i -= i - foundIndex + foundIndex = -1 + } + } + } else { + if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength + for (i = byteOffset; i >= 0; i--) { + var found = true + for (var j = 0; j < valLength; j++) { + if (read(arr, i + j) !== read(val, j)) { + found = false + break + } + } + if (found) return i + } + } + + return -1 +} + +Buffer.prototype.includes = function includes (val, byteOffset, encoding) { + return this.indexOf(val, byteOffset, encoding) !== -1 +} + +Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, true) +} + +Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) { + return bidirectionalIndexOf(this, val, byteOffset, encoding, false) +} + +function hexWrite (buf, string, offset, length) { + offset = Number(offset) || 0 + var remaining = buf.length - offset + if (!length) { + length = remaining + } else { + length = Number(length) + if (length > remaining) { + length = remaining + } + } + + // must be an even number of digits + var strLen = string.length + if (strLen % 2 !== 0) throw new TypeError('Invalid hex string') + + if (length > strLen / 2) { + length = strLen / 2 + } + for (var i = 0; i < length; ++i) { + var parsed = parseInt(string.substr(i * 2, 2), 16) + if (isNaN(parsed)) return i + buf[offset + i] = parsed + } + return i +} + +function utf8Write (buf, string, offset, length) { + return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length) +} + +function asciiWrite (buf, string, offset, length) { + return blitBuffer(asciiToBytes(string), buf, offset, length) +} + +function latin1Write (buf, string, offset, length) { + return asciiWrite(buf, string, offset, length) +} + +function base64Write (buf, string, offset, length) { + return blitBuffer(base64ToBytes(string), buf, offset, length) +} + +function ucs2Write (buf, string, offset, length) { + return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length) +} + +Buffer.prototype.write = function write (string, offset, length, encoding) { + // Buffer#write(string) + if (offset === undefined) { + encoding = 'utf8' + length = this.length + offset = 0 + // Buffer#write(string, encoding) + } else if (length === undefined && typeof offset === 'string') { + encoding = offset + length = this.length + offset = 0 + // Buffer#write(string, offset[, length][, encoding]) + } else if (isFinite(offset)) { + offset = offset | 0 + if (isFinite(length)) { + length = length | 0 + if (encoding === undefined) encoding = 'utf8' + } else { + encoding = length + length = undefined + } + // legacy write(string, encoding, offset, length) - remove in v0.13 + } else { + throw new Error( + 'Buffer.write(string, encoding, offset[, length]) is no longer supported' + ) + } + + var remaining = this.length - offset + if (length === undefined || length > remaining) length = remaining + + if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) { + throw new RangeError('Attempt to write outside buffer bounds') + } + + if (!encoding) encoding = 'utf8' + + var loweredCase = false + for (;;) { + switch (encoding) { + case 'hex': + return hexWrite(this, string, offset, length) + + case 'utf8': + case 'utf-8': + return utf8Write(this, string, offset, length) + + case 'ascii': + return asciiWrite(this, string, offset, length) + + case 'latin1': + case 'binary': + return latin1Write(this, string, offset, length) + + case 'base64': + // Warning: maxLength not taken into account in base64Write + return base64Write(this, string, offset, length) + + case 'ucs2': + case 'ucs-2': + case 'utf16le': + case 'utf-16le': + return ucs2Write(this, string, offset, length) + + default: + if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding) + encoding = ('' + encoding).toLowerCase() + loweredCase = true + } + } +} + +Buffer.prototype.toJSON = function toJSON () { + return { + type: 'Buffer', + data: Array.prototype.slice.call(this._arr || this, 0) + } +} + +function base64Slice (buf, start, end) { + if (start === 0 && end === buf.length) { + return base64.fromByteArray(buf) + } else { + return base64.fromByteArray(buf.slice(start, end)) + } +} + +function utf8Slice (buf, start, end) { + end = Math.min(buf.length, end) + var res = [] + + var i = start + while (i < end) { + var firstByte = buf[i] + var codePoint = null + var bytesPerSequence = (firstByte > 0xEF) ? 4 + : (firstByte > 0xDF) ? 3 + : (firstByte > 0xBF) ? 2 + : 1 + + if (i + bytesPerSequence <= end) { + var secondByte, thirdByte, fourthByte, tempCodePoint + + switch (bytesPerSequence) { + case 1: + if (firstByte < 0x80) { + codePoint = firstByte + } + break + case 2: + secondByte = buf[i + 1] + if ((secondByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F) + if (tempCodePoint > 0x7F) { + codePoint = tempCodePoint + } + } + break + case 3: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F) + if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) { + codePoint = tempCodePoint + } + } + break + case 4: + secondByte = buf[i + 1] + thirdByte = buf[i + 2] + fourthByte = buf[i + 3] + if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) { + tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F) + if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) { + codePoint = tempCodePoint + } + } + } + } + + if (codePoint === null) { + // we did not generate a valid codePoint so insert a + // replacement char (U+FFFD) and advance only 1 byte + codePoint = 0xFFFD + bytesPerSequence = 1 + } else if (codePoint > 0xFFFF) { + // encode to utf16 (surrogate pair dance) + codePoint -= 0x10000 + res.push(codePoint >>> 10 & 0x3FF | 0xD800) + codePoint = 0xDC00 | codePoint & 0x3FF + } + + res.push(codePoint) + i += bytesPerSequence + } + + return decodeCodePointsArray(res) +} + +// Based on http://stackoverflow.com/a/22747272/680742, the browser with +// the lowest limit is Chrome, with 0x10000 args. +// We go 1 magnitude less, for safety +var MAX_ARGUMENTS_LENGTH = 0x1000 + +function decodeCodePointsArray (codePoints) { + var len = codePoints.length + if (len <= MAX_ARGUMENTS_LENGTH) { + return String.fromCharCode.apply(String, codePoints) // avoid extra slice() + } + + // Decode in chunks to avoid "call stack size exceeded". + var res = '' + var i = 0 + while (i < len) { + res += String.fromCharCode.apply( + String, + codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH) + ) + } + return res +} + +function asciiSlice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i] & 0x7F) + } + return ret +} + +function latin1Slice (buf, start, end) { + var ret = '' + end = Math.min(buf.length, end) + + for (var i = start; i < end; ++i) { + ret += String.fromCharCode(buf[i]) + } + return ret +} + +function hexSlice (buf, start, end) { + var len = buf.length + + if (!start || start < 0) start = 0 + if (!end || end < 0 || end > len) end = len + + var out = '' + for (var i = start; i < end; ++i) { + out += toHex(buf[i]) + } + return out +} + +function utf16leSlice (buf, start, end) { + var bytes = buf.slice(start, end) + var res = '' + for (var i = 0; i < bytes.length; i += 2) { + res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256) + } + return res +} + +Buffer.prototype.slice = function slice (start, end) { + var len = this.length + start = ~~start + end = end === undefined ? len : ~~end + + if (start < 0) { + start += len + if (start < 0) start = 0 + } else if (start > len) { + start = len + } + + if (end < 0) { + end += len + if (end < 0) end = 0 + } else if (end > len) { + end = len + } + + if (end < start) end = start + + var newBuf + if (Buffer.TYPED_ARRAY_SUPPORT) { + newBuf = this.subarray(start, end) + newBuf.__proto__ = Buffer.prototype + } else { + var sliceLen = end - start + newBuf = new Buffer(sliceLen, undefined) + for (var i = 0; i < sliceLen; ++i) { + newBuf[i] = this[i + start] + } + } + + return newBuf +} + +/* + * Need to make sure that buffer isn't trying to write out of bounds. + */ +function checkOffset (offset, ext, length) { + if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint') + if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length') +} + +Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + + return val +} + +Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + checkOffset(offset, byteLength, this.length) + } + + var val = this[offset + --byteLength] + var mul = 1 + while (byteLength > 0 && (mul *= 0x100)) { + val += this[offset + --byteLength] * mul + } + + return val +} + +Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + return this[offset] +} + +Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return this[offset] | (this[offset + 1] << 8) +} + +Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + return (this[offset] << 8) | this[offset + 1] +} + +Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return ((this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16)) + + (this[offset + 3] * 0x1000000) +} + +Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] * 0x1000000) + + ((this[offset + 1] << 16) | + (this[offset + 2] << 8) | + this[offset + 3]) +} + +Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var val = this[offset] + var mul = 1 + var i = 0 + while (++i < byteLength && (mul *= 0x100)) { + val += this[offset + i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) { + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) checkOffset(offset, byteLength, this.length) + + var i = byteLength + var mul = 1 + var val = this[offset + --i] + while (i > 0 && (mul *= 0x100)) { + val += this[offset + --i] * mul + } + mul *= 0x80 + + if (val >= mul) val -= Math.pow(2, 8 * byteLength) + + return val +} + +Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) { + if (!noAssert) checkOffset(offset, 1, this.length) + if (!(this[offset] & 0x80)) return (this[offset]) + return ((0xff - this[offset] + 1) * -1) +} + +Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset] | (this[offset + 1] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 2, this.length) + var val = this[offset + 1] | (this[offset] << 8) + return (val & 0x8000) ? val | 0xFFFF0000 : val +} + +Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset]) | + (this[offset + 1] << 8) | + (this[offset + 2] << 16) | + (this[offset + 3] << 24) +} + +Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + + return (this[offset] << 24) | + (this[offset + 1] << 16) | + (this[offset + 2] << 8) | + (this[offset + 3]) +} + +Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, true, 23, 4) +} + +Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 4, this.length) + return ieee754.read(this, offset, false, 23, 4) +} + +Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, true, 52, 8) +} + +Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) { + if (!noAssert) checkOffset(offset, 8, this.length) + return ieee754.read(this, offset, false, 52, 8) +} + +function checkInt (buf, value, offset, ext, max, min) { + if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance') + if (value > max || value < min) throw new RangeError('"value" argument is out of bounds') + if (offset + ext > buf.length) throw new RangeError('Index out of range') +} + +Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var mul = 1 + var i = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + byteLength = byteLength | 0 + if (!noAssert) { + var maxBytes = Math.pow(2, 8 * byteLength) - 1 + checkInt(this, value, offset, byteLength, maxBytes, 0) + } + + var i = byteLength - 1 + var mul = 1 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + this[offset + i] = (value / mul) & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + this[offset] = (value & 0xff) + return offset + 1 +} + +function objectWriteUInt16 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) { + buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>> + (littleEndian ? i : 1 - i) * 8 + } +} + +Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +function objectWriteUInt32 (buf, value, offset, littleEndian) { + if (value < 0) value = 0xffffffff + value + 1 + for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) { + buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff + } +} + +Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset + 3] = (value >>> 24) + this[offset + 2] = (value >>> 16) + this[offset + 1] = (value >>> 8) + this[offset] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = 0 + var mul = 1 + var sub = 0 + this[offset] = value & 0xFF + while (++i < byteLength && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) { + var limit = Math.pow(2, 8 * byteLength - 1) + + checkInt(this, value, offset, byteLength, limit - 1, -limit) + } + + var i = byteLength - 1 + var mul = 1 + var sub = 0 + this[offset + i] = value & 0xFF + while (--i >= 0 && (mul *= 0x100)) { + if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) { + sub = 1 + } + this[offset + i] = ((value / mul) >> 0) - sub & 0xFF + } + + return offset + byteLength +} + +Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80) + if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value) + if (value < 0) value = 0xff + value + 1 + this[offset] = (value & 0xff) + return offset + 1 +} + +Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + } else { + objectWriteUInt16(this, value, offset, true) + } + return offset + 2 +} + +Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 8) + this[offset + 1] = (value & 0xff) + } else { + objectWriteUInt16(this, value, offset, false) + } + return offset + 2 +} + +Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value & 0xff) + this[offset + 1] = (value >>> 8) + this[offset + 2] = (value >>> 16) + this[offset + 3] = (value >>> 24) + } else { + objectWriteUInt32(this, value, offset, true) + } + return offset + 4 +} + +Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) { + value = +value + offset = offset | 0 + if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000) + if (value < 0) value = 0xffffffff + value + 1 + if (Buffer.TYPED_ARRAY_SUPPORT) { + this[offset] = (value >>> 24) + this[offset + 1] = (value >>> 16) + this[offset + 2] = (value >>> 8) + this[offset + 3] = (value & 0xff) + } else { + objectWriteUInt32(this, value, offset, false) + } + return offset + 4 +} + +function checkIEEE754 (buf, value, offset, ext, max, min) { + if (offset + ext > buf.length) throw new RangeError('Index out of range') + if (offset < 0) throw new RangeError('Index out of range') +} + +function writeFloat (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38) + } + ieee754.write(buf, value, offset, littleEndian, 23, 4) + return offset + 4 +} + +Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) { + return writeFloat(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) { + return writeFloat(this, value, offset, false, noAssert) +} + +function writeDouble (buf, value, offset, littleEndian, noAssert) { + if (!noAssert) { + checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308) + } + ieee754.write(buf, value, offset, littleEndian, 52, 8) + return offset + 8 +} + +Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) { + return writeDouble(this, value, offset, true, noAssert) +} + +Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) { + return writeDouble(this, value, offset, false, noAssert) +} + +// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length) +Buffer.prototype.copy = function copy (target, targetStart, start, end) { + if (!start) start = 0 + if (!end && end !== 0) end = this.length + if (targetStart >= target.length) targetStart = target.length + if (!targetStart) targetStart = 0 + if (end > 0 && end < start) end = start + + // Copy 0 bytes; we're done + if (end === start) return 0 + if (target.length === 0 || this.length === 0) return 0 + + // Fatal error conditions + if (targetStart < 0) { + throw new RangeError('targetStart out of bounds') + } + if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds') + if (end < 0) throw new RangeError('sourceEnd out of bounds') + + // Are we oob? + if (end > this.length) end = this.length + if (target.length - targetStart < end - start) { + end = target.length - targetStart + start + } + + var len = end - start + var i + + if (this === target && start < targetStart && targetStart < end) { + // descending copy from end + for (i = len - 1; i >= 0; --i) { + target[i + targetStart] = this[i + start] + } + } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) { + // ascending copy from start + for (i = 0; i < len; ++i) { + target[i + targetStart] = this[i + start] + } + } else { + Uint8Array.prototype.set.call( + target, + this.subarray(start, start + len), + targetStart + ) + } + + return len +} + +// Usage: +// buffer.fill(number[, offset[, end]]) +// buffer.fill(buffer[, offset[, end]]) +// buffer.fill(string[, offset[, end]][, encoding]) +Buffer.prototype.fill = function fill (val, start, end, encoding) { + // Handle string cases: + if (typeof val === 'string') { + if (typeof start === 'string') { + encoding = start + start = 0 + end = this.length + } else if (typeof end === 'string') { + encoding = end + end = this.length + } + if (val.length === 1) { + var code = val.charCodeAt(0) + if (code < 256) { + val = code + } + } + if (encoding !== undefined && typeof encoding !== 'string') { + throw new TypeError('encoding must be a string') + } + if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) { + throw new TypeError('Unknown encoding: ' + encoding) + } + } else if (typeof val === 'number') { + val = val & 255 + } + + // Invalid ranges are not set to a default, so can range check early. + if (start < 0 || this.length < start || this.length < end) { + throw new RangeError('Out of range index') + } + + if (end <= start) { + return this + } + + start = start >>> 0 + end = end === undefined ? this.length : end >>> 0 + + if (!val) val = 0 + + var i + if (typeof val === 'number') { + for (i = start; i < end; ++i) { + this[i] = val + } + } else { + var bytes = Buffer.isBuffer(val) + ? val + : utf8ToBytes(new Buffer(val, encoding).toString()) + var len = bytes.length + for (i = 0; i < end - start; ++i) { + this[i + start] = bytes[i % len] + } + } + + return this +} + +// HELPER FUNCTIONS +// ================ + +var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g + +function base64clean (str) { + // Node strips out invalid characters like \n and \t from the string, base64-js does not + str = stringtrim(str).replace(INVALID_BASE64_RE, '') + // Node converts strings with length < 2 to '' + if (str.length < 2) return '' + // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not + while (str.length % 4 !== 0) { + str = str + '=' + } + return str +} + +function stringtrim (str) { + if (str.trim) return str.trim() + return str.replace(/^\s+|\s+$/g, '') +} + +function toHex (n) { + if (n < 16) return '0' + n.toString(16) + return n.toString(16) +} + +function utf8ToBytes (string, units) { + units = units || Infinity + var codePoint + var length = string.length + var leadSurrogate = null + var bytes = [] + + for (var i = 0; i < length; ++i) { + codePoint = string.charCodeAt(i) + + // is surrogate component + if (codePoint > 0xD7FF && codePoint < 0xE000) { + // last char was a lead + if (!leadSurrogate) { + // no lead yet + if (codePoint > 0xDBFF) { + // unexpected trail + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } else if (i + 1 === length) { + // unpaired lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + continue + } + + // valid lead + leadSurrogate = codePoint + + continue + } + + // 2 leads in a row + if (codePoint < 0xDC00) { + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + leadSurrogate = codePoint + continue + } + + // valid surrogate pair + codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000 + } else if (leadSurrogate) { + // valid bmp char, but last char was a lead + if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD) + } + + leadSurrogate = null + + // encode utf8 + if (codePoint < 0x80) { + if ((units -= 1) < 0) break + bytes.push(codePoint) + } else if (codePoint < 0x800) { + if ((units -= 2) < 0) break + bytes.push( + codePoint >> 0x6 | 0xC0, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x10000) { + if ((units -= 3) < 0) break + bytes.push( + codePoint >> 0xC | 0xE0, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else if (codePoint < 0x110000) { + if ((units -= 4) < 0) break + bytes.push( + codePoint >> 0x12 | 0xF0, + codePoint >> 0xC & 0x3F | 0x80, + codePoint >> 0x6 & 0x3F | 0x80, + codePoint & 0x3F | 0x80 + ) + } else { + throw new Error('Invalid code point') + } + } + + return bytes +} + +function asciiToBytes (str) { + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + // Node's code seems to be doing this and not & 0x7F.. + byteArray.push(str.charCodeAt(i) & 0xFF) + } + return byteArray +} + +function utf16leToBytes (str, units) { + var c, hi, lo + var byteArray = [] + for (var i = 0; i < str.length; ++i) { + if ((units -= 2) < 0) break + + c = str.charCodeAt(i) + hi = c >> 8 + lo = c % 256 + byteArray.push(lo) + byteArray.push(hi) + } + + return byteArray +} + +function base64ToBytes (str) { + return base64.toByteArray(base64clean(str)) +} + +function blitBuffer (src, dst, offset, length) { + for (var i = 0; i < length; ++i) { + if ((i + offset >= dst.length) || (i >= src.length)) break + dst[i + offset] = src[i] + } + return i +} + +function isnan (val) { + return val !== val // eslint-disable-line no-self-compare +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"base64-js":16,"ieee754":20,"isarray":22}],19:[function(require,module,exports){ +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; + +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; + +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; + +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; +}; + +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; + + if (!this._events) + this._events = {}; + + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } + + handler = this._events[type]; + + if (isUndefined(handler)) + return false; + + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } + + return true; +}; + +EventEmitter.prototype.addListener = function(type, listener) { + var m; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events) + this._events = {}; + + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); + + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + var fired = false; + + function g() { + this.removeListener(type, g); + + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } + + g.listener = listener; + this.on(type, g); + + return this; +}; + +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; + + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } + + if (position < 0) + return this; + + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); + } + + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } + + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } + + listeners = this._events[type]; + + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; + + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; + +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; + + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; + +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; + +function isFunction(arg) { + return typeof arg === 'function'; +} + +function isNumber(arg) { + return typeof arg === 'number'; +} + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} + +function isUndefined(arg) { + return arg === void 0; +} + +},{}],20:[function(require,module,exports){ +exports.read = function (buffer, offset, isLE, mLen, nBytes) { + var e, m + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var nBits = -7 + var i = isLE ? (nBytes - 1) : 0 + var d = isLE ? -1 : 1 + var s = buffer[offset + i] + + i += d + + e = s & ((1 << (-nBits)) - 1) + s >>= (-nBits) + nBits += eLen + for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + m = e & ((1 << (-nBits)) - 1) + e >>= (-nBits) + nBits += mLen + for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {} + + if (e === 0) { + e = 1 - eBias + } else if (e === eMax) { + return m ? NaN : ((s ? -1 : 1) * Infinity) + } else { + m = m + Math.pow(2, mLen) + e = e - eBias + } + return (s ? -1 : 1) * m * Math.pow(2, e - mLen) +} + +exports.write = function (buffer, value, offset, isLE, mLen, nBytes) { + var e, m, c + var eLen = nBytes * 8 - mLen - 1 + var eMax = (1 << eLen) - 1 + var eBias = eMax >> 1 + var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0) + var i = isLE ? 0 : (nBytes - 1) + var d = isLE ? 1 : -1 + var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0 + + value = Math.abs(value) + + if (isNaN(value) || value === Infinity) { + m = isNaN(value) ? 1 : 0 + e = eMax + } else { + e = Math.floor(Math.log(value) / Math.LN2) + if (value * (c = Math.pow(2, -e)) < 1) { + e-- + c *= 2 + } + if (e + eBias >= 1) { + value += rt / c + } else { + value += rt * Math.pow(2, 1 - eBias) + } + if (value * c >= 2) { + e++ + c /= 2 + } + + if (e + eBias >= eMax) { + m = 0 + e = eMax + } else if (e + eBias >= 1) { + m = (value * c - 1) * Math.pow(2, mLen) + e = e + eBias + } else { + m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen) + e = 0 + } + } + + for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {} + + e = (e << mLen) | m + eLen += mLen + for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {} + + buffer[offset + i - d] |= s * 128 +} + +},{}],21:[function(require,module,exports){ +/*! + * Determine if an object is a Buffer + * + * @author Feross Aboukhadijeh + * @license MIT + */ + +// The _isBuffer check is for Safari 5-7 support, because it's missing +// Object.prototype.constructor. Remove this eventually +module.exports = function (obj) { + return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer) +} + +function isBuffer (obj) { + return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj) +} + +// For Node v0.10 support. Remove this eventually. +function isSlowBuffer (obj) { + return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0)) +} + +},{}],22:[function(require,module,exports){ +arguments[4][6][0].apply(exports,arguments) +},{"dup":6}],23:[function(require,module,exports){ +// shim for using process in browser +var process = module.exports = {}; + +// cached from whatever global is present so that test runners that stub it +// don't break things. But we need to wrap it in a try catch in case it is +// wrapped in strict mode code which doesn't define any globals. It's inside a +// function because try/catches deoptimize in certain engines. + +var cachedSetTimeout; +var cachedClearTimeout; + +function defaultSetTimout() { + throw new Error('setTimeout has not been defined'); +} +function defaultClearTimeout () { + throw new Error('clearTimeout has not been defined'); +} +(function () { + try { + if (typeof setTimeout === 'function') { + cachedSetTimeout = setTimeout; + } else { + cachedSetTimeout = defaultSetTimout; + } + } catch (e) { + cachedSetTimeout = defaultSetTimout; + } + try { + if (typeof clearTimeout === 'function') { + cachedClearTimeout = clearTimeout; + } else { + cachedClearTimeout = defaultClearTimeout; + } + } catch (e) { + cachedClearTimeout = defaultClearTimeout; + } +} ()) +function runTimeout(fun) { + if (cachedSetTimeout === setTimeout) { + //normal enviroments in sane situations + return setTimeout(fun, 0); + } + // if setTimeout wasn't available but was latter defined + if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { + cachedSetTimeout = setTimeout; + return setTimeout(fun, 0); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedSetTimeout(fun, 0); + } catch(e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedSetTimeout.call(null, fun, 0); + } catch(e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error + return cachedSetTimeout.call(this, fun, 0); + } + } + + +} +function runClearTimeout(marker) { + if (cachedClearTimeout === clearTimeout) { + //normal enviroments in sane situations + return clearTimeout(marker); + } + // if clearTimeout wasn't available but was latter defined + if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { + cachedClearTimeout = clearTimeout; + return clearTimeout(marker); + } + try { + // when when somebody has screwed with setTimeout but no I.E. maddness + return cachedClearTimeout(marker); + } catch (e){ + try { + // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally + return cachedClearTimeout.call(null, marker); + } catch (e){ + // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. + // Some versions of I.E. have different rules for clearTimeout vs setTimeout + return cachedClearTimeout.call(this, marker); + } + } + + + +} +var queue = []; +var draining = false; +var currentQueue; +var queueIndex = -1; + +function cleanUpNextTick() { + if (!draining || !currentQueue) { + return; + } + draining = false; + if (currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + drainQueue(); + } +} + +function drainQueue() { + if (draining) { + return; + } + var timeout = runTimeout(cleanUpNextTick); + draining = true; + + var len = queue.length; + while(len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + if (currentQueue) { + currentQueue[queueIndex].run(); + } + } + queueIndex = -1; + len = queue.length; + } + currentQueue = null; + draining = false; + runClearTimeout(timeout); +} + +process.nextTick = function (fun) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(fun, args)); + if (queue.length === 1 && !draining) { + runTimeout(drainQueue); + } +}; + +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; +process.version = ''; // empty string to avoid regexp issues +process.versions = {}; + +function noop() {} + +process.on = noop; +process.addListener = noop; +process.once = noop; +process.off = noop; +process.removeListener = noop; +process.removeAllListeners = noop; +process.emit = noop; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +}; + +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; +process.umask = function() { return 0; }; + },{}]},{},[1]); diff --git a/inst/js/geojsonhint-v2beta.js b/inst/js/geojsonhint-v201.js similarity index 97% rename from inst/js/geojsonhint-v2beta.js rename to inst/js/geojsonhint-v201.js index 18d8589..477506c 100644 --- a/inst/js/geojsonhint-v2beta.js +++ b/inst/js/geojsonhint-v201.js @@ -1,9 +1,9 @@ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o 3) { return errors.push({ message: 'position should not have more than 3 elements', + level: 'message', line: _.__line__ || line }); } @@ -255,6 +256,7 @@ function hint(gj, options) { message: 'the first and last positions in a LinearRing of coordinates must be the same', line: line }); + return true; } } else if (type === 'Line' && coords.length < 2) { return errors.push({ @@ -269,8 +271,11 @@ function hint(gj, options) { line: line }); } else { - coords.forEach(function(c) { - positionArray(c, type, depth - 1, c.__line__ || line); + var results = coords.map(function(c) { + return positionArray(c, type, depth - 1, c.__line__ || line); + }); + return results.some(function(r) { + return r; }); } } @@ -337,7 +342,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#point + // https://tools.ietf.org/html/rfc7946#section-3.1.2 function Point(point) { crs(point); bbox(point); @@ -347,7 +352,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#polygon + // https://tools.ietf.org/html/rfc7946#section-3.1.6 function Polygon(polygon) { crs(polygon); bbox(polygon); @@ -358,7 +363,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#multipolygon + // https://tools.ietf.org/html/rfc7946#section-3.1.7 function MultiPolygon(multiPolygon) { crs(multiPolygon); bbox(multiPolygon); @@ -369,7 +374,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#linestring + // https://tools.ietf.org/html/rfc7946#section-3.1.4 function LineString(lineString) { crs(lineString); bbox(lineString); @@ -378,7 +383,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#multilinestring + // https://tools.ietf.org/html/rfc7946#section-3.1.5 function MultiLineString(multiLineString) { crs(multiLineString); bbox(multiLineString); @@ -387,7 +392,7 @@ function hint(gj, options) { } } - // http://geojson.org/geojson-spec.html#multipoint + // https://tools.ietf.org/html/rfc7946#section-3.1.3 function MultiPoint(multiPoint) { crs(multiPoint); bbox(multiPoint); @@ -396,6 +401,7 @@ function hint(gj, options) { } } + // https://tools.ietf.org/html/rfc7946#section-3.1.8 function GeometryCollection(geometryCollection) { crs(geometryCollection); bbox(geometryCollection); @@ -426,6 +432,7 @@ function hint(gj, options) { } } + // https://tools.ietf.org/html/rfc7946#section-3.2 function Feature(feature) { crs(feature); bbox(feature); @@ -458,7 +465,7 @@ function hint(gj, options) { } requiredProperty(feature, 'properties', 'object'); if (!requiredProperty(feature, 'geometry', 'object')) { - // http://geojson.org/geojson-spec.html#feature-objects + // https://tools.ietf.org/html/rfc7946#section-3.2 // tolerate null geometry if (feature.geometry) root(feature.geometry); } @@ -525,10 +532,10 @@ function isRingClockwise (coords) { function isPolyRHR (coords) { if (coords && coords.length > 0) { - if (!isRingClockwise(coords[0])) + if (isRingClockwise(coords[0])) return false; var interiorCoords = coords.slice(1, coords.length); - if (interiorCoords.some(isRingClockwise)) + if (!interiorCoords.every(isRingClockwise)) return false; } return true; diff --git a/inst/js/geojsonhint.js b/inst/js/geojsonhint.js deleted file mode 100644 index ab782e0..0000000 --- a/inst/js/geojsonhint.js +++ /dev/null @@ -1,1355 +0,0 @@ -(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o} an array of errors - */ -function hint(str, options) { - - var gj, errors = []; - - if (typeof str === 'object') { - gj = str; - } else if (typeof str === 'string') { - try { - gj = jsonlint.parse(str); - } catch(e) { - var match = e.message.match(/line (\d+)/), - lineNumber = 0; - if (match) { lineNumber = parseInt(match[1], 10); } - return [{ - line: lineNumber - 1, - message: e.message, - error: e - }]; - } - } else { - return [{ - message: 'Expected string or object as input', - line: 0 - }]; - } - - errors = errors.concat(geojsonHintObject.hint(gj, options)); - - return errors; -} - -module.exports.hint = hint; - -},{"./object":4,"jsonlint-lines":3}],3:[function(require,module,exports){ -(function (process){ -/* parser generated by jison 0.4.17 */ -/* - Returns a Parser object of the following structure: - - Parser: { - yy: {} - } - - Parser.prototype: { - yy: {}, - trace: function(), - symbols_: {associative list: name ==> number}, - terminals_: {associative list: number ==> name}, - productions_: [...], - performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$), - table: [...], - defaultActions: {...}, - parseError: function(str, hash), - parse: function(input), - - lexer: { - EOF: 1, - parseError: function(str, hash), - setInput: function(input), - input: function(), - unput: function(str), - more: function(), - less: function(n), - pastInput: function(), - upcomingInput: function(), - showPosition: function(), - test_match: function(regex_match_array, rule_index), - next: function(), - lex: function(), - begin: function(condition), - popState: function(), - _currentRules: function(), - topState: function(), - pushState: function(condition), - - options: { - ranges: boolean (optional: true ==> token location info will include a .range[] member) - flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match) - backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code) - }, - - performAction: function(yy, yy_, $avoiding_name_collisions, YY_START), - rules: [...], - conditions: {associative list: name ==> set}, - } - } - - - token location info (@$, _$, etc.): { - first_line: n, - last_line: n, - first_column: n, - last_column: n, - range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based) - } - - - the parseError function receives a 'hash' object with these members for lexer and parser errors: { - text: (matched text) - token: (the produced terminal token, if any) - line: (yylineno) - } - while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: { - loc: (yylloc) - expected: (string describing the set of expected tokens) - recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error) - } -*/ -var jsonlint = (function(){ -var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,12],$V1=[1,13],$V2=[1,9],$V3=[1,10],$V4=[1,11],$V5=[1,14],$V6=[1,15],$V7=[14,18,22,24],$V8=[18,22],$V9=[22,24]; -var parser = {trace: function trace() { }, -yy: {}, -symbols_: {"error":2,"JSONString":3,"STRING":4,"JSONNumber":5,"NUMBER":6,"JSONNullLiteral":7,"NULL":8,"JSONBooleanLiteral":9,"TRUE":10,"FALSE":11,"JSONText":12,"JSONValue":13,"EOF":14,"JSONObject":15,"JSONArray":16,"{":17,"}":18,"JSONMemberList":19,"JSONMember":20,":":21,",":22,"[":23,"]":24,"JSONElementList":25,"$accept":0,"$end":1}, -terminals_: {2:"error",4:"STRING",6:"NUMBER",8:"NULL",10:"TRUE",11:"FALSE",14:"EOF",17:"{",18:"}",21:":",22:",",23:"[",24:"]"}, -productions_: [0,[3,1],[5,1],[7,1],[9,1],[9,1],[12,2],[13,1],[13,1],[13,1],[13,1],[13,1],[13,1],[15,2],[15,3],[20,3],[19,1],[19,3],[16,2],[16,3],[25,1],[25,3]], -performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { -/* this == yyval */ - -var $0 = $$.length - 1; -switch (yystate) { -case 1: - // replace escaped characters with actual character - this.$ = yytext.replace(/\\(\\|")/g, "$"+"1") - .replace(/\\n/g,'\n') - .replace(/\\r/g,'\r') - .replace(/\\t/g,'\t') - .replace(/\\v/g,'\v') - .replace(/\\f/g,'\f') - .replace(/\\b/g,'\b'); - -break; -case 2: -this.$ = Number(yytext); -break; -case 3: -this.$ = null; -break; -case 4: -this.$ = true; -break; -case 5: -this.$ = false; -break; -case 6: -return this.$ = $$[$0-1]; -break; -case 13: -this.$ = {}; Object.defineProperty(this.$, '__line__', { - value: this._$.first_line, - enumerable: false - }) -break; -case 14: case 19: -this.$ = $$[$0-1]; Object.defineProperty(this.$, '__line__', { - value: this._$.first_line, - enumerable: false - }) -break; -case 15: -this.$ = [$$[$0-2], $$[$0]]; -break; -case 16: -this.$ = {}; this.$[$$[$0][0]] = $$[$0][1]; -break; -case 17: - - this.$ = $$[$0-2]; - if ($$[$0-2][$$[$0][0]] !== undefined) { - if (!this.$.__duplicateProperties__) { - Object.defineProperty(this.$, '__duplicateProperties__', { - value: [], - enumerable: false - }); - } - this.$.__duplicateProperties__.push($$[$0][0]); - } - $$[$0-2][$$[$0][0]] = $$[$0][1]; - -break; -case 18: -this.$ = []; Object.defineProperty(this.$, '__line__', { - value: this._$.first_line, - enumerable: false - }) -break; -case 20: -this.$ = [$$[$0]]; -break; -case 21: -this.$ = $$[$0-2]; $$[$0-2].push($$[$0]); -break; -} -}, -table: [{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,12:1,13:2,15:7,16:8,17:$V5,23:$V6},{1:[3]},{14:[1,16]},o($V7,[2,7]),o($V7,[2,8]),o($V7,[2,9]),o($V7,[2,10]),o($V7,[2,11]),o($V7,[2,12]),o($V7,[2,3]),o($V7,[2,4]),o($V7,[2,5]),o([14,18,21,22,24],[2,1]),o($V7,[2,2]),{3:20,4:$V0,18:[1,17],19:18,20:19},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:23,15:7,16:8,17:$V5,23:$V6,24:[1,21],25:22},{1:[2,6]},o($V7,[2,13]),{18:[1,24],22:[1,25]},o($V8,[2,16]),{21:[1,26]},o($V7,[2,18]),{22:[1,28],24:[1,27]},o($V9,[2,20]),o($V7,[2,14]),{3:20,4:$V0,20:29},{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:30,15:7,16:8,17:$V5,23:$V6},o($V7,[2,19]),{3:5,4:$V0,5:6,6:$V1,7:3,8:$V2,9:4,10:$V3,11:$V4,13:31,15:7,16:8,17:$V5,23:$V6},o($V8,[2,17]),o($V8,[2,15]),o($V9,[2,21])], -defaultActions: {16:[2,6]}, -parseError: function parseError(str, hash) { - if (hash.recoverable) { - this.trace(str); - } else { - function _parseError (msg, hash) { - this.message = msg; - this.hash = hash; - } - _parseError.prototype = Error; - - throw new _parseError(str, hash); - } -}, -parse: function parse(input) { - var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; - var args = lstack.slice.call(arguments, 1); - var lexer = Object.create(this.lexer); - var sharedState = { yy: {} }; - for (var k in this.yy) { - if (Object.prototype.hasOwnProperty.call(this.yy, k)) { - sharedState.yy[k] = this.yy[k]; - } - } - lexer.setInput(input, sharedState.yy); - sharedState.yy.lexer = lexer; - sharedState.yy.parser = this; - if (typeof lexer.yylloc == 'undefined') { - lexer.yylloc = {}; - } - var yyloc = lexer.yylloc; - lstack.push(yyloc); - var ranges = lexer.options && lexer.options.ranges; - if (typeof sharedState.yy.parseError === 'function') { - this.parseError = sharedState.yy.parseError; - } else { - this.parseError = Object.getPrototypeOf(this).parseError; - } - function popStack(n) { - stack.length = stack.length - 2 * n; - vstack.length = vstack.length - n; - lstack.length = lstack.length - n; - } - _token_stack: - var lex = function () { - var token; - token = lexer.lex() || EOF; - if (typeof token !== 'number') { - token = self.symbols_[token] || token; - } - return token; - }; - var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; - while (true) { - state = stack[stack.length - 1]; - if (this.defaultActions[state]) { - action = this.defaultActions[state]; - } else { - if (symbol === null || typeof symbol == 'undefined') { - symbol = lex(); - } - action = table[state] && table[state][symbol]; - } - if (typeof action === 'undefined' || !action.length || !action[0]) { - var errStr = ''; - expected = []; - for (p in table[state]) { - if (this.terminals_[p] && p > TERROR) { - expected.push('\'' + this.terminals_[p] + '\''); - } - } - if (lexer.showPosition) { - errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; - } else { - errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); - } - this.parseError(errStr, { - text: lexer.match, - token: this.terminals_[symbol] || symbol, - line: lexer.yylineno, - loc: yyloc, - expected: expected - }); - } - if (action[0] instanceof Array && action.length > 1) { - throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); - } - switch (action[0]) { - case 1: - stack.push(symbol); - vstack.push(lexer.yytext); - lstack.push(lexer.yylloc); - stack.push(action[1]); - symbol = null; - if (!preErrorSymbol) { - yyleng = lexer.yyleng; - yytext = lexer.yytext; - yylineno = lexer.yylineno; - yyloc = lexer.yylloc; - if (recovering > 0) { - recovering--; - } - } else { - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - case 2: - len = this.productions_[action[1]][1]; - yyval.$ = vstack[vstack.length - len]; - yyval._$ = { - first_line: lstack[lstack.length - (len || 1)].first_line, - last_line: lstack[lstack.length - 1].last_line, - first_column: lstack[lstack.length - (len || 1)].first_column, - last_column: lstack[lstack.length - 1].last_column - }; - if (ranges) { - yyval._$.range = [ - lstack[lstack.length - (len || 1)].range[0], - lstack[lstack.length - 1].range[1] - ]; - } - r = this.performAction.apply(yyval, [ - yytext, - yyleng, - yylineno, - sharedState.yy, - action[1], - vstack, - lstack - ].concat(args)); - if (typeof r !== 'undefined') { - return r; - } - if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); - } - stack.push(this.productions_[action[1]][0]); - vstack.push(yyval.$); - lstack.push(yyval._$); - newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; - stack.push(newState); - break; - case 3: - return true; - } - } - return true; -}}; -/* generated by jison-lex 0.3.4 */ -var lexer = (function(){ -var lexer = ({ - -EOF:1, - -parseError:function parseError(str, hash) { - if (this.yy.parser) { - this.yy.parser.parseError(str, hash); - } else { - throw new Error(str); - } - }, - -// resets the lexer, sets new input -setInput:function (input, yy) { - this.yy = yy || this.yy || {}; - this._input = input; - this._more = this._backtrack = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - this.conditionStack = ['INITIAL']; - this.yylloc = { - first_line: 1, - first_column: 0, - last_line: 1, - last_column: 0 - }; - if (this.options.ranges) { - this.yylloc.range = [0,0]; - } - this.offset = 0; - return this; - }, - -// consumes and returns one char from the input -input:function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.offset++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno++; - this.yylloc.last_line++; - } else { - this.yylloc.last_column++; - } - if (this.options.ranges) { - this.yylloc.range[1]++; - } - - this._input = this._input.slice(1); - return ch; - }, - -// unshifts one char (or a string) into the input -unput:function (ch) { - var len = ch.length; - var lines = ch.split(/(?:\r\n?|\n)/g); - - this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length - len); - //this.yyleng -= len; - this.offset -= len; - var oldLines = this.match.split(/(?:\r\n?|\n)/g); - this.match = this.match.substr(0, this.match.length - 1); - this.matched = this.matched.substr(0, this.matched.length - 1); - - if (lines.length - 1) { - this.yylineno -= lines.length - 1; - } - var r = this.yylloc.range; - - this.yylloc = { - first_line: this.yylloc.first_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) - + oldLines[oldLines.length - lines.length].length - lines[0].length : - this.yylloc.first_column - len - }; - - if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; - } - this.yyleng = this.yytext.length; - return this; - }, - -// When called from action, caches matched text and appends it on next action -more:function () { - this._more = true; - return this; - }, - -// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead. -reject:function () { - if (this.options.backtrack_lexer) { - this._backtrack = true; - } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); - - } - return this; - }, - -// retain first n characters of the match -less:function (n) { - this.unput(this.match.slice(n)); - }, - -// displays already matched input, i.e. for error messages -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, - -// displays upcoming input, i.e. for error messages -upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); - }, - -// displays the character position where the lexing error occurred, i.e. for error messages -showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c + "^"; - }, - -// test the lexed token: return FALSE when not a match, otherwise return token -test_match:function (match, indexed_rule) { - var token, - lines, - backup; - - if (this.options.backtrack_lexer) { - // save context - backup = { - yylineno: this.yylineno, - yylloc: { - first_line: this.yylloc.first_line, - last_line: this.last_line, - first_column: this.yylloc.first_column, - last_column: this.yylloc.last_column - }, - yytext: this.yytext, - match: this.match, - matches: this.matches, - matched: this.matched, - yyleng: this.yyleng, - offset: this.offset, - _more: this._more, - _input: this._input, - yy: this.yy, - conditionStack: this.conditionStack.slice(0), - done: this.done - }; - if (this.options.ranges) { - backup.yylloc.range = this.yylloc.range.slice(0); - } - } - - lines = match[0].match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno += lines.length; - } - this.yylloc = { - first_line: this.yylloc.last_line, - last_line: this.yylineno + 1, - first_column: this.yylloc.last_column, - last_column: lines ? - lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : - this.yylloc.last_column + match[0].length - }; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; - } - this._more = false; - this._backtrack = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]); - if (this.done && this._input) { - this.done = false; - } - if (token) { - return token; - } else if (this._backtrack) { - // recover context - for (var k in backup) { - this[k] = backup[k]; - } - return false; // rule action called reject() implying the next rule should be tested instead. - } - return false; - }, - -// return next match in input -next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) { - this.done = true; - } - - var token, - match, - tempMatch, - index; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - var rules = this._currentRules(); - for (var i = 0; i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (this.options.backtrack_lexer) { - token = this.test_match(tempMatch, rules[i]); - if (token !== false) { - return token; - } else if (this._backtrack) { - match = false; - continue; // rule action called reject() implying a rule MISmatch. - } else { - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; - } - } else if (!this.options.flex) { - break; - } - } - } - if (match) { - token = this.test_match(match, rules[index]); - if (token !== false) { - return token; - } - // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace) - return false; - } - if (this._input === "") { - return this.EOF; - } else { - return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { - text: "", - token: null, - line: this.yylineno - }); - } - }, - -// return next match that has a token -lex:function lex() { - var r = this.next(); - if (r) { - return r; - } else { - return this.lex(); - } - }, - -// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack) -begin:function begin(condition) { - this.conditionStack.push(condition); - }, - -// pop the previously active lexer condition state off the condition stack -popState:function popState() { - var n = this.conditionStack.length - 1; - if (n > 0) { - return this.conditionStack.pop(); - } else { - return this.conditionStack[0]; - } - }, - -// produce the lexer rule set which is active for the currently active lexer condition state -_currentRules:function _currentRules() { - if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) { - return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; - } else { - return this.conditions["INITIAL"].rules; - } - }, - -// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available -topState:function topState(n) { - n = this.conditionStack.length - 1 - Math.abs(n || 0); - if (n >= 0) { - return this.conditionStack[n]; - } else { - return "INITIAL"; - } - }, - -// alias for begin(condition) -pushState:function pushState(condition) { - this.begin(condition); - }, - -// return the number of states currently on the stack -stateStackSize:function stateStackSize() { - return this.conditionStack.length; - }, -options: {}, -performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { -var YYSTATE=YY_START; -switch($avoiding_name_collisions) { -case 0:/* skip whitespace */ -break; -case 1:return 6 -break; -case 2:yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2); return 4 -break; -case 3:return 17 -break; -case 4:return 18 -break; -case 5:return 23 -break; -case 6:return 24 -break; -case 7:return 22 -break; -case 8:return 21 -break; -case 9:return 10 -break; -case 10:return 11 -break; -case 11:return 8 -break; -case 12:return 14 -break; -case 13:return 'INVALID' -break; -} -}, -rules: [/^(?:\s+)/,/^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,/^(?:"(?:\\[\\"bfnrt\/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,/^(?:\{)/,/^(?:\})/,/^(?:\[)/,/^(?:\])/,/^(?:,)/,/^(?::)/,/^(?:true\b)/,/^(?:false\b)/,/^(?:null\b)/,/^(?:$)/,/^(?:.)/], -conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}} -}); -return lexer; -})(); -parser.lexer = lexer; -function Parser () { - this.yy = {}; -} -Parser.prototype = parser;parser.Parser = Parser; -return new Parser; -})(); - - -if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = jsonlint; -exports.Parser = jsonlint.Parser; -exports.parse = function () { return jsonlint.parse.apply(jsonlint, arguments); }; -exports.main = function commonjsMain(args) { - if (!args[1]) { - console.log('Usage: '+args[0]+' FILE'); - process.exit(1); - } - var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8"); - return exports.parser.parse(source); -}; -if (typeof module !== 'undefined' && require.main === module) { - exports.main(process.argv.slice(1)); -} -} -}).call(this,require('_process')) -},{"_process":7,"fs":5,"path":6}],4:[function(require,module,exports){ -/** - * @alias geojsonhint - * @param {(string|object)} GeoJSON given as a string or as an object - * @param {Object} options - * @param {boolean} [options.noDuplicateMembers=true] forbid repeated - * properties. This is only available for string input, becaused parsed - * Objects cannot have duplicate properties. - * @returns {Array} an array of errors - */ -function hint(gj, options) { - - var errors = []; - - function root(_) { - - if ((!options || options.noDuplicateMembers !== false) && - _.__duplicateProperties__) { - errors.push({ - message: 'An object contained duplicate members, making parsing ambigous: ' + _.__duplicateProperties__.join(', '), - line: _.__line__ - }); - } - - if (!_.type) { - errors.push({ - message: 'The type property is required and was not found', - line: _.__line__ - }); - } else if (!types[_.type]) { - errors.push({ - message: 'The type ' + _.type + ' is unknown', - line: _.__line__ - }); - } else if (_) { - types[_.type](_); - } - } - - function everyIs(_, type) { - // make a single exception because typeof null === 'object' - return _.every(function(x) { return (x !== null) && (typeof x === type); }); - } - - function requiredProperty(_, name, type) { - if (typeof _[name] === 'undefined') { - return errors.push({ - message: '"' + name + '" property required', - line: _.__line__ - }); - } else if (type === 'array') { - if (!Array.isArray(_[name])) { - return errors.push({ - message: '"' + name + - '" property should be an array, but is an ' + - (typeof _[name]) + ' instead', - line: _.__line__ - }); - } - } else if (type && typeof _[name] !== type) { - return errors.push({ - message: '"' + name + - '" property should be ' + (type) + - ', but is an ' + (typeof _[name]) + ' instead', - line: _.__line__ - }); - } - } - - // http://geojson.org/geojson-spec.html#feature-collection-objects - function FeatureCollection(featureCollection) { - crs(featureCollection); - bbox(featureCollection); - if (!requiredProperty(featureCollection, 'features', 'array')) { - if (!everyIs(featureCollection.features, 'object')) { - return errors.push({ - message: 'Every feature must be an object', - line: featureCollection.__line__ - }); - } - featureCollection.features.forEach(Feature); - } - } - - // http://geojson.org/geojson-spec.html#positions - function position(_, line) { - if (!Array.isArray(_)) { - return errors.push({ - message: 'position should be an array, is a ' + (typeof _) + - ' instead', - line: _.__line__ || line - }); - } else { - if (_.length < 2) { - return errors.push({ - message: 'position must have 2 or more elements', - line: _.__line__ || line - }); - } - if (!everyIs(_, 'number')) { - return errors.push({ - message: 'each element in a position must be a number', - line: _.__line__ || line - }); - } - } - } - - function positionArray(coords, type, depth, line) { - if (line === undefined && coords.__line__ !== undefined) { - line = coords.__line__; - } - if (depth === 0) { - return position(coords, line); - } else { - if (depth === 1 && type) { - if (type === 'LinearRing') { - if (!Array.isArray(coords[coords.length - 1])) { - return errors.push({ - message: 'a number was found where a coordinate array should have been found: this needs to be nested more deeply', - line: line - }); - } - if (coords.length < 4) { - errors.push({ - message: 'a LinearRing of coordinates needs to have four or more positions', - line: line - }); - } - if (coords.length && - (coords[coords.length - 1].length !== coords[0].length || - !coords[coords.length - 1].every(function(position, index) { - return coords[0][index] === position; - }))) { - errors.push({ - message: 'the first and last positions in a LinearRing of coordinates must be the same', - line: line - }); - } - } else if (type === 'Line' && coords.length < 2) { - errors.push({ - message: 'a line needs to have two or more coordinates to be valid', - line: line - }); - } - } - coords.forEach(function(c) { - positionArray(c, type, depth - 1, c.__line__ || line); - }); - } - } - - function crs(_) { - if (!_.crs) return; - if (typeof _.crs === 'object') { - var strErr = requiredProperty(_.crs, 'type', 'string'), - propErr = requiredProperty(_.crs, 'properties', 'object'); - if (!strErr && !propErr) { - // http://geojson.org/geojson-spec.html#named-crs - if (_.crs.type === 'name') { - requiredProperty(_.crs.properties, 'name', 'string'); - } else if (_.crs.type === 'link') { - requiredProperty(_.crs.properties, 'href', 'string'); - } - } - } else { - errors.push({ - message: 'the value of the crs property must be an object, not a ' + (typeof _.crs), - line: _.__line__ - }); - } - } - - function bbox(_) { - if (!_.bbox) { return; } - if (Array.isArray(_.bbox)) { - if (!everyIs(_.bbox, 'number')) { - return errors.push({ - message: 'each element in a bbox property must be a number', - line: _.bbox.__line__ - }); - } - } else { - errors.push({ - message: 'bbox property must be an array of numbers, but is a ' + (typeof _.bbox), - line: _.__line__ - }); - } - } - - // http://geojson.org/geojson-spec.html#point - function Point(point) { - crs(point); - bbox(point); - if (!requiredProperty(point, 'coordinates', 'array')) { - position(point.coordinates); - } - } - - // http://geojson.org/geojson-spec.html#polygon - function Polygon(polygon) { - crs(polygon); - bbox(polygon); - if (!requiredProperty(polygon, 'coordinates', 'array')) { - positionArray(polygon.coordinates, 'LinearRing', 2); - } - } - - // http://geojson.org/geojson-spec.html#multipolygon - function MultiPolygon(multiPolygon) { - crs(multiPolygon); - bbox(multiPolygon); - if (!requiredProperty(multiPolygon, 'coordinates', 'array')) { - positionArray(multiPolygon.coordinates, 'LinearRing', 3); - } - } - - // http://geojson.org/geojson-spec.html#linestring - function LineString(lineString) { - crs(lineString); - bbox(lineString); - if (!requiredProperty(lineString, 'coordinates', 'array')) { - positionArray(lineString.coordinates, 'Line', 1); - } - } - - // http://geojson.org/geojson-spec.html#multilinestring - function MultiLineString(multiLineString) { - crs(multiLineString); - bbox(multiLineString); - if (!requiredProperty(multiLineString, 'coordinates', 'array')) { - positionArray(multiLineString.coordinates, 'Line', 2); - } - } - - // http://geojson.org/geojson-spec.html#multipoint - function MultiPoint(multiPoint) { - crs(multiPoint); - bbox(multiPoint); - if (!requiredProperty(multiPoint, 'coordinates', 'array')) { - positionArray(multiPoint.coordinates, '', 1); - } - } - - function GeometryCollection(geometryCollection) { - crs(geometryCollection); - bbox(geometryCollection); - if (!requiredProperty(geometryCollection, 'geometries', 'array')) { - geometryCollection.geometries.forEach(function(geometry) { - if (geometry) root(geometry); - }); - } - } - - function Feature(feature) { - crs(feature); - bbox(feature); - // https://github.com/geojson/draft-geojson/blob/master/middle.mkd#feature-object - if (feature.id !== undefined && - typeof feature.id !== 'string' && - typeof feature.id !== 'number') { - errors.push({ - message: 'Feature "id" property must have a string or number value', - line: feature.__line__ - }); - } - if (feature.type !== 'Feature') { - errors.push({ - message: 'GeoJSON features must have a type=feature property', - line: feature.__line__ - }); - } - requiredProperty(feature, 'properties', 'object'); - if (!requiredProperty(feature, 'geometry', 'object')) { - // http://geojson.org/geojson-spec.html#feature-objects - // tolerate null geometry - if (feature.geometry) root(feature.geometry); - } - } - - var types = { - Point: Point, - Feature: Feature, - MultiPoint: MultiPoint, - LineString: LineString, - MultiLineString: MultiLineString, - FeatureCollection: FeatureCollection, - GeometryCollection: GeometryCollection, - Polygon: Polygon, - MultiPolygon: MultiPolygon - }; - - if (typeof gj !== 'object' || - gj === null || - gj === undefined) { - errors.push({ - message: 'The root of a GeoJSON object must be an object.', - line: 0 - }); - return errors; - } - - root(gj); - - errors.forEach(function(err) { - if (err.hasOwnProperty('line') && err.line === undefined) { - delete err.line; - } - }); - - return errors; -} - -module.exports.hint = hint; - -},{}],5:[function(require,module,exports){ - -},{}],6:[function(require,module,exports){ -(function (process){ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -// resolves . and .. elements in a path array with directory names there -// must be no slashes, empty elements, or device names (c:\) in the array -// (so also no leading and trailing slashes - it does not distinguish -// relative and absolute paths) -function normalizeArray(parts, allowAboveRoot) { - // if the path tries to go above the root, `up` ends up > 0 - var up = 0; - for (var i = parts.length - 1; i >= 0; i--) { - var last = parts[i]; - if (last === '.') { - parts.splice(i, 1); - } else if (last === '..') { - parts.splice(i, 1); - up++; - } else if (up) { - parts.splice(i, 1); - up--; - } - } - - // if the path is allowed to go above the root, restore leading ..s - if (allowAboveRoot) { - for (; up--; up) { - parts.unshift('..'); - } - } - - return parts; -} - -// Split a filename into [root, dir, basename, ext], unix version -// 'root' is just a slash, or nothing. -var splitPathRe = - /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; -var splitPath = function(filename) { - return splitPathRe.exec(filename).slice(1); -}; - -// path.resolve([from ...], to) -// posix version -exports.resolve = function() { - var resolvedPath = '', - resolvedAbsolute = false; - - for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { - var path = (i >= 0) ? arguments[i] : process.cwd(); - - // Skip empty and invalid entries - if (typeof path !== 'string') { - throw new TypeError('Arguments to path.resolve must be strings'); - } else if (!path) { - continue; - } - - resolvedPath = path + '/' + resolvedPath; - resolvedAbsolute = path.charAt(0) === '/'; - } - - // At this point the path should be resolved to a full absolute path, but - // handle relative paths to be safe (might happen when process.cwd() fails) - - // Normalize the path - resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { - return !!p; - }), !resolvedAbsolute).join('/'); - - return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; -}; - -// path.normalize(path) -// posix version -exports.normalize = function(path) { - var isAbsolute = exports.isAbsolute(path), - trailingSlash = substr(path, -1) === '/'; - - // Normalize the path - path = normalizeArray(filter(path.split('/'), function(p) { - return !!p; - }), !isAbsolute).join('/'); - - if (!path && !isAbsolute) { - path = '.'; - } - if (path && trailingSlash) { - path += '/'; - } - - return (isAbsolute ? '/' : '') + path; -}; - -// posix version -exports.isAbsolute = function(path) { - return path.charAt(0) === '/'; -}; - -// posix version -exports.join = function() { - var paths = Array.prototype.slice.call(arguments, 0); - return exports.normalize(filter(paths, function(p, index) { - if (typeof p !== 'string') { - throw new TypeError('Arguments to path.join must be strings'); - } - return p; - }).join('/')); -}; - - -// path.relative(from, to) -// posix version -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - -exports.sep = '/'; -exports.delimiter = ':'; - -exports.dirname = function(path) { - var result = splitPath(path), - root = result[0], - dir = result[1]; - - if (!root && !dir) { - // No dirname whatsoever - return '.'; - } - - if (dir) { - // It has a dirname, strip trailing slash - dir = dir.substr(0, dir.length - 1); - } - - return root + dir; -}; - - -exports.basename = function(path, ext) { - var f = splitPath(path)[2]; - // TODO: make this comparison case-insensitive on windows? - if (ext && f.substr(-1 * ext.length) === ext) { - f = f.substr(0, f.length - ext.length); - } - return f; -}; - - -exports.extname = function(path) { - return splitPath(path)[3]; -}; - -function filter (xs, f) { - if (xs.filter) return xs.filter(f); - var res = []; - for (var i = 0; i < xs.length; i++) { - if (f(xs[i], i, xs)) res.push(xs[i]); - } - return res; -} - -// String.prototype.substr - negative index don't work in IE8 -var substr = 'ab'.substr(-1) === 'b' - ? function (str, start, len) { return str.substr(start, len) } - : function (str, start, len) { - if (start < 0) start = str.length + start; - return str.substr(start, len); - } -; - -}).call(this,require('_process')) -},{"_process":7}],7:[function(require,module,exports){ -// shim for using process in browser - -var process = module.exports = {}; -var queue = []; -var draining = false; - -function drainQueue() { - if (draining) { - return; - } - draining = true; - var currentQueue; - var len = queue.length; - while(len) { - currentQueue = queue; - queue = []; - var i = -1; - while (++i < len) { - currentQueue[i](); - } - len = queue.length; - } - draining = false; -} -process.nextTick = function (fun) { - queue.push(fun); - if (!draining) { - setTimeout(drainQueue, 0); - } -}; - -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; -process.version = ''; // empty string to avoid regexp issues - -function noop() {} - -process.on = noop; -process.addListener = noop; -process.once = noop; -process.off = noop; -process.removeListener = noop; -process.removeAllListeners = noop; -process.emit = noop; - -process.binding = function (name) { - throw new Error('process.binding is not supported'); -}; - -// TODO(shtylman) -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; -process.umask = function() { return 0; }; - -},{}]},{},[1]); diff --git a/inst/js/turf-invariant.js b/inst/js/turf-invariant.js index 0e71f21..5e89960 100644 --- a/inst/js/turf-invariant.js +++ b/inst/js/turf-invariant.js @@ -5,35 +5,82 @@ global.turfinvariant = require('@turf/invariant'); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"@turf/invariant":2}],2:[function(require,module,exports){ /** - * Unwrap a coordinate from a Feature with a Point geometry, a Point - * geometry, or a single coordinate. + * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate. * - * @param {*} obj any value - * @returns {Array} a coordinate + * @name getCoord + * @param {Array|Geometry|Feature} obj any value + * @returns {Array} coordinates */ function getCoord(obj) { - if (Array.isArray(obj) && - typeof obj[0] === 'number' && - typeof obj[1] === 'number') { - return obj; - } else if (obj) { - if (obj.type === 'Feature' && - obj.geometry && - obj.geometry.type === 'Point' && - Array.isArray(obj.geometry.coordinates)) { - return obj.geometry.coordinates; - } else if (obj.type === 'Point' && - Array.isArray(obj.coordinates)) { - return obj.coordinates; - } + if (!obj) throw new Error('No obj passed'); + + var coordinates = getCoords(obj); + + // getCoord() must contain at least two numbers (Point) + if (coordinates.length > 1 && + typeof coordinates[0] === 'number' && + typeof coordinates[1] === 'number') { + return coordinates; + } else { + throw new Error('Coordinate is not a valid Point'); + } +} + +/** + * Unwrap coordinates from a Feature, Geometry Object or an Array of numbers + * + * @name getCoords + * @param {Array|Geometry|Feature} obj any value + * @returns {Array} coordinates + */ +function getCoords(obj) { + if (!obj) throw new Error('No obj passed'); + var coordinates; + + // Array of numbers + if (obj.length) { + coordinates = obj; + + // Geometry Object + } else if (obj.coordinates) { + coordinates = obj.coordinates; + + // Feature + } else if (obj.geometry && obj.geometry.coordinates) { + coordinates = obj.geometry.coordinates; } - throw new Error('A coordinate, feature, or point geometry is required'); + // Checks if coordinates contains a number + if (coordinates) { + containsNumber(coordinates); + return coordinates; + } + throw new Error('No valid coordinates'); +} + +/** + * Checks if coordinates contains a number + * + * @name containsNumber + * @param {Array} coordinates GeoJSON Coordinates + * @returns {boolean} true if Array contains a number + */ +function containsNumber(coordinates) { + if (coordinates.length > 1 && + typeof coordinates[0] === 'number' && + typeof coordinates[1] === 'number') { + return true; + } + + if (Array.isArray(coordinates[0]) && coordinates[0].length) { + return containsNumber(coordinates[0]); + } + throw new Error('coordinates must only contain numbers'); } /** * Enforce expectations about types of GeoJSON objects for Turf. * - * @alias geojsonType + * @name geojsonType * @param {GeoJSON} value any GeoJSON object * @param {string} type expected GeoJSON type * @param {string} name name of calling function @@ -51,13 +98,14 @@ function geojsonType(value, type, name) { * Enforce expectations about types of {@link Feature} inputs for Turf. * Internally this uses {@link geojsonType} to judge geometry types. * - * @alias featureOf + * @name featureOf * @param {Feature} feature a feature with an expected geometry type * @param {string} type expected GeoJSON type * @param {string} name name of calling function * @throws {Error} error if value is not the expected type. */ function featureOf(feature, type, name) { + if (!feature) throw new Error('No feature passed'); if (!name) throw new Error('.featureOf() requires a name'); if (!feature || feature.type !== 'Feature' || !feature.geometry) { throw new Error('Invalid input to ' + name + ', Feature with geometry required'); @@ -71,19 +119,20 @@ function featureOf(feature, type, name) { * Enforce expectations about types of {@link FeatureCollection} inputs for Turf. * Internally this uses {@link geojsonType} to judge geometry types. * - * @alias collectionOf - * @param {FeatureCollection} featurecollection a featurecollection for which features will be judged + * @name collectionOf + * @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged * @param {string} type expected GeoJSON type * @param {string} name name of calling function * @throws {Error} if value is not the expected type. */ -function collectionOf(featurecollection, type, name) { +function collectionOf(featureCollection, type, name) { + if (!featureCollection) throw new Error('No featureCollection passed'); if (!name) throw new Error('.collectionOf() requires a name'); - if (!featurecollection || featurecollection.type !== 'FeatureCollection') { + if (!featureCollection || featureCollection.type !== 'FeatureCollection') { throw new Error('Invalid input to ' + name + ', FeatureCollection required'); } - for (var i = 0; i < featurecollection.features.length; i++) { - var feature = featurecollection.features[i]; + for (var i = 0; i < featureCollection.features.length; i++) { + var feature = featureCollection.features[i]; if (!feature || feature.type !== 'Feature' || !feature.geometry) { throw new Error('Invalid input to ' + name + ', Feature with geometry required'); } @@ -93,9 +142,62 @@ function collectionOf(featurecollection, type, name) { } } -module.exports.geojsonType = geojsonType; -module.exports.collectionOf = collectionOf; -module.exports.featureOf = featureOf; -module.exports.getCoord = getCoord; +/** + * Get Geometry from Feature or Geometry Object + * + * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object + * @returns {Geometry} GeoJSON Geometry Object + * @throws {Error} if geojson is not a Feature or Geometry Object + * @example + * var point = { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [110, 40] + * } + * } + * var geom = invariant.getGeom(point) + * //={"type": "Point", "coordinates": [110, 40]} + */ +function getGeom(geojson) { + if (!geojson) throw new Error(' is required'); + if (geojson.geometry) return geojson.geometry; + if (geojson.coordinates || geojson.geometries) return geojson; + throw new Error(' must be a Feature or Geometry Object'); +} + +/** + * Get Geometry Type from Feature or Geometry Object + * + * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object + * @returns {string} GeoJSON Geometry Type + * @throws {Error} if geojson is not a Feature or Geometry Object + * @example + * var point = { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [110, 40] + * } + * } + * var geom = invariant.getGeom(point) + * //="Point" + */ +function getGeomType(geojson) { + return getGeom(geojson).type; +} + +module.exports = { + geojsonType: geojsonType, + collectionOf: collectionOf, + featureOf: featureOf, + getCoord: getCoord, + getCoords: getCoords, + containsNumber: containsNumber, + getGeom: getGeom, + getGeomType: getGeomType +}; },{}]},{},[1]); diff --git a/inst/js/turf-meta.js b/inst/js/turf-meta.js index 86647fb..2164740 100644 --- a/inst/js/turf-meta.js +++ b/inst/js/turf-meta.js @@ -5,28 +5,58 @@ global.turfmeta = require('@turf/meta'); }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{"@turf/meta":2}],2:[function(require,module,exports){ /** - * Iterate over coordinates in any GeoJSON object, similar to - * Array.forEach. + * Callback for coordEach + * + * @private + * @callback coordEachCallback + * @param {Array} currentCoords The current coordinates being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ + +/** + * Iterate over coordinates in any GeoJSON object, similar to Array.forEach() * * @name coordEach - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (value) - * @param {boolean=} excludeWrapCoord whether or not to include - * the final coordinate of LinearRings that wraps the ring in its iteration. + * @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (currentCoords, currentIndex) + * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. * @example - * var point = { type: 'Point', coordinates: [0, 0] }; - * turfMeta.coordEach(point, function(coords) { - * // coords is equal to [0, 0] + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.coordEach(features, function (currentCoords, currentIndex) { + * //=currentCoords + * //=currentIndex * }); */ -function coordEach(layer, callback, excludeWrapCoord) { +function coordEach(geojson, callback, excludeWrapCoord) { var i, j, k, g, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, + currentIndex = 0, isGeometryCollection, - isFeatureCollection = layer.type === 'FeatureCollection', - isFeature = layer.type === 'Feature', - stop = isFeatureCollection ? layer.features.length : 1; + isFeatureCollection = geojson.type === 'FeatureCollection', + isFeature = geojson.type === 'Feature', + stop = isFeatureCollection ? geojson.features.length : 1; // This logic may look a little weird. The reason why it is that way // is because it's trying to be fast. GeoJSON supports multiple kinds @@ -42,8 +72,8 @@ function coordEach(layer, callback, excludeWrapCoord) { // be required with the normalization approach. for (i = 0; i < stop; i++) { - geometryMaybeCollection = (isFeatureCollection ? layer.features[i].geometry : - (isFeature ? layer.geometry : layer)); + geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry : + (isFeature ? geojson.geometry : geojson)); isGeometryCollection = geometryMaybeCollection.type === 'GeometryCollection'; stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1; @@ -57,18 +87,26 @@ function coordEach(layer, callback, excludeWrapCoord) { 1 : 0; if (geometry.type === 'Point') { - callback(coords); + callback(coords, currentIndex); + currentIndex++; } else if (geometry.type === 'LineString' || geometry.type === 'MultiPoint') { - for (j = 0; j < coords.length; j++) callback(coords[j]); + for (j = 0; j < coords.length; j++) { + callback(coords[j], currentIndex); + currentIndex++; + } } else if (geometry.type === 'Polygon' || geometry.type === 'MultiLineString') { for (j = 0; j < coords.length; j++) - for (k = 0; k < coords[j].length - wrapShrink; k++) - callback(coords[j][k]); + for (k = 0; k < coords[j].length - wrapShrink; k++) { + callback(coords[j][k], currentIndex); + currentIndex++; + } } else if (geometry.type === 'MultiPolygon') { for (j = 0; j < coords.length; j++) for (k = 0; k < coords[j].length; k++) - for (l = 0; l < coords[j][k].length - wrapShrink; l++) - callback(coords[j][k][l]); + for (l = 0; l < coords[j][k].length - wrapShrink; l++) { + callback(coords[j][k][l], currentIndex); + currentIndex++; + } } else if (geometry.type === 'GeometryCollection') { for (j = 0; j < geometry.geometries.length; j++) coordEach(geometry.geometries[j], callback, excludeWrapCoord); @@ -78,57 +116,161 @@ function coordEach(layer, callback, excludeWrapCoord) { } } } -module.exports.coordEach = coordEach; /** - * Reduce coordinates in any GeoJSON object into a single value, - * similar to how Array.reduce works. However, in this case we lazily run - * the reduction, so an array of all coordinates is unnecessary. + * Callback for coordReduce + * + * The first time the callback function is called, the values provided as arguments depend + * on whether the reduce method has an initialValue argument. + * + * If an initialValue is provided to the reduce method: + * - The previousValue argument is initialValue. + * - The currentValue argument is the value of the first element present in the array. + * + * If an initialValue is not provided: + * - The previousValue argument is the value of the first element present in the array. + * - The currentValue argument is the value of the second element present in the array. + * + * @private + * @callback coordReduceCallback + * @param {*} previousValue The accumulated value previously returned in the last invocation + * of the callback, or initialValue, if supplied. + * @param {[number, number]} currentCoords The current coordinate being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ + +/** + * Reduce coordinates in any GeoJSON object, similar to Array.reduce() * * @name coordReduce - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (memo, value) and returns - * a new memo - * @param {*} memo the starting value of memo: can be any type. - * @param {boolean=} excludeWrapCoord whether or not to include + * @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (previousValue, currentCoords, currentIndex) + * @param {*} [initialValue] Value to use as the first argument to the first call of the callback. + * @param {boolean} [excludeWrapCoord=false] whether or not to include * the final coordinate of LinearRings that wraps the ring in its iteration. - * @returns {*} combined value + * @returns {*} The value that results from the reduction. + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.coordReduce(features, function (previousValue, currentCoords, currentIndex) { + * //=previousValue + * //=currentCoords + * //=currentIndex + * return currentCoords; + * }); */ -function coordReduce(layer, callback, memo, excludeWrapCoord) { - coordEach(layer, function (coord) { - memo = callback(memo, coord); +function coordReduce(geojson, callback, initialValue, excludeWrapCoord) { + var previousValue = initialValue; + coordEach(geojson, function (currentCoords, currentIndex) { + if (currentIndex === 0 && initialValue === undefined) { + previousValue = currentCoords; + } else { + previousValue = callback(previousValue, currentCoords, currentIndex); + } }, excludeWrapCoord); - return memo; + return previousValue; } -module.exports.coordReduce = coordReduce; /** - * Iterate over property objects in any GeoJSON object, similar to - * Array.forEach. + * Callback for propEach + * + * @private + * @callback propEachCallback + * @param {*} currentProperties The current properties being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ + +/** + * Iterate over properties in any GeoJSON object, similar to Array.forEach() * * @name propEach - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (value) + * @param {FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (currentProperties, currentIndex) * @example - * var point = { type: 'Feature', geometry: null, properties: { foo: 1 } }; - * turfMeta.propEach(point, function(props) { - * // props is equal to { foo: 1} + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {"foo": "bar"}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {"hello": "world"}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.propEach(features, function (currentProperties, currentIndex) { + * //=currentProperties + * //=currentIndex * }); */ -function propEach(layer, callback) { +function propEach(geojson, callback) { var i; - switch (layer.type) { + switch (geojson.type) { case 'FeatureCollection': - for (i = 0; i < layer.features.length; i++) { - callback(layer.features[i].properties, i); + for (i = 0; i < geojson.features.length; i++) { + callback(geojson.features[i].properties, i); } break; case 'Feature': - callback(layer.properties, 0); + callback(geojson.properties, 0); break; } } -module.exports.propEach = propEach; + + +/** + * Callback for propReduce + * + * The first time the callback function is called, the values provided as arguments depend + * on whether the reduce method has an initialValue argument. + * + * If an initialValue is provided to the reduce method: + * - The previousValue argument is initialValue. + * - The currentValue argument is the value of the first element present in the array. + * + * If an initialValue is not provided: + * - The previousValue argument is the value of the first element present in the array. + * - The currentValue argument is the value of the second element present in the array. + * + * @private + * @callback propReduceCallback + * @param {*} previousValue The accumulated value previously returned in the last invocation + * of the callback, or initialValue, if supplied. + * @param {*} currentProperties The current properties being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ /** * Reduce properties in any GeoJSON object into a single value, @@ -136,97 +278,259 @@ module.exports.propEach = propEach; * the reduction, so an array of all properties is unnecessary. * * @name propReduce - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (memo, coord) and returns - * a new memo - * @param {*} memo the starting value of memo: can be any type. - * @returns {*} combined value + * @param {FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (previousValue, currentProperties, currentIndex) + * @param {*} [initialValue] Value to use as the first argument to the first call of the callback. + * @returns {*} The value that results from the reduction. * @example - * // an example of an even more advanced function that gives you the - * // javascript type of each property of every feature - * function propTypes (layer) { - * opts = opts || {} - * return turfMeta.propReduce(layer, function (prev, props) { - * for (var prop in props) { - * if (prev[prop]) continue - * prev[prop] = typeof props[prop] + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {"foo": "bar"}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {"hello": "world"}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } * } - * }, {}) - * } + * ] + * }; + * turf.propReduce(features, function (previousValue, currentProperties, currentIndex) { + * //=previousValue + * //=currentProperties + * //=currentIndex + * return currentProperties + * }); */ -function propReduce(layer, callback, memo) { - propEach(layer, function (prop, i) { - memo = callback(memo, prop, i); +function propReduce(geojson, callback, initialValue) { + var previousValue = initialValue; + propEach(geojson, function (currentProperties, currentIndex) { + if (currentIndex === 0 && initialValue === undefined) { + previousValue = currentProperties; + } else { + previousValue = callback(previousValue, currentProperties, currentIndex); + } }); - return memo; + return previousValue; } -module.exports.propReduce = propReduce; + +/** + * Callback for featureEach + * + * @private + * @callback featureEachCallback + * @param {Feature} currentFeature The current feature being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ /** * Iterate over features in any GeoJSON object, similar to * Array.forEach. * * @name featureEach - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (value) + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (currentFeature, currentIndex) * @example - * var feature = { type: 'Feature', geometry: null, properties: {} }; - * turfMeta.featureEach(feature, function(feature) { - * // feature == feature + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.featureEach(features, function (currentFeature, currentIndex) { + * //=currentFeature + * //=currentIndex * }); */ -function featureEach(layer, callback) { - if (layer.type === 'Feature') { - callback(layer, 0); - } else if (layer.type === 'FeatureCollection') { - for (var i = 0; i < layer.features.length; i++) { - callback(layer.features[i], i); +function featureEach(geojson, callback) { + if (geojson.type === 'Feature') { + callback(geojson, 0); + } else if (geojson.type === 'FeatureCollection') { + for (var i = 0; i < geojson.features.length; i++) { + callback(geojson.features[i], i); } } } -module.exports.featureEach = featureEach; /** - * Get all coordinates from any GeoJSON object, returning an array of coordinate - * arrays. + * Callback for featureReduce + * + * The first time the callback function is called, the values provided as arguments depend + * on whether the reduce method has an initialValue argument. + * + * If an initialValue is provided to the reduce method: + * - The previousValue argument is initialValue. + * - The currentValue argument is the value of the first element present in the array. + * + * If an initialValue is not provided: + * - The previousValue argument is the value of the first element present in the array. + * - The currentValue argument is the value of the second element present in the array. + * + * @private + * @callback featureReduceCallback + * @param {*} previousValue The accumulated value previously returned in the last invocation + * of the callback, or initialValue, if supplied. + * @param {Feature} currentFeature The current Feature being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + */ + +/** + * Reduce features in any GeoJSON object, similar to Array.reduce(). + * + * @name featureReduce + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (previousValue, currentFeature, currentIndex) + * @param {*} [initialValue] Value to use as the first argument to the first call of the callback. + * @returns {*} The value that results from the reduction. + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {"foo": "bar"}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {"hello": "world"}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.featureReduce(features, function (previousValue, currentFeature, currentIndex) { + * //=previousValue + * //=currentFeature + * //=currentIndex + * return currentFeature + * }); + */ +function featureReduce(geojson, callback, initialValue) { + var previousValue = initialValue; + featureEach(geojson, function (currentFeature, currentIndex) { + if (currentIndex === 0 && initialValue === undefined) { + previousValue = currentFeature; + } else { + previousValue = callback(previousValue, currentFeature, currentIndex); + } + }); + return previousValue; +} + +/** + * Get all coordinates from any GeoJSON object. * * @name coordAll - * @param {Object} layer any GeoJSON object + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object * @returns {Array>} coordinate position array + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * var coords = turf.coordAll(features); + * //=coords */ -function coordAll(layer) { +function coordAll(geojson) { var coords = []; - coordEach(layer, function (coord) { + coordEach(geojson, function (coord) { coords.push(coord); }); return coords; } -module.exports.coordAll = coordAll; /** - * Iterate over each geometry in any GeoJSON object, similar to - * Array.forEach. + * Iterate over each geometry in any GeoJSON object, similar to Array.forEach() * * @name geomEach - * @param {Object} layer any GeoJSON object - * @param {Function} callback a method that takes (value) + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (currentGeometry, currentIndex, currentProperties) * @example - * var point = { - * type: 'Feature', - * geometry: { type: 'Point', coordinates: [0, 0] }, - * properties: {} + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] * }; - * turfMeta.geomEach(point, function(geom) { - * // geom is the point geometry + * turf.geomEach(features, function (currentGeometry, currentIndex, currentProperties) { + * //=currentGeometry + * //=currentIndex + * //=currentProperties * }); */ -function geomEach(layer, callback) { +function geomEach(geojson, callback) { var i, j, g, geometry, stopG, geometryMaybeCollection, isGeometryCollection, - isFeatureCollection = layer.type === 'FeatureCollection', - isFeature = layer.type === 'Feature', - stop = isFeatureCollection ? layer.features.length : 1; + geometryProperties, + currentIndex = 0, + isFeatureCollection = geojson.type === 'FeatureCollection', + isFeature = geojson.type === 'Feature', + stop = isFeatureCollection ? geojson.features.length : 1; // This logic may look a little weird. The reason why it is that way // is because it's trying to be fast. GeoJSON supports multiple kinds @@ -242,8 +546,10 @@ function geomEach(layer, callback) { // be required with the normalization approach. for (i = 0; i < stop; i++) { - geometryMaybeCollection = (isFeatureCollection ? layer.features[i].geometry : - (isFeature ? layer.geometry : layer)); + geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry : + (isFeature ? geojson.geometry : geojson)); + geometryProperties = (isFeatureCollection ? geojson.features[i].properties : + (isFeature ? geojson.properties : {})); isGeometryCollection = geometryMaybeCollection.type === 'GeometryCollection'; stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1; @@ -257,16 +563,283 @@ function geomEach(layer, callback) { geometry.type === 'Polygon' || geometry.type === 'MultiLineString' || geometry.type === 'MultiPolygon') { - callback(geometry); + callback(geometry, currentIndex, geometryProperties); + currentIndex++; } else if (geometry.type === 'GeometryCollection') { - for (j = 0; j < geometry.geometries.length; j++) - callback(geometry.geometries[j]); + for (j = 0; j < geometry.geometries.length; j++) { + callback(geometry.geometries[j], currentIndex, geometryProperties); + currentIndex++; + } } else { throw new Error('Unknown Geometry Type'); } } } } -module.exports.geomEach = geomEach; + +/** + * Callback for geomReduce + * + * The first time the callback function is called, the values provided as arguments depend + * on whether the reduce method has an initialValue argument. + * + * If an initialValue is provided to the reduce method: + * - The previousValue argument is initialValue. + * - The currentValue argument is the value of the first element present in the array. + * + * If an initialValue is not provided: + * - The previousValue argument is the value of the first element present in the array. + * - The currentValue argument is the value of the second element present in the array. + * + * @private + * @callback geomReduceCallback + * @param {*} previousValue The accumulated value previously returned in the last invocation + * of the callback, or initialValue, if supplied. + * @param {*} currentGeometry The current Feature being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + * @param {object} currentProperties The current feature properties being processed. + */ + +/** + * Reduce geometry in any GeoJSON object, similar to Array.reduce(). + * + * @name geomReduce + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (previousValue, currentGeometry, currentIndex, currentProperties) + * @param {*} [initialValue] Value to use as the first argument to the first call of the callback. + * @returns {*} The value that results from the reduction. + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {"foo": "bar"}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {"hello": "world"}, + * "geometry": { + * "type": "Point", + * "coordinates": [36, 53] + * } + * } + * ] + * }; + * turf.geomReduce(features, function (previousValue, currentGeometry, currentIndex) { + * //=previousValue + * //=currentGeometry + * //=currentIndex + * return currentGeometry + * }); + */ +function geomReduce(geojson, callback, initialValue) { + var previousValue = initialValue; + geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) { + if (currentIndex === 0 && initialValue === undefined) { + previousValue = currentGeometry; + } else { + previousValue = callback(previousValue, currentGeometry, currentIndex, currentProperties); + } + }); + return previousValue; +} + +/** + * Callback for flattenEach + * + * @private + * @callback flattenEachCallback + * @param {Feature} currentFeature The current flattened feature being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + * @param {number} currentSubIndex The subindex of the current element being processed in the + * array. Starts at index 0 and increases if the flattened feature was a multi-geometry. + */ + +/** + * Iterate over flattened features in any GeoJSON object, similar to + * Array.forEach. + * + * @name flattenEach + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (currentFeature, currentIndex, currentSubIndex) + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {}, + * "geometry": { + * "type": "MultiPoint", + * "coordinates": [ [36, 53], [46, 69] ] + * } + * } + * ] + * }; + * turf.flattenEach(features, function (currentFeature, currentIndex, currentSubIndex) { + * //=currentFeature + * //=currentIndex + * //=currentSubIndex + * }); + */ +function flattenEach(geojson, callback) { + geomEach(geojson, function (geometry, index, properties) { + + // Callback for single geometry + switch (geometry.type) { + case 'Point': + case 'LineString': + case 'Polygon': + callback(feature(geometry, properties), index, 0); + return; + } + + var geomType; + + // Callback for multi-geometry + switch (geometry.type) { + case 'MultiPoint': + geomType = 'Point'; + break; + case 'MultiLineString': + geomType = 'LineString'; + break; + case 'MultiPolygon': + geomType = 'Polygon'; + break; + } + + geometry.coordinates.forEach(function (coordinate, subindex) { + var geom = { + type: geomType, + coordinates: coordinate + }; + callback(feature(geom, properties), index, subindex); + }); + + }); +} + +/** + * Callback for flattenReduce + * + * The first time the callback function is called, the values provided as arguments depend + * on whether the reduce method has an initialValue argument. + * + * If an initialValue is provided to the reduce method: + * - The previousValue argument is initialValue. + * - The currentValue argument is the value of the first element present in the array. + * + * If an initialValue is not provided: + * - The previousValue argument is the value of the first element present in the array. + * - The currentValue argument is the value of the second element present in the array. + * + * @private + * @callback flattenReduceCallback + * @param {*} previousValue The accumulated value previously returned in the last invocation + * of the callback, or initialValue, if supplied. + * @param {Feature} currentFeature The current Feature being processed. + * @param {number} currentIndex The index of the current element being processed in the + * array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise. + * @param {number} currentSubIndex The subindex of the current element being processed in the + * array. Starts at index 0 and increases if the flattened feature was a multi-geometry. + */ + +/** + * Reduce flattened features in any GeoJSON object, similar to Array.reduce(). + * + * @name flattenReduce + * @param {Geometry|FeatureCollection|Feature} geojson any GeoJSON object + * @param {Function} callback a method that takes (previousValue, currentFeature, currentIndex, currentSubIndex) + * @param {*} [initialValue] Value to use as the first argument to the first call of the callback. + * @returns {*} The value that results from the reduction. + * @example + * var features = { + * "type": "FeatureCollection", + * "features": [ + * { + * "type": "Feature", + * "properties": {"foo": "bar"}, + * "geometry": { + * "type": "Point", + * "coordinates": [26, 37] + * } + * }, + * { + * "type": "Feature", + * "properties": {"hello": "world"}, + * "geometry": { + * "type": "MultiPoint", + * "coordinates": [ [36, 53], [46, 69] ] + * } + * } + * ] + * }; + * turf.flattenReduce(features, function (previousValue, currentFeature, currentIndex, currentSubIndex) { + * //=previousValue + * //=currentFeature + * //=currentIndex + * //=currentSubIndex + * return currentFeature + * }); + */ +function flattenReduce(geojson, callback, initialValue) { + var previousValue = initialValue; + flattenEach(geojson, function (currentFeature, currentIndex, currentSubIndex) { + if (currentIndex === 0 && currentSubIndex === 0 && initialValue === undefined) { + previousValue = currentFeature; + } else { + previousValue = callback(previousValue, currentFeature, currentIndex, currentSubIndex); + } + }); + return previousValue; +} + +/** + * Create Feature + * + * @private + * @param {Geometry} geometry GeoJSON Geometry + * @param {Object} properties Properties + * @returns {Feature} GeoJSON Feature + */ +function feature(geometry, properties) { + if (!geometry) throw new Error('No geometry passed'); + + return { + type: 'Feature', + properties: properties || {}, + geometry: geometry + }; +} + +module.exports = { + coordEach: coordEach, + coordReduce: coordReduce, + propEach: propEach, + propReduce: propReduce, + featureEach: featureEach, + featureReduce: featureReduce, + coordAll: coordAll, + geomEach: geomEach, + geomReduce: geomReduce, + flattenEach: flattenEach, + flattenReduce: flattenReduce +}; },{}]},{},[1]); diff --git a/inst/js/turf3104.js b/inst/js/turf3104.js deleted file mode 100644 index 6f04339..0000000 --- a/inst/js/turf3104.js +++ /dev/null @@ -1,17 +0,0 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.turf=t()}}(function(){var t;return function t(e,n,i){function r(o,a){if(!n[o]){if(!e[o]){var u="function"==typeof require&&require;if(!a&&u)return u(o,!0);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var h=n[o]={exports:{}};e[o][0].call(h.exports,function(t){var n=e[o][1][t];return r(n?n:t)},h,h.exports,t,e,n,i)}return n[o].exports}for(var s="function"==typeof require&&require,o=0;o0){e+=Math.abs(s(t[0]));for(var n=1;n2){for(l=0;l=u&&l===a.length-1);l++){if(u>=e){var h=e-u;if(h){var c=s(a[l],a[l-1])-180,f=o(a[l],h,c,n);return f}return r(a[l])}u+=i(a[l],a[l+1],n)}return r(a[a.length-1])}},{"@turf/bearing":8,"@turf/destination":20,"@turf/distance":23,"@turf/helpers":28}],5:[function(t,e,n){function i(t){if("FeatureCollection"===t.type){for(var e=0,n=0;et[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]t&&(e.push(i),n=r)}return e},i.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}},i.prototype.pos=function(t){function e(t,e,n,i,r){var s=function(t){var e=t*t,n=e*t;return[n,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]},o=s(t),a={x:r.x*o[0]+i.x*o[1]+n.x*o[2]+e.x*o[3],y:r.y*o[0]+i.y*o[1]+n.y*o[2]+e.y*o[3],z:r.z*o[0]+i.z*o[1]+n.z*o[2]+e.z*o[3]};return a}var n=t-this.delay;n<0&&(n=0),n>this.duration&&(n=this.duration-1);var i=n/this.duration;if(i>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*i),s=(this.length-1)*i-r;return e(s,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1])},e.exports=i},{}],11:[function(t,e,n){function i(t,e){var n=new o.io.GeoJSONReader,i=n.read(t.geometry),r=i.buffer(e),s=new o.io.GeoJSONWriter;return r=s.write(r),{type:"Feature",geometry:r,properties:{}}}var r=t("@turf/helpers"),s=r.featureCollection,o=t("jsts"),a=t("@mapbox/geojson-normalize");e.exports=function(t,e,n){var o=r.distanceToDegrees(e,n),u=a(t),l=a(s(u.features.map(function(t){return i(t,o)})));return l.features.length>1?l:1===l.features.length?l.features[0]:void 0}},{"@mapbox/geojson-normalize":3,"@turf/helpers":28,jsts:73}],12:[function(t,e,n){function i(t){if("Feature"===t.type&&"Polygon"===t.geometry.type){var n=[];r(t,function(t){n.push(t)});var i,l,h,c,f,g,d,p,v=s(t),m=v.geometry.coordinates,y=0,x=0,E=0,I=n.map(function(t){return[t[0]-m[0],t[1]-m[1]]});for(i=0;i=3){for(var o=[],a=0;a0&&0!==N)if(N>n[n.length-1])N-=n.length;else{var C=l.greaterNumber(N,n);0!==C&&(N-=C)}if(N!==p){var w=t.features[N];if(void 0===typeof e||w.properties[e]===v.properties[e]){var S=s(v,w);if(!S){var L=JSON.stringify(v),b=JSON.stringify(w),R=i(JSON.parse(L)),P=i(JSON.parse(b));S=u.lineStringsIntersect(R.geometry,P.geometry)}S&&(t.features[p]=r(v,w),n.push(x[I].origIndexPosition),n.sort(function(t,e){return t-e}),c.remove(x[I]),t.features.splice(N,1),y.origIndexPosition=p,c.remove(y,function(t,e){return t.origIndexPosition===e.origIndexPosition}),E=!0)}}}if(E){var T=o(v);c.insert({minX:T[0],minY:T[1],maxX:T[2],maxY:T[3],origIndexPosition:p}),p--}}return t}},{"@turf/bbox":7,"@turf/union":57,"geojson-utils":70,"get-closest":71,rbush:77,"turf-overlaps":85}],23:[function(t,e,n){var i=t("@turf/invariant").getCoord,r=t("@turf/helpers").radiansToDistance;e.exports=function(t,e,n){var s=Math.PI/180,o=i(t),a=i(e),u=s*(a[1]-o[1]),l=s*(a[0]-o[0]),h=s*o[1],c=s*a[1],f=Math.pow(Math.sin(u/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(h)*Math.cos(c);return r(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),n)}},{"@turf/helpers":28,"@turf/invariant":33}],24:[function(t,e,n){var i=t("@turf/bbox"),r=t("@turf/bbox-polygon");e.exports=function(t){return r(i(t))}},{"@turf/bbox":7,"@turf/bbox-polygon":6}],25:[function(t,e,n){var i=t("@turf/helpers").featureCollection,r=t("@turf/meta").featureEach,s=t("@turf/meta").coordEach,o=t("@turf/helpers").point;e.exports=function(t){var e=[];return"FeatureCollection"===t.type?r(t,function(t){s(t,function(n){e.push(o(n,t.properties))})}):s(t,function(n){e.push(o(n,t.properties))}),i(e)}},{"@turf/helpers":28,"@turf/meta":40}],26:[function(t,e,n){var i=t("geojson-flatten"),r=t("@turf/helpers").featureCollection;e.exports=function(t){var e=i(t);return"FeatureCollection"===e.type?e:r(i(t))}},{"@turf/helpers":28,"geojson-flatten":68}],27:[function(t,e,n){var i=t("@turf/meta").coordEach;e.exports=function(t){return t=JSON.parse(JSON.stringify(t)),i(t,function(t){t.reverse()}),t}},{"@turf/meta":40}],28:[function(t,e,n){function i(t,e){return{type:"Feature",properties:e||{},geometry:t}}e.exports.feature=i,e.exports.point=function(t,e){if(!Array.isArray(t))throw new Error("Coordinates must be an array");if(t.length<2)throw new Error("Coordinates must be at least 2 numbers long");return i({type:"Point",coordinates:t.slice()},e)},e.exports.polygon=function(t,e){if(!t)throw new Error("No coordinates passed");for(var n=0;np/2;S&&(w-=p/4);for(var L=u([]),b=0;bt[1]!=l>t[1]&&t[0]<(u-o)*(t[1]-a)/(l-a)+o;c&&(i=!i)}return i}var r=t("@turf/invariant");e.exports=function(t,e){var n=r.getCoord(t),s=e.geometry.coordinates;"Polygon"===e.geometry.type&&(s=[s]);for(var o=0,a=!1;o=i;T--)for(var M=e;M<=n-1;M++){var O,_;if(O=Math.min(t[M][T],t[M][T+1]),_=Math.min(t[M+1][T],t[M+1][T+1]),x=Math.min(O,_),O=Math.max(t[M][T],t[M][T+1]),_=Math.max(t[M+1][T],t[M+1][T+1]),E=Math.max(O,_),E>=l[0]&&x<=l[u-1])for(var A=0;A=x&&l[A]<=E){for(var D=4;D>=0;D--)D>0?(h[D]=t[M+b[D-1]][T+R[D-1]]-l[A],f[D]=s[M+b[D-1]],g[D]=o[T+R[D-1]]):(h[0]=.25*(h[1]+h[2]+h[3]+h[4]),f[0]=.5*(s[M]+s[M+1]),g[0]=.5*(o[T]+o[T+1])),h[D]>a?c[D]=1:h[D]<-a?c[D]=-1:c[D]=0;for(D=1;D<=4;D++)if(p=D,v=0,m=4!=D?D+1:1,y=P[c[p]+1][c[v]+1][c[m]+1],0!=y){switch(y){case 1:C=f[p],S=g[p],w=f[v],L=g[v];break;case 2:C=f[v],S=g[v],w=f[m],L=g[m];break;case 3:C=f[m],S=g[m],w=f[p],L=g[p];break;case 4:C=f[p],S=g[p],w=I(v,m),L=N(v,m);break;case 5:C=f[v],S=g[v],w=I(m,p),L=N(m,p);break;case 6:C=f[m],S=g[m],w=I(p,v),L=N(p,v);break;case 7:C=I(p,v),S=N(p,v),w=I(v,m),L=N(v,m);break;case 8:C=I(v,m),S=N(v,m),w=I(m,p),L=N(m,p);break;case 9:C=I(m,p),S=N(m,p),w=I(p,v),L=N(p,v)}d(C,S,w,L,l[A],A)}}}}},{}],35:[function(t,e,n){var i=t("@turf/tin"),r=t("@turf/inside"),s=t("@turf/point-grid"),o=t("@turf/distance"),a=t("@turf/bbox"),u=t("@turf/planepoint"),l=t("@turf/helpers").featureCollection,h=t("@turf/helpers").lineString,c=t("@turf/helpers").point,f=t("@turf/square"),g=t("./conrec");e.exports=function(t,e,n,d){for(var p=i(t,e),v=a(t),m=f(v),y=o(c([m[0],m[1]]),c([m[2],m[1]]),"kilometers")/n,x=s(m,y,"kilometers"),E=[],I=0;I2){var n=[];t.forEach(function(t){n.push([t.x,t.y])});var i=h(n);i.properties={},i.properties[e]=t.level,F.features.push(i)}}),F}},{"./conrec":34,"@turf/bbox":7,"@turf/distance":23,"@turf/helpers":28,"@turf/inside":31,"@turf/planepoint":43,"@turf/point-grid":44,"@turf/square":51,"@turf/tin":54}],36:[function(t,e,n){function i(t,e,n,i,r,s,o,a){var u,l,h,c,f,g={x:null,y:null,onLine1:!1,onLine2:!1};return u=(a-s)*(n-t)-(o-r)*(i-e),0===u?null!==g.x&&null!==g.y&&g:(l=e-s,h=t-r,c=(o-r)*l-(a-s)*h,f=(n-t)*l-(i-e)*h,l=c/u,h=f/u,g.x=t+l*(n-t),g.y=e+l*(i-e),l>=0&&l<=1&&(g.onLine1=!0),h>=0&&h<=1&&(g.onLine2=!0),!(!g.onLine1||!g.onLine2)&&[g.x,g.y])}var r=t("@turf/helpers").point;e.exports=function(t){var e,n,s={type:"FeatureCollection",features:[]};if(n="Feature"===t.type?t.geometry:t,"LineString"===n.type)e=[n.coordinates];else if("MultiLineString"===n.type)e=n.coordinates;else if("MultiPolygon"===n.type)e=[].concat.apply([],n.coordinates);else{if("Polygon"!==n.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=n.coordinates}return e.forEach(function(t){e.forEach(function(e){for(var n=0;n=g&&d===u.length-1);d++){if(g>e&&0===l.length){if(h=e-g,!h)return l.push(u[d]),o(l);c=i(u[d],u[d-1])-180,f=s(u[d],h,c,a),l.push(f.geometry.coordinates)}if(g>=n)return(h=n-g)?(c=i(u[d],u[d-1])-180,f=s(u[d],h,c,a),l.push(f.geometry.coordinates),o(l)):(l.push(u[d]),o(l));if(g>=e&&l.push(u[d]),d===u.length-1)return o(l);g+=r(u[d],u[d+1],a)}return o(u[u.length-1])}},{"@turf/bearing":8,"@turf/destination":20,"@turf/distance":23,"@turf/helpers":28}],39:[function(t,e,n){var i=t("@turf/helpers").lineString,r=t("@turf/point-on-line");e.exports=function(t,e,n){var s;if("Feature"===n.type)s=n.geometry.coordinates;else{if("LineString"!==n.type)throw new Error("input must be a LineString Feature or Geometry");s=n.coordinates}var o,a=r(n,t),u=r(n,e);o=a.properties.index<=u.properties.index?[a,u]:[u,a];for(var l=i([o[0].geometry.coordinates],{}),h=o[0].properties.index+1;h0&&l<1&&(g.onLine1=!0),h>0&&h<1&&(g.onLine2=!0),!(!g.onLine1||!g.onLine2)&&[g.x,g.y])}var r=t("@turf/distance"),s=t("@turf/helpers").point,o=t("@turf/bearing"),a=t("@turf/destination");e.exports=function(t,e,n){var u;if("Feature"===t.type)u=t.geometry.coordinates;else{if("LineString"!==t.type)throw new Error("input must be a LineString Feature or Geometry");u=t.coordinates}for(var l=s([1/0,1/0],{dist:1/0}),h=0,c=0;co;)i=Math.floor((s+1)*Math.random()),n=r[i],r[i]=r[s],r[s]=n;return r.slice(o)}var r=t("@turf/helpers").featureCollection;e.exports=function(t,e){var n=r(i(t.features,e));return n}},{"@turf/helpers":28}],49:[function(t,e,n){function i(t,e,n){return"LineString"===t.geometry.type?{type:"LineString",coordinates:o(t.geometry.coordinates,e,n)}:"MultiLineString"===t.geometry.type?{type:"MultiLineString",coordinates:t.geometry.coordinates.map(function(t){return o(t,e,n)})}:"Polygon"===t.geometry.type?{type:"Polygon",coordinates:a(t.geometry.coordinates,e,n)}:"MultiPolygon"===t.geometry.type?{type:"MultiPolygon",coordinates:t.geometry.coordinates.map(function(t){return a(t,e,n)})}:t}function r(t){return!(t.length<3)&&(3!==t.length||t[2][0]!==t[0][0]||t[2][1]!==t[0][1])}function s(t,e){return{type:"Feature",geometry:t,properties:e}}function o(t,e,n){return u(t.map(function(t){return{x:t[0],y:t[1],z:t[2]}}),e,n).map(function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y]})}function a(t,e,n){return t.map(function(t){var i=t.map(function(t){return{x:t[0],y:t[1]}});if(i.length<4)throw new Error("Invalid polygon");for(var s=u(i,e,n).map(function(t){return[t.x,t.y]});!r(s);)e-=.01*e,s=u(i,e,n).map(function(t){return[t.x,t.y]});return s[s.length-1][0]===s[0][0]&&s[s.length-1][1]===s[0][1]||s.push(s[0]),s})}var u=t("simplify-js"),l=["LineString","MultiLineString","Polygon","MultiPolygon"];e.exports=function(t,e,n){return"Feature"===t.type?s(i(t,e,n),t.properties):"FeatureCollection"===t.type?{type:"FeatureCollection",features:t.features.map(function(t){var r=i(t,e,n);return l.indexOf(r.type)>-1?s(r,t.properties):r})}:"GeometryCollection"===t.type?{type:"GeometryCollection",geometries:t.geometries.map(function(t){return l.indexOf(t.type)>-1?i({type:"Feature",geometry:t},e,n):t})}:t}},{"simplify-js":83}],50:[function(t,e,n){var i=t("@turf/helpers").featureCollection,r=t("@turf/helpers").point,s=t("@turf/helpers").polygon,o=t("@turf/distance");e.exports=function(t,e,n){for(var a=i([]),u=e/o(r([t[0],t[1]]),r([t[2],t[1]]),n),l=u*(t[2]-t[0]),h=e/o(r([t[0],t[1]]),r([t[0],t[3]]),n),c=h*(t[3]-t[1]),f=t[0];f<=t[2];){for(var g=t[1];g<=t[3];){var d=s([[[f,g],[f,g+c],[f+l,g+c],[f+l,g],[f,g]]]);a.features.push(d),g+=c}f+=l}return a}},{"@turf/distance":23,"@turf/helpers":28}],51:[function(t,e,n){var i=t("@turf/distance");e.exports=function(t){var e=i(t.slice(0,2),[t[2],t[1]],"miles"),n=i(t.slice(0,2),[t[0],t[3]],"miles");if(e>=n){var r=(t[1]+t[3])/2;return[t[0],r-(t[2]-t[0])/2,t[2],r+(t[2]-t[0])/2]}var s=(t[0]+t[2])/2;return[s-(t[3]-t[1])/2,t[1],s+(t[3]-t[1])/2,t[3]]}},{"@turf/distance":23}],52:[function(t,e,n){var i=t("@turf/inside");e.exports=function(t,e,n,r){return t=JSON.parse(JSON.stringify(t)),e=JSON.parse(JSON.stringify(e)),t.features.forEach(function(t){t.properties||(t.properties={}),e.features.forEach(function(e){if(void 0===t.properties[r]){var s=i(t,e);s&&(t.properties[r]=e.properties[n])}})}),t}},{"@turf/inside":31}],53:[function(t,e,n){function i(t){var e=r(t),n=2,i=o(e.vertices,e.holes,n),a=[],u=[];i.forEach(function(t,r){var s=i[r];u.push([e.vertices[s*n],e.vertices[s*n+1]])});for(var l=0;l0&&(i+=t[r-1].length,n.holes.push(i))}return n}var s=t("@turf/helpers").polygon,o=t("earcut");e.exports=function(t){if(!t.geometry||"Polygon"!==t.geometry.type&&"MultiPolygon"!==t.geometry.type)throw new Error("input must be a Polygon or MultiPolygon");var e={type:"FeatureCollection",features:[]};return"Polygon"===t.geometry.type?e.features=i(t.geometry.coordinates):t.geometry.coordinates.forEach(function(t){e.features=e.features.concat(i(t))}),e}},{"@turf/helpers":28,earcut:67}],54:[function(t,e,n){function i(t,e,n){this.a=t,this.b=e,this.c=n;var i,r,s=e.x-t.x,o=e.y-t.y,a=n.x-t.x,u=n.y-t.y,l=s*(t.x+e.x)+o*(t.y+e.y),h=a*(t.x+n.x)+u*(t.y+n.y),c=2*(s*(n.y-e.y)-o*(n.x-e.x));this.x=(u*l-o*h)/c,this.y=(s*h-a*l)/c,i=this.x-t.x,r=this.y-t.y,this.r=i*i+r*r}function r(t,e){return e.x-t.x}function s(t){var e,n,i,r,s,o=t.length;t:for(;o;)for(n=t[--o],e=t[--o],i=o;i;)if(s=t[--i],r=t[--i],e===r&&n===s||e===s&&n===r){t.splice(o,2),t.splice(i,2),o-=2;continue t}}function o(t){if(t.length<3)return[];t.sort(r);for(var e,n,o,a,u,l,h=t.length-1,c=t[h].x,f=t[0].x,g=t[h].y,d=g,p=1e-12;h--;)t[h].yd&&(d=t[h].y);var v,m=f-c,y=d-g,x=m>y?m:y,E=.5*(f+c),I=.5*(d+g),N=[new i({x:E-20*x,y:I-x,__sentinel:!0},{x:E,y:I+20*x,__sentinel:!0},{x:E+20*x,y:I-x,__sentinel:!0})],C=[],w=[];for(h=t.length;h--;){for(w.length=0,v=N.length;v--;)m=t[h].x-N[v].x,m>0&&m*m>N[v].r?(C.push(N[v]),N.splice(v,1)):(y=t[h].y-N[v].y,m*m+y*y>N[v].r||(w.push(N[v].a,N[v].b,N[v].b,N[v].c,N[v].c,N[v].a),N.splice(v,1)));for(s(w),v=w.length;v;)n=w[--v],e=w[--v],o=t[h],a=n.x-e.x,u=n.y-e.y,l=2*(a*(o.y-n.y)-u*(o.x-n.x)),Math.abs(l)>p&&N.push(new i(e,n,o))}for(Array.prototype.push.apply(C,N),h=C.length;h--;)(C[h].a.__sentinel||C[h].b.__sentinel||C[h].c.__sentinel)&&C.splice(h,1);return C}var a=t("@turf/helpers").polygon,u=t("@turf/helpers").featureCollection;e.exports=function(t,e){return u(o(t.features.map(function(t){var n={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e&&(n.z=t.properties[e]),n})).map(function(t){return a([[[t.a.x,t.a.y],[t.b.x,t.b.y],[t.c.x,t.c.y],[t.a.x,t.a.y]]],{a:t.a.z,b:t.b.z,c:t.c.z})}))}},{"@turf/helpers":28}],55:[function(t,e,n){var i=t("@turf/helpers").featureCollection,r=t("@turf/helpers").polygon,s=t("@turf/distance");e.exports=function(t,e,n){for(var o=i([]),a=e/s([t[0],t[1]],[t[2],t[1]],n),u=a*(t[2]-t[0]),l=e/s([t[0],t[1]],[t[0],t[3]],n),h=l*(t[3]-t[1]),c=0,f=t[0];f<=t[2];){for(var g=0,d=t[1];d<=t[3];)c%2===0&&g%2===0?o.features.push(r([[[f,d],[f,d+h],[f+u,d],[f,d]]]),r([[[f,d+h],[f+u,d+h],[f+u,d],[f,d+h]]])):c%2===0&&g%2===1?o.features.push(r([[[f,d],[f+u,d+h],[f+u,d],[f,d]]]),r([[[f,d],[f,d+h],[f+u,d+h],[f,d]]])):g%2===0&&c%2===1?o.features.push(r([[[f,d],[f,d+h],[f+u,d+h],[f,d]]]),r([[[f,d],[f+u,d+h],[f+u,d],[f,d]]])):g%2===1&&c%2===1&&o.features.push(r([[[f,d],[f,d+h],[f+u,d],[f,d]]]),r([[[f,d+h],[f+u,d+h],[f+u,d],[f,d+h]]])),d+=h,g++;c++,f+=u}return o}},{"@turf/distance":23,"@turf/helpers":28}],56:[function(t,e,n){function i(t,e,n){return void 0!==n&&(t.geometry.coordinates=s(t.geometry.coordinates,0,n)),t.geometry.coordinates=r(t.geometry.coordinates,e),t}function r(t,e){return t.map(function(t){return"object"==typeof t?r(t,e):Number(t.toFixed(e))})}var s=t("deep-slice");e.exports=function(t,e,n){if(e=e||6,n=n||2,void 0===t)throw new Error("layer is required");switch(t.type){case"FeatureCollection":return t.features=t.features.map(function(t){return i(t,e,n)}),t;case"Feature":return i(t,e,n);default:throw new Error("invalid type")}}},{"deep-slice":66}],57:[function(t,e,n){var i=t("jsts");e.exports=function(){for(var t=new i.io.GeoJSONReader,e=t.read(JSON.stringify(arguments[0].geometry)),n=1;n=0;s--)if(o[s]!=a[s])return!1;for(s=o.length-1;s>=0;s--)if(r=o[s],!u(t[r],e[r]))return!1;return!0}function c(t,e){return!(!t||!e)&&("[object RegExp]"==Object.prototype.toString.call(e)?e.test(t):t instanceof e||e.call({},t)===!0)}function f(t,e,n,i){var r;g.isString(n)&&(i=n,n=null);try{e()}catch(t){r=t}if(i=(n&&n.name?" ("+n.name+").":".")+(i?" "+i:"."),t&&!r&&o(r,n,"Missing expected exception"+i),!t&&c(r,n)&&o(r,n,"Got unwanted exception"+i),t&&r&&n&&!c(r,n)||!t&&r)throw r}var g=t("util/"),d=Array.prototype.slice,p=Object.prototype.hasOwnProperty,v=e.exports=a;v.AssertionError=function(t){this.name="AssertionError",this.actual=t.actual,this.expected=t.expected,this.operator=t.operator,t.message?(this.message=t.message,this.generatedMessage=!1):(this.message=s(this),this.generatedMessage=!0);var e=t.stackStartFunction||o;if(Error.captureStackTrace)Error.captureStackTrace(this,e);else{var n=new Error;if(n.stack){var i=n.stack,r=e.name,a=i.indexOf("\n"+r);if(a>=0){var u=i.indexOf("\n",a+1);i=i.substring(u+1)}this.stack=i}}},g.inherits(v.AssertionError,Error),v.fail=o,v.ok=a,v.equal=function(t,e,n){t!=e&&o(t,e,n,"==",v.equal)},v.notEqual=function(t,e,n){t==e&&o(t,e,n,"!=",v.notEqual)},v.deepEqual=function(t,e,n){u(t,e)||o(t,e,n,"deepEqual",v.deepEqual)},v.notDeepEqual=function(t,e,n){u(t,e)&&o(t,e,n,"notDeepEqual",v.notDeepEqual)},v.strictEqual=function(t,e,n){t!==e&&o(t,e,n,"===",v.strictEqual)},v.notStrictEqual=function(t,e,n){t===e&&o(t,e,n,"!==",v.notStrictEqual)},v.throws=function(t,e,n){f.apply(this,[!0].concat(d.call(arguments)))},v.doesNotThrow=function(t,e){f.apply(this,[!1].concat(d.call(arguments)))},v.ifError=function(t){if(t)throw t};var m=Object.keys||function(t){var e=[];for(var n in t)p.call(t,n)&&e.push(n);return e}},{"util/":91}],61:[function(t,e,n){"use strict";"use restrict";function i(t){var e=32;return t&=-t,t&&e--,65535&t&&(e-=16),16711935&t&&(e-=8),252645135&t&&(e-=4),858993459&t&&(e-=2),1431655765&t&&(e-=1),e}var r=32;n.INT_BITS=r,n.INT_MAX=2147483647,n.INT_MIN=-1<0)-(t<0)},n.abs=function(t){var e=t>>r-1;return(t^e)-e},n.min=function(t,e){return e^(t^e)&-(t65535)<<4,t>>>=e,n=(t>255)<<3,t>>>=n,e|=n,n=(t>15)<<2,t>>>=n,e|=n,n=(t>3)<<1,t>>>=n,e|=n,e|t>>1},n.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},n.popCount=function(t){return t-=t>>>1&1431655765,t=(858993459&t)+(t>>>2&858993459),16843009*(t+(t>>>4)&252645135)>>>24},n.countTrailingZeros=i,n.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1},n.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t-(t>>>1)},n.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,t&=15,27030>>>t&1};var s=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,i=e,r=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--r;t[e]=i<>>8&255]<<16|s[t>>>16&255]<<8|s[t>>>24&255]},n.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},n.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),t=65535&(t|t>>>16),t<<16>>16},n.interleave3=function(t,e,n){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,n&=1023,n=4278190335&(n|n<<16),n=251719695&(n|n<<8),n=3272356035&(n|n<<4),n=1227133513&(n|n<<2),t|n<<2},n.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),t=1023&(t|t>>>16),t<<22>>22},n.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>i(t)+1}},{}],62:[function(t,e,n){"use strict";function i(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var n=t[0].length;return 0===n?[]:1===n?r(t):2===n?s(t):o(t,n)}var r=t("./lib/ch1d"),s=t("./lib/ch2d"),o=t("./lib/chnd");e.exports=i},{"./lib/ch1d":63,"./lib/ch2d":64,"./lib/chnd":65}],63:[function(t,e,n){"use strict";function i(t){for(var e=0,n=0,i=1;it[n][0]&&(n=i);return en?[[n],[e]]:[[e]]}e.exports=i},{}],64:[function(t,e,n){"use strict";function i(t){var e=r(t),n=e.length;if(n<=2)return[];for(var i=new Array(n),s=e[n-1],o=0;o=e[u]&&(a+=1);s[o]=a}}return t}function s(t,e){try{return o(t,!0)}catch(l){var n=a(t);if(n.length<=e)return[];var s=i(t,n),u=o(s,!0);return r(u,n)}}e.exports=s;var o=t("incremental-convex-hull"),a=t("affine-hull")},{"affine-hull":59,"incremental-convex-hull":72}],66:[function(t,e,n){function i(t,e,n){return"object"!=typeof t[0]?t.slice(e,n):t.map(function(t){return i(t,e,n)})}e.exports=i},{}],67:[function(t,e,n){"use strict";function i(t,e,n){n=n||2;var i=e&&e.length,s=i?e[0]*n:t.length,a=r(t,0,s,n,!0),u=[];if(!a)return u;var l,h,f,g,d,p,v;if(i&&(a=c(t,e,a,n)),t.length>80*n){l=f=t[0],h=g=t[1];for(var m=n;mf&&(f=d),p>g&&(g=p);v=Math.max(f-l,g-h)}return o(a,u,n,l,h,v),u}function r(t,e,n,i,r){var s,o;if(r===M(t,e,n,i)>0)for(s=e;s=e;s-=i)o=R(s,t[s],t[s+1],o);return o&&N(o,o.next)&&(P(o),o=o.next),o}function s(t,e){if(!t)return t;e||(e=t);var n,i=t;do if(n=!1,i.steiner||!N(i,i.next)&&0!==I(i.prev,i,i.next))i=i.next;else{if(P(i),i=e=i.prev,i===i.next)return null;n=!0}while(n||i!==e);return e}function o(t,e,n,i,r,c,f){if(t){!f&&c&&p(t,i,r,c);for(var g,d,v=t;t.prev!==t.next;)if(g=t.prev,d=t.next,c?u(t,i,r,c):a(t))e.push(g.i/n),e.push(t.i/n),e.push(d.i/n),P(t),t=d.next,v=d.next;else if(t=d,t===v){f?1===f?(t=l(t,e,n),o(t,e,n,i,r,c,2)):2===f&&h(t,e,n,i,r,c):o(s(t),e,n,i,r,c,1);break}}}function a(t){var e=t.prev,n=t,i=t.next;if(I(e,n,i)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(x(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&I(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function u(t,e,n,i){var r=t.prev,s=t,o=t.next;if(I(r,s,o)>=0)return!1;for(var a=r.xs.x?r.x>o.x?r.x:o.x:s.x>o.x?s.x:o.x,h=r.y>s.y?r.y>o.y?r.y:o.y:s.y>o.y?s.y:o.y,c=m(a,u,e,n,i),f=m(l,h,e,n,i),g=t.nextZ;g&&g.z<=f;){if(g!==t.prev&&g!==t.next&&x(r.x,r.y,s.x,s.y,o.x,o.y,g.x,g.y)&&I(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(g=t.prevZ;g&&g.z>=c;){if(g!==t.prev&&g!==t.next&&x(r.x,r.y,s.x,s.y,o.x,o.y,g.x,g.y)&&I(g.prev,g,g.next)>=0)return!1;g=g.prevZ}return!0}function l(t,e,n){var i=t;do{var r=i.prev,s=i.next.next;!N(r,s)&&C(r,i,i.next,s)&&S(r,s)&&S(s,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(s.i/n),P(i),P(i.next),i=t=s),i=i.next}while(i!==t);return i}function h(t,e,n,i,r,a){var u=t;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&E(u,l)){var h=b(u,l);return u=s(u,u.next),h=s(h,h.next),o(u,e,n,i,r,a),void o(h,e,n,i,r,a)}l=l.next}u=u.next}while(u!==t)}function c(t,e,n,i){var o,a,u,l,h,c=[];for(o=0,a=e.length;o=i.next.y){var a=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>o){if(o=a,a===r){if(s===i.y)return i;if(s===i.next.y)return i.next}n=i.x=i.x&&i.x>=h&&x(sn.x)&&S(i,t)&&(n=i,f=u)),i=i.next;return n}function p(t,e,n,i){var r=t;do null===r.z&&(r.z=m(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,v(r)}function v(t){var e,n,i,r,s,o,a,u,l=1;do{for(n=t,t=null,s=null,o=0;n;){for(o++,i=n,a=0,e=0;e0||u>0&&i;)0===a?(r=i,i=i.nextZ,u--):0!==u&&i?n.z<=i.z?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,u--):(r=n,n=n.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;n=i}s.nextZ=null,l*=2}while(o>1);return t}function m(t,e,n,i,r){return t=32767*(t-n)/r,e=32767*(e-i)/r,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function y(t){var e=t,n=t;do e.x=0&&(t-o)*(i-a)-(n-o)*(e-a)>=0&&(n-o)*(s-a)-(r-o)*(i-a)>=0}function E(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!w(t,e)&&S(t,e)&&S(e,t)&&L(t,e)}function I(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function N(t,e){return t.x===e.x&&t.y===e.y}function C(t,e,n,i){return!!(N(t,e)&&N(n,i)||N(t,i)&&N(n,e))||I(t,e,n)>0!=I(t,e,i)>0&&I(n,i,t)>0!=I(n,i,e)>0}function w(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&C(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function S(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function L(t,e){var n=t,i=!1,r=(t.x+e.x)/2,s=(t.y+e.y)/2;do n.y>s!=n.next.y>s&&r<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next;while(n!==t);return i}function b(t,e){var n=new T(t.i,t.x,t.y),i=new T(e.i,e.x,e.y),r=t.next,s=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,s.next=i,i.prev=s,i}function R(t,e,n,i){var r=new T(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function P(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function T(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function M(t,e,n,i){for(var r=0,s=e,o=n-i;s0&&(i+=t[r-1].length,n.holes.push(i))}return n}},{}],68:[function(t,e,n){function i(t,e){switch(t&&t.type||null){case"FeatureCollection":return t.features=t.features.reduce(function(t,e){return t.concat(i(e))},[]),t;case"Feature":return i(t.geometry).map(function(e){return{type:"Feature",properties:JSON.parse(JSON.stringify(t.properties)),geometry:e}});case"MultiPoint":return t.coordinates.map(function(t){return{type:"Point",coordinates:t}});case"MultiPolygon":return t.coordinates.map(function(t){return{type:"Polygon",coordinates:t}});case"MultiLineString":return t.coordinates.map(function(t){return{type:"LineString",coordinates:t}});case"GeometryCollection":return t.geometries;case"Point":case"Polygon":case"LineString":return[t];default:return t}}e.exports=i},{}],69:[function(t,e,n){function r(t){return t?h(t):[a(),u()]}function s(t){return function(e,n){return[e[0]+t[0],e[1]+t[1]]}}function o(){return Math.random()-.5}function a(){return 360*o()}function u(){return 180*o()}function l(t){return{type:"Point",coordinates:t||[a(),u()]}}function h(t){return[Math.random()*(t[2]-t[0])+t[0],Math.random()*(t[3]-t[1])+t[1]]}function c(t){return{type:"Polygon",coordinates:t}}function f(t){return{type:"Feature",geometry:t,properties:{}}}function g(t){return{type:"FeatureCollection",features:t}}e.exports=function(){throw new Error("call .point() or .polygon() instead")},e.exports.position=r,e.exports.point=function(t,e){var n=[];for(i=0;i0?t+n[e-1]:t}function u(t,e){t=2*t*Math.PI/d[d.length-1];var i=Math.random();h.push([i*n*Math.sin(t),i*n*Math.cos(t)])}"number"!=typeof e&&(e=10),"number"!=typeof n&&(n=10);var l=[];for(i=0;ie!=i[s][0]>e&&t<(i[s][1]-i[r][1])*(e-i[r][0])/(i[s][0]-i[r][0])+i[r][1]&&(o=!o);return o}var i=this.gju={};"undefined"!=typeof e&&e.exports&&(e.exports=i),i.lineStringsIntersect=function(t,e){for(var n=[],i=0;i<=t.coordinates.length-2;++i)for(var r=0;r<=e.coordinates.length-2;++r){var s={x:t.coordinates[i][1],y:t.coordinates[i][0]},o={x:t.coordinates[i+1][1],y:t.coordinates[i+1][0]},a={x:e.coordinates[r][1],y:e.coordinates[r][0]},u={x:e.coordinates[r+1][1],y:e.coordinates[r+1][0]},l=(u.x-a.x)*(s.y-a.y)-(u.y-a.y)*(s.x-a.x),h=(o.x-s.x)*(s.y-a.y)-(o.y-s.y)*(s.x-a.x),c=(u.y-a.y)*(o.x-s.x)-(u.x-a.x)*(o.y-s.y);if(0!=c){var f=l/c,g=h/c;0<=f&&f<=1&&0<=g&&g<=1&&n.push({type:"Point",coordinates:[s.x+f*(o.x-s.x),s.y+f*(o.y-s.y)]})}}return 0==n.length&&(n=!1),n},i.pointInBoundingBox=function(t,e){return!(t.coordinates[1]e[1][0]||t.coordinates[0]e[1][1])},i.pointInPolygon=function(e,r){for(var s="Polygon"==r.type?[r.coordinates]:r.coordinates,o=!1,a=0;an)return!1}return!0},i.area=function(t){for(var e,n,i=0,r=t.coordinates[0],s=r.length-1,o=0;o0;)if(s=C[i-1],o=w[i-1],i--,o-s>1){for(f=t[o].lng()-t[s].lng(),g=t[o].lat()-t[s].lat(),Math.abs(f)>180&&(f=360-Math.abs(f)),f*=Math.cos(I*(t[o].lat()+t[s].lat())),d=f*f+g*g,a=s+1,u=s,h=-1;a180&&(p=360-Math.abs(p)),p*=Math.cos(I*(t[a].lat()+t[s].lat())),m=p*p+v*v,y=t[a].lng()-t[o].lng(),x=t[a].lat()-t[o].lat(),Math.abs(y)>180&&(y=360-Math.abs(y)),y*=Math.cos(I*(t[a].lat()+t[o].lat())),E=y*y+x*x,l=m>=d+E?E:E>=d+m?m:(p*g-v*f)*(p*g-v*f)/d,l>h&&(u=a,h=l);h=0&&("undefined"==typeof s||o0&&e.push(","),e.push("tuple[",n,"]");e.push(")}return orient");var i=new Function("test",e.join("")),r=l[t+1];return r||(r=l),i(r)}function a(t,e,n){this.dimension=t,this.vertices=e,this.simplices=n,this.interior=n.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var i=0;i<=t;++i)this.tuple[i]=this.vertices[i];var r=c[t];r||(r=c[t]=o(t)),this.orient=r}function u(t,e){var n=t.length;if(0===n)throw new Error("Must have at least d+1 points");var r=t[0].length;if(n<=r)throw new Error("Must input at least d+1 points");var s=t.slice(0,r+1),o=l.apply(void 0,s);if(0===o)throw new Error("Input not in general position");for(var u=new Array(r+1),h=0;h<=r;++h)u[h]=h;o<0&&(u[0]=1,u[1]=0);for(var c=new i(u,new Array(r+1),!1),f=c.adjacent,g=new Array(r+2),h=0;h<=r;++h){for(var d=u.slice(),p=0;p<=r;++p)p===h&&(d[p]=-1);var v=d[0];d[0]=d[1],d[1]=v;var m=new i(d,new Array(r+1),!0);f[h]=m,g[h]=m}g[r+1]=c;for(var h=0;h<=r;++h)for(var d=f[h].vertices,y=f[h].adjacent,p=0;p<=r;++p){var x=d[p];if(x<0)y[p]=c;else for(var E=0;E<=r;++E)f[E].vertices.indexOf(x)<0&&(y[p]=f[E])}for(var I=new a(r,s,g),N=!!e,h=r+1;h0;){t=o.pop();for(var a=(t.vertices,t.adjacent),u=0;u<=n;++u){var l=a[u];if(l.boundary&&!(l.lastVisited<=-i)){for(var h=l.vertices,c=0;c<=n;++c){var f=h[c];f<0?r[c]=e:r[c]=s[f]}var g=this.orient();if(g>0)return l;l.lastVisited=-i,0===g&&o.push(l)}}}return null},f.walk=function(t,e){var n=this.vertices.length-1,i=this.dimension,r=this.vertices,s=this.tuple,o=e?this.interior.length*Math.random()|0:this.interior.length-1,a=this.interior[o];t:for(;!a.boundary;){for(var u=a.vertices,l=a.adjacent,h=0;h<=i;++h)s[h]=r[u[h]];a.lastVisited=n;for(var h=0;h<=i;++h){var c=l[h];if(!(c.lastVisited>=n)){var f=s[h];s[h]=t;var g=this.orient();if(s[h]=f,g<0){a=c;continue t}c.boundary?c.lastVisited=-n:c.lastVisited=n}}return}return a},f.addPeaks=function(t,e){var n=this.vertices.length-1,o=this.dimension,a=this.vertices,u=this.tuple,l=this.interior,h=this.simplices,c=[e];e.lastVisited=n,e.vertices[e.vertices.indexOf(-1)]=n,e.boundary=!1,l.push(e);for(var f=[];c.length>0;){var e=c.pop(),g=e.vertices,d=e.adjacent,p=g.indexOf(n);if(!(p<0))for(var v=0;v<=o;++v)if(v!==p){var m=d[v];if(m.boundary&&!(m.lastVisited>=n)){var y=m.vertices;if(m.lastVisited!==-n){for(var x=0,E=0;E<=o;++E)y[E]<0?(x=E,u[E]=t):u[E]=a[y[E]];var I=this.orient();if(I>0){y[x]=n,m.boundary=!1,l.push(m),c.push(m),m.lastVisited=n;continue}m.lastVisited=-n}var N=m.adjacent,C=g.slice(),w=d.slice(),S=new i(C,w,!0);h.push(S);var L=N.indexOf(e);if(!(L<0)){N[L]=S,w[p]=m,C[v]=-1,w[v]=e,d[v]=S,S.flip();for(var E=0;E<=o;++E){var b=C[E];if(!(b<0||b===n)){for(var R=new Array(o-1),P=0,T=0;T<=o;++T){var M=C[T];M<0||T===E||(R[P++]=M)}f.push(new r(R,S,E))}}}}}}f.sort(s);for(var v=0;v+1=0?o[u++]=a[h]:l=1&h;if(l===(1&t)){var c=o[0];o[0]=o[1],o[1]=c}e.push(o)}}return e}},{"robust-orientation":78,"simplicial-complex":82}],73:[function(e,n,i){!function(e,r){"object"==typeof i&&"undefined"!=typeof n?r(i):"function"==typeof t&&t.amd?t(["exports"],r):r(e.jsts=e.jsts||{})}(this,function(t){"use strict";function e(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}function n(){}function i(){}function r(){}function s(){}function o(){}function a(){}function u(){}function l(t){this.name="RuntimeException",this.message=t,this.stack=(new Error).stack,Error.call(this,t)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t}function c(){if(0===arguments.length)l.call(this);else if(1===arguments.length){var t=arguments[0];l.call(this,t)}}function f(){}function g(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)g.call(this,0,0);else if(1===arguments.length){var t=arguments[0];g.call(this,t.x,t.y,t.z)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];g.call(this,e,n,g.NULL_ORDINATE)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2];this.x=i,this.y=r,this.z=s}}function d(){if(this.dimensionsToTest=2,0===arguments.length)d.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new i("only 2 or 3 dimensions may be specified");this.dimensionsToTest=t}}function p(){}function v(){}function m(t){this.message=t||""}function y(){}function x(t){this.message=t||""}function E(t){this.message=t||""}function I(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function N(){if(I.apply(this),0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}function C(){if(this.minx=null,this.maxx=null,this.miny=null,this.maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof g){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof C){var e=arguments[0];this.init(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3];this.init(r,s,o,a)}}function w(){}function S(){w.call(this,"Projective point not representable on the Cartesian plane.")}function L(){}function b(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1}function R(){}function P(t){this.str=t}function T(t){this.value=t}function M(){}function O(){if(this.hi=0,this.lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof O){var e=arguments[0];this.init(e)}else if("string"==typeof arguments[0]){var n=arguments[0];O.call(this,O.parse(n))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i,r)}}function _(){}function A(){}function D(){}function F(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];this.x=e,this.y=n,this.w=1}else if(arguments[0]instanceof F&&arguments[1]instanceof F){var i=arguments[0],r=arguments[1];this.x=i.y*r.w-r.y*i.w,this.y=r.x*i.w-i.x*r.w,this.w=i.x*r.y-r.x*i.y}else if(arguments[0]instanceof g&&arguments[1]instanceof g){var s=arguments[0],o=arguments[1];this.x=s.y-o.y,this.y=o.x-s.x,this.w=s.x*o.y-o.x*s.y}}else if(3===arguments.length){var a=arguments[0],u=arguments[1],l=arguments[2];this.x=a,this.y=u,this.w=l}else if(4===arguments.length){var h=arguments[0],c=arguments[1],f=arguments[2],d=arguments[3],p=h.y-c.y,v=c.x-h.x,m=h.x*c.y-c.x*h.y,y=f.y-d.y,x=d.x-f.x,E=f.x*d.y-d.x*f.y;this.x=v*E-x*m,this.y=y*m-p*E,this.w=p*x-y*v}}function G(){}function q(){}function B(){this.envelope=null,this.factory=null,this.SRID=null,this.userData=null;var t=arguments[0];this.factory=t,this.SRID=t.getSRID()}function z(){}function k(){}function V(){}function Y(){}function X(){}function U(){}function H(){}function j(){}function W(){}function J(){}function Z(){}function K(){}function Q(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function $(t){return null==t?$s:t.color}function tt(t){return null==t?null:t.parent}function et(t,e){null!==t&&(t.color=e)}function nt(t){return null==t?null:t.left}function it(t){return null==t?null:t.right}function rt(){this.root_=null,this.size_=0}function st(){}function ot(){}function at(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function ut(){}function lt(){}function ht(){}function ct(){}function ft(){this.geometries=null;var t=arguments[0],e=arguments[1];if(B.call(this,e),null===t&&(t=[]),B.hasNullElements(t))throw new i("geometries must not contain null elements");this.geometries=t}function gt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function dt(){if(this.geom=null,this.geomFact=null,this.bnRule=null,this.endpointMap=null,1===arguments.length){var t=arguments[0];dt.call(this,t,k.MOD2_BOUNDARY_RULE)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.geom=e,this.geomFact=e.getFactory(),this.bnRule=n}}function pt(){this.count=null}function vt(){}function mt(){}function yt(){}function xt(){}function Et(){}function It(){}function Nt(){}function Ct(){}function wt(){this.points=null;var t=arguments[0],e=arguments[1];B.call(this,e),this.init(t)}function St(){}function Lt(){this.coordinates=null;var t=arguments[0],e=arguments[1];B.call(this,e),this.init(t)}function bt(){}function Rt(){this.shell=null,this.holes=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(B.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),B.hasNullElements(e))throw new i("holes must not contain null elements");if(t.isEmpty()&&B.hasNonEmptyElements(e))throw new i("shell is empty but holes are not");this.shell=t,this.holes=e}function Pt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function Tt(){if(arguments[0]instanceof g&&arguments[1]instanceof ie){var t=arguments[0],e=arguments[1];Tt.call(this,e.getCoordinateSequenceFactory().create(t),e)}else if(b(arguments[0],A)&&arguments[1]instanceof ie){var n=arguments[0],i=arguments[1];wt.call(this,n,i),this.validateConstruction()}}function Mt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function Ot(){if(this.factory=null,this.isUserDataCopied=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.factory=t}}function _t(){}function At(){}function Dt(){}function Ft(){}function Gt(){if(this.dimension=3,this.coordinates=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];Gt.call(this,t,3)}else if(Number.isInteger(arguments[0])){var e=arguments[0];this.coordinates=new Array(e).fill(null);for(var n=0;n-1}function Yt(t){return this.has(t)?this._values[no]:void 0}function Xt(t,e){if(this.objectOnly&&e!==Object(e))throw new TypeError("Invalid value used as weak collection key");if(e!==e||0===e)for(no=t.length;no--&&!Bt(t[no],e););else no=t.indexOf(e);return no>-1}function Ut(t){return Xt.call(this,this._keys,t)}function Ht(t,e){return this.has(t)?this._values[no]=e:this._values[this._keys.push(t)-1]=e,this}function jt(){(this._keys||0).length=this._values.length=0}function Wt(){return Kt(this._itp,this._keys)}function Jt(){return Kt(this._itp,this._values)}function Zt(){return Kt(this._itp,this._keys,this._values)}function Kt(t,e,n){var i=[0],r=!1;return t.push(i),{next:function(){var s,o=i[0];return!r&&o1,"Node capacity must be greater than 1"),this.nodeCapacity=t}}function ze(){}function ke(){}function Ve(){if(0===arguments.length)Ve.call(this,Ve.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];Be.call(this,t)}}function Ye(){var t=arguments[0];Ge.call(this,t)}function Xe(){}function Ue(){this.segString=null,this.coord=null,this.segmentIndex=null,this.segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.segString=t,this.coord=new g(e),this.segmentIndex=n,this.segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))}function He(){this.nodeMap=new rt,this.edge=null;var t=arguments[0];this.edge=t}function je(){this.nodeList=null,this.edge=null,this.nodeIt=null,this.currNode=null,this.nextNode=null,this.currSegIndex=0;var t=arguments[0];this.nodeList=t,this.edge=t.getEdge(),this.nodeIt=t.iterator(),this.readNextNode()}function We(){}function Je(){this.nodeList=new He(this),this.pts=null,this.data=null;var t=arguments[0],e=arguments[1];this.pts=t,this.data=e}function Ze(){this.tempEnv1=new C,this.tempEnv2=new C,this.overlapSeg1=new ce,this.overlapSeg2=new ce}function Ke(){this.pts=null,this.start=null,this.end=null,this.env=null,this.context=null,this.id=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.pts=t,this.start=e,this.end=n,this.context=i}function Qe(){}function $e(){}function tn(){}function en(){if(this.segInt=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}}function nn(){if(this.monoChains=new I,this.index=new Ve,this.idCounter=0,this.nodedSegStrings=null,this.nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];en.call(this,t)}}function rn(){Ze.apply(this),this.si=null;var t=arguments[0];this.si=t}function sn(){if(this.pt=null,1===arguments.length){var t=arguments[0];l.call(this,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];l.call(this,sn.msgWithCoord(e,n)),this.name="TopologyException",this.pt=new g(n)}}function on(){}function an(){this.findAllIntersections=!1,this.isCheckEndSegmentsOnly=!1,this.li=null,this.interiorIntersection=null,this.intSegments=null,this.intersections=new I,this.intersectionCount=0,this.keepIntersections=!0;var t=arguments[0];this.li=t,this.interiorIntersection=null}function un(){this.li=new ae,this.segStrings=null,this.findAllIntersections=!1,this.segInt=null,this._isValid=!0;var t=arguments[0];this.segStrings=t}function ln(){this.nv=null;var t=arguments[0];this.nv=new un(ln.toSegmentStrings(t))}function hn(){this.mapOp=null;var t=arguments[0];this.mapOp=t}function cn(){}function fn(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];this.init(t.length)}else if(Number.isInteger(arguments[0])){var e=arguments[0];this.init(1),this.location[cn.ON]=e}else if(arguments[0]instanceof fn){var n=arguments[0];if(this.init(n.location.length),null!==n)for(var i=0;i=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(r.getPrecisionModel()),this.arg=new Array(2).fill(null),this.arg[0]=new $n(0,i,s),this.arg[1]=new $n(1,r,s)}}function ei(){this.pts=null,this._orientation=null;var t=arguments[0];this.pts=t,this._orientation=ei.orientation(t)}function ni(){this.edges=new I,this.ocaMap=new rt}function ii(){this.ptLocator=new Re,this.geomFact=null,this.resultGeom=null,this.graph=null,this.edgeList=new ni,this.resultPolyList=new I,this.resultLineList=new I,this.resultPointList=new I;var t=arguments[0],e=arguments[1];ti.call(this,t,e),this.graph=new Cn(new Mn),this.geomFact=t.getFactory()}function ri(){this.geom=new Array(2).fill(null),this.snapTolerance=null,this.cbr=null;var t=arguments[0],e=arguments[1];this.geom[0]=t,this.geom[1]=e,this.computeSnapTolerance()}function si(){this.geom=new Array(2).fill(null);var t=arguments[0],e=arguments[1];this.geom[0]=t,this.geom[1]=e}function oi(){this.factory=null,this.interiorPoint=null,this.maxWidth=0;var t=arguments[0];this.factory=t.getFactory(),this.add(t)}function ai(){this.poly=null,this.centreY=null,this.hiY=r.MAX_VALUE,this.loY=-r.MAX_VALUE;var t=arguments[0];this.poly=t,this.hiY=t.getEnvelopeInternal().getMaxY(),this.loY=t.getEnvelopeInternal().getMinY(),this.centreY=oi.avg(this.loY,this.hiY)}function ui(){this.centroid=null,this.minDistance=r.MAX_VALUE,this.interiorPoint=null;var t=arguments[0];this.centroid=t.getCentroid().getCoordinate(),this.addInterior(t),null===this.interiorPoint&&this.addEndpoints(t)}function li(){this.centroid=null,this.minDistance=r.MAX_VALUE,this.interiorPoint=null;var t=arguments[0];this.centroid=t.getCentroid().getCoordinate(),this.add(t)}function hi(){this.tempEnv1=new C,this.selectedSegment=new ce}function ci(){this.items=new I,this.subnode=[null,null]}function fi(){if(this.min=null,this.max=null,0===arguments.length)this.min=0,this.max=0;else if(1===arguments.length){var t=arguments[0];this.init(t.min,t.max)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.init(e,n)}}function gi(){}function di(t,e){var n,i,r,s,o={32:{d:127,c:128,b:0,a:0},64:{d:32752,c:0,b:0,a:0}},a={32:8,64:11}[t];if(s||(n=e<0||1/e<0,isFinite(e)||(s=o[t],n&&(s.d+=1<=2;)i++,r/=2;for(;r<1&&i>0;)i--,r*=2;i<=0&&(r/=2),32===t&&i>254&&(s={d:n?255:127,c:128,b:0,a:0},i=Math.pow(2,a)-1,r=0)}return i}function pi(){this.pt=0,this.level=0,this.interval=null;var t=arguments[0];this.computeKey(t)}function vi(){ci.apply(this),this.interval=null,this.centre=null,this.level=null;var t=arguments[0],e=arguments[1];this.interval=t,this.level=e,this.centre=(t.getMin()+t.getMax())/2}function mi(){}function yi(){ci.apply(this)}function xi(){this.root=null,this.minExtent=1,this.root=new yi}function Ei(){}function Ii(){this.ring=null,this.tree=null,this.crossings=0,this.interval=new fi;var t=arguments[0];this.ring=t,this.buildIndex()}function Ni(){hi.apply(this),this.mcp=null,this.p=null;var t=arguments[0],e=arguments[1];this.mcp=t,this.p=e}function Ci(){}function wi(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}function Si(){this.input=null,this.extremalPts=null,this.centre=null,this.radius=0;var t=arguments[0];this.input=t}function Li(){if(this.inputGeom=null,this.isConvex=null,this.convexHullPts=null,this.minBaseSeg=new ce,this.minWidthPt=null,this.minPtIndex=null,this.minWidth=0,1===arguments.length){var t=arguments[0];Li.call(this,t,!1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.inputGeom=e,this.isConvex=n}}function bi(){this.inputGeom=null,this.distanceTolerance=null;var t=arguments[0];this.inputGeom=t}function Ri(){xe.apply(this),this.distanceTolerance=null;var t=arguments[0];this.distanceTolerance=t}function Pi(){this._orig=null,this._sym=null,this._next=null;var t=arguments[0];this._orig=t}function Ti(){this._isMarked=!1;var t=arguments[0];Pi.call(this,t)}function Mi(){this.vertexMap=new te}function Oi(){this._isStart=!1;var t=arguments[0];Ti.call(this,t)}function _i(){Mi.apply(this)}function Ai(){this.result=null,this.factory=null,this.graph=null,this.lines=new I,this.nodeEdgeStack=new pe,this.ringStartEdge=null,this.graph=new _i}function Di(){this.items=new I,this.subnode=new Array(4).fill(null)}function Fi(){this.pt=new g,this.level=0,this.env=null;var t=arguments[0];this.computeKey(t)}function Gi(){Di.apply(this),this.env=null,this.centrex=null,this.centrey=null,this.level=null;var t=arguments[0],e=arguments[1];this.env=t,this.level=e,this.centrex=(t.getMinX()+t.getMaxX())/2,this.centrey=(t.getMinY()+t.getMaxY())/2}function qi(){Di.apply(this)}function Bi(){this.root=null,this.minExtent=1,this.root=new qi}function zi(t){this.geometryFactory=t||new ie}function ki(t){this.geometryFactory=t||new ie,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new zi(this.geometryFactory)}function Vi(){this.parser=new zi(this.geometryFactory)}function Yi(t){this.geometryFactory=t||new ie,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new re(this.geometryFactory)}function Xi(t){return[t.x,t.y]}function Ui(t,e){this.geometryFactory=t||new ie,this.ol=e||"undefined"!=typeof ol&&ol}function Hi(){if(this.noder=null,this.scaleFactor=null,this.offsetX=null,this.offsetY=null,this.isScaled=!1,2===arguments.length){var t=arguments[0],e=arguments[1];Hi.call(this,t,e,0,0)}else if(4===arguments.length){var n=arguments[0],i=arguments[1];arguments[2],arguments[3],this.noder=n,this.scaleFactor=i,this.isScaled=!this.isIntegerPrecision()}}function ji(){if(this.inputGeom=null,this.isClosedEndpointsInInterior=!0,this.nonSimpleLocation=null,1===arguments.length){var t=arguments[0];this.inputGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.inputGeom=e,this.isClosedEndpointsInInterior=!n.isInBoundary(2)}}function Wi(){this.pt=null,this.isClosed=null,this.degree=null;var t=arguments[0];this.pt=t,this.isClosed=!1,this.degree=0}function Ji(){if(this.quadrantSegments=Ji.DEFAULT_QUADRANT_SEGMENTS,this.endCapStyle=Ji.CAP_ROUND,this.joinStyle=Ji.JOIN_ROUND,this.mitreLimit=Ji.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this.simplifyFactor=Ji.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.setQuadrantSegments(e),this.setEndCapStyle(n)}else if(4===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2],o=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(r),this.setJoinStyle(s),this.setMitreLimit(o)}}function Zi(){this.minIndex=-1,this.minCoord=null,this.minDe=null,this.orientedDe=null}function Ki(){this.array_=[]}function Qi(){this.finder=null,this.dirEdgeList=new I,this.nodes=new I,this.rightMostCoord=null,this.env=null,this.finder=new Zi}function $i(){this.inputLine=null,this.distanceTol=null,this.isDeleted=null,this.angleOrientation=he.COUNTERCLOCKWISE;var t=arguments[0];this.inputLine=t}function tr(){this.ptList=null,this.precisionModel=null,this.minimimVertexDistance=0,this.ptList=new I}function er(){this.maxCurveSegmentError=0,this.filletAngleQuantum=null,this.closingSegLengthFactor=1,this.segList=null,this.distance=0,this.precisionModel=null,this.bufParams=null,this.li=null,this.s0=null,this.s1=null,this.s2=null,this.seg0=new ce,this.seg1=new ce,this.offset0=new ce,this.offset1=new ce,this.side=0,this._hasNarrowConcaveAngle=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this.precisionModel=t,this.bufParams=e,this.li=new ae,this.filletAngleQuantum=Math.PI/2/e.getQuadrantSegments(),e.getQuadrantSegments()>=8&&e.getJoinStyle()===Ji.JOIN_ROUND&&(this.closingSegLengthFactor=er.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)}function nr(){this.distance=0,this.precisionModel=null,this.bufParams=null;var t=arguments[0],e=arguments[1];this.precisionModel=t,this.bufParams=e}function ir(){this.subgraphs=null,this.seg=new ce,this.cga=new he;var t=arguments[0];this.subgraphs=t}function rr(){this.upwardSeg=null,this.leftDepth=null;var t=arguments[0],e=arguments[1];this.upwardSeg=new ce(t),this.leftDepth=e}function sr(){this.inputGeom=null,this.distance=null,this.curveBuilder=null,this.curveList=new I;var t=arguments[0],e=arguments[1],n=arguments[2];this.inputGeom=t,this.distance=e,this.curveBuilder=n}function or(){this._hasIntersection=!1,this.hasProper=!1,this.hasProperInterior=!1,this.hasInterior=!1,this.properIntersectionPoint=null,this.li=null,this.isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this.li=t}function ar(){this.bufParams=null,this.workingPrecisionModel=null,this.workingNoder=null,this.geomFact=null,this.graph=null,this.edgeList=new ni;var t=arguments[0];this.bufParams=t}function ur(){this.li=new ae,this.segStrings=null;var t=arguments[0];this.segStrings=t}function lr(){this.li=null,this.pt=null,this.originalPt=null,this.ptScaled=null,this.p0Scaled=null,this.p1Scaled=null,this.scaleFactor=null,this.minx=null,this.maxx=null,this.miny=null,this.maxy=null,this.corner=new Array(4).fill(null),this.safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this.originalPt=t,this.pt=t,this.scaleFactor=e,this.li=n,e<=0)throw new i("Scale factor must be non-zero");1!==e&&(this.pt=new g(this.scale(t.x),this.scale(t.y)),this.p0Scaled=new g,this.p1Scaled=new g),this.initCorners(this.pt)}function hr(){this.index=null;var t=arguments[0];this.index=t}function cr(){hi.apply(this),this.hotPixel=null,this.parentEdge=null,this.hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this.hotPixel=t,this.parentEdge=e,this.hotPixelVertexIndex=n}function fr(){this.li=null,this.interiorIntersections=null;var t=arguments[0];this.li=t,this.interiorIntersections=new I}function gr(){this.pm=null,this.li=null,this.scaleFactor=null,this.noder=null,this.pointSnapper=null,this.nodedSegStrings=null;var t=arguments[0];this.pm=t,this.li=new ae,this.li.setPrecisionModel(t),this.scaleFactor=t.getScale()}function dr(){if(this.argGeom=null,this.distance=null,this.bufParams=new Ji,this.resultGeometry=null,this.saveException=null,1===arguments.length){var t=arguments[0];this.argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.argGeom=e,this.bufParams=n}}function pr(){this.comps=null;var t=arguments[0];this.comps=t}function vr(){if(this.component=null,this.segIndex=null,this.pt=null,2===arguments.length){var t=arguments[0],e=arguments[1];vr.call(this,t,vr.INSIDE_AREA,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.component=n,this.segIndex=i,this.pt=r}}function mr(){this.pts=null;var t=arguments[0];this.pts=t}function yr(){this.locations=null;var t=arguments[0];this.locations=t}function xr(){if(this.geom=null,this.terminateDistance=0,this.ptLocator=new Re,this.minDistanceLocation=null,this.minDistance=r.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];xr.call(this,t,e,0)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],s=arguments[2];this.geom=new Array(2).fill(null),this.geom[0]=n,this.geom[1]=i,this.terminateDistance=s}}function Er(){this.factory=null,this.directedEdges=new I,this.coordinates=null;var t=arguments[0];this.factory=t}function Ir(){this._isMarked=!1,this._isVisited=!1,this.data=null}function Nr(){Ir.apply(this),this.parentEdge=null,this.from=null,this.to=null,this.p0=null,this.p1=null,this.sym=null,this.edgeDirection=null,this.quadrant=null,this.angle=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.from=t,this.to=e,this.edgeDirection=i,this.p0=t.getCoordinate(),this.p1=n;var r=this.p1.x-this.p0.x,s=this.p1.y-this.p0.y;this.quadrant=Qe.quadrant(r,s),this.angle=Math.atan2(s,r)}function Cr(){var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];Nr.call(this,t,e,n,i)}function wr(){if(Ir.apply(this),this.dirEdge=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];this.setDirectedEdges(t,e)}}function Sr(){this.outEdges=new I,this.sorted=!1}function Lr(){if(Ir.apply(this),this.pt=null,this.deStar=null,1===arguments.length){var t=arguments[0];Lr.call(this,t,new Sr)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.pt=e,this.deStar=n}}function br(){wr.apply(this),this.line=null;var t=arguments[0];this.line=t}function Rr(){this.nodeMap=new rt}function Pr(){this.edges=new Q,this.dirEdges=new Q,this.nodeMap=new Rr}function Tr(){Pr.apply(this)}function Mr(){this.graph=new Tr,this.mergedLineStrings=null,this.factory=null,this.edgeStrings=null}function Or(){this.edgeRing=null,this.next=null,this.label=-1;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];Nr.call(this,t,e,n,i)}function _r(){wr.apply(this),this.line=null;var t=arguments[0];this.line=t}function Ar(){this.geometryFactory=new ie,this.geomGraph=null,this.disconnectedRingcoord=null;var t=arguments[0];this.geomGraph=t}function Dr(){}function Fr(){if(this.edgeEnds=new I,1===arguments.length){var t=arguments[0];Fr.call(this,null,t)}else if(2===arguments.length){var e=(arguments[0],arguments[1]);En.call(this,e.getEdge(),e.getCoordinate(),e.getDirectedCoordinate(),new gn(e.getLabel())),this.insert(e)}}function Gr(){Pn.apply(this)}function qr(){var t=arguments[0],e=arguments[1];yn.call(this,t,e)}function Br(){Nn.apply(this)}function zr(){this.nodes=new xn(new Br)}function kr(){this.li=new ae,this.geomGraph=null,this.nodeGraph=new zr,this.invalidPoint=null;var t=arguments[0];this.geomGraph=t}function Vr(){this.graph=null,this.rings=new I,this.totalEnv=new C,this.index=null,this.nestedPt=null;var t=arguments[0];this.graph=t}function Yr(){if(this.errorType=null,this.pt=null,1===arguments.length){var t=arguments[0];Yr.call(this,t,null)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.errorType=e,null!==n&&(this.pt=n.copy())}}function Xr(){this.parentGeometry=null,this.isSelfTouchingRingFormingHoleValid=!1,this.validErr=null;var t=arguments[0];this.parentGeometry=t}function Ur(){this.factory=null,this.deList=new I,this.lowestEdge=null,this.ring=null,this.ringPts=null,this.holes=null,this.shell=null,this._isHole=null,this._isProcessed=!1,this._isIncludedSet=!1,this._isIncluded=!1;var t=arguments[0];this.factory=t}function Hr(){}function jr(){Pr.apply(this),this.factory=null;var t=arguments[0];this.factory=t}function Wr(){if(this.lineStringAdder=new Jr(this),this.graph=null,this.dangles=new I,this.cutEdges=new I,this.invalidRingLines=new I,this.holeList=null,this.shellList=null,this.polyList=null,this.isCheckingRingsValid=!0,this.extractOnlyPolygonal=null,this.geomFactory=null,0===arguments.length)Wr.call(this,!1);else if(1===arguments.length){var t=arguments[0];this.extractOnlyPolygonal=t}}function Jr(){this.p=null;var t=arguments[0];this.p=t}function Zr(){this.li=new ae,this.ptLocator=new Re,this.arg=null,this.nodes=new xn(new Br),this.im=null,this.isolatedEdges=new I,this.invalidPoint=null;var t=arguments[0];this.arg=t}function Kr(){this.rectEnv=null;var t=arguments[0];this.rectEnv=t.getEnvelopeInternal()}function Qr(){this.li=new ae,this.rectEnv=null,this.diagUp0=null,this.diagUp1=null,this.diagDown0=null,this.diagDown1=null;var t=arguments[0];this.rectEnv=t,this.diagUp0=new g(t.getMinX(),t.getMinY()),this.diagUp1=new g(t.getMaxX(),t.getMaxY()),this.diagDown0=new g(t.getMinX(),t.getMaxY()),this.diagDown1=new g(t.getMaxX(),t.getMinY())}function $r(){this._isDone=!1}function ts(){this.rectangle=null,this.rectEnv=null;var t=arguments[0];this.rectangle=t,this.rectEnv=t.getEnvelopeInternal()}function es(){$r.apply(this),this.rectEnv=null,this._intersects=!1;var t=arguments[0];this.rectEnv=t}function ns(){$r.apply(this),this.rectSeq=null,this.rectEnv=null,this._containsPoint=!1;var t=arguments[0];this.rectSeq=t.getExteriorRing().getCoordinateSequence(),this.rectEnv=t.getEnvelopeInternal()}function is(){$r.apply(this),this.rectEnv=null,this.rectIntersector=null,this.hasIntersection=!1,this.p0=new g,this.p1=new g;var t=arguments[0];this.rectEnv=t.getEnvelopeInternal(),this.rectIntersector=new Qr(this.rectEnv)}function rs(){if(this._relate=null,2===arguments.length){var t=arguments[0],e=arguments[1];ti.call(this,t,e),this._relate=new Zr(this.arg)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];ti.call(this,n,i,r),this._relate=new Zr(this.arg)}}function ss(){this.geomFactory=null,this.skipEmpty=!1,this.inputGeoms=null;var t=arguments[0];this.geomFactory=ss.extractFactory(t),this.inputGeoms=t}function os(){this.pointGeom=null,this.otherGeom=null,this.geomFact=null;var t=arguments[0],e=arguments[1];this.pointGeom=t,this.otherGeom=e,this.geomFact=e.getFactory()}function as(){this.sortIndex=-1,this.comps=null;var t=arguments[0],e=arguments[1];this.sortIndex=t,this.comps=e}function us(){this.inputPolys=null,this.geomFactory=null;var t=arguments[0];this.inputPolys=t,null===this.inputPolys&&(this.inputPolys=new I)}function ls(){if(this.polygons=new I,this.lines=new I,this.points=new I,this.geomFact=null,1===arguments.length){if(b(arguments[0],v)){var t=arguments[0];this.extract(t)}else if(arguments[0]instanceof B){var e=arguments[0];this.extract(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.geomFact=i,this.extract(n)}}function hs(){Ot.CoordinateOperation.apply(this),this.targetPM=null,this.removeCollapsed=!0;var t=arguments[0],e=arguments[1];this.targetPM=t,this.removeCollapsed=e}function cs(){this.targetPM=null,this.removeCollapsed=!0,this.changePrecisionModel=!1,this.isPointwise=!1;var t=arguments[0];this.targetPM=t}function fs(){this.pts=null,this.usePt=null,this.distanceTolerance=null,this.seg=new ce;var t=arguments[0];this.pts=t}function gs(){this.inputGeom=null,this.distanceTolerance=null,this.isEnsureValidTopology=!0;var t=arguments[0];this.inputGeom=t}function ds(){xe.apply(this),this.isEnsureValidTopology=!0,this.distanceTolerance=null;var t=arguments[0],e=arguments[1];this.isEnsureValidTopology=t,this.distanceTolerance=e}function ps(){if(this.parent=null,this.index=null,2===arguments.length){var t=arguments[0],e=arguments[1];ps.call(this,t,e,null,-1)}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],s=arguments[3];ce.call(this,n,i),this.parent=r,this.index=s}}function vs(){if(this.parentLine=null,this.segs=null,this.resultSegs=new I,this.minimumSize=null,1===arguments.length){var t=arguments[0];vs.call(this,t,2)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.parentLine=e,this.minimumSize=n,this.init()}}function ms(){this.index=new Bi}function ys(){this.querySeg=null,this.items=new I;var t=arguments[0];this.querySeg=t}function xs(){this.li=new ae,this.inputIndex=new ms,this.outputIndex=new ms,this.line=null,this.linePts=null,this.distanceTolerance=0;var t=arguments[0],e=arguments[1];this.inputIndex=t,this.outputIndex=e}function Es(){this.inputIndex=new ms,this.outputIndex=new ms,this.distanceTolerance=0}function Is(){this.inputGeom=null,this.lineSimplifier=new Es,this.linestringMap=null;var t=arguments[0];this.inputGeom=t}function Ns(){xe.apply(this),this.linestringMap=null;var t=arguments[0];this.linestringMap=t}function Cs(){this.tps=null;var t=arguments[0];this.tps=t}function ws(){this.seg=null,this.segLen=null,this.splitPt=null,this.minimumLen=0;var t=arguments[0];this.seg=t,this.segLen=t.getLength()}function Ss(){}function Ls(){}function bs(){}function Rs(){if(this.p=null,1===arguments.length){var t=arguments[0];this.p=new g(t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p=new g(e,n)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2];this.p=new g(i,r,s)}}function Ps(){this._isOnConstraint=null,this.constraint=null;var t=arguments[0];Rs.call(this,t)}function Ts(){this._rot=null,this.vertex=null,this.next=null,this.data=null}function Ms(){this.subdiv=null,this.isUsingTolerance=!1;var t=arguments[0];this.subdiv=t,this.isUsingTolerance=t.getTolerance()>0}function Os(){}function _s(){this.subdiv=null,this.lastEdge=null;var t=arguments[0];this.subdiv=t,this.init()}function As(){if(this.seg=null,1===arguments.length){if("string"==typeof arguments[0]){var t=arguments[0];l.call(this,t)}else if(arguments[0]instanceof ce){var e=arguments[0];l.call(this,"Locate failed to converge (at edge: "+e+"). Possible causes include invalid Subdivision topology or very close sites"),this.seg=new ce(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];l.call(this,As.msgWithSpatial(n,i)),this.seg=new ce(i)}}function Ds(){}function Fs(){this.visitedKey=0,this.quadEdges=new I,this.startingEdge=null,this.tolerance=null,this.edgeCoincidenceTolerance=null,this.frameVertex=new Array(3).fill(null),this.frameEnv=null,this.locator=null,this.seg=new ce,this.triEdges=new Array(3).fill(null);var t=arguments[0],e=arguments[1];this.tolerance=e,this.edgeCoincidenceTolerance=e/Fs.EDGE_COINCIDENCE_TOL_FACTOR,this.createFrame(t),this.startingEdge=this.initSubdiv(),this.locator=new _s(this)}function Gs(){}function qs(){this.triList=new I}function Bs(){this.triList=new I}function zs(){this.coordList=new N,this.triCoords=new I}function ks(){if(this.ls=null,this.data=null,2===arguments.length){var t=arguments[0],e=arguments[1];this.ls=new ce(t,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.ls=new ce(n,i),this.data=r}else if(6===arguments.length){var s=arguments[0],o=arguments[1],a=arguments[2],u=arguments[3],l=arguments[4],h=arguments[5];ks.call(this,new g(s,o,a),new g(u,l,h))}else if(7===arguments.length){var c=arguments[0],f=arguments[1],d=arguments[2],p=arguments[3],v=arguments[4],m=arguments[5],y=arguments[6];ks.call(this,new g(c,f,d),new g(p,v,m),y)}}function Vs(){}function Ys(){if(this.p=null,this.data=null,this.left=null,this.right=null,this.count=null,2===arguments.length){var t=arguments[0],e=arguments[1];this.p=new g(t),this.left=null,this.right=null,this.count=1,this.data=e}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.p=new g(n,i),this.left=null,this.right=null,this.count=1,this.data=r}}function Xs(){if(this.root=null,this.numberOfNodes=null,this.tolerance=null,0===arguments.length)Xs.call(this,0);else if(1===arguments.length){var t=arguments[0];this.tolerance=t}}function Us(){this.tolerance=null,this.matchNode=null,this.matchDist=0,this.p=null;var t=arguments[0],e=arguments[1];this.p=t,this.tolerance=e}function Hs(){this.initialVertices=null,this.segVertices=null,this.segments=new I,this.subdiv=null,this.incDel=null,this.convexHull=null,this.splitFinder=new Ls,this.kdt=null,this.vertexFactory=null,this.computeAreaEnv=null,this.splitPt=null,this.tolerance=null;var t=arguments[0],e=arguments[1];this.initialVertices=new I(t),this.tolerance=e,this.kdt=new Xs(e)}function js(){this.siteCoords=null,this.tolerance=0,this.subdiv=null}function Ws(){this.siteCoords=null,this.constraintLines=null,this.tolerance=0,this.subdiv=null,this.constraintVertexMap=new rt}function Js(){this.siteCoords=null,this.tolerance=0,this.subdiv=null,this.clipEnv=null,this.diagramEnv=null}function Zs(){}"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(t){if(void 0===this||null===this)throw new TypeError(this+" is not an object");var e=Object(this),n=Math.max(Math.min(e.length,9007199254740991),0)||0,i=1 in arguments?parseInt(Number(arguments[1]),10)||0:0;i=i<0?Math.max(n+i,0):Math.min(i,n);var r=2 in arguments&&void 0!==arguments[2]?parseInt(Number(arguments[2]),10)||0:n;for(r=r<0?Math.max(n+arguments[2],0):Math.min(r,n);ie.x?1:this.ye.y?1:0},clone:function(){try{var t=null;return t}catch(t){if(t instanceof CloneNotSupportedException)return f.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}finally{}},copy:function(){return new g(this)},toString:function(){return"("+this.x+", "+this.y+", "+this.z+")"},distance3D:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return Math.sqrt(e*e+n*n+i*i)},distance:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},hashCode:function(){var t=17;return t=37*t+g.hashCode(this.x),t=37*t+g.hashCode(this.y)},setCoordinate:function(t){this.x=t.x,this.y=t.y,this.z=t.z},interfaces_:function(){return[s,o,u]},getClass:function(){return g}}),g.hashCode=function(){if(1===arguments.length){var t=arguments[0],e=r.doubleToLongBits(t);return Math.trunc(e^e>>>32)}},e(d.prototype,{compare:function(t,e){var n=t,i=e,r=d.compare(n.x,i.x);if(0!==r)return r;var s=d.compare(n.y,i.y);if(0!==s)return s;if(this.dimensionsToTest<=2)return 0;var o=d.compare(n.z,i.z);return o},interfaces_:function(){return[a]},getClass:function(){return d}}),d.compare=function(t,e){return te?1:r.isNaN(t)?r.isNaN(e)?0:-1:r.isNaN(e)?1:0},g.DimensionalComparator=d,g.serialVersionUID=0x5cbf2c235c7e5800,g.NULL_ORDINATE=r.NaN,g.X=0,g.Y=1,g.Z=2,p.prototype.hasNext=function(){},p.prototype.next=function(){},p.prototype.remove=function(){},v.prototype.add=function(){},v.prototype.addAll=function(){},v.prototype.isEmpty=function(){},v.prototype.iterator=function(){},v.prototype.size=function(){},v.prototype.toArray=function(){},v.prototype.remove=function(){},m.prototype=new Error,m.prototype.name="IndexOutOfBoundsException",y.prototype=Object.create(v.prototype),y.prototype.constructor=y,y.prototype.get=function(){},y.prototype.set=function(){},y.prototype.isEmpty=function(){},x.prototype=new Error,x.prototype.name="NoSuchElementException",E.prototype=new Error,E.prototype.name="OperationNotSupported",I.prototype=Object.create(y.prototype),I.prototype.constructor=I,I.prototype.ensureCapacity=function(){},I.prototype.interfaces_=function(){return[y,v]},I.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},I.prototype.clear=function(){this.array_=[]},I.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},I.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},I.prototype.iterator=function(){return new Ks(this)},I.prototype.get=function(t){if(t<0||t>=this.size())throw new m;return this.array_[t]},I.prototype.isEmpty=function(){return 0===this.array_.length},I.prototype.size=function(){return this.array_.length},I.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e=1){var s=this.get(this.size()-1);if(s.equals2D(i))return null}I.prototype.add.call(this,i)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],a=arguments[1];return this.add(o,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var u=arguments[0],l=arguments[1],h=arguments[2];if(h)for(var c=0;c=0;c--)this.add(u[c],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof g){var f=arguments[0],d=arguments[1],p=arguments[2];if(!p){var v=this.size();if(v>0){if(f>0){var m=this.get(f-1);if(m.equals2D(d))return null}if(fC&&(w=-1);for(var c=N;c!==C;c+=w)this.add(x[c],E);return!0}},closeRing:function(){this.size()>0&&this.add(new g(this.get(0)),!1)},interfaces_:function(){return[]},getClass:function(){return N}}),N.coordArrayType=new Array(0).fill(null),e(C.prototype,{getArea:function(){return this.getWidth()*this.getHeight()},equals:function(t){if(!(t instanceof C))return!1;var e=t;return this.isNull()?e.isNull():this.maxx===e.getMaxX()&&this.maxy===e.getMaxY()&&this.minx===e.getMinX()&&this.miny===e.getMinY()},intersection:function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new C;var e=this.minx>t.minx?this.minx:t.minx,n=this.miny>t.miny?this.miny:t.miny,i=this.maxx=this.minx&&e.getMaxX()<=this.maxx&&e.getMinY()>=this.miny&&e.getMaxY()<=this.maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&n>=this.minx&&n<=this.maxx&&i>=this.miny&&i<=this.maxy}},intersects:function(){if(1===arguments.length){if(arguments[0]instanceof C){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t.minx>this.maxx||t.maxxthis.maxy||t.maxythis.maxx||nthis.maxy||ithis.maxx&&(this.maxx=e.maxx),e.minythis.maxy&&(this.maxy=e.maxy))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.isNull()?(this.minx=n,this.maxx=n,this.miny=i,this.maxy=i):(nthis.maxx&&(this.maxx=n),ithis.maxy&&(this.maxy=i))}},minExtent:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te.minx?1:this.minye.miny?1:this.maxxe.maxx?1:this.maxye.maxy?1:0},translate:function(t,e){return this.isNull()?null:void this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},toString:function(){return"Env["+this.minx+" : "+this.maxx+", "+this.miny+" : "+this.maxy+"]"},setToNull:function(){this.minx=0,this.maxx=-1,this.miny=0,this.maxy=-1},getHeight:function(){return this.isNull()?0:this.maxy-this.miny},maxExtent:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},expandBy:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this.minx-=e,this.maxx+=e,this.miny-=n,this.maxy+=n,(this.minx>this.maxx||this.miny>this.maxy)&&this.setToNull()}},contains:function(){if(1===arguments.length){if(arguments[0]instanceof C){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof g){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return this.covers(n,i)}},centre:function(){return this.isNull()?null:new g((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},init:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof g){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof C){var e=arguments[0];this.minx=e.minx,this.maxx=e.maxx,this.miny=e.miny,this.maxy=e.maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3];rt.maxx&&(e=this.minx-t.maxx);var n=0;return this.maxyt.maxy&&(n=this.miny-t.maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},hashCode:function(){var t=17;return t=37*t+g.hashCode(this.minx),t=37*t+g.hashCode(this.maxx),t=37*t+g.hashCode(this.miny),t=37*t+g.hashCode(this.maxy)},interfaces_:function(){return[s,u]},getClass:function(){return C}}),C.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2],o=arguments[3],a=Math.min(s.x,o.x),u=Math.max(s.x,o.x),l=Math.min(i.x,r.x),h=Math.max(i.x,r.x);return!(l>u||hu||hn?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],s=arguments[2];return is?s:i}},R.wrap=function(t,e){return t<0?e- -t%e:t%e},R.max=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=t;return e>i&&(i=e),n>i&&(i=n),i}if(4===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2],a=arguments[3],i=r;return s>i&&(i=s),o>i&&(i=o),a>i&&(i=a),i}},R.average=function(t,e){return(t+e)/2},R.LOG_10=Math.log(10),P.prototype.append=function(t){this.str+=t},P.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},P.prototype.toString=function(t){return this.str},T.prototype.intValue=function(){return this.value},T.prototype.compareTo=function(t){return this.valuet?1:0},T.isNaN=function(t){return Number.isNaN(t)},M.isWhitespace=function(t){return t<=32&&t>=0||127==t},M.toUpperCase=function(t){return t.toUpperCase()},e(O.prototype,{le:function(t){return this.hi9?(h=!0,c="9"):c="0"+l,o.append(c),n=n.subtract(O.valueOf(l)).multiply(O.TEN),h&&n.selfAdd(O.TEN);var f=!0,g=O.magnitude(n.hi);if(g<0&&Math.abs(g)>=a-u&&(f=!1),!f)break}return e[0]=i,o.toString()},sqr:function(){return this.multiply(this)},doubleValue:function(){return this.hi+this.lo},subtract:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},equals:function(){if(1===arguments.length){var t=arguments[0];return this.hi===t.hi&&this.lo===t.lo}},isZero:function(){return 0===this.hi&&0===this.lo},selfSubtract:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t.hi,-t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},getSpecialNumberString:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},min:function(t){return this.le(t)?this:t},selfDivide:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfDivide(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,s=null,o=null,a=null,u=null,l=null,h=null,c=null;return u=this.hi/n,l=O.SPLIT*u,r=l-u,c=O.SPLIT*n,r=l-r,s=u-r,o=c-n,h=u*n,o=c-o,a=n-o,c=r*o-h+r*a+s*o+s*a,l=(this.hi-h-c+this.lo-u*i)/n,c=u+l,this.hi=c,this.lo=u-c+l,this}},dump:function(){return"DD<"+this.hi+", "+this.lo+">"},divide:function(){if(arguments[0]instanceof O){var t=arguments[0],e=null,n=null,i=null,s=null,o=null,a=null,u=null,l=null;o=this.hi/t.hi,a=O.SPLIT*o,e=a-o,l=O.SPLIT*t.hi,e=a-e,n=o-e,i=l-t.hi,u=o*t.hi,i=l-i,s=t.hi-i,l=e*i-u+e*s+n*i+n*s,a=(this.hi-u-l+this.lo-o*t.lo)/t.hi,l=o+a;var h=l,c=o-l+a;return new O(h,c)}if("number"==typeof arguments[0]){var f=arguments[0];return r.isNaN(f)?O.createNaN():O.copy(this).selfDivide(f,0)}},ge:function(t){return this.hi>t.hi||this.hi===t.hi&&this.lo>=t.lo},pow:function(t){if(0===t)return O.valueOf(1);var e=new O(this),n=O.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2===1&&n.selfMultiply(e),i/=2,i>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},ceil:function(){if(this.isNaN())return O.NaN;var t=Math.ceil(this.hi),e=0;return t===this.hi&&(e=Math.ceil(this.lo)),new O(t,e)},compareTo:function(t){var e=t;return this.hie.hi?1:this.loe.lo?1:0},rint:function(){if(this.isNaN())return this;var t=this.add(.5);return t.floor()},setValue:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},max:function(t){return this.ge(t)?this:t},sqrt:function(){if(this.isZero())return O.valueOf(0);if(this.isNegative())return O.NaN;var t=1/Math.sqrt(this.hi),e=this.hi*t,n=O.valueOf(e),i=this.subtract(n.sqr()),r=i.hi*(.5*t);return n.add(r)},selfAdd:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfAdd(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0],n=null,i=null,r=null,s=null,o=null,a=null;return r=this.hi+e,o=r-this.hi,s=r-o,s=e-o+(this.hi-s),a=s+this.lo,n=r+a,i=a+(r-n),this.hi=n+i,this.lo=i+(n-this.hi),this}}else if(2===arguments.length){var u=arguments[0],l=arguments[1],n=null,i=null,h=null,c=null,r=null,s=null,o=null,a=null;r=this.hi+u,h=this.lo+l,o=r-this.hi,a=h-this.lo,s=r-o,c=h-a,s=u-o+(this.hi-s),c=l-a+(this.lo-c),o=s+h,n=r+o,i=o+(r-n),o=c+i;var f=n+o,g=o+(n-f);return this.hi=f,this.lo=g,this}},selfMultiply:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfMultiply(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,s=null,o=null,a=null,u=null,l=null;u=O.SPLIT*this.hi,r=u-this.hi,l=O.SPLIT*n,r=u-r,s=this.hi-r,o=l-n,u=this.hi*n,o=l-o,a=n-o,l=r*o-u+r*a+s*o+s*a+(this.hi*i+this.lo*n);var h=u+l;r=u-h;var c=l+r;return this.hi=h,this.lo=c,this}},selfSqr:function(){return this.selfMultiply(this)},floor:function(){if(this.isNaN())return O.NaN;var t=Math.floor(this.hi),e=0;return t===this.hi&&(e=Math.floor(this.lo)),new O(t,e)},negate:function(){return this.isNaN()?this:new O(-this.hi,-this.lo)},clone:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}finally{}},multiply:function(){if(arguments[0]instanceof O){var t=arguments[0];return t.isNaN()?O.createNaN():O.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return r.isNaN(e)?O.createNaN():O.copy(this).selfMultiply(e,0)}},isNaN:function(){return r.isNaN(this.hi)},intValue:function(){return Math.trunc(this.hi)},toString:function(){var t=O.magnitude(this.hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},toStandardNotation:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),i=e[0]+1,r=n;if("."===n.charAt(0))r="0"+n;else if(i<0)r="0."+O.stringOfChar("0",-i)+n;else if(n.indexOf(".")===-1){var s=i-n.length,o=O.stringOfChar("0",s);r=n+o+".0"}return this.isNegative()?"-"+r:r},reciprocal:function(){var t=null,e=null,n=null,i=null,r=null,s=null,o=null,a=null;r=1/this.hi,s=O.SPLIT*r,t=s-r,a=O.SPLIT*this.hi,t=s-t,e=r-t,n=a-this.hi,o=r*this.hi,n=a-n,i=this.hi-n,a=t*n-o+t*i+e*n+e*i,s=(1-o-a-r*this.lo)/this.hi;var u=r+s,l=r-u+s;return new O(u,l)},toSciNotation:function(){if(this.isZero())return O.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),i=O.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new IllegalStateException("Found leading zero: "+n);var r="";n.length>1&&(r=n.substring(1));var s=n.charAt(0)+"."+r;return this.isNegative()?"-"+s+i:s+i},abs:function(){return this.isNaN()?O.NaN:this.isNegative()?this.negate():new O(this)},isPositive:function(){return this.hi>0||0===this.hi&&this.lo>0},lt:function(t){return this.hit.hi||this.hi===t.hi&&this.lo>t.lo},isNegative:function(){return this.hi<0||0===this.hi&&this.lo<0},trunc:function(){return this.isNaN()?O.NaN:this.isPositive()?this.floor():this.ceil()},signum:function(){return this.hi>0?1:this.hi<0?-1:this.lo>0?1:this.lo<0?-1:0},interfaces_:function(){return[u,s,o]},getClass:function(){return O}}),O.sqr=function(t){return O.valueOf(t).selfMultiply(t)},O.valueOf=function(){if("string"==typeof arguments[0]){var t=arguments[0];return O.parse(t)}if("number"==typeof arguments[0]){var e=arguments[0];return new O(e)}},O.sqrt=function(t){return O.valueOf(t).sqrt()},O.parse=function(t){for(var e=0,n=t.length;M.isWhitespace(t.charAt(e));)e++;var i=!1;if(e=n);){var l=t.charAt(e);if(e++,M.isDigit(l)){var h=l-"0";s.selfMultiply(O.TEN),s.selfAdd(h),o++}else{if("."!==l){if("e"===l||"E"===l){var c=t.substring(e);try{u=T.parseInt(c)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+c+" in string "+t):e}finally{}break}throw new NumberFormatException("Unexpected character '"+l+"' at position "+e+" in string "+t)}a=o}}var f=s,g=o-a-u;if(0===g)f=s;else if(g>0){var d=O.TEN.pow(g);f=s.divide(d)}else if(g<0){var d=O.TEN.pow(-g);f=s.multiply(d)}return i?f.negate():f},O.createNaN=function(){return new O(r.NaN,r.NaN)},O.copy=function(t){return new O(t)},O.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n)),r=Math.pow(10,i);return 10*r<=e&&(i+=1),i},O.stringOfChar=function(t,e){for(var n=new P,i=0;i0){if(s<=0)return _.signum(o);i=r+s}else{if(!(r<0))return _.signum(o);if(s>=0)return _.signum(o);i=-r-s}var a=_.DP_SAFE_EPSILON*i;return o>=a||-o>=a?_.signum(o):2},_.signum=function(t){return t>0?1:t<0?-1:0},_.DP_SAFE_EPSILON=1e-15,e(A.prototype,{setOrdinate:function(t,e,n){},size:function(){},getOrdinate:function(t,e){},getCoordinate:function(){1===arguments.length?arguments[0]:2===arguments.length&&(arguments[0],arguments[1])},getCoordinateCopy:function(t){},getDimension:function(){},getX:function(t){},clone:function(){},expandEnvelope:function(t){},copy:function(){},getY:function(t){},toCoordinateArray:function(){},interfaces_:function(){return[o]},getClass:function(){return A}}),A.X=0,A.Y=1,A.Z=2,A.M=3,D.arraycopy=function(t,e,n,i,r){for(var s=0,o=e;o0},interfaces_:function(){return[k]},getClass:function(){return Y}}),e(X.prototype,{isInBoundary:function(t){return t>1},interfaces_:function(){return[k]},getClass:function(){return X}}),e(U.prototype,{isInBoundary:function(t){return 1===t},interfaces_:function(){return[k]},getClass:function(){return U}}),k.Mod2BoundaryNodeRule=V,k.EndPointBoundaryNodeRule=Y,k.MultiValentEndPointBoundaryNodeRule=X,k.MonoValentEndPointBoundaryNodeRule=U,k.MOD2_BOUNDARY_RULE=new V,k.ENDPOINT_BOUNDARY_RULE=new Y,k.MULTIVALENT_ENDPOINT_BOUNDARY_RULE=new X,k.MONOVALENT_ENDPOINT_BOUNDARY_RULE=new U,k.OGC_SFS_BOUNDARY_RULE=k.MOD2_BOUNDARY_RULE,e(H.prototype,{interfaces_:function(){return[]},getClass:function(){return H}}),H.isRing=function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))},H.ptNotInList=function(t,e){for(var n=0;n=t?e:[]},H.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e},H.extract=function(t,e,n){e=R.clamp(e,0,t.length),n=R.clamp(n,-1,t.length);var i=n-e+1;n<0&&(i=0),e>=t.length&&(i=0),ni.length)return 1;if(0===n.length)return 0;var r=H.compare(n,i),s=H.isEqualReversed(n,i);return s?0:r},OLDcompare:function(t,e){var n=t,i=e;if(n.lengthi.length)return 1;if(0===n.length)return 0;for(var r=H.increasingDirection(n),s=H.increasingDirection(i),o=r>0?0:n.length-1,a=s>0?0:n.length-1,u=0;u0))return e.value;e=e.right}}return null},rt.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:$s,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do if(n=r,i=t.compareTo(r.key),i<0)r=r.left;else{if(!(i>0)){var s=r.value;return r.value=e,s}r=r.right}while(null!==r);var o={key:t,left:null,right:null,value:e,parent:n,color:$s,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=o:n.right=o,this.fixAfterInsertion(o),this.size_++,null},rt.prototype.fixAfterInsertion=function(t){for(t.color=to;null!=t&&t!=this.root_&&t.parent.color==to;)if(tt(t)==nt(tt(tt(t)))){var e=it(tt(tt(t)));$(e)==to?(et(tt(t),$s),et(e,$s),et(tt(tt(t)),to),t=tt(tt(t))):(t==it(tt(t))&&(t=tt(t),this.rotateLeft(t)),et(tt(t),$s),et(tt(tt(t)),to),this.rotateRight(tt(tt(t))))}else{var e=nt(tt(tt(t)));$(e)==to?(et(tt(t),$s),et(e,$s),et(tt(tt(t)),to),t=tt(tt(t))):(t==nt(tt(t))&&(t=tt(t),this.rotateRight(t)),et(tt(t),$s),et(tt(tt(t)),to),this.rotateLeft(tt(tt(t))))}this.root_.color=$s},rt.prototype.values=function(){var t=new I,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=rt.successor(e));)t.add(e.value);return t},rt.prototype.entrySet=function(){var t=new Q,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=rt.successor(e));)t.add(e);return t},rt.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left==t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},rt.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right==t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},rt.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},rt.successor=function(t){if(null===t)return null; -if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var e=t.parent,n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e},rt.prototype.size=function(){return this.size_},e(st.prototype,{interfaces_:function(){return[]},getClass:function(){return st}}),ot.prototype=new K,at.prototype=new ot,at.prototype.contains=function(t){for(var e=0,n=this.array_.length;e=0;){var o=r.substring(0,s);i.add(o),r=r.substring(s+n),s=r.indexOf(e)}r.length>0&&i.add(r);for(var a=new Array(i.size()).fill(null),u=0;u0)for(var s=r;s0&&i.append(" ");for(var s=0;s0&&i.append(","),i.append(Nt.toString(t.getOrdinate(r,s)))}return i.append(")"),i.toString()}},Ct.ensureValidRing=function(t,e){var n=e.size();if(0===n)return e;if(n<=3)return Ct.createClosedRing(t,e,4);var i=e.getOrdinate(0,A.X)===e.getOrdinate(n-1,A.X)&&e.getOrdinate(0,A.Y)===e.getOrdinate(n-1,A.Y);return i?e:Ct.createClosedRing(t,e,n+1)},Ct.createClosedRing=function(t,e,n){var i=t.create(n,e.getDimension()),r=e.size();Ct.copy(e,0,i,0,r);for(var s=r;s0&&Ct.reverse(this.points),null}},getCoordinate:function(){return this.isEmpty()?null:this.points.getCoordinate(0)},getBoundaryDimension:function(){return this.isClosed()?lt.FALSE:0},isClosed:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},getEndPoint:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},getDimension:function(){return 1},getLength:function(){return he.computeLength(this.points)},getNumPoints:function(){return this.points.size()},reverse:function(){var t=this.points.copy();Ct.reverse(t);var e=this.getFactory().createLineString(t);return e},compareToSameClass:function(){if(1===arguments.length){for(var t=arguments[0],e=t,n=0,i=0;n= 2)");this.points=t},isCoordinate:function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)")},getGeometryType:function(){return"LinearRing"},copy:function(){return new Tt(this.points.copy(),this.factory)},interfaces_:function(){return[]},getClass:function(){return Tt}}),Tt.MINIMUM_VALID_SIZE=4,Tt.serialVersionUID=-0x3b229e262367a600,h(Mt,ft),e(Mt.prototype,{getSortIndex:function(){return B.SORTINDEX_MULTIPOLYGON},equalsExact:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&ft.prototype.equalsExact.call(this,t,e)}return ft.prototype.equalsExact.apply(this,arguments)},getBoundaryDimension:function(){return 1},getDimension:function(){return 2},reverse:function(){for(var t=this.geometries.length,e=new Array(t).fill(null),n=0;n0?e.createPoint(n[0]):e.createPoint():t},interfaces_:function(){return[_t]},getClass:function(){return Dt}}),e(Ft.prototype,{edit:function(t,e){return t instanceof Tt?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof wt?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof Lt?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},interfaces_:function(){return[_t]},getClass:function(){return Ft}}),Ot.NoOpGeometryOperation=At,Ot.CoordinateOperation=Dt,Ot.CoordinateSequenceOperation=Ft,e(Gt.prototype,{setOrdinate:function(t,e,n){switch(e){case A.X:this.coordinates[t].x=n;break;case A.Y:this.coordinates[t].y=n;break;case A.Z:this.coordinates[t].z=n;break;default:throw new i("invalid ordinateIndex")}},size:function(){return this.coordinates.length},getOrdinate:function(t,e){switch(e){case A.X:return this.coordinates[t].x;case A.Y:return this.coordinates[t].y;case A.Z:return this.coordinates[t].z}return r.NaN},getCoordinate:function(){if(1===arguments.length){var t=arguments[0];return this.coordinates[t]}if(2===arguments.length){var e=arguments[0],n=arguments[1];n.x=this.coordinates[e].x,n.y=this.coordinates[e].y,n.z=this.coordinates[e].z}},getCoordinateCopy:function(t){return new g(this.coordinates[t])},getDimension:function(){return this.dimension},getX:function(t){return this.coordinates[t].x},clone:function(){for(var t=new Array(this.size()).fill(null),e=0;e0){var t=new P(17*this.coordinates.length);t.append("("),t.append(this.coordinates[0]);for(var e=1;e3&&(i=3),i<2?new Gt(n):new Gt(n,i)}},interfaces_:function(){return[G,u]},getClass:function(){return qt}}),qt.instance=function(){return qt.instanceObject},qt.serialVersionUID=-0x38e49fa6cf6f2e00,qt.instanceObject=new qt;var no,io=Object.defineProperty,ro=zt({delete:Vt,has:Ut,get:Yt,set:Ht,keys:Wt,values:Jt,entries:Zt,forEach:$t,clear:jt}),so="undefined"!=typeof Map&&Map.prototype.values?Map:ro;te.prototype=new J,te.prototype.get=function(t){return this.map_.get(t)||null},te.prototype.put=function(t,e){return this.map_.set(t,e),e},te.prototype.values=function(){for(var t=new I,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},te.prototype.entrySet=function(){var t=new Q;return this.map_.entries().forEach(function(e){return t.add(e)}),t},te.prototype.size=function(){return this.map_.size()},e(ee.prototype,{equals:function(t){if(!(t instanceof ee))return!1;var e=t;return this.modelType===e.modelType&&this.scale===e.scale},compareTo:function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits(); -return new T(n).compareTo(new T(i))},getScale:function(){return this.scale},isFloating:function(){return this.modelType===ee.FLOATING||this.modelType===ee.FLOATING_SINGLE},getType:function(){return this.modelType},toString:function(){var t="UNKNOWN";return this.modelType===ee.FLOATING?t="Floating":this.modelType===ee.FLOATING_SINGLE?t="Floating-Single":this.modelType===ee.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},makePrecise:function(){if("number"==typeof arguments[0]){var t=arguments[0];if(r.isNaN(t))return t;if(this.modelType===ee.FLOATING_SINGLE){var e=t;return e}return this.modelType===ee.FIXED?Math.round(t*this.scale)/this.scale:t}if(arguments[0]instanceof g){var n=arguments[0];if(this.modelType===ee.FLOATING)return null;n.x=this.makePrecise(n.x),n.y=this.makePrecise(n.y)}},getMaximumSignificantDigits:function(){var t=16;return this.modelType===ee.FLOATING?t=16:this.modelType===ee.FLOATING_SINGLE?t=6:this.modelType===ee.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},setScale:function(t){this.scale=Math.abs(t)},interfaces_:function(){return[u,s]},getClass:function(){return ee}}),ee.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},e(ne.prototype,{readResolve:function(){return ne.nameToTypeMap.get(this.name)},toString:function(){return this.name},interfaces_:function(){return[u]},getClass:function(){return ne}}),ne.serialVersionUID=-552860263173159e4,ne.nameToTypeMap=new te,ee.Type=ne,ee.serialVersionUID=0x6bee6404e9a25c00,ee.FIXED=new ne("FIXED"),ee.FLOATING=new ne("FLOATING"),ee.FLOATING_SINGLE=new ne("FLOATING SINGLE"),ee.maximumPreciseValue=9007199254740992,e(ie.prototype,{toGeometry:function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new g(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new g(t.getMinX(),t.getMinY()),new g(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new g(t.getMinX(),t.getMinY()),new g(t.getMinX(),t.getMaxY()),new g(t.getMaxX(),t.getMaxY()),new g(t.getMaxX(),t.getMinY()),new g(t.getMinX(),t.getMinY())]),null)},createLineString:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLineString(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(b(arguments[0],A)){var e=arguments[0];return new wt(e,this)}}},createMultiLineString:function(){if(0===arguments.length)return new gt(null,this);if(1===arguments.length){var t=arguments[0];return new gt(t,this)}},buildGeometry:function(t){for(var e=null,n=!1,i=!1,r=t.iterator();r.hasNext();){var s=r.next(),o=s.getClass();null===e&&(e=o),o!==e&&(n=!0),s.isGeometryCollectionOrDerived()&&(i=!0)}if(null===e)return this.createGeometryCollection();if(n||i)return this.createGeometryCollection(ie.toGeometryArray(t));var a=t.iterator().next(),u=t.size()>1;if(u){if(a instanceof Rt)return this.createMultiPolygon(ie.toPolygonArray(t));if(a instanceof wt)return this.createMultiLineString(ie.toLineStringArray(t));if(a instanceof Lt)return this.createMultiPoint(ie.toPointArray(t));f.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},createMultiPointFromCoords:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},createPoint:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof g){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(b(arguments[0],A)){var e=arguments[0];return new Lt(e,this)}}},getCoordinateSequenceFactory:function(){return this.coordinateSequenceFactory},createPolygon:function(){if(0===arguments.length)return new Rt(null,null,this);if(1===arguments.length){if(b(arguments[0],A)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Tt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return new Rt(i,r,this)}},getSRID:function(){return this.SRID},createGeometryCollection:function(){if(0===arguments.length)return new ft(null,this);if(1===arguments.length){var t=arguments[0];return new ft(t,this)}},createGeometry:function(t){var e=new Ot(this);return e.edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return arguments[1],this.coordinateSequenceFactory.create(t)}}})},getPrecisionModel:function(){return this.precisionModel},createLinearRing:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(b(arguments[0],A)){var e=arguments[0];return new Tt(e,this)}}},createMultiPolygon:function(){if(0===arguments.length)return new Mt(null,this);if(1===arguments.length){var t=arguments[0];return new Mt(t,this)}},createMultiPoint:function(){if(0===arguments.length)return new Pt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return new Pt(t,this)}if(arguments[0]instanceof Array){var e=arguments[0];return this.createMultiPoint(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(b(arguments[0],A)){var n=arguments[0];if(null===n)return this.createMultiPoint(new Array(0).fill(null));for(var i=new Array(n.size()).fill(null),r=0;rn?(this.intLineIndex[t][0]=0,this.intLineIndex[t][1]=1):(this.intLineIndex[t][0]=1,this.intLineIndex[t][1]=0)}},isProper:function(){return this.hasIntersection()&&this._isProper},setPrecisionModel:function(t){this.precisionModel=t},isInteriorIntersection:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;er?i:r;else{var o=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);s=i>r?o:a,0!==s||t.equals(e)||(s=Math.max(o,a))}return f.isTrue(!(0===s&&!t.equals(e)),"Bad distance calculation"),s},oe.nonRobustComputeEdgeDistance=function(t,e,n){var i=t.x-e.x,r=t.y-e.y,s=Math.sqrt(i*i+r*r);return f.isTrue(!(0===s&&!t.equals(e)),"Invalid distance calculation"),s},oe.DONT_INTERSECT=0,oe.DO_INTERSECT=1,oe.COLLINEAR=2,oe.NO_INTERSECTION=0,oe.POINT_INTERSECTION=1,oe.COLLINEAR_INTERSECTION=2,h(ae,oe),e(ae.prototype,{isInSegmentEnvelopes:function(t){var e=new C(this.inputLines[0][0],this.inputLines[0][1]),n=new C(this.inputLines[1][0],this.inputLines[1][1]);return e.contains(t)&&n.contains(t)},computeIntersection:function(){if(3!==arguments.length)return oe.prototype.computeIntersection.apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];return this._isProper=!1,C.intersects(e,n,t)&&0===he.orientationIndex(e,n,t)&&0===he.orientationIndex(n,e,t)?(this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this.result=oe.POINT_INTERSECTION,null):void(this.result=oe.NO_INTERSECTION)},normalizeToMinimum:function(t,e,n,i,r){r.x=this.smallestInAbsValue(t.x,e.x,n.x,i.x),r.y=this.smallestInAbsValue(t.y,e.y,n.y,i.y),t.x-=r.x,t.y-=r.y,e.x-=r.x,e.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},safeHCoordinateIntersection:function(t,e,n,i){var r=null;try{r=F.intersection(t,e,n,i)}catch(s){if(!(s instanceof S))throw s;r=ae.nearestEndpoint(t,e,n,i)}finally{}return r},intersection:function(t,e,n,i){var r=this.intersectionWithNormalization(t,e,n,i);return this.isInSegmentEnvelopes(r)||(r=new g(ae.nearestEndpoint(t,e,n,i))),null!==this.precisionModel&&this.precisionModel.makePrecise(r),r},smallestInAbsValue:function(t,e,n,i){var r=t,s=Math.abs(r);return Math.abs(e)1e-4&&D.out.println("Distance = "+r.distance(s))},intersectionWithNormalization:function(t,e,n,i){var r=new g(t),s=new g(e),o=new g(n),a=new g(i),u=new g;this.normalizeToEnvCentre(r,s,o,a,u);var l=this.safeHCoordinateIntersection(r,s,o,a);return l.x+=u.x,l.y+=u.y,l},computeCollinearIntersection:function(t,e,n,i){var r=C.intersects(t,e,n),s=C.intersects(t,e,i),o=C.intersects(n,i,t),a=C.intersects(n,i,e);return r&&s?(this.intPt[0]=n,this.intPt[1]=i,oe.COLLINEAR_INTERSECTION):o&&a?(this.intPt[0]=t,this.intPt[1]=e,oe.COLLINEAR_INTERSECTION):r&&o?(this.intPt[0]=n,this.intPt[1]=t,!n.equals(t)||s||a?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):r&&a?(this.intPt[0]=n,this.intPt[1]=e,!n.equals(e)||s||o?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):s&&o?(this.intPt[0]=i,this.intPt[1]=t,!i.equals(t)||r||a?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):s&&a?(this.intPt[0]=i,this.intPt[1]=e,!i.equals(e)||r||o?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):oe.NO_INTERSECTION},normalizeToEnvCentre:function(t,e,n,i,r){var s=t.xe.x?t.x:e.x,u=t.y>e.y?t.y:e.y,l=n.xi.x?n.x:i.x,f=n.y>i.y?n.y:i.y,g=s>l?s:l,d=ah?o:h,v=u0&&s>0||r<0&&s<0)return oe.NO_INTERSECTION;var o=he.orientationIndex(n,i,t),a=he.orientationIndex(n,i,e);if(o>0&&a>0||o<0&&a<0)return oe.NO_INTERSECTION;var u=0===r&&0===s&&0===o&&0===a;return u?this.computeCollinearIntersection(t,e,n,i):(0===r||0===s||0===o||0===a?(this._isProper=!1,t.equals2D(n)||t.equals2D(i)?this.intPt[0]=t:e.equals2D(n)||e.equals2D(i)?this.intPt[0]=e:0===r?this.intPt[0]=new g(n):0===s?this.intPt[0]=new g(i):0===o?this.intPt[0]=new g(t):0===a&&(this.intPt[0]=new g(e))):(this._isProper=!0,this.intPt[0]=this.intersection(t,e,n,i)),oe.POINT_INTERSECTION)},interfaces_:function(){return[]},getClass:function(){return ae}}),ae.nearestEndpoint=function(t,e,n,i){var r=t,s=he.distancePointLine(t,n,i),o=he.distancePointLine(e,n,i);return o0?n>0?-r:r:n>0?r:-r;if(0===e||0===n)return i>0?t>0?r:-r:t>0?-r:r;if(0=i?(t=-t,e=-e,n=-n,i=-i):(r=-r,s=-t,t=-n,n=s,s=-e,e=-i,i=s),0=n))return-r;r=-r,t=-t,n=-n}for(;;){if(a+=1,o=Math.floor(n/t),n-=o*t,i-=o*e,i<0)return-r;if(i>e)return r;if(t>n+n){if(ei+i)return-r;n=t-n,i=e-i,r=-r}if(0===i)return 0===n?0:-r;if(0===n)return r;if(o=Math.floor(t/n),t-=o*n,e-=o*i,e<0)return r;if(e>i)return-r;if(n>t+t){if(ie+e)return r;t=n-t,e=i-e,r=-r}if(0===e)return 0===t?0:r;if(0===t)return-r}},e(le.prototype,{countSegment:function(t,e){if(t.xi&&(n=e.x,i=t.x),this.p.x>=n&&this.p.x<=i&&(this.isPointOnSegment=!0),null}if(t.y>this.p.y&&e.y<=this.p.y||e.y>this.p.y&&t.y<=this.p.y){var r=t.x-this.p.x,s=t.y-this.p.y,o=e.x-this.p.x,a=e.y-this.p.y,u=ue.signOfDet2x2(r,s,o,a);if(0===u)return this.isPointOnSegment=!0,null;a0&&this.crossingCount++}},isPointInPolygon:function(){return this.getLocation()!==L.EXTERIOR},getLocation:function(){return this.isPointOnSegment?L.BOUNDARY:this.crossingCount%2===1?L.INTERIOR:L.EXTERIOR},isOnSegment:function(){return this.isPointOnSegment},interfaces_:function(){return[]},getClass:function(){return le}}),le.locatePointInRing=function(){if(arguments[0]instanceof g&&b(arguments[1],A)){for(var t=arguments[0],e=arguments[1],n=new le(t),i=new g,r=new g,s=1;s1||u<0||u>1)&&(r=!0)}}else r=!0;return r?R.min(he.distancePointLine(t,n,i),he.distancePointLine(e,n,i),he.distancePointLine(n,t,e),he.distancePointLine(i,t,e)):0},he.isPointInRing=function(t,e){return he.locatePointInRing(t,e)!==L.EXTERIOR},he.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new g;t.getCoordinate(0,i);for(var r=i.x,s=i.y,o=1;on.y&&(n=o,r=s)}var a=r;do a-=1,a<0&&(a=e);while(t[a].equals2D(n)&&a!==r);var u=r;do u=(u+1)%e;while(t[u].equals2D(n)&&u!==r);var l=t[a],h=t[u];if(l.equals2D(n)||h.equals2D(n)||l.equals2D(h))return!1;var c=he.computeOrientation(l,n,h),f=!1;return f=0===c?l.x>h.x:c>0},he.locatePointInRing=function(t,e){return le.locatePointInRing(t,e)},he.distancePointLinePerpendicular=function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)},he.computeOrientation=function(t,e,n){return he.orientationIndex(t,e,n)},he.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new i("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r=1)return o.distance(u);var c=((a.y-o.y)*(u.x-a.x)-(a.x-o.x)*(u.y-a.y))/l;return Math.abs(c)*Math.sqrt(l)}},he.isOnLine=function(t,e){for(var n=new ae,i=1;i=0&&n>=0?Math.max(e,n):e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof g){var i=arguments[0];return he.orientationIndex(this.p0,this.p1,i)}},toGeometry:function(t){return t.createLineString([this.p0,this.p1])},isVertical:function(){return this.p0.x===this.p1.x},equals:function(t){if(!(t instanceof ce))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},intersection:function(t){var e=new ae;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},project:function(){if(arguments[0]instanceof g){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new g(t);var e=this.projectionFactor(t),n=new g;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof ce){var i=arguments[0],r=this.projectionFactor(i.p0),s=this.projectionFactor(i.p1);if(r>=1&&s>=1)return null;if(r<=0&&s<=0)return null;var o=this.project(i.p0);r<0&&(o=this.p0),r>1&&(o=this.p1);var a=this.project(i.p1);return s<0&&(a=this.p0),s>1&&(a=this.p1),new ce(o,a)}},normalize:function(){this.p1.compareTo(this.p0)<0&&this.reverse()},angle:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},getCoordinate:function(t){return 0===t?this.p0:this.p1},distancePerpendicular:function(t){return he.distancePointLinePerpendicular(t,this.p0,this.p1)},minY:function(){return Math.min(this.p0.y,this.p1.y)},midPoint:function(){return ce.midPoint(this.p0,this.p1)},projectionFactor:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;if(i<=0)return r.NaN;var s=((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i;return s},closestPoints:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=r.MAX_VALUE,s=null,o=this.closestPoint(t.p0);i=o.distance(t.p0),n[0]=o,n[1]=t.p0;var a=this.closestPoint(t.p1);s=a.distance(t.p1),s0&&e<1)return this.project(t);var n=this.p0.distance(t),i=this.p1.distance(t);return n1||r.isNaN(e))&&(e=1),e},toString:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},isHorizontal:function(){return this.p0.y===this.p1.y},distance:function(){if(arguments[0]instanceof ce){var t=arguments[0];return he.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof g){var e=arguments[0];return he.distancePointLine(e,this.p0,this.p1)}},pointAlong:function(t){var e=new g;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},hashCode:function(){var t=java.lang.Double.doubleToLongBits(this.p0.x);t^=31*java.lang.Double.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=java.lang.Double.doubleToLongBits(this.p1.x);n^=31*java.lang.Double.doubleToLongBits(this.p1.y);var i=Math.trunc(n)^Math.trunc(n>>32);return e^i},interfaces_:function(){return[s,u]},getClass:function(){return ce}}),ce.midPoint=function(t,e){return new g((t.x+e.x)/2,(t.y+e.y)/2)},ce.serialVersionUID=0x2d2172135f411c00,e(fe.prototype,{isIntersects:function(){return!this.isDisjoint()},isCovers:function(){var t=fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])||fe.isTrue(this.matrix[L.INTERIOR][L.BOUNDARY])||fe.isTrue(this.matrix[L.BOUNDARY][L.INTERIOR])||fe.isTrue(this.matrix[L.BOUNDARY][L.BOUNDARY]);return t&&this.matrix[L.EXTERIOR][L.INTERIOR]===lt.FALSE&&this.matrix[L.EXTERIOR][L.BOUNDARY]===lt.FALSE},isCoveredBy:function(){var t=fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])||fe.isTrue(this.matrix[L.INTERIOR][L.BOUNDARY])||fe.isTrue(this.matrix[L.BOUNDARY][L.INTERIOR])||fe.isTrue(this.matrix[L.BOUNDARY][L.BOUNDARY]);return t&&this.matrix[L.INTERIOR][L.EXTERIOR]===lt.FALSE&&this.matrix[L.BOUNDARY][L.EXTERIOR]===lt.FALSE},set:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e=0&&e>=0&&this.setAtLeast(t,e,n)},isWithin:function(){return fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])&&this.matrix[L.INTERIOR][L.EXTERIOR]===lt.FALSE&&this.matrix[L.BOUNDARY][L.EXTERIOR]===lt.FALSE},isTouches:function(t,e){return t>e?this.isTouches(e,t):(t===lt.A&&e===lt.A||t===lt.L&&e===lt.L||t===lt.L&&e===lt.A||t===lt.P&&e===lt.A||t===lt.P&&e===lt.L)&&this.matrix[L.INTERIOR][L.INTERIOR]===lt.FALSE&&(fe.isTrue(this.matrix[L.INTERIOR][L.BOUNDARY])||fe.isTrue(this.matrix[L.BOUNDARY][L.INTERIOR])||fe.isTrue(this.matrix[L.BOUNDARY][L.BOUNDARY]))},isOverlaps:function(t,e){return t===lt.P&&e===lt.P||t===lt.A&&e===lt.A?fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])&&fe.isTrue(this.matrix[L.INTERIOR][L.EXTERIOR])&&fe.isTrue(this.matrix[L.EXTERIOR][L.INTERIOR]):t===lt.L&&e===lt.L&&1===this.matrix[L.INTERIOR][L.INTERIOR]&&fe.isTrue(this.matrix[L.INTERIOR][L.EXTERIOR])&&fe.isTrue(this.matrix[L.EXTERIOR][L.INTERIOR])},isEquals:function(t,e){return t===e&&fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])&&this.matrix[L.INTERIOR][L.EXTERIOR]===lt.FALSE&&this.matrix[L.BOUNDARY][L.EXTERIOR]===lt.FALSE&&this.matrix[L.EXTERIOR][L.INTERIOR]===lt.FALSE&&this.matrix[L.EXTERIOR][L.BOUNDARY]===lt.FALSE},toString:function(){for(var t=new P("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,lt.toDimensionSymbol(this.matrix[e][n]));return t.toString()},setAll:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.matrix[e][n]=t},get:function(t,e){return this.matrix[t][e]},transpose:function(){var t=this.matrix[1][0];return this.matrix[1][0]=this.matrix[0][1],this.matrix[0][1]=t,t=this.matrix[2][0],this.matrix[2][0]=this.matrix[0][2],this.matrix[0][2]=t,t=this.matrix[2][1],this.matrix[2][1]=this.matrix[1][2],this.matrix[1][2]=t,this},matches:function(t){if(9!==t.length)throw new i("Should be length 9: "+t);for(var e=0;e<3;e++)for(var n=0;n<3;n++)if(!fe.matches(this.matrix[e][n],t.charAt(3*e+n)))return!1;return!0},add:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))},isDisjoint:function(){return this.matrix[L.INTERIOR][L.INTERIOR]===lt.FALSE&&this.matrix[L.INTERIOR][L.BOUNDARY]===lt.FALSE&&this.matrix[L.BOUNDARY][L.INTERIOR]===lt.FALSE&&this.matrix[L.BOUNDARY][L.BOUNDARY]===lt.FALSE; -},isCrosses:function(t,e){return t===lt.P&&e===lt.L||t===lt.P&&e===lt.A||t===lt.L&&e===lt.A?fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])&&fe.isTrue(this.matrix[L.INTERIOR][L.EXTERIOR]):t===lt.L&&e===lt.P||t===lt.A&&e===lt.P||t===lt.A&&e===lt.L?fe.isTrue(this.matrix[L.INTERIOR][L.INTERIOR])&&fe.isTrue(this.matrix[L.EXTERIOR][L.INTERIOR]):t===lt.L&&e===lt.L&&0===this.matrix[L.INTERIOR][L.INTERIOR]},interfaces_:function(){return[o]},getClass:function(){return fe}}),fe.matches=function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],e=arguments[1];return e===lt.SYM_DONTCARE||e===lt.SYM_TRUE&&(t>=0||t===lt.TRUE)||e===lt.SYM_FALSE&&t===lt.FALSE||e===lt.SYM_P&&t===lt.P||e===lt.SYM_L&&t===lt.L||e===lt.SYM_A&&t===lt.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var n=arguments[0],i=arguments[1],r=new fe(n);return r.matches(i)}},fe.isTrue=function(t){return t>=0||t===lt.TRUE};var lo=Object.freeze({Coordinate:g,CoordinateList:N,Envelope:C,LineSegment:ce,GeometryFactory:ie,Geometry:B,Point:Lt,LineString:wt,LinearRing:Tt,Polygon:Rt,GeometryCollection:ft,MultiPoint:Pt,MultiLineString:gt,MultiPolygon:Mt,Dimension:lt,IntersectionMatrix:fe,PrecisionModel:ee});e(ge.prototype,{addPoint:function(t){this.ptCount+=1,this.ptCentSum.x+=t.x,this.ptCentSum.y+=t.y},setBasePoint:function(t){null===this.areaBasePt&&(this.areaBasePt=t)},addLineSegments:function(t){for(var e=0,n=0;n0&&this.addPoint(t[0])},addHole:function(t){for(var e=he.isCCW(t),n=0;n0)t.x=this.cg3.x/3/this.areasum2,t.y=this.cg3.y/3/this.areasum2;else if(this.totalLength>0)t.x=this.lineCentSum.x/this.totalLength,t.y=this.lineCentSum.y/this.totalLength;else{if(!(this.ptCount>0))return null;t.x=this.ptCentSum.x/this.ptCount,t.y=this.ptCentSum.y/this.ptCount}return t},addShell:function(t){t.length>0&&this.setBasePoint(t[0]);for(var e=!he.isCCW(t),n=0;n=this.size())throw new IndexOutOfBoundsException;return this.array_[t]},pe.prototype.push=function(t){return this.array_.push(t),t},pe.prototype.pop=function(t){if(0===this.array_.length)throw new de;return this.array_.pop()},pe.prototype.peek=function(){if(0===this.array_.length)throw new de;return this.array_[this.array_.length-1]},pe.prototype.empty=function(){return 0===this.array_.length},pe.prototype.isEmpty=function(){return this.empty()},pe.prototype.search=function(t){return this.array_.indexOf(t)},pe.prototype.size=function(){return this.array_.length},pe.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e50&&(t=this.reduce(this.inputPts));var e=this.preSort(t),n=this.grahamScan(e),i=this.toCoordinateArray(n);return this.lineOrPolygon(i)},padArray3:function(t){for(var e=new Array(3).fill(null),n=0;ne[2].y&&(e[2]=t[i]),t[i].x+t[i].y>e[3].x+e[3].y&&(e[3]=t[i]),t[i].x>e[4].x&&(e[4]=t[i]),t[i].x-t[i].y>e[5].x-e[5].y&&(e[5]=t[i]),t[i].y0;)e=n.pop();e=n.push(e),e=n.push(t[i])}return e=n.push(t[0]),n},interfaces_:function(){return[]},getClass:function(){return me}}),me.extractCoordinates=function(t){var e=new ve;return t.apply(e),e.getCoordinates()},e(ye.prototype,{compare:function(t,e){var n=t,i=e;return ye.polarCompare(this.origin,n,i)},interfaces_:function(){return[a]},getClass:function(){return ye}}),ye.polarCompare=function(t,e,n){var i=e.x-t.x,r=e.y-t.y,s=n.x-t.x,o=n.y-t.y,a=he.computeOrientation(t,e,n);if(a===he.COUNTERCLOCKWISE)return 1;if(a===he.CLOCKWISE)return-1;var u=i*i+r*r,l=s*s+o*o;return ul?1:0},me.RadialComparator=ye,e(xe.prototype,{transformPoint:function(t,e){return this.factory.createPoint(this.transformCoordinates(t.getCoordinateSequence(),t))},transformPolygon:function(t,e){var n=!0,i=this.transformLinearRing(t.getExteriorRing(),t);null!==i&&i instanceof Tt&&!i.isEmpty()||(n=!1);for(var r=new I,s=0;s0&&i<4&&!this.preserveType?this.factory.createLineString(n):this.factory.createLinearRing(n)},interfaces_:function(){return[]},getClass:function(){return xe}}),e(Ee.prototype,{snapVertices:function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),i=0;i=0&&t.add(s+1,new g(r),!1)}},findSegmentIndexToSnap:function(t,e){for(var n=r.MAX_VALUE,i=-1,s=0;se&&(e=i)}return e}if(2===arguments.length){var r=arguments[0],s=arguments[1];return Math.min(Ie.computeOverlaySnapTolerance(r),Ie.computeOverlaySnapTolerance(s))}},Ie.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal(),n=Math.min(e.getHeight(),e.getWidth()),i=n*Ie.SNAP_PRECISION_FACTOR;return i},Ie.snapToSelf=function(t,e,n){var i=new Ie(t);return i.snapToSelf(e,n)},Ie.SNAP_PRECISION_FACTOR=1e-9,h(Ne,xe),e(Ne.prototype,{snapLine:function(t,e){var n=new Ee(t,this.snapTolerance);return n.setAllowSnappingToSourceVertices(this.isSelfSnap),n.snapTo(e)},transformCoordinates:function(t,e){var n=t.toCoordinateArray(),i=this.snapLine(n,this.snapPts);return this.factory.getCoordinateSequenceFactory().create(i)},interfaces_:function(){return[]},getClass:function(){return Ne}}),e(Ce.prototype,{getCommon:function(){return r.longBitsToDouble(this.commonBits)},add:function(t){var e=r.doubleToLongBits(t);if(this.isFirst)return this.commonBits=e,this.commonSignExp=Ce.signExpBits(this.commonBits),this.isFirst=!1,null;var n=Ce.signExpBits(e);return n!==this.commonSignExp?(this.commonBits=0,null):(this.commonMantissaBitsCount=Ce.numCommonMostSigMantissaBits(this.commonBits,e),void(this.commonBits=Ce.zeroLowerBits(this.commonBits,64-(12+this.commonMantissaBitsCount))))},toString:function(){if(1===arguments.length){var t=arguments[0],e=r.longBitsToDouble(t),n=Long.toBinaryString(t),i="0000000000000000000000000000000000000000000000000000000000000000"+n,s=i.substring(i.length-64),o=s.substring(0,1)+" "+s.substring(1,12)+"(exp) "+s.substring(12)+" [ "+e+" ]";return o}},interfaces_:function(){return[]},getClass:function(){return Ce}}),Ce.getBit=function(t,e){var n=1<>52},Ce.zeroLowerBits=function(t,e){var n=(1<=0;i--){if(Ce.getBit(t,i)!==Ce.getBit(e,i))return n;n++}return 52},e(we.prototype,{addCommonBits:function(t){var e=new Le(this.commonCoord);t.apply(e),t.geometryChanged()},removeCommonBits:function(t){if(0===this.commonCoord.x&&0===this.commonCoord.y)return t;var e=new g(this.commonCoord);e.x=-e.x,e.y=-e.y;var n=new Le(e);return t.apply(n),t.geometryChanged(),t},getCommonCoordinate:function(){return this.commonCoord},add:function(t){t.apply(this.ccFilter),this.commonCoord=this.ccFilter.getCommonCoordinate()},interfaces_:function(){return[]},getClass:function(){return we}}),e(Se.prototype,{filter:function(t){this.commonBitsX.add(t.x),this.commonBitsY.add(t.y)},getCommonCoordinate:function(){return new g(this.commonBitsX.getCommon(),this.commonBitsY.getCommon())},interfaces_:function(){return[z]},getClass:function(){return Se}}),e(Le.prototype,{filter:function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,i=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,i)},isDone:function(){return!1},isGeometryChanged:function(){return!0},interfaces_:function(){return[ct]},getClass:function(){return Le}}),we.CommonCoordinateFilter=Se,we.Translater=Le,e(be.prototype,{next:function(){if(this.atStart)return this.atStart=!1,be.isAtomic(this.parent)&&this.index++,this.parent;if(null!==this.subcollectionIterator){if(this.subcollectionIterator.hasNext())return this.subcollectionIterator.next();this.subcollectionIterator=null}if(this.index>=this.max)throw new x;var t=this.parent.getGeometryN(this.index++);return t instanceof ft?(this.subcollectionIterator=new be(t),this.subcollectionIterator.next()):t},remove:function(){throw new UnsupportedOperationException(this.getClass().getName())},hasNext:function(){if(this.atStart)return!0;if(null!==this.subcollectionIterator){if(this.subcollectionIterator.hasNext())return!0;this.subcollectionIterator=null}return!(this.index>=this.max)},interfaces_:function(){return[p]},getClass:function(){return be}}),be.isAtomic=function(t){return!(t instanceof ft)},e(Re.prototype,{locateInternal:function(){if(arguments[0]instanceof g&&arguments[1]instanceof Rt){var t=arguments[0],e=arguments[1];if(e.isEmpty())return L.EXTERIOR;var n=e.getExteriorRing(),i=this.locateInPolygonRing(t,n);if(i===L.EXTERIOR)return L.EXTERIOR;if(i===L.BOUNDARY)return L.BOUNDARY;for(var r=0;r0||this.isIn?L.INTERIOR:L.EXTERIOR)},interfaces_:function(){return[]},getClass:function(){return Re}}),e(Pe.prototype,{interfaces_:function(){return[]},getClass:function(){return Pe}}),Pe.octant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new i("Cannot compute the octant for point ( "+t+", "+e+" )");var n=Math.abs(t),r=Math.abs(e);return t>=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof g&&arguments[1]instanceof g){var s=arguments[0],o=arguments[1],a=o.x-s.x,u=o.y-s.y;if(0===a&&0===u)throw new i("Cannot compute the octant for two identical points "+s);return Pe.octant(a,u)}},e(Te.prototype,{getCoordinates:function(){},size:function(){},getCoordinate:function(t){},isClosed:function(){},setData:function(t){},getData:function(){},interfaces_:function(){return[]},getClass:function(){return Te}}),e(Me.prototype,{getCoordinates:function(){return this.pts},size:function(){return this.pts.length},getCoordinate:function(t){return this.pts[t]},isClosed:function(){return this.pts[0].equals(this.pts[this.pts.length-1])},getSegmentOctant:function(t){return t===this.pts.length-1?-1:Pe.octant(this.getCoordinate(t),this.getCoordinate(t+1))},setData:function(t){this.data=t},getData:function(){return this.data},toString:function(){return se.toLineString(new Gt(this.pts))},interfaces_:function(){return[Te]},getClass:function(){return Me}}),e(Oe.prototype,{getBounds:function(){},interfaces_:function(){return[]},getClass:function(){return Oe}}),e(_e.prototype,{getItem:function(){return this.item},getBounds:function(){return this.bounds},interfaces_:function(){return[Oe,u]},getClass:function(){return _e}}),e(Ae.prototype,{poll:function(){if(this.isEmpty())return null;var t=this.items.get(1);return this.items.set(1,this.items.get(this._size)),this._size-=1,this.reorder(1),t},size:function(){return this._size},reorder:function(t){for(var e=null,n=this.items.get(t);2*t<=this._size&&(e=2*t,e!==this._size&&this.items.get(e+1).compareTo(this.items.get(e))<0&&e++,this.items.get(e).compareTo(n)<0);t=e)this.items.set(t,this.items.get(e));this.items.set(t,n)},clear:function(){this._size=0,this.items.clear()},isEmpty:function(){return 0===this._size},add:function(t){this.items.add(null),this._size+=1;var e=this._size;for(this.items.set(0,t);t.compareTo(this.items.get(Math.trunc(e/2)))<0;e/=2)this.items.set(e,this.items.get(Math.trunc(e/2)));this.items.set(e,t)},interfaces_:function(){return[]},getClass:function(){return Ae}}),e(De.prototype,{visitItem:function(t){},interfaces_:function(){return[]},getClass:function(){return De}}),e(Fe.prototype,{insert:function(t,e){},remove:function(t,e){},query:function(){1===arguments.length?arguments[0]:2===arguments.length&&(arguments[0],arguments[1])},interfaces_:function(){return[]},getClass:function(){return Fe}}),e(Ge.prototype,{getLevel:function(){return this.level},size:function(){return this.childBoundables.size()},getChildBoundables:function(){return this.childBoundables},addChildBoundable:function(t){f.isTrue(null===this.bounds),this.childBoundables.add(t)},isEmpty:function(){return this.childBoundables.isEmpty()},getBounds:function(){return null===this.bounds&&(this.bounds=this.computeBounds()),this.bounds},interfaces_:function(){return[Oe,u]},getClass:function(){return Ge}}),Ge.serialVersionUID=0x5a1e55ec41369800;var ho={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return ho.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?ut.sort(n,e):ut.sort(n);for(var i=t.iterator(),r=0,s=n.length;rqe.area(this.boundable2)?(this.expand(this.boundable1,this.boundable2,t,e),null):(this.expand(this.boundable2,this.boundable1,t,e),null);if(n)return this.expand(this.boundable1,this.boundable2,t,e),null;if(r)return this.expand(this.boundable2,this.boundable1,t,e),null;throw new i("neither boundable is composite")},isLeaves:function(){return!(qe.isComposite(this.boundable1)||qe.isComposite(this.boundable2))},compareTo:function(t){var e=t;return this._distancee._distance?1:0},expand:function(t,e,n,i){for(var r=t.getChildBoundables(),s=r.iterator();s.hasNext();){var o=s.next(),a=new qe(o,e,this.itemDistance);a.getDistance()-2),i.getLevel()===n)return r.add(i),null;for(var s=i.getChildBoundables().iterator();s.hasNext();){var o=s.next();o instanceof Ge?this.boundablesAtLevel(n,o,r):(f.isTrue(o instanceof _e),n===-1&&r.add(o))}return null}},query:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new I;return this.isEmpty()?e:(this.getIntersectsOp().intersects(this.root.getBounds(),t)&&this.query(t,this.root,e),e)}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this.root.getBounds(),n)&&this.query(n,this.root,i)}else if(3===arguments.length)if(b(arguments[2],De)&&arguments[0]instanceof Object&&arguments[1]instanceof Ge)for(var r=arguments[0],s=arguments[1],o=arguments[2],a=s.getChildBoundables(),u=0;ue&&(e=r)}}return e+1}},createParentBoundables:function(t,e){f.isTrue(!t.isEmpty());var n=new I;n.add(this.createNode(e));var i=new I(t);ho.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var s=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(s)}return n},isEmpty:function(){return this.built?this.root.isEmpty():this.itemBoundables.isEmpty()},interfaces_:function(){return[u]},getClass:function(){return Be}}),Be.compareDoubles=function(t,e){return t>e?1:t0);for(var n=new I,i=0;i0;){var c=h.poll(),f=c.getDistance();if(f>=u)break;c.isLeaves()?(u=f,l=c):c.expandToQueue(h,u)}return[l.getBoundable(0).getItem(),l.getBoundable(1).getItem()]}}else if(3===arguments.length){var g=arguments[0],d=arguments[1],p=arguments[2],v=new _e(g,d),e=new qe(this.getRoot(),v,p);return this.nearestNeighbour(e)[0]}},interfaces_:function(){return[Fe,u]},getClass:function(){return Ve}}),Ve.centreX=function(t){return Ve.avg(t.getMinX(),t.getMaxX())},Ve.avg=function(t,e){return(t+e)/2},Ve.centreY=function(t){return Ve.avg(t.getMinY(),t.getMaxY())},h(Ye,Ge),e(Ye.prototype,{computeBounds:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){ -var n=e.next();null===t?t=new C(n.getBounds()):t.expandToInclude(n.getBounds())}return t},interfaces_:function(){return[]},getClass:function(){return Ye}}),Ve.STRtreeNode=Ye,Ve.serialVersionUID=0x39920f7d5f261e0,Ve.xComparator={interfaces_:function(){return[a]},compare:function(t,e){return Be.compareDoubles(Ve.centreX(t.getBounds()),Ve.centreX(e.getBounds()))}},Ve.yComparator={interfaces_:function(){return[a]},compare:function(t,e){return Be.compareDoubles(Ve.centreY(t.getBounds()),Ve.centreY(e.getBounds()))}},Ve.intersectsOp={interfaces_:function(){return[IntersectsOp]},intersects:function(t,e){return t.intersects(e)}},Ve.DEFAULT_NODE_CAPACITY=10,e(Xe.prototype,{interfaces_:function(){return[]},getClass:function(){return Xe}}),Xe.relativeSign=function(t,e){return te?1:0},Xe.compare=function(t,e,n){if(e.equals2D(n))return 0;var i=Xe.relativeSign(e.x,n.x),r=Xe.relativeSign(e.y,n.y);switch(t){case 0:return Xe.compareValue(i,r);case 1:return Xe.compareValue(r,i);case 2:return Xe.compareValue(r,-i);case 3:return Xe.compareValue(-i,r);case 4:return Xe.compareValue(-i,-r);case 5:return Xe.compareValue(-r,-i);case 6:return Xe.compareValue(-r,i);case 7:return Xe.compareValue(i,-r)}return f.shouldNeverReachHere("invalid octant value"),0},Xe.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0},e(Ue.prototype,{getCoordinate:function(){return this.coord},print:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},compareTo:function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:Xe.compare(this.segmentOctant,this.coord,e.coord)},isEndPoint:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},isInterior:function(){return this._isInterior},interfaces_:function(){return[s]},getClass:function(){return Ue}}),e(He.prototype,{getSplitCoordinates:function(){var t=new N;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()},addCollapsedNodes:function(){var t=new I;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this.edge.getCoordinate(n),n)}},print:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){var n=e.next();n.print(t)}},findCollapsesFromExistingVertices:function(t){for(var e=0;ethis.currNode.segmentIndex,null)},remove:function(){throw new UnsupportedOperationException(this.getClass().getName())},hasNext:function(){return null!==this.nextNode},readNextNode:function(){this.nodeIt.hasNext()?this.nextNode=this.nodeIt.next():this.nextNode=null},interfaces_:function(){return[p]},getClass:function(){return je}}),e(We.prototype,{addIntersection:function(t,e){},interfaces_:function(){return[Te]},getClass:function(){return We}}),e(Je.prototype,{getCoordinates:function(){return this.pts},size:function(){return this.pts.length},getCoordinate:function(t){return this.pts[t]},isClosed:function(){return this.pts[0].equals(this.pts[this.pts.length-1])},getSegmentOctant:function(t){return t===this.pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},setData:function(t){this.data=t},safeOctant:function(t,e){return t.equals2D(e)?0:Pe.octant(t,e)},getData:function(){return this.data},addIntersection:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=(arguments[2],arguments[3]),s=new g(n.getIntersection(r));this.addIntersection(s,i)}},toString:function(){return se.toLineString(new Gt(this.pts))},getNodeList:function(){return this.nodeList},addIntersectionNode:function(t,e){var n=e,i=n+1;if(ie?t:e;return 0===i&&3===r?3:i},Qe.isInHalfPlane=function(t,e){return e===Qe.SE?t===Qe.SE||t===Qe.SW:t===e||t===e+1},Qe.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new i("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?Qe.NE:Qe.SE:e>=0?Qe.NW:Qe.SW}if(arguments[0]instanceof g&&arguments[1]instanceof g){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new i("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?Qe.NE:Qe.SE:r.y>=n.y?Qe.NW:Qe.SW}},Qe.NE=0,Qe.NW=1,Qe.SW=2,Qe.SE=3,e($e.prototype,{interfaces_:function(){return[]},getClass:function(){return $e}}),$e.getChainStartIndices=function(t){var e=0,n=new I;n.add(new T(e));do{var i=$e.findChainEnd(t,e);n.add(new T(i)),e=i}while(e=t.length-1)return t.length-1;for(var i=Qe.quadrant(t[n],t[n+1]),r=e+1;rn.getId()&&(n.computeOverlaps(s,t),this.nOverlaps++),this.segInt.isDone())return null}},interfaces_:function(){return[]},getClass:function(){return nn}}),h(rn,Ze),e(rn.prototype,{overlap:function(){if(4!==arguments.length)return Ze.prototype.overlap.apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3],r=t.getContext(),s=n.getContext();this.si.processIntersections(r,e,s,i)},interfaces_:function(){return[]},getClass:function(){return rn}}),nn.SegmentOverlapAction=rn,h(sn,l),e(sn.prototype,{getCoordinate:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return sn}}),sn.msgWithCoord=function(t,e){return null!==e?t+" [ "+e+" ]":t},e(on.prototype,{processIntersections:function(t,e,n,i){},isDone:function(){},interfaces_:function(){return[]},getClass:function(){return on}}),e(an.prototype,{getInteriorIntersection:function(){return this.interiorIntersection},setCheckEndSegmentsOnly:function(t){this.isCheckEndSegmentsOnly=t},getIntersectionSegments:function(){return this.intSegments},count:function(){return this.intersectionCount},getIntersections:function(){return this.intersections},setFindAllIntersections:function(t){this.findAllIntersections=t},setKeepIntersections:function(t){this.keepIntersections=t},processIntersections:function(t,e,n,i){if(!this.findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===i)return null;if(this.isCheckEndSegmentsOnly){var r=this.isEndSegment(t,e)||this.isEndSegment(n,i);if(!r)return null}var s=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[i],u=n.getCoordinates()[i+1];this.li.computeIntersection(s,o,a,u),this.li.hasIntersection()&&this.li.isInteriorIntersection()&&(this.intSegments=new Array(4).fill(null),this.intSegments[0]=s,this.intSegments[1]=o,this.intSegments[2]=a,this.intSegments[3]=u,this.interiorIntersection=this.li.getIntersection(0),this.keepIntersections&&this.intersections.add(this.interiorIntersection),this.intersectionCount++)},isEndSegment:function(t,e){return 0===e||e>=t.size()-2},hasIntersection:function(){return null!==this.interiorIntersection},isDone:function(){return!this.findAllIntersections&&null!==this.interiorIntersection},interfaces_:function(){return[on]},getClass:function(){return an}}),an.createAllIntersectionsFinder=function(t){var e=new an(t);return e.setFindAllIntersections(!0),e},an.createAnyIntersectionFinder=function(t){return new an(t)},an.createIntersectionCounter=function(t){var e=new an(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e},e(un.prototype,{execute:function(){return null!==this.segInt?null:void this.checkInteriorIntersections()},getIntersections:function(){return this.segInt.getIntersections()},isValid:function(){return this.execute(),this._isValid},setFindAllIntersections:function(t){this.findAllIntersections=t},checkInteriorIntersections:function(){this._isValid=!0,this.segInt=new an(this.li),this.segInt.setFindAllIntersections(this.findAllIntersections);var t=new nn;if(t.setSegmentIntersector(this.segInt),t.computeNodes(this.segStrings),this.segInt.hasIntersection())return this._isValid=!1,null},checkValid:function(){if(this.execute(),!this._isValid)throw new sn(this.getErrorMessage(),this.segInt.getInteriorIntersection())},getErrorMessage:function(){if(this._isValid)return"no intersections found";var t=this.segInt.getIntersectionSegments();return"found non-noded intersection between "+se.toLineString(t[0],t[1])+" and "+se.toLineString(t[2],t[3])},interfaces_:function(){return[]},getClass:function(){return un}}),un.computeIntersections=function(t){var e=new un(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()},e(ln.prototype,{checkValid:function(){this.nv.checkValid()},interfaces_:function(){return[]},getClass:function(){return ln}}),ln.toSegmentStrings=function(t){for(var e=new I,n=t.iterator();n.hasNext();){var i=n.next();e.add(new Me(i.getCoordinates(),i))}return e},ln.checkValid=function(t){var e=new ln(t);e.checkValid()},e(hn.prototype,{map:function(t){for(var e=new I,n=0;nthis.location.length){var e=new Array(3).fill(null);e[cn.ON]=this.location[cn.ON],e[cn.LEFT]=L.NONE,e[cn.RIGHT]=L.NONE,this.location=e}for(var n=0;n1&&t.append(L.toLocationSymbol(this.location[cn.LEFT])),t.append(L.toLocationSymbol(this.location[cn.ON])),this.location.length>1&&t.append(L.toLocationSymbol(this.location[cn.RIGHT])),t.toString()},setLocations:function(t,e,n){this.location[cn.ON]=t,this.location[cn.LEFT]=e,this.location[cn.RIGHT]=n},get:function(t){return t1},isAnyNull:function(){for(var t=0;tthis.maxNodeDegree&&(this.maxNodeDegree=n),t=this.getNext(t)}while(t!==this.startDe);this.maxNodeDegree*=2},addPoints:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var s=r;s=0;s--)this.pts.add(i[s])}},isHole:function(){return this._isHole},setInResult:function(){var t=this.startDe;do t.getEdge().setInResult(!0),t=t.getNext();while(t!==this.startDe)},containsPoint:function(t){var e=this.getLinearRing(),n=e.getEnvelopeInternal();if(!n.contains(t))return!1;if(!he.isPointInRing(t,e.getCoordinates()))return!1;for(var i=this.holes.iterator();i.hasNext();){var r=i.next();if(r.containsPoint(t))return!1}return!0},addHole:function(t){this.holes.add(t)},isShell:function(){return null===this.shell},getLabel:function(){return this.label},getEdges:function(){return this.edges},getMaxNodeDegree:function(){return this.maxNodeDegree<0&&this.computeMaxNodeDegree(),this.maxNodeDegree},getShell:function(){return this.shell},mergeLabel:function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=e.getLocation(n,cn.RIGHT);if(i===L.NONE)return null;if(this.label.getLocation(n)===L.NONE)return this.label.setLocation(n,i),null}},setShell:function(t){this.shell=t,null!==t&&t.addHole(this)},toPolygon:function(t){for(var e=new Array(this.holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)},isInResult:function(){return this._isInResult},isVisited:function(){return this._isVisited},interfaces_:function(){return[]},getClass:function(){return mn}}),h(yn,mn),e(yn.prototype,{isIncidentEdgeInResult:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();){var e=t.next();if(e.getEdge().isInResult())return!0}return!1},isIsolated:function(){return 1===this.label.getGeometryCount()},getCoordinate:function(){return this.coord},print:function(t){t.println("node "+this.coord+" lbl: "+this.label)},computeIM:function(t){},computeMergedLocation:function(t,e){var n=L.NONE;if(n=this.label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==L.BOUNDARY&&(n=i)}return n},setLabel:function(){if(2!==arguments.length)return mn.prototype.setLabel.apply(this,arguments);var t=arguments[0],e=arguments[1];null===this.label?this.label=new gn(t,e):this.label.setLocation(t,e)},getEdges:function(){return this.edges},mergeLabel:function(){if(arguments[0]instanceof yn){var t=arguments[0];this.mergeLabel(t.label)}else if(arguments[0]instanceof gn)for(var e=arguments[0],n=0;n<2;n++){var i=this.computeMergedLocation(e,n),r=this.label.getLocation(n);r===L.NONE&&this.label.setLocation(n,i)}},add:function(t){this.edges.insert(t),t.setNode(this)},setLabelBoundary:function(t){if(null===this.label)return null;var e=L.NONE;null!==this.label&&(e=this.label.getLocation(t));var n=null;switch(e){case L.BOUNDARY:n=L.INTERIOR;break;case L.INTERIOR:n=L.BOUNDARY;break;default:n=L.BOUNDARY}this.label.setLocation(t,n)},interfaces_:function(){return[]},getClass:function(){return yn}}),e(xn.prototype,{find:function(t){return this.nodeMap.get(t)},addNode:function(){if(arguments[0]instanceof g){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof yn){var n=arguments[0],e=this.nodeMap.get(n.getCoordinate());return null===e?(this.nodeMap.put(n.getCoordinate(),n),n):(e.mergeLabel(n),e)}},print:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next();n.print(t)}},iterator:function(){return this.nodeMap.values().iterator()},values:function(){return this.nodeMap.values()},getBoundaryNodes:function(t){for(var e=new I,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===L.BOUNDARY&&e.add(i)}return e},add:function(t){var e=t.getCoordinate(),n=this.addNode(e);n.add(t)},interfaces_:function(){return[]},getClass:function(){return xn}}),e(En.prototype,{compareDirection:function(t){return this.dx===t.dx&&this.dy===t.dy?0:this.quadrant>t.quadrant?1:this.quadrant2){s.linkDirectedEdgesForMinimalEdgeRings();var o=s.buildMinimalRings(),a=this.findShell(o);null!==a?(this.placePolygonHoles(a,o),e.add(a)):n.addAll(o)}else i.add(s)}return i},containsPoint:function(t){for(var e=this.shellList.iterator();e.hasNext();){var n=e.next();if(n.containsPoint(t))return!0}return!1},buildMaximalEdgeRings:function(t){for(var e=new I,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new vn(i,this.geometryFactory);e.add(r),r.setInResult()}}return e},placePolygonHoles:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}},getPolygons:function(){var t=this.computePolygons(this.shellList);return t},findEdgeRingContaining:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),s=null,o=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),h=l.getEnvelopeInternal();null!==s&&(o=s.getLinearRing().getEnvelopeInternal());var c=!1;h.contains(i)&&he.isPointInRing(r,l.getCoordinates())&&(c=!0),c&&(null===s||o.contains(h))&&(s=u)}return s},findShell:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return f.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},add:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];Cn.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new I,s=this.buildMinimalEdgeRings(i,this.shellList,r);this.sortShellsAndHoles(s,this.shellList,r),this.placeFreeHoles(this.shellList,r)}},interfaces_:function(){return[]},getClass:function(){return wn}}),e(Sn.prototype,{collectLines:function(t){for(var e=this.op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next();this.collectLineEdge(n,t,this.lineEdgesList),this.collectBoundaryTouchEdge(n,t,this.lineEdgesList)}},labelIsolatedLine:function(t,e){var n=this.ptLocator.locate(t.getCoordinate(),this.op.getArgGeometry(e));t.getLabel().setLocation(e,n)},build:function(t){return this.findCoveredLineEdges(),this.collectLines(t),this.buildLines(t),this.resultLineList},collectLineEdge:function(t,e,n){var i=t.getLabel(),r=t.getEdge();t.isLineEdge()&&(t.isVisited()||!ii.isResultOfOp(i,e)||r.isCovered()||(n.add(r),t.setVisitedEdge(!0)))},findCoveredLineEdges:function(){for(var t=this.op.getGraph().getNodes().iterator();t.hasNext();){var e=t.next();e.getEdges().findCoveredLineEdges()}for(var n=this.op.getGraph().getEdgeEnds().iterator();n.hasNext();){var i=n.next(),r=i.getEdge();if(i.isLineEdge()&&!r.isCoveredSet()){var s=this.op.isCoveredByA(i.getCoordinate());r.setCovered(s)}}},labelIsolatedLines:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getLabel();n.isIsolated()&&(i.isNull(0)?this.labelIsolatedLine(n,0):this.labelIsolatedLine(n,1))}},buildLines:function(t){for(var e=this.lineEdgesList.iterator();e.hasNext();){var n=e.next(),i=(n.getLabel(),this.geometryFactory.createLineString(n.getCoordinates()));this.resultLineList.add(i),n.setInResult(!0)}},collectBoundaryTouchEdge:function(t,e,n){var i=t.getLabel();return t.isLineEdge()?null:t.isVisited()?null:t.isInteriorAreaEdge()?null:t.getEdge().isInResult()?null:(f.isTrue(!(t.isInResult()||t.getSym().isInResult())||!t.getEdge().isInResult()),void(ii.isResultOfOp(i,e)&&e===ii.INTERSECTION&&(n.add(t.getEdge()),t.setVisitedEdge(!0))))},interfaces_:function(){return[]},getClass:function(){return Sn}}),e(Ln.prototype,{filterCoveredNodeToPoint:function(t){var e=t.getCoordinate();if(!this.op.isCoveredByLA(e)){var n=this.geometryFactory.createPoint(e);this.resultPointList.add(n)}},extractNonCoveredResultNodes:function(t){for(var e=this.op.getGraph().getNodes().iterator();e.hasNext();){var n=e.next();if(!(n.isInResult()||n.isIncidentEdgeInResult()||0!==n.getEdges().getDegree()&&t!==ii.INTERSECTION)){var i=n.getLabel();ii.isResultOfOp(i,t)&&this.filterCoveredNodeToPoint(n)}}},build:function(t){return this.extractNonCoveredResultNodes(t),this.resultPointList},interfaces_:function(){return[]},getClass:function(){return Ln}}),e(bn.prototype,{locate:function(t){},interfaces_:function(){return[]},getClass:function(){return bn}}),e(Rn.prototype,{locate:function(t){return Rn.locate(t,this.geom)},interfaces_:function(){return[bn]},getClass:function(){return Rn}}),Rn.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&he.isPointInRing(t,e.getCoordinates())},Rn.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Rn.isPointInRing(t,n))return!1;for(var i=0;i=0;n--){var i=this.edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)},computeDepths:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=(t.getLabel(),t.getDepth(cn.LEFT)),i=t.getDepth(cn.RIGHT),r=this.computeDepths(e+1,this.edgeList.size(),n),s=this.computeDepths(0,e,r);if(s!==i)throw new sn("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[0],a=arguments[1],u=arguments[2],l=u,h=o;h=0;r--){var s=this.resultAreaEdgeList.get(r),o=s.getSym();switch(null===e&&s.getEdgeRing()===t&&(e=s),i){case this.SCANNING_FOR_INCOMING:if(o.getEdgeRing()!==t)continue;n=o,i=this.LINKING_TO_OUTGOING;break;case this.LINKING_TO_OUTGOING:if(s.getEdgeRing()!==t)continue;n.setNextMin(s),i=this.SCANNING_FOR_INCOMING}}i===this.LINKING_TO_OUTGOING&&(f.isTrue(null!==e,"found null for first outgoing dirEdge"),f.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))},getOutgoingDegree:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){var n=e.next();n.isInResult()&&t++}return t}if(1===arguments.length){for(var i=arguments[0],t=0,e=this.iterator();e.hasNext();){var n=e.next();n.getEdgeRing()===i&&t++}return t}},getLabel:function(){return this.label},findCoveredLineEdges:function(){for(var t=L.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=L.INTERIOR;break}if(i.isInResult()){t=L.EXTERIOR;break}}}if(t===L.NONE)return null;for(var r=t,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();n.isLineEdge()?n.getEdge().setCovered(r===L.INTERIOR):(n.isInResult()&&(r=L.EXTERIOR),i.isInResult()&&(r=L.INTERIOR))}},computeLabelling:function(t){Pn.prototype.computeLabelling.call(this,t),this.label=new gn(L.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next(),i=n.getEdge(),r=i.getLabel(),s=0;s<2;s++){var o=r.getLocation(s);o!==L.INTERIOR&&o!==L.BOUNDARY||this.label.setLocation(s,L.INTERIOR)}},interfaces_:function(){return[]},getClass:function(){return Tn}}),h(Mn,Nn),e(Mn.prototype,{createNode:function(t){return new yn(t,new Tn)},interfaces_:function(){return[]},getClass:function(){return Mn}}),e(On.prototype,{computeIntersections:function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},interfaces_:function(){return[]},getClass:function(){return On}}),e(_n.prototype,{isDelete:function(){return this.eventType===_n.DELETE},setDeleteEventIndex:function(t){this.deleteEventIndex=t},getObject:function(){return this.obj},compareTo:function(t){var e=t;return this.xValuee.xValue?1:this.eventTypee.eventType?1:0},getInsertEvent:function(){return this.insertEvent},isInsert:function(){return this.eventType===_n.INSERT},isSameLabel:function(t){return null!==this.label&&this.label===t.label},getDeleteEventIndex:function(){return this.deleteEventIndex},interfaces_:function(){return[s]},getClass:function(){return _n}}),_n.INSERT=1,_n.DELETE=2,e(An.prototype,{interfaces_:function(){return[]},getClass:function(){return An}}),e(Dn.prototype,{isTrivialIntersection:function(t,e,n,i){if(t===n&&1===this.li.getIntersectionNum()){if(Dn.isAdjacentSegments(e,i))return!0;if(t.isClosed()){var r=t.getNumPoints()-1;if(0===e&&i===r||0===i&&e===r)return!0}}return!1},getProperIntersectionPoint:function(){return this.properIntersectionPoint},setIsDoneIfProperInt:function(t){this.isDoneWhenProperInt=t},hasProperInteriorIntersection:function(){return this.hasProperInterior},isBoundaryPointInternal:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next(),r=i.getCoordinate();if(t.isIntersection(r))return!0}return!1},hasProperIntersection:function(){return this.hasProper},hasIntersection:function(){return this._hasIntersection},isDone:function(){return this._isDone},isBoundaryPoint:function(t,e){return!(null===e||!this.isBoundaryPointInternal(t,e[0])&&!this.isBoundaryPointInternal(t,e[1]))},setBoundaryNodes:function(t,e){this.bdyNodes=new Array(2).fill(null),this.bdyNodes[0]=t,this.bdyNodes[1]=e},addIntersections:function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],s=t.getCoordinates()[e+1],o=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this.li.computeIntersection(r,s,o,a),this.li.hasIntersection()&&(this.recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this.numIntersections++,this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,!this.includeProper&&this.li.isProper()||(t.addIntersections(this.li,e,0),n.addIntersections(this.li,i,1)),this.li.isProper()&&(this.properIntersectionPoint=this.li.getIntersection(0).copy(),this.hasProper=!0,this.isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this.li,this.bdyNodes)||(this.hasProperInterior=!0))))},interfaces_:function(){return[]},getClass:function(){return Dn}}),Dn.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)},h(Fn,An),e(Fn.prototype,{prepareEvents:function(){ho.sort(this.events);for(var t=0;te||this.maxs?1:0},interfaces_:function(){return[a]},getClass:function(){return qn}}),Gn.NodeComparator=qn,h(Bn,Gn),e(Bn.prototype,{query:function(t,e,n){return this.intersects(t,e)?void n.visitItem(this.item):null},interfaces_:function(){return[]},getClass:function(){return Bn}}),h(zn,Gn),e(zn.prototype,{buildExtent:function(t,e){this.min=Math.min(t.min,e.min),this.max=Math.max(t.max,e.max)},query:function(t,e,n){return this.intersects(t,e)?(null!==this.node1&&this.node1.query(t,e,n),void(null!==this.node2&&this.node2.query(t,e,n))):null},interfaces_:function(){return[]},getClass:function(){return zn}}),e(kn.prototype,{buildTree:function(){ho.sort(this.leaves,new IntervalRTreeNode.NodeComparator);for(var t=this.leaves,e=null,n=new I;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},insert:function(t,e,n){if(null!==this.root)throw new IllegalStateException("Index cannot be added to once it has been queried");this.leaves.add(new Bn(t,e,n))},query:function(t,e,n){this.init(),this.root.query(t,e,n)},buildRoot:function(){return null!==this.root?null:void(this.root=this.buildTree())},printNode:function(t){D.out.println(se.toLineString(new g(t.min,this.level),new g(t.max,this.level)))},init:function(){return null!==this.root?null:void this.buildRoot()},buildLevel:function(t,e){this.level++,e.clear();for(var n=0;n0||!e.coord.equals2D(i);r||n--;var s=new Array(n).fill(null),o=0;s[o++]=new g(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)s[o++]=this.edge.pts[a];return r&&(s[o]=e.coord),new Qn(s,new gn(this.edge.label))},add:function(t,e,n){var i=new jn(t,e,n),r=this.nodeMap.get(i);return null!==r?r:(this.nodeMap.put(i,i),i)},isIntersection:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next();if(n.coord.equals(t))return!0}return!1},interfaces_:function(){return[]},getClass:function(){return Wn}}),e(Jn.prototype,{getChainStartIndices:function(t){var e=0,n=new I;n.add(new T(e));do{var i=this.findChainEnd(t,e);n.add(new T(i)),e=i}while(en?e:n},getMinX:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return ee&&(i=1),this.depth[t][n]=i}}},getDelta:function(t){return this.depth[t][cn.RIGHT]-this.depth[t][cn.LEFT]},getLocation:function(t,e){return this.depth[t][e]<=0?L.EXTERIOR:L.INTERIOR},toString:function(){return"A: "+this.depth[0][1]+","+this.depth[0][2]+" B: "+this.depth[1][1]+","+this.depth[1][2]},add:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<2;e++)for(var n=1;n<3;n++){var i=t.getLocation(e,n);i!==L.EXTERIOR&&i!==L.INTERIOR||(this.isNull(e,n)?this.depth[e][n]=Kn.depthAtLocation(i):this.depth[e][n]+=Kn.depthAtLocation(i))}else if(3===arguments.length){var r=arguments[0],s=arguments[1],o=arguments[2];o===L.INTERIOR&&this.depth[r][s]++}},interfaces_:function(){return[]},getClass:function(){return Kn}}),Kn.depthAtLocation=function(t){return t===L.EXTERIOR?0:t===L.INTERIOR?1:Kn.NULL_VALUE},Kn.NULL_VALUE=-1,h(Qn,mn),e(Qn.prototype,{getDepth:function(){return this.depth},getCollapsedEdge:function(){var t=new Array(2).fill(null);t[0]=this.pts[0],t[1]=this.pts[1];var e=new Qn(t,gn.toLineLabel(this.label));return e},isIsolated:function(){return this._isIsolated},getCoordinates:function(){return this.pts},setIsolated:function(t){this._isIsolated=t},setName:function(t){this.name=t},equals:function(t){if(!(t instanceof Qn))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,i=!0,r=this.pts.length,s=0;s0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}},print:function(t){t.print("edge "+this.name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this.label+" "+this.depthDelta)},computeIM:function(t){Qn.updateIM(this.label,t)},isCollapsed:function(){return!!this.label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},isClosed:function(){return this.pts[0].equals(this.pts[this.pts.length-1])},getMaximumSegmentIndex:function(){return this.pts.length-1},getDepthDelta:function(){return this.depthDelta},getNumPoints:function(){return this.pts.length},printReverse:function(t){t.print("edge "+this.name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},getMonotoneChainEdge:function(){return null===this.mce&&(this.mce=new Zn(this)),this.mce},getEnvelope:function(){if(null===this.env){this.env=new C;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this.label+" "+this.depthDelta),t.toString()},isPointwiseEqual:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e=2,"found LineString with single point"),this.insertBoundaryPoint(this.argIndex,e[0]),this.insertBoundaryPoint(this.argIndex,e[e.length-1])},getInvalidPoint:function(){return this.invalidPoint},getBoundaryPoints:function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,i=t.iterator();i.hasNext();){var r=i.next();e[n++]=r.getCoordinate().copy()}return e},getBoundaryNodes:function(){return null===this.boundaryNodes&&(this.boundaryNodes=this.nodes.getBoundaryNodes(this.argIndex)),this.boundaryNodes},addSelfIntersectionNode:function(t,e,n){return this.isBoundaryNode(t,e)?null:void(n===L.BOUNDARY&&this.useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n))},addPolygonRing:function(t,e,n){if(t.isEmpty())return null;var i=H.removeRepeatedPoints(t.getCoordinates());if(i.length<4)return this._hasTooFewPoints=!0,this.invalidPoint=i[0],null;var r=e,s=n;he.isCCW(i)&&(r=n,s=e);var o=new Qn(i,new gn(this.argIndex,L.BOUNDARY,r,s));this.lineEdgeMap.put(t,o),this.insertEdge(o),this.insertPoint(this.argIndex,i[0],L.BOUNDARY)},insertPoint:function(t,e,n){var i=this.nodes.addNode(e),r=i.getLabel();null===r?i.label=new gn(t,n):r.setLocation(t,n)},createEdgeSetIntersector:function(){return new Fn},addSelfIntersectionNodes:function(t){for(var e=this.edges.iterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.eiList.iterator();r.hasNext();){var s=r.next();this.addSelfIntersectionNode(t,s.coord,i)}},add:function(){if(1!==arguments.length)return Cn.prototype.add.apply(this,arguments);var t=arguments[0];if(t.isEmpty())return null;if(t instanceof Mt&&(this.useBoundaryDeterminationRule=!1),t instanceof Rt)this.addPolygon(t);else if(t instanceof wt)this.addLineString(t);else if(t instanceof Lt)this.addPoint(t);else if(t instanceof Pt)this.addCollection(t);else if(t instanceof gt)this.addCollection(t);else if(t instanceof Mt)this.addCollection(t);else{if(!(t instanceof ft))throw new UnsupportedOperationException(t.getClass().getName());this.addCollection(t)}},addCollection:function(t){for(var e=0;e50?(null===this.areaPtLocator&&(this.areaPtLocator=new Xn(this.parentGeom)),this.areaPtLocator.locate(t)):this.ptLocator.locate(t,this.parentGeom)},findEdge:function(){if(1===arguments.length){var t=arguments[0];return this.lineEdgeMap.get(t)}return Cn.prototype.findEdge.apply(this,arguments)},interfaces_:function(){return[]},getClass:function(){return $n}}),$n.determineBoundary=function(t,e){return t.isInBoundary(e)?L.BOUNDARY:L.INTERIOR},e(ti.prototype,{getArgGeometry:function(t){return this.arg[t].getGeometry()},setComputationPrecision:function(t){this.resultPrecisionModel=t,this.li.setPrecisionModel(this.resultPrecisionModel)},interfaces_:function(){return[]},getClass:function(){return ti}}),e(ei.prototype,{compareTo:function(t){var e=t,n=ei.compareOriented(this.pts,this._orientation,e.pts,e._orientation);return n},interfaces_:function(){return[s]},getClass:function(){return ei}}),ei.orientation=function(t){return 1===H.increasingDirection(t)},ei.compareOriented=function(t,e,n,i){for(var r=e?1:-1,s=i?1:-1,o=e?t.length:-1,a=i?n.length:-1,u=e?0:t.length-1,l=i?0:n.length-1;;){var h=t[u].compareTo(n[l]);if(0!==h)return h;u+=r,l+=s;var c=u===o,f=l===a;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}},e(ni.prototype,{print:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")},addAll:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},findEdgeIndex:function(t){for(var e=0;ethis.maxWidth)&&(this.interiorPoint=e,this.maxWidth=n)},getInteriorPoint:function(){return this.interiorPoint},widestGeometry:function t(){if(arguments[0]instanceof ft){var e=arguments[0];if(e.isEmpty())return e;for(var t=e.getGeometryN(0),n=1;nt.getEnvelopeInternal().getWidth()&&(t=e.getGeometryN(n));return t}if(arguments[0]instanceof B){var i=arguments[0];return i instanceof ft?this.widestGeometry(i):i}},horizontalBisector:function(t){var e=t.getEnvelopeInternal(),n=ai.getBisectorY(t);return this.factory.createLineString([new g(e.getMinX(),n),new g(e.getMaxX(),n)])},add:function(t){if(t instanceof Rt)this.addPolygon(t);else if(t instanceof ft)for(var e=t,n=0;nthis.loY&&(this.loY=t):t>this.centreY&&tt&&(t=n)}return t+1},nodeSize:function(){for(var t=0,e=0;e<2;e++)null!==this.subnode[e]&&(t+=this.subnode[e].nodeSize());return t+1},add:function(t){this.items.add(t)},interfaces_:function(){return[]},getClass:function(){return ci}}),ci.getSubnodeIndex=function(t,e){var n=-1;return t.min>=e&&(n=1),t.max<=e&&(n=0),n},e(fi.prototype,{expandToInclude:function(t){t.max>this.max&&(this.max=t.max),t.minn||this.max=this.min&&e<=this.max}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return n>=this.min&&i<=this.max}},init:function(t,e){this.min=t,this.max=e,t>e&&(this.min=e,this.max=t)},getMax:function(){return this.max},interfaces_:function(){return[]},getClass:function(){return fi}}),gi.exponent=function(t){return di(64,t)-1023},gi.powerOf2=function(t){return Math.pow(2,t)},e(pi.prototype,{getInterval:function(){return this.interval},getLevel:function(){return this.level},computeKey:function(t){for(this.level=pi.computeLevel(t),this.interval=new fi,this.computeInterval(this.level,t);!this.interval.contains(t);)this.level+=1,this.computeInterval(this.level,t)},computeInterval:function(t,e){var n=gi.powerOf2(t);this.pt=Math.floor(e.getMin()/n)*n,this.interval.init(this.pt,this.pt+n)},getPoint:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return pi}}),pi.computeLevel=function(t){var e=t.getWidth(),n=gi.exponent(e)+1;return n},h(vi,ci),e(vi.prototype,{getInterval:function(){return this.interval},find:function(t){var e=ci.getSubnodeIndex(t,this.centre);if(e===-1)return this;if(null!==this.subnode[e]){var n=this.subnode[e];return n.find(t)}return this},insert:function(t){f.isTrue(null===this.interval||this.interval.contains(t.interval));var e=ci.getSubnodeIndex(t.interval,this.centre);if(t.level===this.level-1)this.subnode[e]=t;else{var n=this.createSubnode(e);n.insert(t),this.subnode[e]=n}},isSearchMatch:function(t){return t.overlaps(this.interval)},getSubnode:function(t){return null===this.subnode[t]&&(this.subnode[t]=this.createSubnode(t)),this.subnode[t]},getNode:function(t){var e=ci.getSubnodeIndex(t,this.centre);if(e!==-1){var n=this.getSubnode(e);return n.getNode(t)}return this},createSubnode:function(t){var e=0,n=0;switch(t){case 0:e=this.interval.getMin(),n=this.centre;break;case 1:e=this.centre,n=this.interval.getMax()}var i=new fi(e,n),r=new vi(i,this.level-1);return r},interfaces_:function(){return[]},getClass:function(){return vi}}),vi.createNode=function(t){var e=new pi(t),n=new vi(e.getInterval(),e.getLevel());return n},vi.createExpanded=function(t,e){var n=new fi(e);null!==t&&n.expandToInclude(t.interval);var i=vi.createNode(n);return null!==t&&i.insert(t),i},e(mi.prototype,{interfaces_:function(){return[]},getClass:function(){return mi}});mi.isZeroWidth=function(t,e){var n=e-t;if(0===n)return!0;var i=Math.max(Math.abs(t),Math.abs(e)),r=n/i,s=gi.exponent(r);return s<=mi.MIN_BINARY_EXPONENT};mi.MIN_BINARY_EXPONENT=-50,h(yi,ci),e(yi.prototype,{insert:function(t,e){var n=ci.getSubnodeIndex(t,yi.origin);if(n===-1)return this.add(e),null;var i=this.subnode[n];if(null===i||!i.getInterval().contains(t)){var r=vi.createExpanded(i,t);this.subnode[n]=r}this.insertContained(this.subnode[n],t,e)},isSearchMatch:function(t){return!0},insertContained:function(t,e,n){f.isTrue(t.getInterval().contains(e));var i=mi.isZeroWidth(e.getMin(),e.getMax()),r=null;r=i?t.find(e):t.getNode(e),r.add(n)},interfaces_:function(){return[]},getClass:function(){return yi}}),yi.origin=0,e(xi.prototype,{size:function(){return null!==this.root?this.root.size():0},insert:function(t,e){this.collectStats(t);var n=xi.ensureExtent(t,this.minExtent);this.root.insert(n,e)},query:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];return this.query(new fi(t,t))}if(arguments[0]instanceof fi){var e=arguments[0],n=new I;return this.query(e,n),n}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.root.addAllItemsFromOverlapping(i,r)}},iterator:function(){var t=new I;return this.root.addAllItems(t),t.iterator()},remove:function(t,e){var n=xi.ensureExtent(t,this.minExtent);return this.root.remove(n,e)},collectStats:function(t){var e=t.getWidth();e0&&(this.minExtent=e)},depth:function(){return null!==this.root?this.root.depth():0},nodeSize:function(){return null!==this.root?this.root.nodeSize():0},interfaces_:function(){return[]},getClass:function(){return xi}}),xi.ensureExtent=function(t,e){var n=t.getMin(),i=t.getMax();return n!==i?t:(n===i&&(n-=e/2,i=n+e/2),new fi(n,i))},e(Ei.prototype,{isInside:function(t){},interfaces_:function(){return[]},getClass:function(){return Ei}}),e(Ii.prototype,{testLineSegment:function(t,e){var n=null,i=null,r=null,s=null,o=null,a=e.p0,u=e.p1;i=a.x-t.x,r=a.y-t.y,s=u.x-t.x,o=u.y-t.y,(r>0&&o<=0||o>0&&r<=0)&&(n=ue.signOfDet2x2(i,r,s,o)/(o-r),0Math.PI;)t-=Ci.PI_TIMES_2;for(;t<=-Math.PI;)t+=Ci.PI_TIMES_2;return t},Ci.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}},Ci.isAcute=function(t,e,n){var i=t.x-e.x,r=t.y-e.y,s=n.x-e.x,o=n.y-e.y,a=i*s+r*o;return a>0},Ci.isObtuse=function(t,e,n){var i=t.x-e.x,r=t.y-e.y,s=n.x-e.x,o=n.y-e.y,a=i*s+r*o;return a<0},Ci.interiorAngle=function(t,e,n){var i=Ci.angle(e,t),r=Ci.angle(e,n);return Math.abs(r-i)},Ci.normalizePositive=function(t){if(t<0){for(;t<0;)t+=Ci.PI_TIMES_2;t>=Ci.PI_TIMES_2&&(t=0)}else{for(;t>=Ci.PI_TIMES_2;)t-=Ci.PI_TIMES_2;t<0&&(t=0)}return t},Ci.angleBetween=function(t,e,n){var i=Ci.angle(e,t),r=Ci.angle(e,n);return Ci.diff(i,r)},Ci.diff=function(t,e){var n=null;return n=tMath.PI&&(n=2*Math.PI-n),n},Ci.toRadians=function(t){return t*Math.PI/180},Ci.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?Ci.COUNTERCLOCKWISE:n<0?Ci.CLOCKWISE:Ci.NONE},Ci.angleBetweenOriented=function(t,e,n){var i=Ci.angle(e,t),r=Ci.angle(e,n),s=r-i;return s<=-Math.PI?s+Ci.PI_TIMES_2:s>Math.PI?s-Ci.PI_TIMES_2:s},Ci.PI_TIMES_2=2*Math.PI,Ci.PI_OVER_2=Math.PI/2,Ci.PI_OVER_4=Math.PI/4,Ci.COUNTERCLOCKWISE=he.COUNTERCLOCKWISE,Ci.CLOCKWISE=he.CLOCKWISE,Ci.NONE=he.COLLINEAR,e(wi.prototype,{area:function(){return wi.area(this.p0,this.p1,this.p2)},signedArea:function(){return wi.signedArea(this.p0,this.p1,this.p2)},interpolateZ:function(t){if(null===t)throw new i("Supplied point is null.");return wi.interpolateZ(t,this.p0,this.p1,this.p2)},longestSideLength:function(){return wi.longestSideLength(this.p0,this.p1,this.p2)},isAcute:function(){return wi.isAcute(this.p0,this.p1,this.p2)},circumcentre:function(){return wi.circumcentre(this.p0,this.p1,this.p2)},area3D:function(){return wi.area3D(this.p0,this.p1,this.p2)},centroid:function(){return wi.centroid(this.p0,this.p1,this.p2)},inCentre:function(){return wi.inCentre(this.p0,this.p1,this.p2)},interfaces_:function(){return[]},getClass:function(){return wi}}),wi.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},wi.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},wi.det=function(t,e,n,i){return t*i-e*n},wi.interpolateZ=function(t,e,n,i){var r=e.x,s=e.y,o=n.x-r,a=i.x-r,u=n.y-s,l=i.y-s,h=o*l-a*u,c=t.x-r,f=t.y-s,g=(l*c-a*f)/h,d=(-u*c+o*f)/h,p=e.z+g*(n.z-e.z)+d*(i.z-e.z);return p},wi.longestSideLength=function(t,e,n){var i=t.distance(e),r=e.distance(n),s=n.distance(t),o=i;return r>o&&(o=r),s>o&&(o=s),o},wi.isAcute=function(t,e,n){return!!Ci.isAcute(t,e,n)&&!!Ci.isAcute(e,n,t)&&!!Ci.isAcute(n,t,e)},wi.circumcentre=function(t,e,n){var i=n.x,r=n.y,s=t.x-i,o=t.y-r,a=e.x-i,u=e.y-r,l=2*wi.det(s,o,a,u),h=wi.det(o,s*s+o*o,u,a*a+u*u),c=wi.det(s,s*s+o*o,a,a*a+u*u),f=i-h/l,d=r+c/l;return new g(f,d)},wi.perpendicularBisector=function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new F(t.x+n/2,t.y+i/2,1),s=new F(t.x-i+n/2,t.y+n+i/2,1);return new F(r,s)},wi.angleBisector=function(t,e,n){var i=e.distance(t),r=e.distance(n),s=i/(i+r),o=n.x-t.x,a=n.y-t.y,u=new g(t.x+s*o,t.y+s*a);return u},wi.area3D=function(t,e,n){var i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,o=n.x-t.x,a=n.y-t.y,u=n.z-t.z,l=r*u-s*a,h=s*o-i*u,c=i*a-r*o,f=l*l+h*h+c*c,g=Math.sqrt(f)/2;return g},wi.centroid=function(t,e,n){var i=(t.x+e.x+n.x)/3,r=(t.y+e.y+n.y)/3;return new g(i,r)},wi.inCentre=function(t,e,n){var i=e.distance(n),r=t.distance(n),s=t.distance(e),o=i+r+s,a=(i*t.x+r*e.x+s*n.x)/o,u=(i*t.y+r*e.y+s*n.y)/o;return new g(a,u)},e(Si.prototype,{getRadius:function(){return this.compute(),this.radius},getDiameter:function(){switch(this.compute(),this.extremalPts.length){case 0:return this.input.getFactory().createLineString();case 1:return this.input.getFactory().createPoint(this.centre)}var t=this.extremalPts[0],e=this.extremalPts[1];return this.input.getFactory().createLineString([t,e])},getExtremalPoints:function(){return this.compute(),this.extremalPts},computeCirclePoints:function(){if(this.input.isEmpty())return this.extremalPts=new Array(0).fill(null),null;if(1===this.input.getNumPoints()){var t=this.input.getCoordinates();return this.extremalPts=[new g(t[0])],null}var e=this.input.convexHull(),n=e.getCoordinates(),t=n;if(n[0].equals2D(n[n.length-1])&&(t=new Array(n.length-1).fill(null),H.copyDeep(n,0,t,0,n.length-1)),t.length<=2)return this.extremalPts=H.copyDeep(t),null;for(var i=Si.lowestPoint(t),r=Si.pointWitMinAngleWithX(t,i),s=0;s=i;)i=r,s=o,o=Li.nextIndex(t,s),r=e.distancePerpendicular(t[o]);return ii&&(i=u),uo&&(o=l),l=t.length&&(e=0),e},Li.computeC=function(t,e,n){return t*n.y-e*n.x},Li.getMinimumDiameter=function(t){return new Li(t).getDiameter()},Li.getMinimumRectangle=function(t){return new Li(t).getMinimumRectangle()},Li.computeSegmentForLine=function(t,e,n){var i=null,r=null;return Math.abs(e)>Math.abs(t)?(i=new g(0,n/e),r=new g(1,n/e-t/e)):(i=new g(n/t,0),r=new g(n/t-e/t,1)),new ce(i,r)};var co=Object.freeze({Centroid:ge,CGAlgorithms:he,ConvexHull:me,InteriorPointArea:oi,InteriorPointLine:ui,InteriorPointPoint:li,RobustLineIntersector:ae,MCPointInRing:Ii,MinimumBoundingCircle:Si,MinimumDiameter:Li});e(bi.prototype,{getResultGeometry:function(){return new Ri(this.distanceTolerance).transform(this.inputGeom)},setDistanceTolerance:function(t){if(t<=0)throw new i("Tolerance must be positive");this.distanceTolerance=t},interfaces_:function(){return[]},getClass:function(){return bi}}),bi.densifyPoints=function(t,e,n){for(var i=new ce,r=new N,s=0;s1)for(var u=o/a,l=1;lo?1:st&&(t=n)}return t+1},isEmpty:function t(){var t=!0;this.items.isEmpty()||(t=!1);for(var e=0;e<4;e++)null!==this.subnode[e]&&(this.subnode[e].isEmpty()||(t=!1));return t},add:function(t){this.items.add(t)},interfaces_:function(){return[u]},getClass:function(){return Di}}),Di.getSubnodeIndex=function(t,e,n){var i=-1;return t.getMinX()>=e&&(t.getMinY()>=n&&(i=3),t.getMaxY()<=n&&(i=1)),t.getMaxX()<=e&&(t.getMinY()>=n&&(i=2),t.getMaxY()<=n&&(i=0)),i},e(Fi.prototype,{getLevel:function(){return this.level},computeKey:function(){if(1===arguments.length){var t=arguments[0];for(this.level=Fi.computeQuadLevel(t),this.env=new C,this.computeKey(this.level,t);!this.env.contains(t);)this.level+=1,this.computeKey(this.level,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=gi.powerOf2(e);this.pt.x=Math.floor(n.getMinX()/i)*i,this.pt.y=Math.floor(n.getMinY()/i)*i,this.env.init(this.pt.x,this.pt.x+i,this.pt.y,this.pt.y+i)}},getEnvelope:function(){return this.env},getCentre:function(){return new g((this.env.getMinX()+this.env.getMaxX())/2,(this.env.getMinY()+this.env.getMaxY())/2)},getPoint:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return Fi}}),Fi.computeQuadLevel=function(t){var e=t.getWidth(),n=t.getHeight(),i=e>n?e:n,r=gi.exponent(i)+1;return r},h(Gi,Di),e(Gi.prototype,{find:function(t){var e=Di.getSubnodeIndex(t,this.centrex,this.centrey);if(e===-1)return this;if(null!==this.subnode[e]){var n=this.subnode[e];return n.find(t)}return this},isSearchMatch:function(t){return this.env.intersects(t)},getSubnode:function(t){return null===this.subnode[t]&&(this.subnode[t]=this.createSubnode(t)),this.subnode[t]},getEnvelope:function(){return this.env},getNode:function(t){var e=Di.getSubnodeIndex(t,this.centrex,this.centrey);if(e!==-1){var n=this.getSubnode(e);return n.getNode(t)}return this},createSubnode:function(t){var e=0,n=0,i=0,r=0;switch(t){case 0:e=this.env.getMinX(),n=this.centrex,i=this.env.getMinY(),r=this.centrey;break;case 1:e=this.centrex,n=this.env.getMaxX(),i=this.env.getMinY(),r=this.centrey;break;case 2:e=this.env.getMinX(),n=this.centrex,i=this.centrey,r=this.env.getMaxY();break;case 3:e=this.centrex,n=this.env.getMaxX(),i=this.centrey,r=this.env.getMaxY()}var s=new C(e,n,i,r),o=new Gi(s,this.level-1);return o},insertNode:function(t){f.isTrue(null===this.env||this.env.contains(t.env));var e=Di.getSubnodeIndex(t.env,this.centrex,this.centrey);if(t.level===this.level-1)this.subnode[e]=t;else{var n=this.createSubnode(e);n.insertNode(t),this.subnode[e]=n}},interfaces_:function(){return[]},getClass:function(){return Gi}}),Gi.createNode=function(t){var e=new Fi(t),n=new Gi(e.getEnvelope(),e.getLevel());return n},Gi.createExpanded=function(t,e){var n=new C(e);null!==t&&n.expandToInclude(t.env);var i=Gi.createNode(n);return null!==t&&i.insertNode(t),i},h(qi,Di),e(qi.prototype,{insert:function(t,e){var n=Di.getSubnodeIndex(t,qi.origin.x,qi.origin.y);if(n===-1)return this.add(e),null;var i=this.subnode[n];if(null===i||!i.getEnvelope().contains(t)){var r=Gi.createExpanded(i,t);this.subnode[n]=r}this.insertContained(this.subnode[n],t,e)},isSearchMatch:function(t){return!0},insertContained:function(t,e,n){f.isTrue(t.getEnvelope().contains(e));var i=mi.isZeroWidth(e.getMinX(),e.getMaxX()),r=mi.isZeroWidth(e.getMinY(),e.getMaxY()),s=null;s=i||r?t.find(e):t.getNode(e),s.add(n)},interfaces_:function(){return[]},getClass:function(){return qi}}),qi.origin=new g(0,0),e(Bi.prototype,{size:function(){return null!==this.root?this.root.size():0},insert:function(t,e){this.collectStats(t);var n=Bi.ensureExtent(t,this.minExtent);this.root.insert(n,e)},query:function(){if(1===arguments.length){var t=arguments[0],e=new Yn;return this.query(t,e),e.getItems()}if(2===arguments.length){var n=arguments[0],i=arguments[1];this.root.visit(n,i)}},queryAll:function(){var t=new I;return this.root.addAllItems(t),t},remove:function(t,e){var n=Bi.ensureExtent(t,this.minExtent);return this.root.remove(n,e)},collectStats:function(t){var e=t.getWidth();e0&&(this.minExtent=e);var n=t.getHeight();n0&&(this.minExtent=n)},depth:function(){return null!==this.root?this.root.depth():0},isEmpty:function(){return null===this.root},interfaces_:function(){return[Fe,u]},getClass:function(){return Bi}}),Bi.ensureExtent=function(t,e){var n=t.getMinX(),i=t.getMaxX(),r=t.getMinY(),s=t.getMaxY();return n!==i&&r!==s?t:(n===i&&(n-=e/2,i=n+e/2),r===s&&(r-=e/2,s=r+e/2),new C(n,i,r,s))},Bi.serialVersionUID=-0x678b60c967a25400;var vo=Object.freeze({Quadtree:Bi}),mo=Object.freeze({STRtree:Ve}),yo=Object.freeze({quadtree:vo,strtree:mo}),xo=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];e(zi.prototype,{read:function(t){var e=void 0;e="string"==typeof t?JSON.parse(t):t;var n=e.type;if(!Eo[n])throw new Error("Unknown GeoJSON type: "+e.type);return xo.indexOf(n)!==-1?Eo[n].apply(this,[e.coordinates]):"GeometryCollection"===n?Eo[n].apply(this,[e.geometries]):Eo[n].apply(this,[e])},write:function(t){var e=t.getGeometryType();if(!Io[e])throw new Error("Geometry is not supported");return Io[e].apply(this,[t])}});var Eo={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!Eo[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=Eo.bbox.apply(this,[t.bbox])),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n0&&this.minIndexthis.minCoord.y&&n.y>this.minCoord.y&&i===he.CLOCKWISE&&(r=!0),r&&(this.minIndex=this.minIndex-1)},getRightmostSideOfSegment:function(t,e){var n=t.getEdge(),i=n.getCoordinates();if(e<0||e+1>=i.length)return-1;if(i[e].y===i[e+1].y)return-1;var r=cn.LEFT;return i[e].ythis.minCoord.x)&&(this.minDe=t,this.minIndex=n,this.minCoord=e[n])},findRightmostEdgeAtNode:function(){var t=this.minDe.getNode(),e=t.getEdges();this.minDe=e.getRightmostEdge(),this.minDe.isForward()||(this.minDe=this.minDe.getSym(),this.minIndex=this.minDe.getEdge().getCoordinates().length-1)},findEdge:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}f.isTrue(0!==this.minIndex||this.minCoord.equals(this.minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this.minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this.orientedDe=this.minDe;var i=this.getRightmostSide(this.minDe,this.minIndex);i===cn.LEFT&&(this.orientedDe=this.minDe.getSym())},interfaces_:function(){return[]},getClass:function(){return Zi}}),Ki.prototype.addLast=function(t){this.array_.push(t)},Ki.prototype.removeFirst=function(){return this.array_.shift()},Ki.prototype.isEmpty=function(){return 0===this.array_.length},e(Qi.prototype,{clearVisitedEdges:function(){for(var t=this.dirEdgeList.iterator();t.hasNext();){var e=t.next();e.setVisited(!1)}},getRightmostCoordinate:function(){return this.rightMostCoord},computeNodeDepth:function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new sn("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();i.setVisited(!0),this.copySymDepths(i)}},computeDepth:function(t){this.clearVisitedEdges();var e=this.finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(cn.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},create:function(t){this.addReachable(t),this.finder.findEdge(this.dirEdgeList),this.rightMostCoord=this.finder.getCoordinate()},findResultEdges:function(){for(var t=this.dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(cn.RIGHT)>=1&&e.getDepth(cn.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},computeDepths:function(t){var e=new Q,n=new Ki,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r); -for(var s=r.getEdges().iterator();s.hasNext();){var o=s.next(),a=o.getSym();if(!a.isVisited()){var u=a.getNode();e.contains(u)||(n.addLast(u),e.add(u))}}}},compareTo:function(t){var e=t;return this.rightMostCoord.xe.rightMostCoord.x?1:0},getEnvelope:function(){if(null===this.env){for(var t=new C,e=this.dirEdgeList.iterator();e.hasNext();)for(var n=e.next(),i=n.getEdge().getCoordinates(),r=0;r=0;n--)this.addPt(t[n])},isRedundant:function(t){if(this.ptList.size()<1)return!1;var e=this.ptList.get(this.ptList.size()-1),n=t.distance(e);return n=2&&(n=this.ptList.get(this.ptList.size()-2)),t.equals(e)?null:void this.ptList.add(t)},setMinimumVertexDistance:function(t){this.minimimVertexDistance=t},interfaces_:function(){return[]},getClass:function(){return tr}}),tr.COORDINATE_ARRAY_TYPE=new Array(0).fill(null),e(er.prototype,{addNextSegment:function(t,e){if(this.s0=this.s1,this.s1=this.s2,this.s2=t,this.seg0.setCoordinates(this.s0,this.s1),this.computeOffsetSegment(this.seg0,this.side,this.distance,this.offset0),this.seg1.setCoordinates(this.s1,this.s2),this.computeOffsetSegment(this.seg1,this.side,this.distance,this.offset1),this.s1.equals(this.s2))return null;var n=he.computeOrientation(this.s0,this.s1,this.s2),i=n===he.CLOCKWISE&&this.side===cn.LEFT||n===he.COUNTERCLOCKWISE&&this.side===cn.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},addLineEndCap:function(t,e){var n=new ce(t,e),i=new ce;this.computeOffsetSegment(n,cn.LEFT,this.distance,i);var r=new ce;this.computeOffsetSegment(n,cn.RIGHT,this.distance,r);var s=e.x-t.x,o=e.y-t.y,a=Math.atan2(o,s);switch(this.bufParams.getEndCapStyle()){case Ji.CAP_ROUND:this.segList.addPt(i.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,he.CLOCKWISE,this.distance),this.segList.addPt(r.p1);break;case Ji.CAP_FLAT:this.segList.addPt(i.p1),this.segList.addPt(r.p1);break;case Ji.CAP_SQUARE:var u=new g;u.x=Math.abs(this.distance)*Math.cos(a),u.y=Math.abs(this.distance)*Math.sin(a);var l=new g(i.p1.x+u.x,i.p1.y+u.y),h=new g(r.p1.x+u.x,r.p1.y+u.y);this.segList.addPt(l),this.segList.addPt(h)}},getCoordinates:function(){var t=this.segList.getCoordinates();return t},addMitreJoin:function(t,e,n,i){var r=!0,s=null;try{s=F.intersection(e.p0,e.p1,n.p0,n.p1);var o=i<=0?1:s.distance(t)/Math.abs(i);o>this.bufParams.getMitreLimit()&&(r=!1)}catch(t){if(!(t instanceof S))throw t;s=new g(0,0),r=!1}finally{}r?this.segList.addPt(s):this.addLimitedMitreJoin(e,n,i,this.bufParams.getMitreLimit())},addFilletCorner:function(t,e,n,i,r){var s=e.x-t.x,o=e.y-t.y,a=Math.atan2(o,s),u=n.x-t.x,l=n.y-t.y,h=Math.atan2(l,u);i===he.CLOCKWISE?a<=h&&(a+=2*Math.PI):a>=h&&(a-=2*Math.PI),this.segList.addPt(e),this.addFilletArc(t,a,h,i,r),this.segList.addPt(n)},addOutsideTurn:function(t,e){return this.offset0.p1.distance(this.offset1.p0)0){var n=new g((this.closingSegLengthFactor*this.offset0.p1.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset0.p1.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(n);var i=new g((this.closingSegLengthFactor*this.offset1.p0.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset1.p0.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(i)}else this.segList.addPt(this.s1);this.segList.addPt(this.offset1.p0)}},createCircle:function(t){var e=new g(t.x+this.distance,t.y);this.segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this.distance),this.segList.closeRing()},addBevelJoin:function(t,e){this.segList.addPt(t.p1),this.segList.addPt(e.p0)},init:function(t){this.distance=t,this.maxCurveSegmentError=t*(1-Math.cos(this.filletAngleQuantum/2)),this.segList=new tr,this.segList.setPrecisionModel(this.precisionModel),this.segList.setMinimumVertexDistance(t*er.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},addCollinear:function(t){this.li.computeIntersection(this.s0,this.s1,this.s1,this.s2);var e=this.li.getIntersectionNum();e>=2&&(this.bufParams.getJoinStyle()===Ji.JOIN_BEVEL||this.bufParams.getJoinStyle()===Ji.JOIN_MITRE?(t&&this.segList.addPt(this.offset0.p1),this.segList.addPt(this.offset1.p0)):this.addFilletCorner(this.s1,this.offset0.p1,this.offset1.p0,he.CLOCKWISE,this.distance))},closeRing:function(){this.segList.closeRing()},hasNarrowConcaveAngle:function(){return this._hasNarrowConcaveAngle},interfaces_:function(){return[]},getClass:function(){return er}}),er.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,er.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,er.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,er.MAX_CLOSING_SEG_LEN_FACTOR=80,e(nr.prototype,{getOffsetCurve:function(t,e){if(this.distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var s=r.getCoordinates();return n&&H.reverse(s),s},computeSingleSidedBufferCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);if(e){n.addSegments(t,!0);var r=$i.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],cn.LEFT),n.addFirstSegment();for(var o=s-2;o>=0;o--)n.addNextSegment(r[o],!0)}else{n.addSegments(t,!1);var a=$i.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],cn.LEFT),n.addFirstSegment();for(var o=2;o<=u;o++)n.addNextSegment(a[o],!0)}n.addLastSegment(),n.closeRing()},computeRingBufferCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);e===cn.RIGHT&&(i=-i);var r=$i.simplify(t,i),s=r.length-1;n.initSideSegments(r[s-1],r[0],e);for(var o=1;o<=s;o++){var a=1!==o;n.addNextSegment(r[o],a)}n.closeRing()},computeLineBufferCurve:function(t,e){var n=this.simplifyTolerance(this.distance),i=$i.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],cn.LEFT);for(var s=2;s<=r;s++)e.addNextSegment(i[s],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var o=$i.simplify(t,-n),a=o.length-1;e.initSideSegments(o[a],o[a-1],cn.LEFT);for(var s=a-2;s>=0;s--)e.addNextSegment(o[s],!0);e.addLastSegment(),e.addLineEndCap(o[1],o[0]),e.closeRing()},computePointCurve:function(t,e){switch(this.bufParams.getEndCapStyle()){case Ji.CAP_ROUND:e.createCircle(t);break;case Ji.CAP_SQUARE:e.createSquare(t)}},getLineCurve:function(t,e){if(this.distance=e,e<0&&!this.bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this.bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);var s=i.getCoordinates();return s},getBufferParameters:function(){return this.bufParams},simplifyTolerance:function(t){return t*this.bufParams.getSimplifyFactor()},getRingCurve:function(t,e,n){if(this.distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return nr.copyCoordinates(t);var i=this.getSegGen(n);return this.computeRingBufferCurve(t,e,i),i.getCoordinates()},computeOffsetCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);if(e){var r=$i.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],cn.LEFT),n.addFirstSegment();for(var o=s-2;o>=0;o--)n.addNextSegment(r[o],!0)}else{var a=$i.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],cn.LEFT),n.addFirstSegment();for(var o=2;o<=u;o++)n.addNextSegment(a[o],!0)}n.addLastSegment()},getSegGen:function(t){return new er(this.precisionModel,this.bufParams,t)},interfaces_:function(){return[]},getClass:function(){return nr}}),nr.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;nr.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(b(arguments[2],y)&&arguments[0]instanceof g&&arguments[1]instanceof In)for(var s=arguments[0],o=arguments[1],a=arguments[2],u=o.getEdge().getCoordinates(),n=0;nthis.seg.p1.y&&this.seg.reverse();var l=Math.max(this.seg.p0.x,this.seg.p1.x);if(!(lthis.seg.p1.y||he.computeOrientation(this.seg.p0,this.seg.p1,s)===he.RIGHT)){var h=o.getDepth(cn.LEFT);this.seg.p0.equals(u[n])||(h=o.getDepth(cn.RIGHT));var c=new rr(this.seg,h);a.add(c)}}else if(b(arguments[2],y)&&arguments[0]instanceof g&&b(arguments[1],y))for(var f=arguments[0],d=arguments[1],p=arguments[2],n=d.iterator();n.hasNext();){var v=n.next();v.isForward()&&this.findStabbedSegments(f,v,p)}},getDepth:function(t){var e=this.findStabbedSegments(t);if(0===e.size())return 0;var n=ho.min(e);return n.leftDepth},interfaces_:function(){return[]},getClass:function(){return ir}}),e(rr.prototype,{compareTo:function(t){var e=t;if(this.upwardSeg.minX()>=e.upwardSeg.maxX())return 1;if(this.upwardSeg.maxX()<=e.upwardSeg.minX())return-1;var n=this.upwardSeg.orientationIndex(e.upwardSeg);return 0!==n?n:(n=-1*e.upwardSeg.orientationIndex(this.upwardSeg),0!==n?n:this.upwardSeg.compareTo(e.upwardSeg))},compareX:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},toString:function(){return this.upwardSeg.toString()},interfaces_:function(){return[s]},getClass:function(){return rr}}),ir.DepthSegment=rr,e(sr.prototype,{addPoint:function(t){if(this.distance<=0)return null;var e=t.getCoordinates(),n=this.curveBuilder.getLineCurve(e,this.distance);this.addCurve(n,L.EXTERIOR,L.INTERIOR)},addPolygon:function(t){var e=this.distance,n=cn.LEFT;this.distance<0&&(e=-this.distance,n=cn.RIGHT);var i=t.getExteriorRing(),r=H.removeRepeatedPoints(i.getCoordinates());if(this.distance<0&&this.isErodedCompletely(i,this.distance))return null;if(this.distance<=0&&r.length<3)return null;this.addPolygonRing(r,e,n,L.EXTERIOR,L.INTERIOR);for(var s=0;s0&&this.isErodedCompletely(o,-this.distance)||this.addPolygonRing(a,e,cn.opposite(n),L.INTERIOR,L.EXTERIOR)}},isTriangleErodedCompletely:function(t,e){var n=new wi(t[0],t[1],t[2]),i=n.inCentre(),r=he.distancePointLine(i,n.p0,n.p1);return r=Tt.MINIMUM_VALID_SIZE&&he.isCCW(t)&&(s=r,o=i,n=cn.opposite(n));var a=this.curveBuilder.getRingCurve(t,n,e);this.addCurve(a,s,o)},add:function(t){if(t.isEmpty())return null;if(t instanceof Rt)this.addPolygon(t);else if(t instanceof wt)this.addLineString(t);else if(t instanceof Lt)this.addPoint(t);else if(t instanceof Pt)this.addCollection(t);else if(t instanceof gt)this.addCollection(t);else if(t instanceof Mt)this.addCollection(t);else{if(!(t instanceof ft))throw new UnsupportedOperationException(t.getClass().getName());this.addCollection(t)}},isErodedCompletely:function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r},addCollection:function(t){for(var e=0;ei||this.maxys;if(o)return!1;var a=this.intersectsToleranceSquare(t,e);return f.isTrue(!(o&&a),"Found bad envelope test"),a},initCorners:function(t){var e=.5;this.minx=t.x-e,this.maxx=t.x+e,this.miny=t.y-e,this.maxy=t.y+e,this.corner[0]=new g(this.maxx,this.maxy),this.corner[1]=new g(this.minx,this.maxy),this.corner[2]=new g(this.minx,this.miny),this.corner[3]=new g(this.maxx,this.miny)},intersects:function(t,e){return 1===this.scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this.p0Scaled),this.copyScaled(e,this.p1Scaled),this.intersectsScaled(this.p0Scaled,this.p1Scaled))},scale:function(t){return Math.round(t*this.scaleFactor)},getCoordinate:function(){return this.originalPt},copyScaled:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},getSafeEnvelope:function(){if(null===this.safeEnv){var t=lr.SAFE_ENV_EXPANSION_FACTOR/this.scaleFactor;this.safeEnv=new C(this.originalPt.x-t,this.originalPt.x+t,this.originalPt.y-t,this.originalPt.y+t)}return this.safeEnv},intersectsPixelClosure:function(t,e){return this.li.computeIntersection(t,e,this.corner[0],this.corner[1]),!!(this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[1],this.corner[2]),this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[2],this.corner[3]),this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[3],this.corner[0]),this.li.hasIntersection()))))},intersectsToleranceSquare:function(t,e){var n=!1,i=!1;return this.li.computeIntersection(t,e,this.corner[0],this.corner[1]),!!(this.li.isProper()||(this.li.computeIntersection(t,e,this.corner[1],this.corner[2]),this.li.isProper()||(this.li.hasIntersection()&&(n=!0),this.li.computeIntersection(t,e,this.corner[2],this.corner[3]),this.li.isProper()||(this.li.hasIntersection()&&(i=!0),this.li.computeIntersection(t,e,this.corner[3],this.corner[0]),this.li.isProper()||n&&i||t.equals(this.pt)||e.equals(this.pt)))))},addSnappedNode:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!0)},interfaces_:function(){return[]},getClass:function(){return lr}}),lr.SAFE_ENV_EXPANSION_FACTOR=.75,e(hr.prototype,{snap:function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],n=arguments[1],i=arguments[2],r=e.getSafeEnvelope(),s=new cr(e,n,i);return this.index.query(r,{interfaces_:function(){return[De]},visitItem:function(t){var e=t;e.select(r,s)}}),s.isNodeAdded()}},interfaces_:function(){return[]},getClass:function(){return hr}}),h(cr,hi),e(cr.prototype,{isNodeAdded:function(){return this._isNodeAdded},select:function(){if(2!==arguments.length)return hi.prototype.select.apply(this,arguments);var t=arguments[0],e=arguments[1],n=t.getContext();return null!==this.parentEdge&&n===this.parentEdge&&e===this.hotPixelVertexIndex?null:void(this._isNodeAdded=this.hotPixel.addSnappedNode(n,e))},interfaces_:function(){return[]},getClass:function(){return cr}}),hr.HotPixelSnapAction=cr,e(fr.prototype,{processIntersections:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],s=t.getCoordinates()[e+1],o=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this.li.computeIntersection(r,s,o,a),this.li.hasIntersection()&&this.li.isInteriorIntersection()){for(var u=0;u=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof sn))throw t;this.saveException=t}finally{}if(null!==this.resultGeometry)return null}throw this.saveException}if(1===arguments.length){var e=arguments[0],n=dr.precisionScaleFactor(this.argGeom,this.distance,e),i=new ee(n);this.bufferFixedPrecision(i)}},computeGeometry:function(){if(this.bufferOriginalPrecision(),null!==this.resultGeometry)return null;var t=this.argGeom.getFactory().getPrecisionModel();t.getType()===ee.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},setQuadrantSegments:function(t){this.bufParams.setQuadrantSegments(t)},bufferOriginalPrecision:function(){try{var t=new ar(this.bufParams);this.resultGeometry=t.buffer(this.argGeom,this.distance)}catch(t){if(!(t instanceof l))throw t;this.saveException=t}finally{}},getResultGeometry:function(t){return this.distance=t,this.computeGeometry(),this.resultGeometry},setEndCapStyle:function(t){this.bufParams.setEndCapStyle(t)},interfaces_:function(){return[]},getClass:function(){return dr}}),dr.bufferOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new dr(t),i=n.getResultGeometry(e);return i}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof B&&"number"==typeof arguments[1]){var r=arguments[0],s=arguments[1],o=arguments[2],a=new dr(r);a.setQuadrantSegments(o);var i=a.getResultGeometry(s);return i}if(arguments[2]instanceof Ji&&arguments[0]instanceof B&&"number"==typeof arguments[1]){var u=arguments[0],l=arguments[1],h=arguments[2],a=new dr(u,h),i=a.getResultGeometry(l);return i}}else if(4===arguments.length){var c=arguments[0],f=arguments[1],g=arguments[2],d=arguments[3],a=new dr(c);a.setQuadrantSegments(g),a.setEndCapStyle(d);var i=a.getResultGeometry(f);return i}},dr.precisionScaleFactor=function(t,e,n){var i=t.getEnvelopeInternal(),r=R.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY())),s=e>0?e:0,o=r+2*s,a=Math.trunc(Math.log(o)/Math.log(10)+1),u=n-a,l=Math.pow(10,u);return l},dr.CAP_ROUND=Ji.CAP_ROUND,dr.CAP_BUTT=Ji.CAP_FLAT,dr.CAP_FLAT=Ji.CAP_FLAT,dr.CAP_SQUARE=Ji.CAP_SQUARE,dr.MAX_PRECISION_DIGITS=12;var wo=Object.freeze({BufferOp:dr,BufferParameters:Ji});e(pr.prototype,{filter:function(t){t instanceof Rt&&this.comps.add(t)},interfaces_:function(){return[ht]},getClass:function(){return pr}}),pr.getPolygons=function(){if(1===arguments.length){var t=arguments[0];return pr.getPolygons(t,new I)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Rt?n.add(e):e instanceof ft&&e.apply(new pr(n)),n}},e(vr.prototype,{isInsideArea:function(){return this.segIndex===vr.INSIDE_AREA},getCoordinate:function(){return this.pt},getGeometryComponent:function(){return this.component},getSegmentIndex:function(){return this.segIndex},interfaces_:function(){return[]},getClass:function(){return vr}}),vr.INSIDE_AREA=-1,e(mr.prototype,{filter:function(t){t instanceof Lt&&this.pts.add(t)},interfaces_:function(){return[ht]},getClass:function(){return mr}}),mr.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof Lt?ho.singletonList(t):mr.getPoints(t,new I)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Lt?n.add(e):e instanceof ft&&e.apply(new mr(n)),n}},e(yr.prototype,{filter:function(t){(t instanceof Lt||t instanceof wt||t instanceof Rt)&&this.locations.add(new vr(t,0,t.getCoordinate())); -},interfaces_:function(){return[ht]},getClass:function(){return yr}}),yr.getLocations=function(t){var e=new I;return t.apply(new yr(e)),e},e(xr.prototype,{computeContainmentDistance:function(){if(0===arguments.length){var t=new Array(2).fill(null);if(this.computeContainmentDistance(0,t),this.minDistance<=this.terminateDistance)return null;this.computeContainmentDistance(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=1-e,r=pr.getPolygons(this.geom[e]);if(r.size()>0){var s=yr.getLocations(this.geom[i]);if(this.computeContainmentDistance(s,r,n),this.minDistance<=this.terminateDistance)return this.minDistanceLocation[i]=n[0],this.minDistanceLocation[e]=n[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&b(arguments[0],y)&&b(arguments[1],y)){for(var o=arguments[0],a=arguments[1],u=arguments[2],l=0;lthis.minDistance)return null;for(var i=t.getCoordinates(),r=e.getCoordinate(),s=0;sthis.minDistance)return null;for(var i=l.getCoordinates(),f=h.getCoordinates(),s=0;st&&H.reverse(this.coordinates)}return this.coordinates},toLineString:function(){return this.factory.createLineString(this.getCoordinates())},add:function(t){this.directedEdges.add(t)},interfaces_:function(){return[]},getClass:function(){return Er}}),e(Ir.prototype,{setVisited:function(t){this._isVisited=t},isMarked:function(){return this._isMarked},setData:function(t){this.data=t},getData:function(){return this.data},setMarked:function(t){this._isMarked=t},getContext:function(){return this.data},isVisited:function(){return this._isVisited},setContext:function(t){this.data=t},interfaces_:function(){return[]},getClass:function(){return Ir}}),Ir.getComponentWithVisitedState=function(t,e){for(;t.hasNext();){var n=t.next();if(n.isVisited()===e)return n}return null},Ir.setVisited=function(t,e){for(;t.hasNext();){var n=t.next();n.setVisited(e)}},Ir.setMarked=function(t,e){for(;t.hasNext();){var n=t.next();n.setMarked(e)}},h(Nr,Ir),e(Nr.prototype,{isRemoved:function(){return null===this.parentEdge},compareDirection:function(t){return this.quadrant>t.quadrant?1:this.quadrant=t.getNumPoints()&&null===i)return null;var s=t.getCoordinate(r);null!==i&&i.segmentIndex===n.segmentIndex&&(s=i.coord);var o=new En(t,n.coord,s,new gn(t.getLabel()));e.add(o)},createEdgeEndForPrev:function(t,e,n,i){var r=n.segmentIndex;if(0===n.dist){if(0===r)return null;r--}var s=t.getCoordinate(r);null!==i&&i.segmentIndex>=r&&(s=i.coord);var o=new gn(t.getLabel());o.flip();var a=new En(t,n.coord,s,o);e.add(a)},computeEdgeEnds:function(){if(1===arguments.length){for(var t=arguments[0],e=new I,n=t;n.hasNext();){var i=n.next();this.computeEdgeEnds(i,e)}return e}if(2===arguments.length){var r=arguments[0],s=arguments[1],o=r.getEdgeIntersectionList();o.addEndpoints();var a=o.iterator(),u=null,l=null;if(!a.hasNext())return null;var h=a.next();do u=l,l=h,h=null,a.hasNext()&&(h=a.next()),null!==l&&(this.createEdgeEndForPrev(r,s,l,u),this.createEdgeEndForNext(r,s,l,h));while(null!==l)}},interfaces_:function(){return[]},getClass:function(){return Dr}}),h(Fr,En),e(Fr.prototype,{insert:function(t){this.edgeEnds.add(t)},print:function(t){t.println("EdgeEndBundle--> Label: "+this.label);for(var e=this.iterator();e.hasNext();){var n=e.next();n.print(t),t.println()}},iterator:function(){return this.edgeEnds.iterator()},getEdgeEnds:function(){return this.edgeEnds},computeLabelOn:function(t,e){for(var n=0,i=!1,r=this.iterator();r.hasNext();){var s=r.next(),o=s.getLabel().getLocation(t);o===L.BOUNDARY&&n++,o===L.INTERIOR&&(i=!0)}var o=L.NONE;i&&(o=L.INTERIOR),n>0&&(o=$n.determineBoundary(e,n)),this.label.setLocation(t,o)},computeLabelSide:function(t,e){for(var n=this.iterator();n.hasNext();){var i=n.next();if(i.getLabel().isArea()){var r=i.getLabel().getLocation(t,e);if(r===L.INTERIOR)return this.label.setLocation(t,e,L.INTERIOR),null;r===L.EXTERIOR&&this.label.setLocation(t,e,L.EXTERIOR)}}},getLabel:function(){return this.label},computeLabelSides:function(t){this.computeLabelSide(t,cn.LEFT),this.computeLabelSide(t,cn.RIGHT)},updateIM:function(t){Qn.updateIM(this.label,t)},computeLabel:function(t){for(var e=!1,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().isArea()&&(e=!0)}e?this.label=new gn(L.NONE,L.NONE,L.NONE):this.label=new gn(L.NONE);for(var r=0;r<2;r++)this.computeLabelOn(r,t),e&&this.computeLabelSides(r)},interfaces_:function(){return[]},getClass:function(){return Fr}}),h(Gr,Pn),e(Gr.prototype,{updateIM:function(t){for(var e=this.iterator();e.hasNext();){var n=e.next();n.updateIM(t)}},insert:function(t){var e=this.edgeMap.get(t);null===e?(e=new Fr(t),this.insertEdgeEnd(t,e)):e.insert(t)},interfaces_:function(){return[]},getClass:function(){return Gr}}),h(qr,yn),e(qr.prototype,{updateIMFromEdges:function(t){this.edges.updateIM(t)},computeIM:function(t){t.setAtLeastIfValid(this.label.getLocation(0),this.label.getLocation(1),0)},interfaces_:function(){return[]},getClass:function(){return qr}}),h(Br,Nn),e(Br.prototype,{createNode:function(t){return new qr(t,new Gr)},interfaces_:function(){return[]},getClass:function(){return Br}}),e(zr.prototype,{insertEdgeEnds:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.nodes.add(n)}},getNodeIterator:function(){return this.nodes.iterator()},copyNodesAndLabels:function(t,e){for(var n=t.getNodeIterator();n.hasNext();){var i=n.next(),r=this.nodes.addNode(i.getCoordinate());r.setLabel(e,i.getLabel().getLocation(e))}},build:function(t){this.computeIntersectionNodes(t,0),this.copyNodesAndLabels(t,0);var e=new Dr,n=e.computeEdgeEnds(t.getEdgeIterator());this.insertEdgeEnds(n)},computeIntersectionNodes:function(t,e){for(var n=t.getEdgeIterator();n.hasNext();)for(var i=n.next(),r=i.getLabel().getLocation(e),s=i.getEdgeIntersectionList().iterator();s.hasNext();){var o=s.next(),a=this.nodes.addNode(o.coord);r===L.BOUNDARY?a.setLabelBoundary(e):a.getLabel().isNull(e)&&a.setLabel(e,L.INTERIOR)}},interfaces_:function(){return[]},getClass:function(){return zr}}),e(kr.prototype,{isNodeEdgeAreaLabelsConsistent:function(){for(var t=this.nodeGraph.getNodeIterator();t.hasNext();){var e=t.next();if(!e.getEdges().isAreaLabelsConsistent(this.geomGraph))return this.invalidPoint=e.getCoordinate().copy(),!1}return!0},getInvalidPoint:function(){return this.invalidPoint},hasDuplicateRings:function(){for(var t=this.nodeGraph.getNodeIterator();t.hasNext();)for(var e=t.next(),n=e.getEdges().iterator();n.hasNext();){var i=n.next();if(i.getEdgeEnds().size()>1)return this.invalidPoint=i.getEdge().getCoordinate(0),!0}return!1},isNodeConsistentArea:function(){var t=this.geomGraph.computeSelfNodes(this.li,!0,!0);return t.hasProperIntersection()?(this.invalidPoint=t.getProperIntersectionPoint(),!1):(this.nodeGraph.build(this.geomGraph),this.isNodeEdgeAreaLabelsConsistent())},interfaces_:function(){return[]},getClass:function(){return kr}}),e(Vr.prototype,{buildIndex:function(){this.index=new Ve;for(var t=0;t=1&&(e=t.getCoordinateN(0)),this.validErr=new Yr(Yr.RING_NOT_CLOSED,e)}},checkShellsNotNested:function(t,e){for(var n=0;n=0;i--)n.add(t[i],!1)},Ur.findEdgeRingContaining=function(t,e){for(var n=t.getRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),s=null,o=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getRing(),h=l.getEnvelopeInternal();if(!h.equals(i)&&h.contains(i)){r=H.ptNotInList(n.getCoordinates(),l.getCoordinates());var c=!1;he.isPointInRing(r,l.getCoordinates())&&(c=!0),c&&(null===s||o.contains(h))&&(s=u,o=s.getRing().getEnvelopeInternal())}}return s},e(Hr.prototype,{compare:function(t,e){var n=t,i=e;return n.getRing().getEnvelope().compareTo(i.getRing().getEnvelope())},interfaces_:function(){return[a]},getClass:function(){return Hr}}),Ur.EnvelopeComparator=Hr,h(jr,Pr),e(jr.prototype,{findEdgeRing:function(t){var e=new Ur(this.factory);return e.build(t),e},computeDepthParity:function(){if(0===arguments.length)for(;;){var t=null;if(null===t)return null;this.computeDepthParity(t)}else 1===arguments.length&&arguments[0]},computeNextCWEdges:function(){for(var t=this.nodeIterator();t.hasNext();){var e=t.next();jr.computeNextCWEdges(e)}},addEdge:function(t){if(t.isEmpty())return null;var e=H.removeRepeatedPoints(t.getCoordinates());if(e.length<2)return null;var n=e[0],i=e[e.length-1],r=this.getNode(n),s=this.getNode(i),o=new Or(r,s,e[1],!0),a=new Or(s,r,e[e.length-2],!1),u=new _r(t);u.setDirectedEdges(o,a),this.add(u)},deleteCutEdges:function(){this.computeNextCWEdges(),jr.findLabeledEdgeRings(this.dirEdges);for(var t=new I,e=this.dirEdges.iterator();e.hasNext();){var n=e.next();if(!n.isMarked()){var i=n.getSym();if(n.getLabel()===i.getLabel()){n.setMarked(!0),i.setMarked(!0);var r=n.getEdge();t.add(r.getLine())}}}return t},getEdgeRings:function(){this.computeNextCWEdges(),jr.label(this.dirEdges,-1);var t=jr.findLabeledEdgeRings(this.dirEdges);this.convertMaximalToMinimalEdgeRings(t);for(var e=new I,n=this.dirEdges.iterator();n.hasNext();){var i=n.next();if(!i.isMarked()&&!i.isInRing()){var r=this.findEdgeRing(i);e.add(r)}}return e},getNode:function(t){var e=this.findNode(t);return null===e&&(e=new Lr(t),this.add(e)),e},convertMaximalToMinimalEdgeRings:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getLabel(),r=jr.findIntersectionNodes(n,i);if(null!==r)for(var s=r.iterator();s.hasNext();){var o=s.next();jr.computeNextCCWEdges(o,i)}}},deleteDangles:function(){for(var t=this.findNodesOfDegree(1),e=new Q,n=new pe,i=t.iterator();i.hasNext();)n.push(i.next());for(;!n.isEmpty();){var r=n.pop();jr.deleteAllEdges(r);for(var s=r.getOutEdges().getEdges(),i=s.iterator();i.hasNext();){var o=i.next();o.setMarked(!0);var a=o.getSym();null!==a&&a.setMarked(!0);var u=o.getEdge();e.add(u.getLine());var l=o.getToNode();1===jr.getDegreeNonDeleted(l)&&n.push(l)}}return e},interfaces_:function(){return[]},getClass:function(){return jr}}),jr.findLabeledEdgeRings=function(t){for(var e=new I,n=1,i=t.iterator();i.hasNext();){var r=i.next();if(!(r.isMarked()||r.getLabel()>=0)){e.add(r);var s=Ur.findDirEdgesInRing(r);jr.label(s,n),n++}}return e},jr.getDegreeNonDeleted=function(t){for(var e=t.getOutEdges().getEdges(),n=0,i=e.iterator();i.hasNext();){var r=i.next();r.isMarked()||n++}return n},jr.deleteAllEdges=function(t){for(var e=t.getOutEdges().getEdges(),n=e.iterator();n.hasNext();){var i=n.next();i.setMarked(!0);var r=i.getSym();null!==r&&r.setMarked(!0)}},jr.label=function(t,e){for(var n=t.iterator();n.hasNext();){var i=n.next();i.setLabel(e)}},jr.computeNextCWEdges=function(t){for(var e=t.getOutEdges(),n=null,i=null,r=e.getEdges().iterator();r.hasNext();){var s=r.next();if(!s.isMarked()){if(null===n&&(n=s),null!==i){var o=i.getSym();o.setNext(s)}i=s}}if(null!==i){var o=i.getSym();o.setNext(n)}},jr.computeNextCCWEdges=function(t,e){for(var n=t.getOutEdges(),i=null,r=null,s=n.getEdges(),o=s.size()-1;o>=0;o--){var a=s.get(o),u=a.getSym(),l=null;a.getLabel()===e&&(l=a);var h=null;u.getLabel()===e&&(h=u),null===l&&null===h||(null!==h&&(r=h),null!==l&&(null!==r&&(r.setNext(l),r=null),null===i&&(i=l)))}null!==r&&(f.isTrue(null!==i),r.setNext(i))},jr.getDegree=function(t,e){for(var n=t.getOutEdges().getEdges(),i=0,r=n.iterator();r.hasNext();){var s=r.next();s.getLabel()===e&&i++}return i},jr.findIntersectionNodes=function(t,e){var n=t,i=null;do{var r=n.getFromNode();jr.getDegree(r,e)>1&&(null===i&&(i=new I),i.add(r)),n=n.getNext(),f.isTrue(null!==n,"found null DE in ring"),f.isTrue(n===t||!n.isInRing(),"found DE already in ring")}while(n!==t);return i},e(Wr.prototype,{getGeometry:function(){return null===this.geomFactory&&(this.geomFactory=new ie),this.polygonize(),this.extractOnlyPolygonal?this.geomFactory.buildGeometry(this.polyList):this.geomFactory.createGeometryCollection(ie.toGeometryArray(this.polyList))},getInvalidRingLines:function(){return this.polygonize(),this.invalidRingLines},findValidRings:function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isValid()?e.add(r):n.add(r.getLineString())}},polygonize:function(){if(null!==this.polyList)return null;if(this.polyList=new I,null===this.graph)return null;this.dangles=this.graph.deleteDangles(),this.cutEdges=this.graph.deleteCutEdges();var t=this.graph.getEdgeRings(),e=new I;this.invalidRingLines=new I,this.isCheckingRingsValid?this.findValidRings(t,e,this.invalidRingLines):e=t,this.findShellsAndHoles(e),Wr.assignHolesToShells(this.holeList,this.shellList),ho.sort(this.shellList,new Ur.EnvelopeComparator);var n=!0;this.extractOnlyPolygonal&&(Wr.findDisjointShells(this.shellList),n=!1),this.polyList=Wr.extractPolygons(this.shellList,n)},getDangles:function(){return this.polygonize(),this.dangles},getCutEdges:function(){return this.polygonize(),this.cutEdges},getPolygons:function(){return this.polygonize(),this.polyList},add:function(){if(b(arguments[0],v))for(var t=arguments[0],e=t.iterator();e.hasNext();){var n=e.next();this.add(n)}else if(arguments[0]instanceof wt){var i=arguments[0];this.geomFactory=i.getFactory(),null===this.graph&&(this.graph=new jr(this.geomFactory)),this.graph.addEdge(i)}else if(arguments[0]instanceof B){var r=arguments[0];r.apply(this.lineStringAdder)}},setCheckRingsValid:function(t){this.isCheckingRingsValid=t},findShellsAndHoles:function(t){this.holeList=new I,this.shellList=new I;for(var e=t.iterator();e.hasNext();){var n=e.next();n.computeHole(),n.isHole()?this.holeList.add(n):this.shellList.add(n)}},interfaces_:function(){return[]},getClass:function(){return Wr}}),Wr.findOuterShells=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getOuterHole();null===i||i.isProcessed()||(n.setIncluded(!0),i.setProcessed(!0))}},Wr.extractPolygons=function(t,e){for(var n=new I,i=t.iterator();i.hasNext();){var r=i.next();(e||r.isIncluded())&&n.add(r.getPolygon())}return n},Wr.assignHolesToShells=function(t,e){for(var n=t.iterator();n.hasNext();){var i=n.next();Wr.assignHoleToShell(i,e)}},Wr.assignHoleToShell=function(t,e){var n=Ur.findEdgeRingContaining(t,e);null!==n&&n.addHole(t)},Wr.findDisjointShells=function(t){Wr.findOuterShells(t);var e=null;do{e=!1;for(var n=t.iterator();n.hasNext();){var i=n.next();i.isIncludedSet()||(i.updateIncluded(),i.isIncludedSet()||(e=!0))}}while(e)},e(Jr.prototype,{filter:function(t){t instanceof wt&&this.p.add(t)},interfaces_:function(){return[q]},getClass:function(){return Jr}}),Wr.LineStringAdder=Jr;var Ro=Object.freeze({Polygonizer:Wr});e(Zr.prototype,{insertEdgeEnds:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.nodes.add(n)}},computeProperIntersectionIM:function(t,e){var n=this.arg[0].getGeometry().getDimension(),i=this.arg[1].getGeometry().getDimension(),r=t.hasProperIntersection(),s=t.hasProperInteriorIntersection();2===n&&2===i?r&&e.setAtLeast("212101212"):2===n&&1===i?(r&&e.setAtLeast("FFF0FFFF2"),s&&e.setAtLeast("1FFFFF1FF")):1===n&&2===i?(r&&e.setAtLeast("F0FFFFFF2"),s&&e.setAtLeast("1F1FFFFFF")):1===n&&1===i&&s&&e.setAtLeast("0FFFFFFFF")},labelIsolatedEdges:function(t,e){for(var n=this.arg[t].getEdgeIterator();n.hasNext();){var i=n.next();i.isIsolated()&&(this.labelIsolatedEdge(i,e,this.arg[e].getGeometry()),this.isolatedEdges.add(i))}},labelIsolatedEdge:function(t,e,n){if(n.getDimension()>0){var i=this.ptLocator.locate(t.getCoordinate(),n);t.getLabel().setAllLocations(e,i)}else t.getLabel().setAllLocations(e,L.EXTERIOR)},computeIM:function(){var t=new fe;if(t.set(L.EXTERIOR,L.EXTERIOR,2),!this.arg[0].getGeometry().getEnvelopeInternal().intersects(this.arg[1].getGeometry().getEnvelopeInternal()))return this.computeDisjointIM(t),t;this.arg[0].computeSelfNodes(this.li,!1),this.arg[1].computeSelfNodes(this.li,!1);var e=this.arg[0].computeEdgeIntersections(this.arg[1],this.li,!1);this.computeIntersectionNodes(0),this.computeIntersectionNodes(1),this.copyNodesAndLabels(0),this.copyNodesAndLabels(1),this.labelIsolatedNodes(),this.computeProperIntersectionIM(e,t);var n=new Dr,i=n.computeEdgeEnds(this.arg[0].getEdgeIterator());this.insertEdgeEnds(i);var r=n.computeEdgeEnds(this.arg[1].getEdgeIterator());return this.insertEdgeEnds(r),this.labelNodeEdges(),this.labelIsolatedEdges(0,1),this.labelIsolatedEdges(1,0),this.updateIM(t),t},labelNodeEdges:function(){for(var t=this.nodes.iterator();t.hasNext();){var e=t.next();e.getEdges().computeLabelling(this.arg)}},copyNodesAndLabels:function(t){for(var e=this.arg[t].getNodeIterator();e.hasNext();){var n=e.next(),i=this.nodes.addNode(n.getCoordinate());i.setLabel(t,n.getLabel().getLocation(t))}},labelIntersectionNodes:function(t){for(var e=this.arg[t].getEdgeIterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.getEdgeIntersectionList().iterator();r.hasNext();){var s=r.next(),o=this.nodes.find(s.coord);o.getLabel().isNull(t)&&(i===L.BOUNDARY?o.setLabelBoundary(t):o.setLabel(t,L.INTERIOR))}},labelIsolatedNode:function(t,e){var n=this.ptLocator.locate(t.getCoordinate(),this.arg[e].getGeometry());t.getLabel().setAllLocations(e,n)},computeIntersectionNodes:function(t){for(var e=this.arg[t].getEdgeIterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.getEdgeIntersectionList().iterator();r.hasNext();){var s=r.next(),o=this.nodes.addNode(s.coord);i===L.BOUNDARY?o.setLabelBoundary(t):o.getLabel().isNull(t)&&o.setLabel(t,L.INTERIOR)}},labelIsolatedNodes:function(){for(var t=this.nodes.iterator();t.hasNext();){var e=t.next(),n=e.getLabel();f.isTrue(n.getGeometryCount()>0,"node with empty label found"),e.isIsolated()&&(n.isNull(0)?this.labelIsolatedNode(e,0):this.labelIsolatedNode(e,1))}},updateIM:function(t){for(var e=this.isolatedEdges.iterator();e.hasNext();){var n=e.next();n.updateIM(t)}for(var i=this.nodes.iterator();i.hasNext();){var r=i.next();r.updateIM(t),r.updateIMFromEdges(t)}},computeDisjointIM:function(t){var e=this.arg[0].getGeometry();e.isEmpty()||(t.set(L.INTERIOR,L.EXTERIOR,e.getDimension()),t.set(L.BOUNDARY,L.EXTERIOR,e.getBoundaryDimension()));var n=this.arg[1].getGeometry();n.isEmpty()||(t.set(L.EXTERIOR,L.INTERIOR,n.getDimension()),t.set(L.EXTERIOR,L.BOUNDARY,n.getBoundaryDimension()))},interfaces_:function(){return[]},getClass:function(){return Zr}}),e(Kr.prototype,{isContainedInBoundary:function(t){if(t instanceof Rt)return!1;if(t instanceof Lt)return this.isPointContainedInBoundary(t);if(t instanceof wt)return this.isLineStringContainedInBoundary(t);for(var e=0;e0){var i=t;t=e,e=i}var r=!1;return e.y>t.y&&(r=!0),r?this.li.computeIntersection(t,e,this.diagDown0,this.diagDown1):this.li.computeIntersection(t,e,this.diagUp0,this.diagUp1),!!this.li.hasIntersection()},interfaces_:function(){return[]},getClass:function(){return Qr}}),e($r.prototype,{applyTo:function(t){for(var e=0;e=this.rectEnv.getMinX()&&e.getMaxX()<=this.rectEnv.getMaxX()?(this._intersects=!0,null):e.getMinY()>=this.rectEnv.getMinY()&&e.getMaxY()<=this.rectEnv.getMaxY()?(this._intersects=!0,null):void 0:null},intersects:function(){return this._intersects},interfaces_:function(){return[]},getClass:function(){return es}}),h(ns,$r),e(ns.prototype,{isDone:function(){return this._containsPoint===!0},visit:function(t){if(!(t instanceof Rt))return null;var e=t.getEnvelopeInternal();if(!this.rectEnv.intersects(e))return null;for(var n=new g,i=0;i<4;i++)if(this.rectSeq.getCoordinate(i,n),e.contains(n)&&Rn.containsPointInPolygon(n,t))return this._containsPoint=!0,null},containsPoint:function(){return this._containsPoint},interfaces_:function(){return[]},getClass:function(){return ns}}),h(is,$r),e(is.prototype,{intersects:function(){return this.hasIntersection},isDone:function(){return this.hasIntersection===!0},visit:function(t){var e=t.getEnvelopeInternal();if(!this.rectEnv.intersects(e))return null;var n=Vn.getLines(t);this.checkIntersectionWithLineStrings(n)},checkIntersectionWithLineStrings:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();if(this.checkIntersectionWithSegments(n),this.hasIntersection)return null}},checkIntersectionWithSegments:function(t){for(var e=t.getCoordinateSequence(),n=1;n=t.size()?null:t.get(e)},us.union=function(t){var e=new us(t);return e.union()},us.STRTREE_NODE_CAPACITY=4,e(ls.prototype,{unionNoOpt:function(t){var e=this.geomFact.createPoint();return si.overlayOp(t,e,ii.UNION)},unionWithNull:function(t,e){return null===t&&null===e?null:null===e?t:null===t?e:t.union(e)},extract:function(){if(b(arguments[0],v))for(var t=arguments[0],e=t.iterator();e.hasNext();){var n=e.next();this.extract(n)}else if(arguments[0]instanceof B){var i=arguments[0];null===this.geomFact&&(this.geomFact=i.getFactory()),as.extract(i,B.SORTINDEX_POLYGON,this.polygons),as.extract(i,B.SORTINDEX_LINESTRING,this.lines),as.extract(i,B.SORTINDEX_POINT,this.points)}},union:function t(){if(null===this.geomFact)return null;var e=null;if(this.points.size()>0){var n=this.geomFact.buildGeometry(this.points);e=this.unionNoOpt(n)}var i=null;if(this.lines.size()>0){var r=this.geomFact.buildGeometry(this.lines);i=this.unionNoOpt(r)}var s=null;this.polygons.size()>0&&(s=us.union(this.polygons));var o=this.unionWithNull(i,s),t=null;return t=null===e?o:null===o?e:os.union(e,o),null===t?this.geomFact.createGeometryCollection():t},interfaces_:function(){return[]},getClass:function(){return ls}}),ls.union=function(){if(1===arguments.length){if(b(arguments[0],v)){var t=arguments[0],e=new ls(t);return e.union()}if(arguments[0]instanceof B){var n=arguments[0],e=new ls(n);return e.union()}}else if(2===arguments.length){var i=arguments[0],r=arguments[1],e=new ls(i,r);return e.union()}};var To=Object.freeze({UnaryUnionOp:ls}),Mo=Object.freeze({IsValidOp:Xr,ConsistentAreaTester:kr}),Oo=Object.freeze({BoundaryOp:dt,IsSimpleOp:ji,buffer:wo,distance:So,linemerge:Lo,overlay:bo,polygonize:Ro,relate:Po,union:To,valid:Mo});h(hs,Ot.CoordinateOperation),e(hs.prototype,{editCoordinates:function(t,e){if(0===t.length)return null;for(var n=new Array(t.length).fill(null),i=0;i=2&&(i=!0);var r=e.edit(t,new hs(this.targetPM,i));return r},changePM:function(t,e){var n=this.createEditor(t.getFactory(),e);return n.edit(t,new Ot.NoOpGeometryOperation)},setRemoveCollapsedComponents:function(t){this.removeCollapsed=t},createFactory:function(t,e){var n=new ie(e,t.getSRID(),t.getCoordinateSequenceFactory());return n},setChangePrecisionModel:function(t){this.changePrecisionModel=t},reduce:function(t){var e=this.reducePointwise(t);return this.isPointwise?e:b(e,bt)?e.isValid()?e:this.fixPolygonalTopology(e):e},setPointwise:function(t){this.isPointwise=t},createEditor:function(t,e){if(t.getPrecisionModel()===e)return new Ot;var n=this.createFactory(t,e),i=new Ot(n);return i},interfaces_:function(){return[]},getClass:function(){return cs}}),cs.reduce=function(t,e){var n=new cs(e);return n.reduce(t)},cs.reducePointwise=function(t,e){var n=new cs(e);return n.setPointwise(!0),n.reduce(t)};var _o=Object.freeze({GeometryPrecisionReducer:cs});e(fs.prototype,{simplifySection:function(t,e){if(t+1===e)return null;this.seg.p0=this.pts[t],this.seg.p1=this.pts[e];for(var n=-1,i=t,r=t+1;rn&&(n=s,i=r)}if(n<=this.distanceTolerance)for(var r=t+1;rthis.distanceTolerance&&(s=!1);var l=new ce;if(l.p0=this.linePts[t],l.p1=this.linePts[e],i[0]=t,i[1]=e,this.hasBadIntersection(this.line,i,l)&&(s=!1),s){var r=this.flatten(t,e);return this.line.addToResult(r),null}this.simplifySection(t,u,n),this.simplifySection(u,e,n)},hasBadOutputIntersection:function(t){for(var e=this.outputIndex.query(t),n=e.iterator();n.hasNext();){var i=n.next();if(this.hasInteriorIntersection(i,t))return!0}return!1},findFurthestPoint:function(t,e,n,i){var r=new ce;r.p0=t[e],r.p1=t[n];for(var s=-1,o=e,a=e+1;as&&(s=l,o=a)}return i[0]=s,o},simplify:function(t){this.line=t,this.linePts=t.getParentCoordinates(),this.simplifySection(0,this.linePts.length-1,0)},remove:function(t,e,n){for(var i=e;i=e[0]&&ir&&(u=r),s.setMinimumLength(u),s.splitAt(o),s.getSplitPoint()},interfaces_:function(){return[Ss]},getClass:function(){return Ls}}),Ls.projectedSplitPoint=function(t,e){var n=t.getLineSegment(),i=n.project(e);return i},e(bs.prototype,{interfaces_:function(){return[]},getClass:function(){return bs}}),bs.triArea=function(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)},bs.isInCircleDDNormalized=function(t,e,n,i){var r=O.valueOf(t.x).selfSubtract(i.x),s=O.valueOf(t.y).selfSubtract(i.y),o=O.valueOf(e.x).selfSubtract(i.x),a=O.valueOf(e.y).selfSubtract(i.y),u=O.valueOf(n.x).selfSubtract(i.x),l=O.valueOf(n.y).selfSubtract(i.y),h=r.multiply(a).selfSubtract(o.multiply(s)),c=o.multiply(l).selfSubtract(u.multiply(a)),f=u.multiply(s).selfSubtract(r.multiply(l)),g=r.multiply(r).selfAdd(s.multiply(s)),d=o.multiply(o).selfAdd(a.multiply(a)),p=u.multiply(u).selfAdd(l.multiply(l)),v=g.selfMultiply(c).selfAdd(d.selfMultiply(f)).selfAdd(p.selfMultiply(h)),m=v.doubleValue()>0;return m},bs.checkRobustInCircle=function(t,e,n,i){var r=bs.isInCircleNonRobust(t,e,n,i),s=bs.isInCircleDDSlow(t,e,n,i),o=bs.isInCircleCC(t,e,n,i),a=wi.circumcentre(t,e,n);D.out.println("p radius diff a = "+Math.abs(i.distance(a)-t.distance(a))/t.distance(a)),r===s&&r===o||(D.out.println("inCircle robustness failure (double result = "+r+", DD result = "+s+", CC result = "+o+")"),D.out.println(se.toLineString(new Gt([t,e,n,i]))),D.out.println("Circumcentre = "+se.toPoint(a)+" radius = "+t.distance(a)),D.out.println("p radius diff a = "+Math.abs(i.distance(a)/t.distance(a)-1)),D.out.println("p radius diff b = "+Math.abs(i.distance(a)/e.distance(a)-1)),D.out.println("p radius diff c = "+Math.abs(i.distance(a)/n.distance(a)-1)),D.out.println())},bs.isInCircleDDFast=function(t,e,n,i){var r=O.sqr(t.x).selfAdd(O.sqr(t.y)).selfMultiply(bs.triAreaDDFast(e,n,i)),s=O.sqr(e.x).selfAdd(O.sqr(e.y)).selfMultiply(bs.triAreaDDFast(t,n,i)),o=O.sqr(n.x).selfAdd(O.sqr(n.y)).selfMultiply(bs.triAreaDDFast(t,e,i)),a=O.sqr(i.x).selfAdd(O.sqr(i.y)).selfMultiply(bs.triAreaDDFast(t,e,n)),u=r.selfSubtract(s).selfAdd(o).selfSubtract(a),l=u.doubleValue()>0;return l},bs.isInCircleCC=function(t,e,n,i){var r=wi.circumcentre(t,e,n),s=t.distance(r),o=i.distance(r)-s;return o<=0},bs.isInCircleNormalized=function(t,e,n,i){var r=t.x-i.x,s=t.y-i.y,o=e.x-i.x,a=e.y-i.y,u=n.x-i.x,l=n.y-i.y,h=r*a-o*s,c=o*l-u*a,f=u*s-r*l,g=r*r+s*s,d=o*o+a*a,p=u*u+l*l,v=g*c+d*f+p*h;return v>0},bs.isInCircleDDSlow=function(t,e,n,i){var r=O.valueOf(i.x),s=O.valueOf(i.y),o=O.valueOf(t.x),a=O.valueOf(t.y),u=O.valueOf(e.x),l=O.valueOf(e.y),h=O.valueOf(n.x),c=O.valueOf(n.y),f=o.multiply(o).add(a.multiply(a)).multiply(bs.triAreaDDSlow(u,l,h,c,r,s)),g=u.multiply(u).add(l.multiply(l)).multiply(bs.triAreaDDSlow(o,a,h,c,r,s)),d=h.multiply(h).add(c.multiply(c)).multiply(bs.triAreaDDSlow(o,a,u,l,r,s)),p=r.multiply(r).add(s.multiply(s)).multiply(bs.triAreaDDSlow(o,a,u,l,h,c)),v=f.subtract(g).add(d).subtract(p),m=v.doubleValue()>0;return m},bs.isInCircleNonRobust=function(t,e,n,i){var r=(t.x*t.x+t.y*t.y)*bs.triArea(e,n,i)-(e.x*e.x+e.y*e.y)*bs.triArea(t,n,i)+(n.x*n.x+n.y*n.y)*bs.triArea(t,e,i)-(i.x*i.x+i.y*i.y)*bs.triArea(t,e,n)>0;return r},bs.isInCircleRobust=function(t,e,n,i){return bs.isInCircleNormalized(t,e,n,i)},bs.triAreaDDSlow=function(t,e,n,i,r,s){return n.subtract(t).multiply(s.subtract(e)).subtract(i.subtract(e).multiply(r.subtract(t)))},bs.triAreaDDFast=function(t,e,n){var i=O.valueOf(e.x).selfSubtract(t.x).selfMultiply(O.valueOf(n.y).selfSubtract(t.y)),r=O.valueOf(e.y).selfSubtract(t.y).selfMultiply(O.valueOf(n.x).selfSubtract(t.x));return i.selfSubtract(r)},e(Rs.prototype,{circleCenter:function(t,e){var n=new Rs(this.getX(),this.getY()),i=this.bisector(n,t),r=this.bisector(t,e),s=new F(i,r),o=null;try{o=new Rs(s.getX(),s.getY())}catch(i){if(!(i instanceof S))throw i;D.err.println("a: "+n+" b: "+t+" c: "+e),D.err.println(i)}finally{}return o},dot:function(t){return this.p.x*t.getX()+this.p.y*t.getY()},magn:function(){return Math.sqrt(this.p.x*this.p.x+this.p.y*this.p.y)},getZ:function(){return this.p.z},bisector:function(t,e){var n=e.getX()-t.getX(),i=e.getY()-t.getY(),r=new F(t.getX()+n/2,t.getY()+i/2,1),s=new F(t.getX()-i+n/2,t.getY()+n+i/2,1);return new F(r,s)},equals:function(){if(1===arguments.length){var t=arguments[0];return this.p.x===t.getX()&&this.p.y===t.getY()}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.p.distance(e.getCoordinate())0},getX:function(){return this.p.x},crossProduct:function(t){return this.p.x*t.getY()-this.p.y*t.getX()},setZ:function(t){this.p.z=t},times:function(t){return new Rs(t*this.p.x,t*this.p.y)},cross:function(){return new Rs(this.p.y,-this.p.x)},leftOf:function(t){return this.isCCW(t.orig(),t.dest())},toString:function(){return"POINT ("+this.p.x+" "+this.p.y+")"},sub:function(t){return new Rs(this.p.x-t.getX(),this.p.y-t.getY())},getY:function(){return this.p.y},classify:function(t,e){var n=this,i=e.sub(t),r=n.sub(t),s=i.crossProduct(r);return s>0?Rs.LEFT:s<0?Rs.RIGHT:i.getX()*r.getX()<0||i.getY()*r.getY()<0?Rs.BEHIND:i.magn()n?10*e:10*n,this.frameVertex[0]=new Rs((t.getMaxX()+t.getMinX())/2,t.getMaxY()+i),this.frameVertex[1]=new Rs(t.getMinX()-i,t.getMinY()-i),this.frameVertex[2]=new Rs(t.getMaxX()+i,t.getMinY()-i),this.frameEnv=new C(this.frameVertex[0].getCoordinate(),this.frameVertex[1].getCoordinate()),this.frameEnv.expandToInclude(this.frameVertex[2].getCoordinate())},getTriangleCoordinates:function(t){var e=new zs;return this.visitTriangles(e,t),e.getTriangles()},getVertices:function(t){for(var e=new Q,n=this.quadEdges.iterator();n.hasNext();){var i=n.next(),r=i.orig();!t&&this.isFrameVertex(r)||e.add(r);var s=i.dest();!t&&this.isFrameVertex(s)||e.add(s)}return e},fetchTriangleToVisit:function(t,e,n,i){var r=t,s=0,o=!1;do{this.triEdges[s]=r,this.isFrameEdge(r)&&(o=!0);var a=r.sym();i.contains(a)||e.push(a),i.add(r),s++,r=r.lNext()}while(r!==t);return o&&!n?null:this.triEdges},getEdges:function(){if(0===arguments.length)return this.quadEdges;if(1===arguments.length){for(var t=arguments[0],e=this.getPrimaryEdges(!1),n=new Array(e.size()).fill(null),i=0,r=e.iterator();r.hasNext();){var s=r.next();n[i++]=t.createLineString([s.orig().getCoordinate(),s.dest().getCoordinate()])}return t.createMultiLineString(n)}},getVertexUniqueEdges:function(t){for(var e=new I,n=new Q,i=this.quadEdges.iterator();i.hasNext();){var r=i.next(),s=r.orig();n.contains(s)||(n.add(s),!t&&this.isFrameVertex(s)||e.add(r));var o=r.sym(),a=o.orig();n.contains(a)||(n.add(a),!t&&this.isFrameVertex(a)||e.add(o))}return e},getTriangleEdges:function(t){var e=new qs;return this.visitTriangles(e,t),e.getTriangleEdges()},getPrimaryEdges:function(t){this.visitedKey++;var e=new I,n=new pe;n.push(this.startingEdge);for(var i=new Q;!n.empty();){var r=n.pop();if(!i.contains(r)){var s=r.getPrimary();!t&&this.isFrameEdge(s)||e.add(s),n.push(r.oNext()),n.push(r.sym().oNext()),i.add(r),i.add(r.sym())}}return e},delete:function(t){Ts.splice(t,t.oPrev()),Ts.splice(t.sym(),t.sym().oPrev());var e=t.sym(),n=t.rot(),i=t.rot().sym();this.quadEdges.remove(t),this.quadEdges.remove(e),this.quadEdges.remove(n),this.quadEdges.remove(i),t.delete(),e.delete(),n.delete(),i.delete()},locateFromEdge:function(t,e){for(var n=0,i=this.quadEdges.size(),r=e;;){if(n++,n>i)throw new As(r.toLineSegment());if(t.equals(r.orig())||t.equals(r.dest()))break;if(t.rightOf(r))r=r.sym();else if(t.rightOf(r.oNext())){if(t.rightOf(r.dPrev()))break;r=r.dPrev()}else r=r.oNext()}return r},getTolerance:function(){return this.tolerance},getVoronoiCellPolygons:function(t){this.visitTriangles(new Gs,!0);for(var e=new I,n=this.getVertexUniqueEdges(!1),i=n.iterator();i.hasNext();){var r=i.next();e.add(this.getVoronoiCellPolygon(r,t))}return e},getVoronoiDiagram:function(t){var e=this.getVoronoiCellPolygons(t);return t.createGeometryCollection(ie.toGeometryArray(e))},getTriangles:function(t){for(var e=this.getTriangleCoordinates(!1),n=new Array(e.size()).fill(null),i=0,r=e.iterator();r.hasNext();){var s=r.next();n[i++]=t.createPolygon(t.createLinearRing(s),null)}return t.createGeometryCollection(n)},insertSite:function(t){var e=this.locate(t);if(t.equals(e.orig(),this.tolerance)||t.equals(e.dest(),this.tolerance))return e;var n=this.makeEdge(e.orig(),t);Ts.splice(n,e);var i=n;do n=this.connect(e,n.sym()),e=n.oPrev();while(e.lNext()!==i);return i},locate:function(){if(1===arguments.length){if(arguments[0]instanceof Rs){var t=arguments[0];return this.locator.locate(t)}if(arguments[0]instanceof g){var e=arguments[0];return this.locator.locate(new Rs(e))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=this.locator.locate(new Rs(n));if(null===r)return null;var s=r;r.dest().getCoordinate().equals2D(n)&&(s=r.sym());var o=s;do{if(o.dest().getCoordinate().equals2D(i))return o;o=o.oNext()}while(o!==s);return null}},interfaces_:function(){return[]},getClass:function(){return Fs}}),Fs.getTriangleEdges=function(t,e){if(e[0]=t,e[1]=e[0].lNext(),e[2]=e[1].lNext(),e[2].lNext()!==e[0])throw new i("Edges do not form a triangle")},e(Gs.prototype,{visit:function(t){for(var e=t[0].orig().getCoordinate(),n=t[1].orig().getCoordinate(),i=t[2].orig().getCoordinate(),r=wi.circumcentre(e,n,i),s=new Rs(r),o=0;o<3;o++)t[o].rot().setOrig(s)},interfaces_:function(){return[Ds]},getClass:function(){return Gs}}),e(qs.prototype,{getTriangleEdges:function(){return this.triList},visit:function(t){this.triList.add(t.clone())},interfaces_:function(){return[Ds]},getClass:function(){return qs}}),e(Bs.prototype,{visit:function(t){this.triList.add([t[0].orig(),t[1].orig(),t[2].orig()])},getTriangleVertices:function(){return this.triList},interfaces_:function(){return[Ds]},getClass:function(){return Bs}}),e(zs.prototype,{checkTriangleSize:function(t){var e="";t.length>=2?e=se.toLineString(t[0],t[1]):t.length>=1&&(e=se.toPoint(t[0]))},visit:function(t){this.coordList.clear();for(var e=0;e<3;e++){var n=t[e].orig();this.coordList.add(n.getCoordinate())}if(this.coordList.size()>0){this.coordList.closeRing();var i=this.coordList.toCoordinateArray();if(4!==i.length)return null;this.triCoords.add(i)}},getTriangles:function(){return this.triCoords},interfaces_:function(){return[Ds]},getClass:function(){return zs}}),Fs.TriangleCircumcentreVisitor=Gs,Fs.TriangleEdgesListVisitor=qs,Fs.TriangleVertexListVisitor=Bs,Fs.TriangleCoordinatesVisitor=zs,Fs.EDGE_COINCIDENCE_TOL_FACTOR=1e3,e(ks.prototype,{getLineSegment:function(){return this.ls},getEndZ:function(){var t=this.ls.getCoordinate(1);return t.z},getStartZ:function(){var t=this.ls.getCoordinate(0);return t.z},intersection:function(t){return this.ls.intersection(t.getLineSegment())},getStart:function(){return this.ls.getCoordinate(0)},getEnd:function(){return this.ls.getCoordinate(1)},getEndY:function(){var t=this.ls.getCoordinate(1);return t.y},getStartX:function(){var t=this.ls.getCoordinate(0);return t.x},equalsTopo:function(t){return this.ls.equalsTopo(t.getLineSegment())},getStartY:function(){var t=this.ls.getCoordinate(0);return t.y},setData:function(t){this.data=t},getData:function(){return this.data},getEndX:function(){var t=this.ls.getCoordinate(1);return t.x},toString:function(){return this.ls.toString()},interfaces_:function(){return[]},getClass:function(){return ks}}),e(Vs.prototype,{visit:function(t){},interfaces_:function(){return[]},getClass:function(){return Vs}}),e(Ys.prototype,{isRepeated:function(){return this.count>1},getRight:function(){return this.right},getCoordinate:function(){return this.p},setLeft:function(t){this.left=t},getX:function(){return this.p.x},getData:function(){return this.data},getCount:function(){return this.count},getLeft:function(){return this.left},getY:function(){return this.p.y},increment:function(){this.count=this.count+1},setRight:function(t){this.right=t},interfaces_:function(){return[]},getClass:function(){return Ys}}),e(Xs.prototype,{insert:function(){if(1===arguments.length){var t=arguments[0];return this.insert(t,null)}if(2===arguments.length){var e=arguments[0],n=arguments[1];if(null===this.root)return this.root=new Ys(e,n),this.root;if(this.tolerance>0){var i=this.findBestMatchNode(e);if(null!==i)return i.increment(),i}return this.insertExact(e,n)}},query:function(){var t=arguments,e=this;if(1===arguments.length){var n=arguments[0],i=new I;return this.query(n,i),i}if(2===arguments.length)if(arguments[0]instanceof C&&b(arguments[1],y))!function(){var n=t[0],i=t[1];e.queryNode(e.root,n,!0,{interfaces_:function(){return[Vs]},visit:function(t){i.add(t)}})}();else if(arguments[0]instanceof C&&b(arguments[1],Vs)){var r=arguments[0],s=arguments[1];this.queryNode(this.root,r,!0,s)}},queryNode:function(t,e,n,i){if(null===t)return null;var r=null,s=null,o=null;n?(r=e.getMinX(),s=e.getMaxX(),o=t.getX()):(r=e.getMinY(),s=e.getMaxY(),o=t.getY());var a=r0&&te)&&xr.isWithinDistance(this,t,e)},distance:function(t){return xr.distance(this,t)},isEquivalentClass:function(t){return this.getClass()===t.getClass()}});var Go="1.3.0 (6e65adb)";t.version=Go,t.algorithm=co,t.densify=fo,t.dissolve=go,t.geom=lo,t.geomgraph=po,t.index=yo,t.io=No,t.noding=Co,t.operation=Oo,t.precision=_o,t.simplify=Ao,t.triangulate=Fo,Object.defineProperty(t,"__esModule",{value:!0})})},{}],74:[function(t,e,n){"use strict";function i(t){var e=t.length;if(e<3){for(var n=new Array(e),i=0;i1&&r(t[o[h-2]],t[o[h-1]],l)<=0;)h-=1,o.pop();for(o.push(u),h=a.length;h>1&&r(t[a[h-2]],t[a[h-1]],l)>=0;)h-=1,a.pop();a.push(u)}for(var n=new Array(a.length+o.length-2),c=0,i=0,f=o.length;i0;--g)n[c++]=a[g];return n}e.exports=i;var r=t("robust-orientation")[3]},{"robust-orientation":78}],75:[function(t,e,n){function i(){if(!a){a=!0;for(var t,e=o.length;e;){t=o,o=[];for(var n=-1;++nn;){if(o-n>600){var u=o-n+1,l=e-n+1,h=Math.log(u),c=.5*Math.exp(2*h/3),f=.5*Math.sqrt(h*c*(u-c)/u)*(l-u/2<0?-1:1),g=Math.max(n,Math.floor(e-l*c/u+f)),d=Math.min(o,Math.floor(e+(u-l)*c/u+f));i(t,e,g,d,a)}var p=t[e],v=n,m=o;for(r(t,n,e),a(t[o],p)>0&&r(t,n,o);v0;)m--}0===a(t[n],p)?r(t,n,m):(m++,r(t,m,o)),m<=e&&(n=m+1),e<=m&&(o=m-1)}}function r(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function s(t,e){return te?1:0}e.exports=i},{}],77:[function(t,e,n){"use strict";function i(t,e){return this instanceof i?(this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),void this.clear()):new i(t,e)}function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-(1/0),maxY:-(1/0)}}function m(t,e,n,i,r){for(var s,o=[e,n];o.length;)n=o.pop(),e=o.pop(),n-e<=i||(s=e+Math.ceil((n-e)/i/2)*i,y(t,s,e,n,r),o.push(e,s,s,n))}e.exports=i;var y=t("quickselect");i.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],i=this.toBBox;if(!p(t,e))return n;for(var r,s,o,a,u=[];e;){for(r=0,s=e.children.length;r=0&&s[e].children.length>this._maxEntries;)this._split(s,e),e--;this._adjustParentBBoxes(r,s,e)},_split:function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var o=this._chooseSplitIndex(n,r,i),a=v(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,s(n,this.toBBox),s(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},_splitRoot:function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,s(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var i,r,s,a,u,l,c,f;for(l=c=1/0,i=e;i<=n-e;i++)r=o(t,0,i,this.toBBox),s=o(t,i,n,this.toBBox),a=g(r,s),u=h(r)+h(s),a=e;r--)s=t.children[r],a(h,t.leaf?u(s):s),f+=c(h);return f},_adjustParentBBoxes:function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():s(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}}},{quickselect:76}],78:[function(t,e,n){"use strict";function i(t,e){for(var n=new Array(t.length-1),i=1;i>1;return["sum(",o(t.slice(0,e)),",",o(t.slice(e)),")"].join("")}function a(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],n=0;n0){if(s<=0)return o;i=r+s}else{if(!(r<0))return o;if(s>=0)return o;i=-(r+s)}var a=m*i;return o>=a||o<=-a?o:x(t,e,n)},function(t,e,n,i){var r=t[0]-i[0],s=e[0]-i[0],o=n[0]-i[0],a=t[1]-i[1],u=e[1]-i[1],l=n[1]-i[1],h=t[2]-i[2],c=e[2]-i[2],f=n[2]-i[2],g=s*l,d=o*u,p=o*a,v=r*l,m=r*u,x=s*a,I=h*(g-d)+c*(p-v)+f*(m-x),N=(Math.abs(g)+Math.abs(d))*Math.abs(h)+(Math.abs(p)+Math.abs(v))*Math.abs(c)+(Math.abs(m)+Math.abs(x))*Math.abs(f),C=y*N;return I>C||-I>C?I:E(t,e,n,i)}];h()},{"robust-scale":79,"robust-subtract":80,"robust-sum":81,"two-product":86}],79:[function(t,e,n){"use strict";function i(t,e){var n=t.length;if(1===n){var i=r(t[0],e);return i[0]?i:[i[1]]}var o=new Array(2*n),a=[.1,.1],u=[.1,.1],l=0;r(t[0],e,a),a[0]&&(o[l++]=a[0]);for(var h=1;h=r?(s=g,h+=1,h=r?(s=g,h+=1,h>1,a=o(t[s],e);a<=0?(0===a&&(r=s),n=s+1):a>0&&(i=s-1)}return r}function c(t,e){for(var n=new Array(t.length),i=0,r=n.length;i=t.length||0!==o(t[p],s))break}return n}function f(t,e){if(!e)return c(l(d(t,0)),t,0);for(var n=new Array(e),i=0;i>>h&1&&l.push(r[h]);e.push(l)}return u(e)}function d(t,e){if(e<0)return[];for(var n=[],i=(1<1?(i=n.x,r=n.y):a>0&&(i+=s*a,r+=o*a)}return s=t.x-i,o=t.y-r,s*s+o*o}function r(t,n){for(var i,r=t[0],s=[r],o=1,a=t.length;on&&(s.push(i),r=i);return r!==i&&s.push(i),s}function s(t,e){var n,r,s,o,a=t.length,u="undefined"!=typeof Uint8Array?Uint8Array:Array,l=new u(a),h=0,c=a-1,f=[],g=[];for(l[h]=l[c]=1;c;){for(r=0,n=h+1;nr&&(o=n,r=s);r>e&&(l[o]=1,f.push(h,o,o,c)),c=f.pop(),h=f.pop()}for(n=0;n0}},{}],85:[function(t,e,n){function i(t,e){var n=t[0],i=t[1],r=e[0],s=e[1];return o([n,r,s,n])!=o([i,r,s,i])&&o([n,i,r,n])!=o([n,i,s,n])}function r(t,e){for(var n=0;n=3&&(i.depth=arguments[2]),arguments.length>=4&&(i.colors=arguments[3]),p(e)?i.showHidden=e:e&&n._extend(i,e),I(i.showHidden)&&(i.showHidden=!1),I(i.depth)&&(i.depth=2),I(i.colors)&&(i.colors=!1),I(i.customInspect)&&(i.customInspect=!0),i.colors&&(i.stylize=s),u(i,t,i.depth)}function s(t,e){var n=r.styles[e];return n?"["+r.colors[n][0]+"m"+t+"["+r.colors[n][1]+"m":t}function o(t,e){return t}function a(t){var e={};return t.forEach(function(t,n){e[t]=!0}),e}function u(t,e,i){if(t.customInspect&&e&&L(e.inspect)&&e.inspect!==n.inspect&&(!e.constructor||e.constructor.prototype!==e)){var r=e.inspect(i,t);return x(r)||(r=u(t,r,i)),r}var s=l(t,e);if(s)return s;var o=Object.keys(e),p=a(o);if(t.showHidden&&(o=Object.getOwnPropertyNames(e)),S(e)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return h(e);if(0===o.length){if(L(e)){var v=e.name?": "+e.name:"";return t.stylize("[Function"+v+"]","special")}if(N(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(w(e))return t.stylize(Date.prototype.toString.call(e),"date");if(S(e))return h(e)}var m="",y=!1,E=["{","}"];if(d(e)&&(y=!0,E=["[","]"]),L(e)){var I=e.name?": "+e.name:"";m=" [Function"+I+"]"}if(N(e)&&(m=" "+RegExp.prototype.toString.call(e)),w(e)&&(m=" "+Date.prototype.toUTCString.call(e)),S(e)&&(m=" "+h(e)),0===o.length&&(!y||0==e.length))return E[0]+m+E[1];if(i<0)return N(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special");t.seen.push(e);var C;return C=y?c(t,e,i,p,o):o.map(function(n){return f(t,e,i,p,n,y)}),t.seen.pop(),g(C,m,E)}function l(t,e){if(I(e))return t.stylize("undefined","undefined");if(x(e)){var n="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(n,"string")}return y(e)?t.stylize(""+e,"number"):p(e)?t.stylize(""+e,"boolean"):v(e)?t.stylize("null","null"):void 0}function h(t){return"["+Error.prototype.toString.call(t)+"]"}function c(t,e,n,i,r){for(var s=[],o=0,a=e.length;o-1&&(a=s?a.split("\n").map(function(t){return" "+t}).join("\n").substr(2):"\n"+a.split("\n").map(function(t){return" "+t}).join("\n"))):a=t.stylize("[Circular]","special")),I(o)){if(s&&r.match(/^\d+$/))return a;o=JSON.stringify(""+r),o.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function g(t,e,n){var i=0,r=t.reduce(function(t,e){return i++,e.indexOf("\n")>=0&&i++,t+e.replace(/\u001b\[\d\d?m/g,"").length+1},0);return r>60?n[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+n[1]:n[0]+e+" "+t.join(", ")+" "+n[1]}function d(t){return Array.isArray(t)}function p(t){return"boolean"==typeof t}function v(t){return null===t}function m(t){return null==t}function y(t){return"number"==typeof t}function x(t){return"string"==typeof t}function E(t){return"symbol"==typeof t}function I(t){return void 0===t}function N(t){return C(t)&&"[object RegExp]"===R(t)}function C(t){return"object"==typeof t&&null!==t}function w(t){return C(t)&&"[object Date]"===R(t)}function S(t){return C(t)&&("[object Error]"===R(t)||t instanceof Error)}function L(t){return"function"==typeof t}function b(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||"undefined"==typeof t}function R(t){return Object.prototype.toString.call(t)}function P(t){return t<10?"0"+t.toString(10):t.toString(10)}function T(){var t=new Date,e=[P(t.getHours()),P(t.getMinutes()),P(t.getSeconds())].join(":");return[t.getDate(),D[t.getMonth()],e].join(" ")}function M(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var O=/%[sdj%]/g;n.format=function(t){if(!x(t)){for(var e=[],n=0;n=s)return t;switch(t){case"%s":return String(i[n++]);case"%d":return Number(i[n++]);case"%j":try{return JSON.stringify(i[n++])}catch(t){return"[Circular]"}default:return t}}),a=i[n];n=u&&l===a.length-1);l++){if(u>=e){var c=e-u;if(c){var h=o(a[l],a[l-1])-180;return s(a[l],c,h,n)}return r(a[l])}u+=i(a[l],a[l+1],n)}return r(a[a.length-1])}},{"@turf/bearing":3,"@turf/destination":5,"@turf/distance":8,"@turf/helpers":11}],3:[function(t,e,n){function i(t,e,n){if(!0===n)return r(t,e);var i=Math.PI/180,s=180/Math.PI,a=o(t),u=o(e),l=i*a[0],c=i*u[0],h=i*a[1],f=i*u[1],p=Math.sin(c-l)*Math.cos(f),d=Math.cos(h)*Math.sin(f)-Math.sin(h)*Math.cos(f)*Math.cos(c-l);return s*Math.atan2(p,d)}function r(t,e){var n=i(e,t);return n=(n+180)%360}var o=t("@turf/invariant").getCoord;e.exports=i},{"@turf/invariant":4}],4:[function(t,e,n){function i(t){if(!t)throw new Error("No obj passed");var e=r(t);if(e.length>1&&"number"==typeof e[0]&&"number"==typeof e[1])return e;throw new Error("Coordinate is not a valid Point")}function r(t){if(!t)throw new Error("No obj passed");var e;if(t.length?e=t:t.coordinates?e=t.coordinates:t.geometry&&t.geometry.coordinates&&(e=t.geometry.coordinates),e)return o(e),e;throw new Error("No valid coordinates")}function o(t){if(t.length>1&&"number"==typeof t[0]&&"number"==typeof t[1])return!0;if(Array.isArray(t[0])&&t[0].length)return o(t[0]);throw new Error("coordinates must only contain numbers")}function s(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function a(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function u(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var i=0;i is required");if(t.geometry)return t.geometry;if(t.coordinates||t.geometries)return t;throw new Error(" must be a Feature or Geometry Object")}function c(t){return l(t).type}e.exports={geojsonType:s,collectionOf:u,featureOf:a,getCoord:i,getCoords:r,containsNumber:o,getGeom:l,getGeomType:c}},{}],5:[function(t,e,n){var i=t("@turf/invariant").getCoord,r=t("@turf/helpers"),o=r.point,s=r.distanceToRadians;e.exports=function(t,e,n,r){var a=Math.PI/180,u=180/Math.PI,l=i(t),c=a*l[0],h=a*l[1],f=a*n,p=s(e,r),d=Math.asin(Math.sin(h)*Math.cos(p)+Math.cos(h)*Math.sin(p)*Math.cos(f)),g=c+Math.atan2(Math.sin(f)*Math.sin(p)*Math.cos(h),Math.cos(p)-Math.sin(h)*Math.sin(d));return o([u*g,u*d])}},{"@turf/helpers":6,"@turf/invariant":7}],6:[function(t,e,n){function i(t,e){if(!t)throw new Error("No geometry passed");return{type:"Feature",properties:e||{},geometry:t}}function r(t,e){if(!t)throw new Error("No coordinates passed");if(void 0===t.length)throw new Error("Coordinates must be an array");if(t.length<2)throw new Error("Coordinates must be at least 2 numbers long");if("number"!=typeof t[0]||"number"!=typeof t[1])throw new Error("Coordinates must numbers");return i({type:"Point",coordinates:t},e)}function o(t,e){if(!t)throw new Error("No coordinates passed");for(var n=0;n=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function p(t,e){if(void 0===t||null===t)throw new Error("radians is required");var n=E[e||"kilometers"];if(!n)throw new Error("units is invalid");return t*n}function d(t,e){if(void 0===t||null===t)throw new Error("distance is required");var n=E[e||"kilometers"];if(!n)throw new Error("units is invalid");return t/n}function g(t,e){return y(d(t,e))}function v(t){if(null===t||void 0===t)throw new Error("bearing is required");var e=t%360;return e<0&&(e+=360),e}function y(t){if(null===t||void 0===t)throw new Error("radians is required");return t%(2*Math.PI)*180/Math.PI}function m(t){if(null===t||void 0===t)throw new Error("degrees is required");return t%360*Math.PI/180}function x(t,e,n){if(null===t||void 0===t)throw new Error("distance is required");if(!(t>=0))throw new Error("distance must be a positive number");return p(d(t,e),n||"kilometers")}var E={miles:3960,nauticalmiles:3441.145,degrees:57.2957795,radians:1,inches:250905600,yards:6969600,meters:6373e3,metres:6373e3,centimeters:6373e5,centimetres:6373e5,kilometers:6373,kilometres:6373,feet:20908792.65};e.exports={feature:i,featureCollection:a,geometryCollection:h,point:r,multiPoint:l,lineString:s,multiLineString:u,polygon:o,multiPolygon:c,radiansToDistance:p,distanceToRadians:d,distanceToDegrees:g,radians2degrees:y,degrees2radians:m,bearingToAngle:v,convertDistance:x,round:f}},{}],7:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],8:[function(t,e,n){var i=t("@turf/invariant").getCoord,r=t("@turf/helpers").radiansToDistance;e.exports=function(t,e,n){var o=Math.PI/180,s=i(t),a=i(e),u=o*(a[1]-s[1]),l=o*(a[0]-s[0]),c=o*s[1],h=o*a[1],f=Math.pow(Math.sin(u/2),2)+Math.pow(Math.sin(l/2),2)*Math.cos(c)*Math.cos(h);return r(2*Math.atan2(Math.sqrt(f),Math.sqrt(1-f)),n)}},{"@turf/helpers":9,"@turf/invariant":10}],9:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],10:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],11:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],12:[function(t,e,n){var i=t("@mapbox/geojson-area").geometry,r=t("@turf/meta").geomReduce;e.exports=function(t){return r(t,function(t,e){return t+i(e)},0)}},{"@mapbox/geojson-area":13,"@turf/meta":14}],13:[function(t,e,n){function i(t){var e,n=0;switch(t.type){case"Polygon":return r(t.coordinates);case"MultiPolygon":for(e=0;e0){e+=Math.abs(o(t[0]));for(var n=1;n2){for(l=0;l0&&(r[0][0]===r[r.length-1][0]&&r[0][1]===r[r.length-1][1]||r.push(r[0]),n.push(r))}return n}function r(t){return t.geometry?t.geometry.type:t.type}var o=t("@turf/helpers"),s=t("lineclip"),a=t("@turf/invariant").getCoords,u=o.lineString,l=o.multiLineString,c=o.polygon,h=o.multiPolygon;e.exports=function(t,e){var n=r(t),o=a(t),f=t.properties;switch(n){case"LineString":case"MultiLineString":var p=[];return"LineString"===n&&(o=[o]),o.forEach(function(t){s(t,e,p)}),1===p.length?u(p[0],f):l(p,f);case"Polygon":return c(i(o,e),f);case"MultiPolygon":return h(o.map(function(t){return i(t,e)}),f);default:throw new Error("geometry "+n+" not supported")}}},{"@turf/helpers":17,"@turf/invariant":18,lineclip:19}],17:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],18:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],19:[function(t,e,n){"use strict";function i(t,e,n){var i,r,a,u,l,c=t.length,h=s(t[0],e),f=[];for(n||(n=[]),i=1;ie[2]&&(n|=2),t[1]e[3]&&(n|=8),n}e.exports=i,i.polyline=i,i.polygon=r},{}],20:[function(t,e,n){var i=t("@turf/helpers").polygon;e.exports=function(t){var e=[t[0],t[1]],n=[t[0],t[3]],r=[t[2],t[3]],o=[t[2],t[1]];return i([[e,o,r,n,e]])}},{"@turf/helpers":21}],21:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],22:[function(t,e,n){var i=t("@turf/meta").coordEach;e.exports=function(t){var e=[1/0,1/0,-1/0,-1/0];return i(t,function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]t&&(e.push(i),n=r)}return e},i.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}},i.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var i=Math.floor((this.points.length-1)*n),r=(this.length-1)*n-i;return function(t,e,n,i,r){var o=function(t){var e=t*t;return[e*t,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:r.x*o[0]+i.x*o[1]+n.x*o[2]+e.x*o[3],y:r.y*o[0]+i.y*o[1]+n.y*o[2]+e.y*o[3],z:r.z*o[0]+i.z*o[1]+n.z*o[2]+e.z*o[3]}}(r,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},e.exports=i},{}],29:[function(t,e,n){function i(t,e,n,u){var c=t.properties||{},f="Feature"===t.type?t.geometry:t;switch(f.type){case"Point":return h(f.coordinates,e,u,n,c);case"GeometryCollection":var p=[];return g(t,function(t){var r=i(t,e,n,u);r&&p.push(r)}),y(p)}var v=m(x(e,n),"meters"),E=a(t),I={type:f.type,coordinates:o(f.coordinates,E)},w=new l.io.GeoJSONReader,N=w.read(I),b=N.buffer(v);if(b=(new l.io.GeoJSONWriter).write(b),!r(b.coordinates))return b.coordinates=s(b.coordinates,E),d(b,c)}function r(t){return Array.isArray(t[0])?r(t[0]):isNaN(t[0])}function o(t,e){return"object"!=typeof t[0]?e(t):t.map(function(t){return o(t,e)})}function s(t,e){return"object"!=typeof t[0]?e.invert(t):t.map(function(t){return s(t,e)})}function a(t){var e=f(t).geometry.coordinates.reverse(),n=e.map(function(t){return-t});return u.geoTransverseMercator().center(e).rotate(n).scale(6373e3)}var u=t("d3-geo"),l=t("jsts"),c=t("@turf/meta"),h=t("@turf/circle"),f=t("@turf/center"),p=t("@turf/helpers"),d=p.feature,g=c.geomEach,v=c.featureEach,y=p.featureCollection,m=p.radiansToDistance,x=p.distanceToRadians;e.exports=function(t,e,n,r){if(!t)throw new Error("geojson is required");if(void 0===e)throw new Error("radius is required");if(r<=0)throw new Error("steps must be greater than 0");r=r||64,n=n||"kilometers";var o=[];switch(t.type){case"GeometryCollection":return g(t,function(t){var s=i(t,e,n,r);s&&o.push(s)}),y(o);case"FeatureCollection":return v(t,function(t){var s=i(t,e,n,r);s&&v(s,function(t){t&&o.push(t)})}),y(o)}return i(t,e,n,r)}},{"@turf/center":30,"@turf/circle":34,"@turf/helpers":39,"@turf/meta":40,"d3-geo":42,jsts:43}],30:[function(t,e,n){var i=t("@turf/bbox"),r=t("@turf/helpers").point;e.exports=function(t,e){var n=i(t),o=(n[0]+n[2])/2,s=(n[1]+n[3])/2;return r([o,s],e)}},{"@turf/bbox":31,"@turf/helpers":33}],31:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":32,dup:22}],32:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],33:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],34:[function(t,e,n){var i=t("@turf/destination"),r=t("@turf/helpers").polygon;e.exports=function(t,e,n,o,s){if(!t)throw new Error("center is required");if(!e)throw new Error("radius is required");n=n||64,s=s||t.properties||{};for(var a=[],u=0;u=0?(o>=b?10:o>=C?5:o>=S?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=b?10:o>=C?5:o>=S?2:1)}function r(t,e,n){var i=Math.abs(e-t)/Math.max(0,n),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=b?r*=10:o>=C?r*=5:o>=S&&(r*=2),ee?1:t>=e?0:NaN},a=function(t){return 1===t.length&&(t=e(t)),{left:function(e,n,i,r){for(null==i&&(i=0),null==r&&(r=e.length);i>>1;t(e[o],n)<0?i=o+1:r=o}return i},right:function(e,n,i,r){for(null==i&&(i=0),null==r&&(r=e.length);i>>1;t(e[o],n)>0?r=o:i=o+1}return i}}},u=a(s),l=u.right,c=u.left,h=function(t,e){null==e&&(e=n);for(var i=0,r=t.length-1,o=t[0],s=new Array(r<0?0:r);it?1:e>=t?0:NaN},d=function(t){return null===t?NaN:+t},g=function(t,e){var n,i,r=t.length,o=0,s=-1,a=0,u=0;if(null==e)for(;++s1)return u/(o-1)},v=function(t,e){var n=g(t,e);return n?Math.sqrt(n):n},y=function(t,e){var n,i,r,o=t.length,s=-1;if(null==e){for(;++s=n)for(i=r=n;++sn&&(i=n),r=n)for(i=r=n;++sn&&(i=n),r0)for(t=Math.ceil(t/s),e=Math.floor(e/s),o=new Array(r=Math.ceil(e-t+1));++uf;)p.pop(),--d;var g,v=new Array(d+1);for(o=0;o<=d;++o)g=v[o]=[],g.x0=o>0?p[o-1]:h,g.x1=o=1)return+n(t[i-1],i-1,t);var i,r=(i-1)*e,o=Math.floor(r),s=+n(t[o],o,t);return s+(+n(t[o+1],o+1,t)-s)*(r-o)}},T=function(t,e,n){return t=E.call(t,d).sort(s),Math.ceil((n-e)/(2*(P(t,.75)-P(t,.25))*Math.pow(t.length,-1/3)))},O=function(t,e,n){return Math.ceil((n-e)/(3.5*v(t)*Math.pow(t.length,-1/3)))},_=function(t,e){var n,i,r=t.length,o=-1;if(null==e){for(;++o=n)for(i=n;++oi&&(i=n)}else for(;++o=n)for(i=n;++oi&&(i=n);return i},A=function(t,e){var n,i=t.length,r=i,o=-1,s=0;if(null==e)for(;++o=0;)for(i=t[r],e=i.length;--e>=0;)n[--s]=i[e];return n},G=function(t,e){var n,i,r=t.length,o=-1;if(null==e){for(;++o=n)for(i=n;++on&&(i=n)}else for(;++o=n)for(i=n;++on&&(i=n);return i},q=function(t,e){for(var n=e.length,i=new Array(n);n--;)i[n]=t[e[n]];return i},k=function(t,e){if(n=t.length){var n,i,r=0,o=0,a=t[o];for(null==e&&(e=s);++r1?0:t<-1?je:Math.acos(t)}function o(t){return t>1?ze:t<-1?-ze:Math.asin(t)}function s(t){return(t=en(t/2))*t}function a(){}function u(t,e){t&&an.hasOwnProperty(t.type)&&an[t.type](t,e)}function l(t,e,n){var i,r=-1,o=t.length-n;for(e.lineStart();++r=0?1:-1,r=i*n,o=Ze(e),s=en(e),a=fe*s,u=he*o+a*Ze(r),l=a*i*en(r);ln.add(Je(l,u)),ce=t,he=o,fe=s}function g(t){return[Je(t[1],t[0]),o(t[2])]}function v(t){var e=t[0],n=t[1],i=Ze(n);return[i*Ze(e),i*en(e),en(n)]}function y(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function m(t,e){return[t[1]*e[2]-t[2]*e[1],t[2]*e[0]-t[0]*e[2],t[0]*e[1]-t[1]*e[0]]}function x(t,e){t[0]+=e[0],t[1]+=e[1],t[2]+=e[2]}function E(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function I(t){var e=rn(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=e,t[1]/=e,t[2]/=e}function w(t,e){Ie.push(we=[pe=t,ge=t]),eve&&(ve=e)}function N(t,e){var n=v([t*Ue,e*Ue]);if(Ee){var i=m(Ee,n),r=[i[1],-i[0],0],o=m(r,i);I(o),o=g(o);var s,a=t-ye,u=a>0?1:-1,l=o[0]*Ye*u,c=We(a)>180;c^(u*yeve&&(ve=s):(l=(l+360)%360-180,c^(u*yeve&&(ve=e))),c?tR(pe,ge)&&(ge=t):R(t,ge)>R(pe,ge)&&(pe=t):ge>=pe?(tge&&(ge=t)):t>ye?R(pe,t)>R(pe,ge)&&(ge=t):R(t,ge)>R(pe,ge)&&(pe=t)}else Ie.push(we=[pe=t,ge=t]);eve&&(ve=e),Ee=n,ye=t}function b(){dn.point=N}function C(){we[0]=pe,we[1]=ge,dn.point=w,Ee=null}function S(t,e){if(Ee){var n=t-ye;pn.add(We(n)>180?n+(n>0?360:-360):n)}else me=t,xe=e;hn.point(t,e),N(t,e)}function M(){hn.lineStart()}function L(){S(me,xe),hn.lineEnd(),We(pn)>Be&&(pe=-(ge=180)),we[0]=pe,we[1]=ge,Ee=null}function R(t,e){return(e-=t)<0?e+360:e}function P(t,e){return t[0]-e[0]}function T(t,e){return t[0]<=t[1]?t[0]<=e&&e<=t[1]:eje?t-Xe:t<-je?t+Xe:t,e]}function V(t,e,n){return(t%=Xe)?e||n?xn(Y(t),U(e,n)):Y(t):e||n?U(e,n):z}function X(t){return function(e,n){return e+=t,[e>je?e-Xe:e<-je?e+Xe:e,n]}}function Y(t){var e=X(t);return e.invert=X(-t),e}function U(t,e){function n(t,e){var n=Ze(e),u=Ze(t)*n,l=en(t)*n,c=en(e),h=c*i+u*r;return[Je(l*s-h*a,u*i-c*r),o(h*s+l*a)]}var i=Ze(t),r=en(t),s=Ze(e),a=en(e);return n.invert=function(t,e){var n=Ze(e),u=Ze(t)*n,l=en(t)*n,c=en(e),h=c*s-l*a;return[Je(l*s+c*a,u*i+h*r),o(h*i-u*r)]},n}function W(t,e,n,i,r,o){if(n){var s=Ze(e),a=en(e),u=i*n;null==r?(r=e+i*Xe,o=e-u/2):(r=H(s,r),o=H(s,o),(i>0?ro)&&(r+=i*Xe));for(var l,c=r;i>0?c>o:c0)do{u.point(0===c||3===c?t:i,c>1?r:n)}while((c=(c+s+4)%4)!==h);else u.point(o[0],o[1])}function a(e,r){return We(e[0]-t)0?0:3:We(e[0]-i)0?2:1:We(e[1]-n)0?1:0:r>0?3:2}function u(t,e){return l(t.x,e.x)}function l(t,e){var n=a(t,1),i=a(e,1);return n!==i?n-i:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(a){function l(t,e){o(t,e)&&M.point(t,e)}function c(){for(var e=0,n=0,i=y.length;nr&&(h-o)*(r-s)>(f-s)*(t-o)&&++e:f<=r&&(h-o)*(r-s)<(f-s)*(t-o)&&--e;return e}function h(){M=L,v=[],y=[],S=!0}function f(){var t=c(),n=S&&t,i=(v=e.merge(v)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),s(null,null,1,a),a.lineEnd()),i&&Fn(v,u,t,s,a),a.polygonEnd()),M=a,v=y=m=null}function p(){R.point=g,y&&y.push(m=[]),C=!0,b=!1,w=N=NaN}function d(){v&&(g(x,E),I&&b&&L.rejoin(),v.push(L.result())),R.point=l,b&&M.lineEnd()}function g(e,s){var a=o(e,s);if(y&&m.push([e,s]),C)x=e,E=s,I=a,C=!1,a&&(M.lineStart(),M.point(e,s));else if(a&&b)M.point(e,s);else{var u=[w=Math.max(qn,Math.min(Gn,w)),N=Math.max(qn,Math.min(Gn,N))],l=[e=Math.max(qn,Math.min(Gn,e)),s=Math.max(qn,Math.min(Gn,s))];An(u,l,t,n,i,r)?(b||(M.lineStart(),M.point(u[0],u[1])),M.point(l[0],l[1]),a||M.lineEnd(),S=!1):a&&(M.lineStart(),M.point(e,s),S=!1)}w=e,N=s,b=a}var v,y,m,x,E,I,w,N,b,C,S,M=a,L=_n(),R={point:l,lineStart:p,lineEnd:d,polygonStart:h,polygonEnd:f};return R}}function Q(){Vn.point=tt,Vn.lineEnd=$}function $(){Vn.point=Vn.lineEnd=a}function tt(t,e){t*=Ue,e*=Ue,En=t,In=en(e),wn=Ze(e),Vn.point=et}function et(t,e){t*=Ue,e*=Ue;var n=en(e),i=Ze(e),r=We(t-En),o=Ze(r),s=en(r),a=i*s,u=wn*n-In*i*o,l=In*n+wn*i*o;zn.add(Je(rn(a*a+u*u),l)),En=t,In=n,wn=i}function nt(t,e){return!(!t||!Jn.hasOwnProperty(t.type))&&Jn[t.type](t,e)}function it(t,e){return 0===Wn(t,e)}function rt(t,e){var n=Wn(t[0],t[1]);return Wn(t[0],e)+Wn(e,t[1])<=n+Be}function ot(t,e){return!!jn(t.map(st),at(e))}function st(t){return t=t.map(at),t.pop(),t}function at(t){return[t[0]*Ue,t[1]*Ue]}function ut(t,n,i){var r=e.range(t,n-Be,i).concat(n);return function(t){return r.map(function(e){return[t,e]})}}function lt(t,n,i){var r=e.range(t,n-Be,i).concat(n);return function(t){return r.map(function(e){return[e,t]})}}function ct(){function t(){return{type:"MultiLineString",coordinates:n()}}function n(){return e.range(Ke(s/y)*y,o,y).map(p).concat(e.range(Ke(c/m)*m,l,m).map(d)).concat(e.range(Ke(r/g)*g,i,g).filter(function(t){return We(t%y)>Be}).map(h)).concat(e.range(Ke(u/v)*v,a,v).filter(function(t){return We(t%m)>Be}).map(f))}var i,r,o,s,a,u,l,c,h,f,p,d,g=10,v=g,y=90,m=360,x=2.5;return t.lines=function(){return n().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[p(s).concat(d(l).slice(1),p(o).reverse().slice(1),d(c).reverse().slice(1))]}},t.extent=function(e){return arguments.length?t.extentMajor(e).extentMinor(e):t.extentMinor()},t.extentMajor=function(e){return arguments.length?(s=+e[0][0],o=+e[1][0],c=+e[0][1],l=+e[1][1],s>o&&(e=s,s=o,o=e),c>l&&(e=c,c=l,l=e),t.precision(x)):[[s,c],[o,l]]},t.extentMinor=function(e){return arguments.length?(r=+e[0][0],i=+e[1][0],u=+e[0][1],a=+e[1][1],r>i&&(e=r,r=i,i=e),u>a&&(e=u,u=a,a=e),t.precision(x)):[[r,u],[i,a]]},t.step=function(e){return arguments.length?t.stepMajor(e).stepMinor(e):t.stepMinor()},t.stepMajor=function(e){return arguments.length?(y=+e[0],m=+e[1],t):[y,m]},t.stepMinor=function(e){return arguments.length?(g=+e[0],v=+e[1],t):[g,v]},t.precision=function(e){return arguments.length?(x=+e,h=ut(u,a,90),f=lt(r,i,x),p=ut(c,l,90),d=lt(s,o,x),t):x},t.extentMajor([[-180,-90+Be],[180,90-Be]]).extentMinor([[-180,-80-Be],[180,80+Be]])}function ht(){return ct()()}function ft(){ei.point=pt}function pt(t,e){ei.point=dt,Nn=Cn=t,bn=Sn=e}function dt(t,e){ti.add(Sn*t-Cn*e),Cn=t,Sn=e}function gt(){dt(Nn,bn)}function vt(t,e){tri&&(ri=t),eoi&&(oi=e)}function yt(t,e){ai+=t,ui+=e,++li}function mt(){vi.point=xt}function xt(t,e){vi.point=Et,yt(Rn=t,Pn=e)}function Et(t,e){var n=t-Rn,i=e-Pn,r=rn(n*n+i*i);ci+=r*(Rn+t)/2,hi+=r*(Pn+e)/2,fi+=r,yt(Rn=t,Pn=e)}function It(){vi.point=yt}function wt(){vi.point=bt}function Nt(){Ct(Mn,Ln)}function bt(t,e){vi.point=Ct,yt(Mn=Rn=t,Ln=Pn=e)}function Ct(t,e){var n=t-Rn,i=e-Pn,r=rn(n*n+i*i);ci+=r*(Rn+t)/2,hi+=r*(Pn+e)/2,fi+=r,r=Pn*t-Rn*e,pi+=r*(Rn+t),di+=r*(Pn+e),gi+=3*r,yt(Rn=t,Pn=e)}function St(t){this._context=t}function Mt(t,e){Ni.point=Lt,mi=Ei=t,xi=Ii=e}function Lt(t,e){Ei-=t,Ii-=e,wi.add(rn(Ei*Ei+Ii*Ii)),Ei=t,Ii=e}function Rt(){this._string=[]}function Pt(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function Tt(t){return t.length>1}function Ot(t,e){return((t=t.x)[0]<0?t[1]-ze-Be:ze-t[1])-((e=e.x)[0]<0?e[1]-ze-Be:ze-e[1])}function _t(t){var e,n=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?je:-je,u=We(o-n);We(u-je)0?ze:-ze),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),e=0):r!==a&&u>=je&&(We(n-r)Be?He((en(e)*(o=Ze(i))*en(n)-en(i)*(r=Ze(e))*en(t))/(r*o*s)):(e+i)/2}function Dt(t,e,n,i){var r;if(null==t)r=n*ze,i.point(-je,r),i.point(0,r),i.point(je,r),i.point(je,0),i.point(je,-r),i.point(0,-r),i.point(-je,-r),i.point(-je,0),i.point(-je,r);else if(We(t[0]-e[0])>Be){var o=t[0]4*e&&v--){var I=a+p,w=u+d,N=l+g,b=rn(I*I+w*w+N*N),C=o(N/=b),S=We(We(N)-1)e||We((m*P+x*T)/E-.5)>.3||a*p+u*d+l*g2?t[2]%360*Ue:0,r()):[I*Ye,w*Ye,N*Ye]},e.precision=function(t){return arguments.length?(R=Ti(i,L=t*t),o()):rn(L)},e.fitExtent=function(t,n){return qt(e,t,n)},e.fitSize=function(t,n){return kt(e,t,n)},function(){return s=t.apply(this,arguments),e.invert=s.invert&&n,r()}}function Xt(t){var e=0,n=je/3,i=Vt(t),r=i(e,n);return r.parallels=function(t){return arguments.length?i(e=t[0]*Ue,n=t[1]*Ue):[e*Ye,n*Ye]},r}function Yt(t){function e(t,e){return[t*n,en(e)/n]}var n=Ze(t);return e.invert=function(t,e){return[t/n,o(e*n)]},e}function Ut(t,e){function n(t,e){var n=rn(s-2*r*en(e))/r;return[n*en(t*=r),a-n*Ze(t)]}var i=en(t),r=(i+en(e))/2;if(We(r)0?e<-ze+Be&&(e=-ze+Be):e>ze-Be&&(e=ze-Be);var n=o/tn(Qt(e),r);return[n*en(r*t),o-n*Ze(r*t)]}var i=Ze(t),r=t===e?en(t):$e(i/Ze(e))/$e(Qt(e)/Qt(t)),o=i*tn(Qt(t),r)/r;return r?(n.invert=function(t,e){var n=o-e,i=nn(r)*rn(t*t+n*n);return[Je(t,We(n))/r*nn(n),2*He(tn(o/i,1/r))-ze]},n):Zt}function te(t,e){return[t,e]}function ee(t,e){function n(t,e){var n=o-e,i=r*t;return[n*en(i),o-n*Ze(i)]}var i=Ze(t),r=t===e?en(t):(i-Ze(e))/(e-t),o=i/r+t;return We(r)0?1:t<0?-1:0},rn=Math.sqrt,on=Math.tan,sn={Feature:function(t,e){u(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,i=-1,r=n.length;++iBe?ve=90:pn<-Be&&(de=-90),we[0]=pe,we[1]=ge}},gn=function(t){var e,n,i,r,o,s,a;if(ve=ge=-(pe=de=1/0),Ie=[],un(t,dn),n=Ie.length){for(Ie.sort(P),e=1,i=Ie[0],o=[i];eR(i[0],i[1])&&(i[1]=r[1]),R(r[0],i[1])>R(i[0],i[1])&&(i[0]=r[0])):o.push(i=r);for(s=-1/0,n=o.length-1,e=0,i=o[n];e<=n;i=r,++e)r=o[e],(a=R(i[1],r[0]))>s&&(s=a,pe=r[0],ge=i[1])}return Ie=we=null,pe===1/0||de===1/0?[[NaN,NaN],[NaN,NaN]]:[[pe,de],[ge,ve]]},vn={sphere:a,point:O,lineStart:A,lineEnd:G,polygonStart:function(){vn.lineStart=q,vn.lineEnd=k},polygonEnd:function(){vn.lineStart=A,vn.lineEnd=G}},yn=function(t){Ne=be=Ce=Se=Me=Le=Re=Pe=Te=Oe=_e=0,un(t,vn);var e=Te,n=Oe,i=_e,r=e*e+n*n+i*i;return r<1e-12&&(e=Le,n=Re,i=Pe,be2?t[2]*Ue:0),e.invert=function(e){return e=t.invert(e[0]*Ue,e[1]*Ue),e[0]*=Ye,e[1]*=Ye,e},e},On=function(){function t(t,e){n.push(t=i(t,e)),t[0]*=Ye,t[1]*=Ye}function e(){var t=r.apply(this,arguments),e=o.apply(this,arguments)*Ue,u=s.apply(this,arguments)*Ue;return n=[],i=V(-t[0]*Ue,-t[1]*Ue,0).invert,W(a,e,u,1),t={type:"Polygon",coordinates:[n]},n=i=null,t}var n,i,r=mn([0,0]),o=mn(90),s=mn(6),a={point:t};return e.center=function(t){return arguments.length?(r="function"==typeof t?t:mn([+t[0],+t[1]]),e):r},e.radius=function(t){return arguments.length?(o="function"==typeof t?t:mn(+t),e):o},e.precision=function(t){return arguments.length?(s="function"==typeof t?t:mn(+t),e):s},e},_n=function(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:a,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}},An=function(t,e,n,i,r,o){var s,a=t[0],u=t[1],l=e[0],c=e[1],h=0,f=1,p=l-a,d=c-u;if(s=n-a,p||!(s>0)){if(s/=p,p<0){if(s0){if(s>f)return;s>h&&(h=s)}if(s=r-a,p||!(s<0)){if(s/=p,p<0){if(s>f)return;s>h&&(h=s)}else if(p>0){if(s0)){if(s/=d,d<0){if(s0){if(s>f)return;s>h&&(h=s)}if(s=o-u,d||!(s<0)){if(s/=d,d<0){if(s>f)return;s>h&&(h=s)}else if(d>0){if(s0&&(t[0]=a+h*p,t[1]=u+h*d),f<1&&(e[0]=a+f*p,e[1]=u+f*d),!0}}}}},Dn=function(t,e){return We(t[0]-e[0])=0;--o)r.point((c=l[o])[0],c[1]);else i(f.x,f.p.x,-1,r);f=f.p}f=f.o,l=f.z,p=!p}while(!f.v);r.lineEnd()}}},Gn=1e9,qn=-Gn,kn=function(){var t,e,n,i=0,r=0,o=960,s=500;return n={stream:function(n){return t&&e===n?t:t=K(i,r,o,s)(e=n)},extent:function(a){return arguments.length?(i=+a[0][0],r=+a[0][1],o=+a[1][0],s=+a[1][1],t=e=null,n):[[i,r],[o,s]]}}},Bn=ae(),jn=function(t,e){var n=e[0],i=e[1],r=[en(n),-Ze(n),0],s=0,a=0;Bn.reset();for(var u=0,l=t.length;u=0?1:-1,L=M*S,R=L>je,P=g*b;if(Bn.add(Je(P*M*en(L),y*C+P*Ze(L))),s+=R?S+M*Xe:S,R^p>=n^w>=n){var T=m(v(f),v(E));I(T);var O=m(r,T);I(O);var _=(R^S>=0?-1:1)*o(O[2]);(i>_||i===_&&(T[0]||T[1]))&&(a+=R^S>=0?1:-1)}}return(s<-Be||s0){for(I||(s.polygonStart(),I=!0),s.lineStart(),t=0;t1&&2&r&&o.push(o.pop().concat(o.shift())),g.push(o.filter(Tt))}var d,g,v,y=n(s),m=o.invert(r[0],r[1]),x=_n(),E=n(x),I=!1,w={point:a,lineStart:l,lineEnd:c,polygonStart:function(){w.point=h,w.lineStart=f,w.lineEnd=p,g=[],d=[]},polygonEnd:function(){w.point=a,w.lineStart=l,w.lineEnd=c,g=e.merge(g);var t=jn(d,m);g.length?(I||(s.polygonStart(),I=!0),Fn(g,Ot,t,i,s)):t&&(I||(s.polygonStart(),I=!0),s.lineStart(),i(null,null,1,s),s.lineEnd()),I&&(s.polygonEnd(),I=!1),g=d=null},sphere:function(){s.polygonStart(),s.lineStart(),i(null,null,1,s),s.lineEnd(),s.polygonEnd()}};return w}},Si=Ci(function(){return!0},_t,Dt,[-je,-ze]),Mi=function(t,e){function n(n,i,r,o){W(o,t,e,r,n,i)}function i(t,e){return Ze(t)*Ze(e)>a}function r(t){var e,n,r,a,c;return{lineStart:function(){a=r=!1,c=1},point:function(h,f){var p,d=[h,f],g=i(h,f),v=u?g?0:s(h,f):g?s(h+(h<0?je:-je),f):0;if(!e&&(a=r=g)&&t.lineStart(),g!==r&&(!(p=o(e,d))||Dn(e,p)||Dn(d,p))&&(d[0]+=Be,d[1]+=Be,g=i(d[0],d[1])),g!==r)c=0,g?(t.lineStart(),p=o(d,e),t.point(p[0],p[1])):(p=o(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(l&&e&&u^g){var y;v&n||!(y=o(d,e,!0))||(c=0,u?(t.lineStart(),t.point(y[0][0],y[0][1]),t.point(y[1][0],y[1][1]),t.lineEnd()):(t.point(y[1][0],y[1][1]),t.lineEnd(),t.lineStart(),t.point(y[0][0],y[0][1])))}!g||e&&Dn(e,d)||t.point(d[0],d[1]),e=d,r=g,n=v},lineEnd:function(){r&&t.lineEnd(),e=null},clean:function(){return c|(a&&r)<<1}}}function o(t,e,n){var i=v(t),r=v(e),o=[1,0,0],s=m(i,r),u=y(s,s),l=s[0],c=u-l*l;if(!c)return!n&&t;var h=a*u/c,f=-a*l/c,p=m(o,s),d=E(o,h);x(d,E(s,f));var I=p,w=y(d,I),N=y(I,I),b=w*w-N*(y(d,d)-1);if(!(b<0)){var C=rn(b),S=E(I,(-w-C)/N);if(x(S,d),S=g(S),!n)return S;var M,L=t[0],R=e[0],P=t[1],T=e[1];R0^S[1]<(We(S[0]-L)je^(L<=S[0]&&S[0]<=R)){var D=E(I,(-w+C)/N);return x(D,d),[S,g(D)]}}}function s(e,n){var i=u?t:je-t,r=0;return e<-i?r|=1:e>i&&(r|=2),n<-i?r|=4:n>i&&(r|=8),r}var a=Ze(t),u=a>0,l=We(a)>Be;return Ci(i,r,n,u?[0,-t]:[-je,t-je])},Li=function(t){return{stream:Ft(t)}};Gt.prototype={constructor:Gt,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var Ri=16,Pi=Ze(30*Ue),Ti=function(t,e){return+e?jt(t,e):Bt(t)},Oi=Ft({point:function(t,e){this.stream.point(t*Ue,e*Ue)}}),_i=function(){return Xt(Ut).scale(155.424).center([0,33.6442])},Ai=function(){return _i().parallels([29.5,45.5]).scale(1070).translate([480,250]).rotate([96,0]).center([-.6,38.7])},Di=function(){function t(t){var e=t[0],n=t[1];return a=null,r.point(e,n),a||(o.point(e,n),a)||(s.point(e,n),a)}function e(){return n=i=null,t}var n,i,r,o,s,a,u=Ai(),l=_i().rotate([154,0]).center([-2,58.5]).parallels([55,65]),c=_i().rotate([157,0]).center([-3,19.9]).parallels([8,18]),h={point:function(t,e){a=[t,e]}};return t.invert=function(t){var e=u.scale(),n=u.translate(),i=(t[0]-n[0])/e,r=(t[1]-n[1])/e;return(r>=.12&&r<.234&&i>=-.425&&i<-.214?l:r>=.166&&r<.234&&i>=-.214&&i<-.115?c:u).invert(t)},t.stream=function(t){return n&&i===t?n:n=Wt([u.stream(i=t),l.stream(t),c.stream(t)])},t.precision=function(t){return arguments.length?(u.precision(t),l.precision(t),c.precision(t),e()):u.precision()},t.scale=function(e){return arguments.length?(u.scale(e),l.scale(.35*e),c.scale(e),t.translate(u.translate())):u.scale()},t.translate=function(t){if(!arguments.length)return u.translate();var n=u.scale(),i=+t[0],a=+t[1];return r=u.translate(t).clipExtent([[i-.455*n,a-.238*n],[i+.455*n,a+.238*n]]).stream(h),o=l.translate([i-.307*n,a+.201*n]).clipExtent([[i-.425*n+Be,a+.12*n+Be],[i-.214*n-Be,a+.234*n-Be]]).stream(h),s=c.translate([i-.205*n,a+.212*n]).clipExtent([[i-.214*n+Be,a+.166*n+Be],[i-.115*n-Be,a+.234*n-Be]]).stream(h),e()},t.fitExtent=function(e,n){return qt(t,e,n)},t.fitSize=function(e,n){return kt(t,e,n)},t.scale(1070)},Fi=Ht(function(t){return rn(2/(1+t))});Fi.invert=Jt(function(t){return 2*o(t/2)});var Gi=function(){return zt(Fi).scale(124.75).clipAngle(179.999)},qi=Ht(function(t){return(t=r(t))&&t/en(t)});qi.invert=Jt(function(t){return t});var ki=function(){return zt(qi).scale(79.4188).clipAngle(179.999)};Zt.invert=function(t,e){return[t,2*He(Qe(e))-ze]};var Bi=function(){return Kt(Zt).scale(961/Xe)},ji=function(){return Xt($t).scale(109.5).parallels([30,30])};te.invert=te;var zi=function(){return zt(te).scale(152.63)},Vi=function(){return Xt(ee).scale(131.154).center([0,13.9389])};ne.invert=Jt(He);var Xi=function(){return zt(ne).scale(144.049).clipAngle(60)},Yi=function(){function t(){return r=o=null,s}var e,n,i,r,o,s,a=1,u=0,l=0,c=1,h=1,f=Qn,p=null,d=Qn;return s={stream:function(t){return r&&o===t?r:r=f(d(o=t))},clipExtent:function(r){return arguments.length?(d=null==r?(p=e=n=i=null,Qn):K(p=+r[0][0],e=+r[0][1],n=+r[1][0],i=+r[1][1]),t()):null==p?null:[[p,e],[n,i]]},scale:function(e){return arguments.length?(f=ie((a=+e)*c,a*h,u,l),t()):a},translate:function(e){return arguments.length?(f=ie(a*c,a*h,u=+e[0],l=+e[1]),t()):[u,l]},reflectX:function(e){return arguments.length?(f=ie(a*(c=e?-1:1),a*h,u,l),t()):c<0},reflectY:function(e){return arguments.length?(f=ie(a*c,a*(h=e?-1:1),u,l),t()):h<0},fitExtent:function(t,e){return qt(s,t,e)},fitSize:function(t,e){return kt(s,t,e)}}};re.invert=Jt(o);var Ui=function(){return zt(re).scale(249.5).clipAngle(90+Be)};oe.invert=Jt(function(t){return 2*He(t)});var Wi=function(){return zt(oe).scale(250).clipAngle(142)};se.invert=function(t,e){return[-e,2*He(Qe(t))-ze]};var Hi=function(){var t=Kt(se),e=t.center,n=t.rotate;return t.center=function(t){return arguments.length?e([-t[1],t[0]]):(t=e(),[t[1],-t[0]])},t.rotate=function(t){return arguments.length?n([t[0],t[1],t.length>2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90]).scale(159.155)};t.geoArea=fn,t.geoBounds=gn,t.geoCentroid=yn,t.geoCircle=On,t.geoClipExtent=kn,t.geoContains=Zn,t.geoDistance=Wn,t.geoGraticule=ct,t.geoGraticule10=ht, +t.geoInterpolate=Kn,t.geoLength=Xn,t.geoPath=bi,t.geoAlbers=Ai,t.geoAlbersUsa=Di,t.geoAzimuthalEqualArea=Gi,t.geoAzimuthalEqualAreaRaw=Fi,t.geoAzimuthalEquidistant=ki,t.geoAzimuthalEquidistantRaw=qi,t.geoConicConformal=ji,t.geoConicConformalRaw=$t,t.geoConicEqualArea=_i,t.geoConicEqualAreaRaw=Ut,t.geoConicEquidistant=Vi,t.geoConicEquidistantRaw=ee,t.geoEquirectangular=zi,t.geoEquirectangularRaw=te,t.geoGnomonic=Xi,t.geoGnomonicRaw=ne,t.geoIdentity=Yi,t.geoProjection=zt,t.geoProjectionMutator=Vt,t.geoMercator=Bi,t.geoMercatorRaw=Zt,t.geoOrthographic=Ui,t.geoOrthographicRaw=re,t.geoStereographic=Wi,t.geoStereographicRaw=oe,t.geoTransverseMercator=Hi,t.geoTransverseMercatorRaw=se,t.geoRotation=Tn,t.geoStream=un,t.geoTransform=Li,Object.defineProperty(t,"__esModule",{value:!0})})},{"d3-array":41}],43:[function(e,n,i){!function(e,r){"object"==typeof i&&void 0!==n?r(i):"function"==typeof t&&t.amd?t(["exports"],r):r(e.jsts=e.jsts||{})}(this,function(t){"use strict";function e(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])}function n(){}function i(){}function r(){}function o(){}function s(){}function a(){}function u(){}function l(t){this.name="RuntimeException",this.message=t,this.stack=(new Error).stack,Error.call(this,t)}function c(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t}function h(){if(0===arguments.length)l.call(this);else if(1===arguments.length){var t=arguments[0];l.call(this,t)}}function f(){}function p(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)p.call(this,0,0);else if(1===arguments.length){var t=arguments[0];p.call(this,t.x,t.y,t.z)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];p.call(this,e,n,p.NULL_ORDINATE)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];this.x=i,this.y=r,this.z=o}}function d(){if(this.dimensionsToTest=2,0===arguments.length)d.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new i("only 2 or 3 dimensions may be specified");this.dimensionsToTest=t}}function g(){}function v(){}function y(t){this.message=t||""}function m(){}function x(t){this.message=t||""}function E(t){this.message=t||""}function I(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function w(){if(I.apply(this),0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}function N(){if(this.minx=null,this.maxx=null,this.miny=null,this.maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof p){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof N){var e=arguments[0];this.init(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.init(r,o,s,a)}}function b(){}function C(){b.call(this,"Projective point not representable on the Cartesian plane.")}function S(){}function M(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1}function L(){}function R(t){this.str=t}function P(t){this.value=t}function T(){}function O(){if(this.hi=0,this.lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof O){var e=arguments[0];this.init(e)}else if("string"==typeof arguments[0]){var n=arguments[0];O.call(this,O.parse(n))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i,r)}}function _(){}function A(){}function D(){}function F(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];this.x=e,this.y=n,this.w=1}else if(arguments[0]instanceof F&&arguments[1]instanceof F){var i=arguments[0],r=arguments[1];this.x=i.y*r.w-r.y*i.w,this.y=r.x*i.w-i.x*r.w,this.w=i.x*r.y-r.x*i.y}else if(arguments[0]instanceof p&&arguments[1]instanceof p){var o=arguments[0],s=arguments[1];this.x=o.y-s.y,this.y=s.x-o.x,this.w=o.x*s.y-s.x*o.y}}else if(3===arguments.length){var a=arguments[0],u=arguments[1],l=arguments[2];this.x=a,this.y=u,this.w=l}else if(4===arguments.length){var c=arguments[0],h=arguments[1],f=arguments[2],d=arguments[3],g=c.y-h.y,v=h.x-c.x,y=c.x*h.y-h.x*c.y,m=f.y-d.y,x=d.x-f.x,E=f.x*d.y-d.x*f.y;this.x=v*E-x*y,this.y=m*y-g*E,this.w=g*x-m*v}}function G(){}function q(){}function k(){this.envelope=null,this.factory=null,this.SRID=null,this.userData=null;var t=arguments[0];this.factory=t,this.SRID=t.getSRID()}function B(){}function j(){}function z(){}function V(){}function X(){}function Y(){}function U(){}function W(){}function H(){}function J(){}function Z(){}function K(){}function Q(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function $(t){return null==t?$o:t.color}function tt(t){return null==t?null:t.parent}function et(t,e){null!==t&&(t.color=e)}function nt(t){return null==t?null:t.left}function it(t){return null==t?null:t.right}function rt(){this.root_=null,this.size_=0}function ot(){}function st(){}function at(){this.array_=[],arguments[0]instanceof v&&this.addAll(arguments[0])}function ut(){}function lt(){}function ct(){}function ht(){}function ft(){this.geometries=null;var t=arguments[0],e=arguments[1];if(k.call(this,e),null===t&&(t=[]),k.hasNullElements(t))throw new i("geometries must not contain null elements");this.geometries=t}function pt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function dt(){if(this.geom=null,this.geomFact=null,this.bnRule=null,this.endpointMap=null,1===arguments.length){var t=arguments[0];dt.call(this,t,j.MOD2_BOUNDARY_RULE)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.geom=e,this.geomFact=e.getFactory(),this.bnRule=n}}function gt(){this.count=null}function vt(){}function yt(){}function mt(){}function xt(){}function Et(){}function It(){}function wt(){}function Nt(){}function bt(){this.points=null;var t=arguments[0],e=arguments[1];k.call(this,e),this.init(t)}function Ct(){}function St(){this.coordinates=null;var t=arguments[0],e=arguments[1];k.call(this,e),this.init(t)}function Mt(){}function Lt(){this.shell=null,this.holes=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(k.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),k.hasNullElements(e))throw new i("holes must not contain null elements");if(t.isEmpty()&&k.hasNonEmptyElements(e))throw new i("shell is empty but holes are not");this.shell=t,this.holes=e}function Rt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function Pt(){if(arguments[0]instanceof p&&arguments[1]instanceof ne){var t=arguments[0],e=arguments[1];Pt.call(this,e.getCoordinateSequenceFactory().create(t),e)}else if(M(arguments[0],A)&&arguments[1]instanceof ne){var n=arguments[0],i=arguments[1];bt.call(this,n,i),this.validateConstruction()}}function Tt(){var t=arguments[0],e=arguments[1];ft.call(this,t,e)}function Ot(){if(this.factory=null,this.isUserDataCopied=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.factory=t}}function _t(){}function At(){}function Dt(){}function Ft(){}function Gt(){if(this.dimension=3,this.coordinates=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];Gt.call(this,t,3)}else if(Number.isInteger(arguments[0])){var e=arguments[0];this.coordinates=new Array(e).fill(null);for(var n=0;n-1}function zt(t){return this.has(t)?this._values[es]:void 0}function Vt(t,e){if(this.objectOnly&&e!==Object(e))throw new TypeError("Invalid value used as weak collection key");if(e!==e||0===e)for(es=t.length;es--&&!kt(t[es],e););else es=t.indexOf(e);return es>-1}function Xt(t){return Vt.call(this,this._keys,t)}function Yt(t,e){return this.has(t)?this._values[es]=e:this._values[this._keys.push(t)-1]=e,this}function Ut(){(this._keys||0).length=this._values.length=0}function Wt(){return Zt(this._itp,this._keys)}function Ht(){return Zt(this._itp,this._values)}function Jt(){return Zt(this._itp,this._keys,this._values)}function Zt(t,e,n){var i=[0],r=!1;return t.push(i),{next:function(){var o,s=i[0];return!r&&s1,"Node capacity must be greater than 1"),this.nodeCapacity=t}}function ke(){}function Be(){}function je(){if(0===arguments.length)je.call(this,je.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];qe.call(this,t)}}function ze(){var t=arguments[0];Fe.call(this,t)}function Ve(){}function Xe(){this.segString=null,this.coord=null,this.segmentIndex=null,this.segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.segString=t,this.coord=new p(e),this.segmentIndex=n,this.segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))}function Ye(){this.nodeMap=new rt,this.edge=null;var t=arguments[0];this.edge=t}function Ue(){this.nodeList=null,this.edge=null,this.nodeIt=null,this.currNode=null,this.nextNode=null,this.currSegIndex=0;var t=arguments[0];this.nodeList=t,this.edge=t.getEdge(),this.nodeIt=t.iterator(),this.readNextNode()}function We(){}function He(){this.nodeList=new Ye(this),this.pts=null,this.data=null;var t=arguments[0],e=arguments[1];this.pts=t,this.data=e}function Je(){this.tempEnv1=new N,this.tempEnv2=new N,this.overlapSeg1=new ce,this.overlapSeg2=new ce}function Ze(){this.pts=null,this.start=null,this.end=null,this.env=null,this.context=null,this.id=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.pts=t,this.start=e,this.end=n,this.context=i}function Ke(){}function Qe(){}function $e(){}function tn(){if(this.segInt=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setSegmentIntersector(t)}}function en(){if(this.monoChains=new I,this.index=new je,this.idCounter=0,this.nodedSegStrings=null,this.nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];tn.call(this,t)}}function nn(){Je.apply(this),this.si=null;var t=arguments[0];this.si=t}function rn(){if(this.pt=null,1===arguments.length){var t=arguments[0];l.call(this,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];l.call(this,rn.msgWithCoord(e,n)),this.name="TopologyException",this.pt=new p(n)}}function on(){}function sn(){this.findAllIntersections=!1,this.isCheckEndSegmentsOnly=!1,this.li=null,this.interiorIntersection=null,this.intSegments=null,this.intersections=new I,this.intersectionCount=0,this.keepIntersections=!0;var t=arguments[0];this.li=t,this.interiorIntersection=null}function an(){this.li=new se,this.segStrings=null,this.findAllIntersections=!1,this.segInt=null,this._isValid=!0;var t=arguments[0];this.segStrings=t}function un(){this.nv=null;var t=arguments[0];this.nv=new an(un.toSegmentStrings(t))}function ln(){this.mapOp=null;var t=arguments[0];this.mapOp=t}function cn(){}function hn(){if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];this.init(t.length)}else if(Number.isInteger(arguments[0])){var e=arguments[0];this.init(1),this.location[cn.ON]=e}else if(arguments[0]instanceof hn){var n=arguments[0];if(this.init(n.location.length),null!==n)for(var i=0;i=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(r.getPrecisionModel()),this.arg=new Array(2).fill(null),this.arg[0]=new Qn(0,i,o),this.arg[1]=new Qn(1,r,o)}}function ti(){this.pts=null,this._orientation=null;var t=arguments[0];this.pts=t,this._orientation=ti.orientation(t)}function ei(){this.edges=new I,this.ocaMap=new rt}function ni(){this.ptLocator=new Me,this.geomFact=null,this.resultGeom=null,this.graph=null,this.edgeList=new ei,this.resultPolyList=new I,this.resultLineList=new I,this.resultPointList=new I;var t=arguments[0],e=arguments[1];$n.call(this,t,e),this.graph=new wn(new Pn),this.geomFact=t.getFactory()}function ii(){this.geom=new Array(2).fill(null),this.snapTolerance=null,this.cbr=null;var t=arguments[0],e=arguments[1];this.geom[0]=t,this.geom[1]=e,this.computeSnapTolerance()}function ri(){this.geom=new Array(2).fill(null);var t=arguments[0],e=arguments[1];this.geom[0]=t,this.geom[1]=e}function oi(){this.factory=null,this.interiorPoint=null,this.maxWidth=0;var t=arguments[0];this.factory=t.getFactory(),this.add(t)}function si(){this.poly=null,this.centreY=null,this.hiY=r.MAX_VALUE,this.loY=-r.MAX_VALUE;var t=arguments[0];this.poly=t,this.hiY=t.getEnvelopeInternal().getMaxY(),this.loY=t.getEnvelopeInternal().getMinY(),this.centreY=oi.avg(this.loY,this.hiY)}function ai(){this.centroid=null,this.minDistance=r.MAX_VALUE,this.interiorPoint=null;var t=arguments[0];this.centroid=t.getCentroid().getCoordinate(),this.addInterior(t),null===this.interiorPoint&&this.addEndpoints(t)}function ui(){this.centroid=null,this.minDistance=r.MAX_VALUE,this.interiorPoint=null;var t=arguments[0];this.centroid=t.getCentroid().getCoordinate(),this.add(t)}function li(){this.tempEnv1=new N,this.selectedSegment=new ce}function ci(){this.items=new I,this.subnode=[null,null]}function hi(){if(this.min=null,this.max=null,0===arguments.length)this.min=0,this.max=0;else if(1===arguments.length){var t=arguments[0];this.init(t.min,t.max)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.init(e,n)}}function fi(){}function pi(t,e){var n,i,r,o,s={32:{d:127,c:128,b:0,a:0},64:{d:32752,c:0,b:0,a:0}},a={32:8,64:11}[t];if(o||(n=e<0||1/e<0,isFinite(e)||(o=s[t],n&&(o.d+=1<=2;)i++,r/=2;for(;r<1&&i>0;)i--,r*=2;i<=0&&(r/=2),32===t&&i>254&&(o={d:n?255:127,c:128,b:0,a:0},i=Math.pow(2,a)-1,r=0)}return i}function di(){this.pt=0,this.level=0,this.interval=null;var t=arguments[0];this.computeKey(t)}function gi(){ci.apply(this),this.interval=null,this.centre=null,this.level=null;var t=arguments[0],e=arguments[1];this.interval=t,this.level=e,this.centre=(t.getMin()+t.getMax())/2}function vi(){}function yi(){ci.apply(this)}function mi(){this.root=null,this.minExtent=1,this.root=new yi}function xi(){}function Ei(){this.ring=null,this.tree=null,this.crossings=0,this.interval=new hi;var t=arguments[0];this.ring=t,this.buildIndex()}function Ii(){li.apply(this),this.mcp=null,this.p=null;var t=arguments[0],e=arguments[1];this.mcp=t,this.p=e}function wi(){}function Ni(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}function bi(){this.input=null,this.extremalPts=null,this.centre=null,this.radius=0;var t=arguments[0];this.input=t}function Ci(){if(this.inputGeom=null,this.isConvex=null,this.convexHullPts=null,this.minBaseSeg=new ce,this.minWidthPt=null,this.minPtIndex=null,this.minWidth=0,1===arguments.length){var t=arguments[0];Ci.call(this,t,!1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.inputGeom=e,this.isConvex=n}}function Si(){this.inputGeom=null,this.distanceTolerance=null;var t=arguments[0];this.inputGeom=t}function Mi(){me.apply(this),this.distanceTolerance=null;var t=arguments[0];this.distanceTolerance=t}function Li(){this._orig=null,this._sym=null,this._next=null;var t=arguments[0];this._orig=t}function Ri(){this._isMarked=!1;var t=arguments[0];Li.call(this,t)}function Pi(){this.vertexMap=new $t}function Ti(){this._isStart=!1;var t=arguments[0];Ri.call(this,t)}function Oi(){Pi.apply(this)}function _i(){this.result=null,this.factory=null,this.graph=null,this.lines=new I,this.nodeEdgeStack=new de,this.ringStartEdge=null,this.graph=new Oi}function Ai(){this.items=new I,this.subnode=new Array(4).fill(null)}function Di(){this.pt=new p,this.level=0,this.env=null;var t=arguments[0];this.computeKey(t)}function Fi(){Ai.apply(this),this.env=null,this.centrex=null,this.centrey=null,this.level=null;var t=arguments[0],e=arguments[1];this.env=t,this.level=e,this.centrex=(t.getMinX()+t.getMaxX())/2,this.centrey=(t.getMinY()+t.getMaxY())/2}function Gi(){Ai.apply(this)}function qi(){this.root=null,this.minExtent=1,this.root=new Gi}function ki(t){this.geometryFactory=t||new ne}function Bi(t){this.geometryFactory=t||new ne,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new ki(this.geometryFactory)}function ji(){this.parser=new ki(this.geometryFactory)}function zi(t){this.geometryFactory=t||new ne,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new ie(this.geometryFactory)}function Vi(t){return[t.x,t.y]}function Xi(t,e){this.geometryFactory=t||new ne, +this.ol=e||"undefined"!=typeof ol&&ol}function Yi(){if(this.noder=null,this.scaleFactor=null,this.offsetX=null,this.offsetY=null,this.isScaled=!1,2===arguments.length){var t=arguments[0],e=arguments[1];Yi.call(this,t,e,0,0)}else if(4===arguments.length){var n=arguments[0],i=arguments[1];arguments[2],arguments[3],this.noder=n,this.scaleFactor=i,this.isScaled=!this.isIntegerPrecision()}}function Ui(){if(this.inputGeom=null,this.isClosedEndpointsInInterior=!0,this.nonSimpleLocation=null,1===arguments.length){var t=arguments[0];this.inputGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.inputGeom=e,this.isClosedEndpointsInInterior=!n.isInBoundary(2)}}function Wi(){this.pt=null,this.isClosed=null,this.degree=null;var t=arguments[0];this.pt=t,this.isClosed=!1,this.degree=0}function Hi(){if(this.quadrantSegments=Hi.DEFAULT_QUADRANT_SEGMENTS,this.endCapStyle=Hi.CAP_ROUND,this.joinStyle=Hi.JOIN_ROUND,this.mitreLimit=Hi.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this.simplifyFactor=Hi.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.setQuadrantSegments(e),this.setEndCapStyle(n)}else if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(r),this.setJoinStyle(o),this.setMitreLimit(s)}}function Ji(){this.minIndex=-1,this.minCoord=null,this.minDe=null,this.orientedDe=null}function Zi(){this.array_=[]}function Ki(){this.finder=null,this.dirEdgeList=new I,this.nodes=new I,this.rightMostCoord=null,this.env=null,this.finder=new Ji}function Qi(){this.inputLine=null,this.distanceTol=null,this.isDeleted=null,this.angleOrientation=le.COUNTERCLOCKWISE;var t=arguments[0];this.inputLine=t}function $i(){this.ptList=null,this.precisionModel=null,this.minimimVertexDistance=0,this.ptList=new I}function tr(){this.maxCurveSegmentError=0,this.filletAngleQuantum=null,this.closingSegLengthFactor=1,this.segList=null,this.distance=0,this.precisionModel=null,this.bufParams=null,this.li=null,this.s0=null,this.s1=null,this.s2=null,this.seg0=new ce,this.seg1=new ce,this.offset0=new ce,this.offset1=new ce,this.side=0,this._hasNarrowConcaveAngle=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this.precisionModel=t,this.bufParams=e,this.li=new se,this.filletAngleQuantum=Math.PI/2/e.getQuadrantSegments(),e.getQuadrantSegments()>=8&&e.getJoinStyle()===Hi.JOIN_ROUND&&(this.closingSegLengthFactor=tr.MAX_CLOSING_SEG_LEN_FACTOR),this.init(n)}function er(){this.distance=0,this.precisionModel=null,this.bufParams=null;var t=arguments[0],e=arguments[1];this.precisionModel=t,this.bufParams=e}function nr(){this.subgraphs=null,this.seg=new ce,this.cga=new le;var t=arguments[0];this.subgraphs=t}function ir(){this.upwardSeg=null,this.leftDepth=null;var t=arguments[0],e=arguments[1];this.upwardSeg=new ce(t),this.leftDepth=e}function rr(){this.inputGeom=null,this.distance=null,this.curveBuilder=null,this.curveList=new I;var t=arguments[0],e=arguments[1],n=arguments[2];this.inputGeom=t,this.distance=e,this.curveBuilder=n}function or(){this._hasIntersection=!1,this.hasProper=!1,this.hasProperInterior=!1,this.hasInterior=!1,this.properIntersectionPoint=null,this.li=null,this.isSelfIntersection=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var t=arguments[0];this.li=t}function sr(){this.bufParams=null,this.workingPrecisionModel=null,this.workingNoder=null,this.geomFact=null,this.graph=null,this.edgeList=new ei;var t=arguments[0];this.bufParams=t}function ar(){this.li=new se,this.segStrings=null;var t=arguments[0];this.segStrings=t}function ur(){this.li=null,this.pt=null,this.originalPt=null,this.ptScaled=null,this.p0Scaled=null,this.p1Scaled=null,this.scaleFactor=null,this.minx=null,this.maxx=null,this.miny=null,this.maxy=null,this.corner=new Array(4).fill(null),this.safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this.originalPt=t,this.pt=t,this.scaleFactor=e,this.li=n,e<=0)throw new i("Scale factor must be non-zero");1!==e&&(this.pt=new p(this.scale(t.x),this.scale(t.y)),this.p0Scaled=new p,this.p1Scaled=new p),this.initCorners(this.pt)}function lr(){this.index=null;var t=arguments[0];this.index=t}function cr(){li.apply(this),this.hotPixel=null,this.parentEdge=null,this.hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this.hotPixel=t,this.parentEdge=e,this.hotPixelVertexIndex=n}function hr(){this.li=null,this.interiorIntersections=null;var t=arguments[0];this.li=t,this.interiorIntersections=new I}function fr(){this.pm=null,this.li=null,this.scaleFactor=null,this.noder=null,this.pointSnapper=null,this.nodedSegStrings=null;var t=arguments[0];this.pm=t,this.li=new se,this.li.setPrecisionModel(t),this.scaleFactor=t.getScale()}function pr(){if(this.argGeom=null,this.distance=null,this.bufParams=new Hi,this.resultGeometry=null,this.saveException=null,1===arguments.length){var t=arguments[0];this.argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.argGeom=e,this.bufParams=n}}function dr(){this.comps=null;var t=arguments[0];this.comps=t}function gr(){if(this.component=null,this.segIndex=null,this.pt=null,2===arguments.length){var t=arguments[0],e=arguments[1];gr.call(this,t,gr.INSIDE_AREA,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.component=n,this.segIndex=i,this.pt=r}}function vr(){this.pts=null;var t=arguments[0];this.pts=t}function yr(){this.locations=null;var t=arguments[0];this.locations=t}function mr(){if(this.geom=null,this.terminateDistance=0,this.ptLocator=new Me,this.minDistanceLocation=null,this.minDistance=r.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];mr.call(this,t,e,0)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],o=arguments[2];this.geom=new Array(2).fill(null),this.geom[0]=n,this.geom[1]=i,this.terminateDistance=o}}function xr(){this.factory=null,this.directedEdges=new I,this.coordinates=null;var t=arguments[0];this.factory=t}function Er(){this._isMarked=!1,this._isVisited=!1,this.data=null}function Ir(){Er.apply(this),this.parentEdge=null,this.from=null,this.to=null,this.p0=null,this.p1=null,this.sym=null,this.edgeDirection=null,this.quadrant=null,this.angle=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this.from=t,this.to=e,this.edgeDirection=i,this.p0=t.getCoordinate(),this.p1=n;var r=this.p1.x-this.p0.x,o=this.p1.y-this.p0.y;this.quadrant=Ke.quadrant(r,o),this.angle=Math.atan2(o,r)}function wr(){var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];Ir.call(this,t,e,n,i)}function Nr(){if(Er.apply(this),this.dirEdge=null,0===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];this.setDirectedEdges(t,e)}}function br(){this.outEdges=new I,this.sorted=!1}function Cr(){if(Er.apply(this),this.pt=null,this.deStar=null,1===arguments.length){var t=arguments[0];Cr.call(this,t,new br)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.pt=e,this.deStar=n}}function Sr(){Nr.apply(this),this.line=null;var t=arguments[0];this.line=t}function Mr(){this.nodeMap=new rt}function Lr(){this.edges=new Q,this.dirEdges=new Q,this.nodeMap=new Mr}function Rr(){Lr.apply(this)}function Pr(){this.graph=new Rr,this.mergedLineStrings=null,this.factory=null,this.edgeStrings=null}function Tr(){this.edgeRing=null,this.next=null,this.label=-1;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];Ir.call(this,t,e,n,i)}function Or(){Nr.apply(this),this.line=null;var t=arguments[0];this.line=t}function _r(){this.geometryFactory=new ne,this.geomGraph=null,this.disconnectedRingcoord=null;var t=arguments[0];this.geomGraph=t}function Ar(){}function Dr(){if(this.edgeEnds=new I,1===arguments.length){var t=arguments[0];Dr.call(this,null,t)}else if(2===arguments.length){var e=(arguments[0],arguments[1]);xn.call(this,e.getEdge(),e.getCoordinate(),e.getDirectedCoordinate(),new fn(e.getLabel())),this.insert(e)}}function Fr(){Ln.apply(this)}function Gr(){var t=arguments[0],e=arguments[1];yn.call(this,t,e)}function qr(){In.apply(this)}function kr(){this.nodes=new mn(new qr)}function Br(){this.li=new se,this.geomGraph=null,this.nodeGraph=new kr,this.invalidPoint=null;var t=arguments[0];this.geomGraph=t}function jr(){this.graph=null,this.rings=new I,this.totalEnv=new N,this.index=null,this.nestedPt=null;var t=arguments[0];this.graph=t}function zr(){if(this.errorType=null,this.pt=null,1===arguments.length){var t=arguments[0];zr.call(this,t,null)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.errorType=e,null!==n&&(this.pt=n.copy())}}function Vr(){this.parentGeometry=null,this.isSelfTouchingRingFormingHoleValid=!1,this.validErr=null;var t=arguments[0];this.parentGeometry=t}function Xr(){this.factory=null,this.deList=new I,this.lowestEdge=null,this.ring=null,this.ringPts=null,this.holes=null,this.shell=null,this._isHole=null,this._isProcessed=!1,this._isIncludedSet=!1,this._isIncluded=!1;var t=arguments[0];this.factory=t}function Yr(){}function Ur(){Lr.apply(this),this.factory=null;var t=arguments[0];this.factory=t}function Wr(){if(this.lineStringAdder=new Hr(this),this.graph=null,this.dangles=new I,this.cutEdges=new I,this.invalidRingLines=new I,this.holeList=null,this.shellList=null,this.polyList=null,this.isCheckingRingsValid=!0,this.extractOnlyPolygonal=null,this.geomFactory=null,0===arguments.length)Wr.call(this,!1);else if(1===arguments.length){var t=arguments[0];this.extractOnlyPolygonal=t}}function Hr(){this.p=null;var t=arguments[0];this.p=t}function Jr(){this.li=new se,this.ptLocator=new Me,this.arg=null,this.nodes=new mn(new qr),this.im=null,this.isolatedEdges=new I,this.invalidPoint=null;var t=arguments[0];this.arg=t}function Zr(){this.rectEnv=null;var t=arguments[0];this.rectEnv=t.getEnvelopeInternal()}function Kr(){this.li=new se,this.rectEnv=null,this.diagUp0=null,this.diagUp1=null,this.diagDown0=null,this.diagDown1=null;var t=arguments[0];this.rectEnv=t,this.diagUp0=new p(t.getMinX(),t.getMinY()),this.diagUp1=new p(t.getMaxX(),t.getMaxY()),this.diagDown0=new p(t.getMinX(),t.getMaxY()),this.diagDown1=new p(t.getMaxX(),t.getMinY())}function Qr(){this._isDone=!1}function $r(){this.rectangle=null,this.rectEnv=null;var t=arguments[0];this.rectangle=t,this.rectEnv=t.getEnvelopeInternal()}function to(){Qr.apply(this),this.rectEnv=null,this._intersects=!1;var t=arguments[0];this.rectEnv=t}function eo(){Qr.apply(this),this.rectSeq=null,this.rectEnv=null,this._containsPoint=!1;var t=arguments[0];this.rectSeq=t.getExteriorRing().getCoordinateSequence(),this.rectEnv=t.getEnvelopeInternal()}function no(){Qr.apply(this),this.rectEnv=null,this.rectIntersector=null,this.hasIntersection=!1,this.p0=new p,this.p1=new p;var t=arguments[0];this.rectEnv=t.getEnvelopeInternal(),this.rectIntersector=new Kr(this.rectEnv)}function io(){if(this._relate=null,2===arguments.length){var t=arguments[0],e=arguments[1];$n.call(this,t,e),this._relate=new Jr(this.arg)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];$n.call(this,n,i,r),this._relate=new Jr(this.arg)}}function ro(){this.geomFactory=null,this.skipEmpty=!1,this.inputGeoms=null;var t=arguments[0];this.geomFactory=ro.extractFactory(t),this.inputGeoms=t}function oo(){this.pointGeom=null,this.otherGeom=null,this.geomFact=null;var t=arguments[0],e=arguments[1];this.pointGeom=t,this.otherGeom=e,this.geomFact=e.getFactory()}function so(){this.sortIndex=-1,this.comps=null;var t=arguments[0],e=arguments[1];this.sortIndex=t,this.comps=e}function ao(){this.inputPolys=null,this.geomFactory=null;var t=arguments[0];this.inputPolys=t,null===this.inputPolys&&(this.inputPolys=new I)}function uo(){if(this.polygons=new I,this.lines=new I,this.points=new I,this.geomFact=null,1===arguments.length){if(M(arguments[0],v)){var t=arguments[0];this.extract(t)}else if(arguments[0]instanceof k){var e=arguments[0];this.extract(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.geomFact=i,this.extract(n)}}function lo(){Ot.CoordinateOperation.apply(this),this.targetPM=null,this.removeCollapsed=!0;var t=arguments[0],e=arguments[1];this.targetPM=t,this.removeCollapsed=e}function co(){this.targetPM=null,this.removeCollapsed=!0,this.changePrecisionModel=!1,this.isPointwise=!1;var t=arguments[0];this.targetPM=t}function ho(){this.pts=null,this.usePt=null,this.distanceTolerance=null,this.seg=new ce;var t=arguments[0];this.pts=t}function fo(){this.inputGeom=null,this.distanceTolerance=null,this.isEnsureValidTopology=!0;var t=arguments[0];this.inputGeom=t}function po(){me.apply(this),this.isEnsureValidTopology=!0,this.distanceTolerance=null;var t=arguments[0],e=arguments[1];this.isEnsureValidTopology=t,this.distanceTolerance=e}function go(){if(this.parent=null,this.index=null,2===arguments.length){var t=arguments[0],e=arguments[1];go.call(this,t,e,null,-1)}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],o=arguments[3];ce.call(this,n,i),this.parent=r,this.index=o}}function vo(){if(this.parentLine=null,this.segs=null,this.resultSegs=new I,this.minimumSize=null,1===arguments.length){var t=arguments[0];vo.call(this,t,2)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.parentLine=e,this.minimumSize=n,this.init()}}function yo(){this.index=new qi}function mo(){this.querySeg=null,this.items=new I;var t=arguments[0];this.querySeg=t}function xo(){this.li=new se,this.inputIndex=new yo,this.outputIndex=new yo,this.line=null,this.linePts=null,this.distanceTolerance=0;var t=arguments[0],e=arguments[1];this.inputIndex=t,this.outputIndex=e}function Eo(){this.inputIndex=new yo,this.outputIndex=new yo,this.distanceTolerance=0}function Io(){this.inputGeom=null,this.lineSimplifier=new Eo,this.linestringMap=null;var t=arguments[0];this.inputGeom=t}function wo(){me.apply(this),this.linestringMap=null;var t=arguments[0];this.linestringMap=t}function No(){this.tps=null;var t=arguments[0];this.tps=t}function bo(){this.seg=null,this.segLen=null,this.splitPt=null,this.minimumLen=0;var t=arguments[0];this.seg=t,this.segLen=t.getLength()}function Co(){}function So(){}function Mo(){}function Lo(){if(this.p=null,1===arguments.length){var t=arguments[0];this.p=new p(t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.p=new p(e,n)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2];this.p=new p(i,r,o)}}function Ro(){this._isOnConstraint=null,this.constraint=null;var t=arguments[0];Lo.call(this,t)}function Po(){this._rot=null,this.vertex=null,this.next=null,this.data=null}function To(){this.subdiv=null,this.isUsingTolerance=!1;var t=arguments[0];this.subdiv=t,this.isUsingTolerance=t.getTolerance()>0}function Oo(){}function _o(){this.subdiv=null,this.lastEdge=null;var t=arguments[0];this.subdiv=t,this.init()}function Ao(){if(this.seg=null,1===arguments.length){if("string"==typeof arguments[0]){var t=arguments[0];l.call(this,t)}else if(arguments[0]instanceof ce){var e=arguments[0];l.call(this,"Locate failed to converge (at edge: "+e+"). Possible causes include invalid Subdivision topology or very close sites"),this.seg=new ce(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];l.call(this,Ao.msgWithSpatial(n,i)),this.seg=new ce(i)}}function Do(){}function Fo(){this.visitedKey=0,this.quadEdges=new I,this.startingEdge=null,this.tolerance=null,this.edgeCoincidenceTolerance=null,this.frameVertex=new Array(3).fill(null),this.frameEnv=null,this.locator=null,this.seg=new ce,this.triEdges=new Array(3).fill(null);var t=arguments[0],e=arguments[1];this.tolerance=e,this.edgeCoincidenceTolerance=e/Fo.EDGE_COINCIDENCE_TOL_FACTOR,this.createFrame(t),this.startingEdge=this.initSubdiv(),this.locator=new _o(this)}function Go(){}function qo(){this.triList=new I}function ko(){this.triList=new I}function Bo(){this.coordList=new w,this.triCoords=new I}function jo(){if(this.ls=null,this.data=null,2===arguments.length){var t=arguments[0],e=arguments[1];this.ls=new ce(t,e)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.ls=new ce(n,i),this.data=r}else if(6===arguments.length){var o=arguments[0],s=arguments[1],a=arguments[2],u=arguments[3],l=arguments[4],c=arguments[5];jo.call(this,new p(o,s,a),new p(u,l,c))}else if(7===arguments.length){var h=arguments[0],f=arguments[1],d=arguments[2],g=arguments[3],v=arguments[4],y=arguments[5],m=arguments[6];jo.call(this,new p(h,f,d),new p(g,v,y),m)}}function zo(){}function Vo(){if(this.p=null,this.data=null,this.left=null,this.right=null,this.count=null,2===arguments.length){var t=arguments[0],e=arguments[1];this.p=new p(t),this.left=null,this.right=null,this.count=1,this.data=e}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.p=new p(n,i),this.left=null,this.right=null,this.count=1,this.data=r}}function Xo(){if(this.root=null,this.numberOfNodes=null,this.tolerance=null,0===arguments.length)Xo.call(this,0);else if(1===arguments.length){var t=arguments[0];this.tolerance=t}}function Yo(){this.tolerance=null,this.matchNode=null,this.matchDist=0,this.p=null;var t=arguments[0],e=arguments[1];this.p=t,this.tolerance=e}function Uo(){this.initialVertices=null,this.segVertices=null,this.segments=new I,this.subdiv=null,this.incDel=null,this.convexHull=null,this.splitFinder=new So,this.kdt=null,this.vertexFactory=null,this.computeAreaEnv=null,this.splitPt=null,this.tolerance=null;var t=arguments[0],e=arguments[1];this.initialVertices=new I(t),this.tolerance=e,this.kdt=new Xo(e)}function Wo(){this.siteCoords=null,this.tolerance=0,this.subdiv=null}function Ho(){this.siteCoords=null,this.constraintLines=null,this.tolerance=0,this.subdiv=null,this.constraintVertexMap=new rt}function Jo(){this.siteCoords=null,this.tolerance=0,this.subdiv=null,this.clipEnv=null,this.diagramEnv=null}function Zo(){}"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(t){if(void 0===this||null===this)throw new TypeError(this+" is not an object");var e=Object(this),n=Math.max(Math.min(e.length,9007199254740991),0)||0,i=1 in arguments?parseInt(Number(arguments[1]),10)||0:0;i=i<0?Math.max(n+i,0):Math.min(i,n);var r=2 in arguments&&void 0!==arguments[2]?parseInt(Number(arguments[2]),10)||0:n;for(r=r<0?Math.max(n+arguments[2],0):Math.min(r,n);ie.x?1:this.ye.y?1:0},clone:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return f.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}},copy:function(){return new p(this)},toString:function(){return"("+this.x+", "+this.y+", "+this.z+")"},distance3D:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return Math.sqrt(e*e+n*n+i*i)},distance:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},hashCode:function(){var t=17;return t=37*t+p.hashCode(this.x),t=37*t+p.hashCode(this.y)},setCoordinate:function(t){this.x=t.x,this.y=t.y,this.z=t.z},interfaces_:function(){return[o,s,u]},getClass:function(){return p}}),p.hashCode=function(){if(1===arguments.length){var t=arguments[0],e=r.doubleToLongBits(t);return Math.trunc(e^e>>>32)}},e(d.prototype,{compare:function(t,e){var n=t,i=e,r=d.compare(n.x,i.x);if(0!==r)return r;var o=d.compare(n.y,i.y);return 0!==o?o:this.dimensionsToTest<=2?0:d.compare(n.z,i.z)},interfaces_:function(){return[a]},getClass:function(){return d}}),d.compare=function(t,e){return te?1:r.isNaN(t)?r.isNaN(e)?0:-1:r.isNaN(e)?1:0},p.DimensionalComparator=d,p.serialVersionUID=0x5cbf2c235c7e5800,p.NULL_ORDINATE=r.NaN,p.X=0,p.Y=1,p.Z=2,g.prototype.hasNext=function(){},g.prototype.next=function(){},g.prototype.remove=function(){},v.prototype.add=function(){},v.prototype.addAll=function(){},v.prototype.isEmpty=function(){},v.prototype.iterator=function(){},v.prototype.size=function(){},v.prototype.toArray=function(){},v.prototype.remove=function(){},y.prototype=new Error,y.prototype.name="IndexOutOfBoundsException",m.prototype=Object.create(v.prototype),m.prototype.constructor=m,m.prototype.get=function(){},m.prototype.set=function(){},m.prototype.isEmpty=function(){},x.prototype=new Error,x.prototype.name="NoSuchElementException",E.prototype=new Error,E.prototype.name="OperationNotSupported",I.prototype=Object.create(m.prototype),I.prototype.constructor=I,I.prototype.ensureCapacity=function(){},I.prototype.interfaces_=function(){return[m,v]},I.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},I.prototype.clear=function(){this.array_=[]},I.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},I.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},I.prototype.iterator=function(){return new Ko(this)},I.prototype.get=function(t){if(t<0||t>=this.size())throw new y;return this.array_[t]},I.prototype.isEmpty=function(){return 0===this.array_.length},I.prototype.size=function(){return this.array_.length},I.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e=1){var o=this.get(this.size()-1);if(o.equals2D(i))return null}I.prototype.add.call(this,i)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var s=arguments[0],a=arguments[1];return this.add(s,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var u=arguments[0],l=arguments[1],c=arguments[2];if(c)for(var h=0;h=0;h--)this.add(u[h],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof p){var f=arguments[0],d=arguments[1],g=arguments[2];if(!g){var v=this.size();if(v>0){if(f>0){var y=this.get(f-1);if(y.equals2D(d))return null}if(fN&&(b=-1);for(var h=w;h!==N;h+=b)this.add(x[h],E);return!0}},closeRing:function(){this.size()>0&&this.add(new p(this.get(0)),!1)},interfaces_:function(){return[]},getClass:function(){return w}}),w.coordArrayType=new Array(0).fill(null),e(N.prototype,{getArea:function(){return this.getWidth()*this.getHeight()},equals:function(t){if(!(t instanceof N))return!1;var e=t;return this.isNull()?e.isNull():this.maxx===e.getMaxX()&&this.maxy===e.getMaxY()&&this.minx===e.getMinX()&&this.miny===e.getMinY()},intersection:function(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new N;var e=this.minx>t.minx?this.minx:t.minx,n=this.miny>t.miny?this.miny:t.miny;return new N(e,this.maxx=this.minx&&e.getMaxX()<=this.maxx&&e.getMinY()>=this.miny&&e.getMaxY()<=this.maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&n>=this.minx&&n<=this.maxx&&i>=this.miny&&i<=this.maxy}},intersects:function(){if(1===arguments.length){if(arguments[0]instanceof N){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t.minx>this.maxx||t.maxxthis.maxy||t.maxythis.maxx||nthis.maxy||ithis.maxx&&(this.maxx=e.maxx),e.minythis.maxy&&(this.maxy=e.maxy))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.isNull()?(this.minx=n,this.maxx=n,this.miny=i,this.maxy=i):(nthis.maxx&&(this.maxx=n),ithis.maxy&&(this.maxy=i))}},minExtent:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te.minx?1:this.minye.miny?1:this.maxxe.maxx?1:this.maxye.maxy?1:0},translate:function(t,e){return this.isNull()?null:void this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},toString:function(){return"Env["+this.minx+" : "+this.maxx+", "+this.miny+" : "+this.maxy+"]"},setToNull:function(){this.minx=0,this.maxx=-1,this.miny=0,this.maxy=-1},getHeight:function(){return this.isNull()?0:this.maxy-this.miny},maxExtent:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},expandBy:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this.minx-=e,this.maxx+=e,this.miny-=n,this.maxy+=n,(this.minx>this.maxx||this.miny>this.maxy)&&this.setToNull()}},contains:function(){if(1===arguments.length){if(arguments[0]instanceof N){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof p){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return this.covers(n,i)}},centre:function(){return this.isNull()?null:new p((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},init:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof p){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof N){var e=arguments[0];this.minx=e.minx,this.maxx=e.maxx,this.miny=e.miny,this.maxy=e.maxy}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];rt.maxx&&(e=this.minx-t.maxx);var n=0;return this.maxyt.maxy&&(n=this.miny-t.maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},hashCode:function(){var t=17;return t=37*t+p.hashCode(this.minx),t=37*t+p.hashCode(this.maxx),t=37*t+p.hashCode(this.miny),t=37*t+p.hashCode(this.maxy)},interfaces_:function(){return[o,u]},getClass:function(){return N}}),N.intersects=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),u=Math.max(o.x,s.x),l=Math.min(i.x,r.x),c=Math.max(i.x,r.x);return!(l>u||cu||cn?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],o=arguments[2];return io?o:i}},L.wrap=function(t,e){return t<0?e- -t%e:t%e},L.max=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],i=t;return e>i&&(i=e),n>i&&(i=n),i}if(4===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],i=r;return o>i&&(i=o),s>i&&(i=s),a>i&&(i=a),i}},L.average=function(t,e){return(t+e)/2},L.LOG_10=Math.log(10),R.prototype.append=function(t){this.str+=t},R.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},R.prototype.toString=function(t){return this.str},P.prototype.intValue=function(){return this.value},P.prototype.compareTo=function(t){return this.valuet?1:0},P.isNaN=function(t){return Number.isNaN(t)},T.isWhitespace=function(t){return t<=32&&t>=0||127==t},T.toUpperCase=function(t){return t.toUpperCase()},e(O.prototype,{le:function(t){return this.hi9?(c=!0,h="9"):h="0"+l,s.append(h),n=n.subtract(O.valueOf(l)).multiply(O.TEN),c&&n.selfAdd(O.TEN);var f=!0,p=O.magnitude(n.hi);if(p<0&&Math.abs(p)>=a-u&&(f=!1),!f)break}return e[0]=i,s.toString()},sqr:function(){return this.multiply(this)},doubleValue:function(){return this.hi+this.lo},subtract:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},equals:function(){if(1===arguments.length){var t=arguments[0];return this.hi===t.hi&&this.lo===t.lo}},isZero:function(){return 0===this.hi&&0===this.lo},selfSubtract:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t.hi,-t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},getSpecialNumberString:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},min:function(t){return this.le(t)?this:t},selfDivide:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfDivide(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,o=null,s=null,a=null,u=null,l=null,c=null,h=null;return u=this.hi/n,l=O.SPLIT*u,r=l-u,h=O.SPLIT*n,r=l-r,o=u-r,s=h-n,c=u*n,s=h-s,a=n-s,h=r*s-c+r*a+o*s+o*a,l=(this.hi-c-h+this.lo-u*i)/n,h=u+l,this.hi=h,this.lo=u-h+l,this}},dump:function(){return"DD<"+this.hi+", "+this.lo+">"},divide:function(){if(arguments[0]instanceof O){var t=arguments[0],e=null,n=null,i=null,o=null,s=null,a=null,u=null,l=null;s=this.hi/t.hi,a=O.SPLIT*s,e=a-s,l=O.SPLIT*t.hi,e=a-e,n=s-e,i=l-t.hi,u=s*t.hi,i=l-i,o=t.hi-i,l=e*i-u+e*o+n*i+n*o,a=(this.hi-u-l+this.lo-s*t.lo)/t.hi,l=s+a;return new O(l,s-l+a)}if("number"==typeof arguments[0]){var c=arguments[0];return r.isNaN(c)?O.createNaN():O.copy(this).selfDivide(c,0)}},ge:function(t){return this.hi>t.hi||this.hi===t.hi&&this.lo>=t.lo},pow:function(t){if(0===t)return O.valueOf(1);var e=new O(this),n=O.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2==1&&n.selfMultiply(e),(i/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},ceil:function(){if(this.isNaN())return O.NaN;var t=Math.ceil(this.hi),e=0;return t===this.hi&&(e=Math.ceil(this.lo)),new O(t,e)},compareTo:function(t){var e=t;return this.hie.hi?1:this.loe.lo?1:0},rint:function(){return this.isNaN()?this:this.add(.5).floor()},setValue:function(){if(arguments[0]instanceof O){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},max:function(t){return this.ge(t)?this:t},sqrt:function(){if(this.isZero())return O.valueOf(0);if(this.isNegative())return O.NaN;var t=1/Math.sqrt(this.hi),e=this.hi*t,n=O.valueOf(e),i=this.subtract(n.sqr()),r=i.hi*(.5*t);return n.add(r)},selfAdd:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfAdd(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0],n=null,i=null,r=null,o=null,s=null,a=null;return r=this.hi+e,s=r-this.hi,o=r-s,o=e-s+(this.hi-o),a=o+this.lo,n=r+a,i=a+(r-n),this.hi=n+i,this.lo=i+(n-this.hi),this}}else if(2===arguments.length){var u=arguments[0],l=arguments[1],n=null,i=null,c=null,h=null,r=null,o=null,s=null,a=null;r=this.hi+u,c=this.lo+l,s=r-this.hi,a=c-this.lo,o=r-s,h=c-a,o=u-s+(this.hi-o),h=l-a+(this.lo-h),s=o+c,n=r+s,i=s+(r-n),s=h+i;var f=n+s,p=s+(n-f);return this.hi=f,this.lo=p,this}},selfMultiply:function(){if(1===arguments.length){if(arguments[0]instanceof O){var t=arguments[0];return this.selfMultiply(t.hi,t.lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,o=null,s=null,a=null,u=null,l=null;u=O.SPLIT*this.hi,r=u-this.hi,l=O.SPLIT*n,r=u-r,o=this.hi-r,s=l-n,u=this.hi*n,s=l-s,a=n-s,l=r*s-u+r*a+o*s+o*a+(this.hi*i+this.lo*n);var c=u+l;r=u-c;var h=l+r;return this.hi=c,this.lo=h,this}},selfSqr:function(){return this.selfMultiply(this)},floor:function(){if(this.isNaN())return O.NaN;var t=Math.floor(this.hi),e=0;return t===this.hi&&(e=Math.floor(this.lo)),new O(t,e)},negate:function(){return this.isNaN()?this:new O(-this.hi,-this.lo)},clone:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}},multiply:function(){if(arguments[0]instanceof O){var t=arguments[0];return t.isNaN()?O.createNaN():O.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return r.isNaN(e)?O.createNaN():O.copy(this).selfMultiply(e,0)}},isNaN:function(){return r.isNaN(this.hi)},intValue:function(){return Math.trunc(this.hi)},toString:function(){var t=O.magnitude(this.hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},toStandardNotation:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),i=e[0]+1,r=n;if("."===n.charAt(0))r="0"+n;else if(i<0)r="0."+O.stringOfChar("0",-i)+n;else if(-1===n.indexOf(".")){var o=i-n.length,s=O.stringOfChar("0",o);r=n+s+".0"}return this.isNegative()?"-"+r:r},reciprocal:function(){var t=null,e=null,n=null,i=null,r=null,o=null,s=null,a=null;r=1/this.hi,o=O.SPLIT*r,t=o-r,a=O.SPLIT*this.hi,t=o-t,e=r-t,n=a-this.hi,s=r*this.hi,n=a-n,i=this.hi-n,a=t*n-s+t*i+e*n+e*i,o=(1-s-a-r*this.lo)/this.hi;var u=r+o;return new O(u,r-u+o)},toSciNotation:function(){if(this.isZero())return O.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),i=O.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(0))throw new IllegalStateException("Found leading zero: "+n);var r="";n.length>1&&(r=n.substring(1));var o=n.charAt(0)+"."+r;return this.isNegative()?"-"+o+i:o+i},abs:function(){return this.isNaN()?O.NaN:this.isNegative()?this.negate():new O(this)},isPositive:function(){return this.hi>0||0===this.hi&&this.lo>0},lt:function(t){return this.hit.hi||this.hi===t.hi&&this.lo>t.lo},isNegative:function(){return this.hi<0||0===this.hi&&this.lo<0},trunc:function(){return this.isNaN()?O.NaN:this.isPositive()?this.floor():this.ceil()},signum:function(){return this.hi>0?1:this.hi<0?-1:this.lo>0?1:this.lo<0?-1:0},interfaces_:function(){return[u,o,s]},getClass:function(){return O}}),O.sqr=function(t){return O.valueOf(t).selfMultiply(t)},O.valueOf=function(){if("string"==typeof arguments[0]){var t=arguments[0];return O.parse(t)}if("number"==typeof arguments[0]){return new O(arguments[0])}},O.sqrt=function(t){return O.valueOf(t).sqrt()},O.parse=function(t){for(var e=0,n=t.length;T.isWhitespace(t.charAt(e));)e++;var i=!1;if(e=n);){var l=t.charAt(e);if(e++,T.isDigit(l)){var c=l-"0";o.selfMultiply(O.TEN),o.selfAdd(c),s++}else{if("."!==l){if("e"===l||"E"===l){var h=t.substring(e);try{u=P.parseInt(h)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+h+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+l+"' at position "+e+" in string "+t)}a=s}}var f=o,p=s-a-u;if(0===p)f=o;else if(p>0){var d=O.TEN.pow(p);f=o.divide(d)}else if(p<0){var d=O.TEN.pow(-p);f=o.multiply(d)}return i?f.negate():f},O.createNaN=function(){return new O(r.NaN,r.NaN)},O.copy=function(t){return new O(t)},O.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i},O.stringOfChar=function(t,e){for(var n=new R,i=0;i0){if(o<=0)return _.signum(s);i=r+o}else{if(!(r<0))return _.signum(s);if(o>=0)return _.signum(s);i=-r-o}var a=_.DP_SAFE_EPSILON*i;return s>=a||-s>=a?_.signum(s):2},_.signum=function(t){return t>0?1:t<0?-1:0},_.DP_SAFE_EPSILON=1e-15,e(A.prototype,{setOrdinate:function(t,e,n){},size:function(){},getOrdinate:function(t,e){},getCoordinate:function(){1===arguments.length?arguments[0]:2===arguments.length&&(arguments[0],arguments[1])},getCoordinateCopy:function(t){},getDimension:function(){},getX:function(t){},clone:function(){},expandEnvelope:function(t){},copy:function(){},getY:function(t){},toCoordinateArray:function(){},interfaces_:function(){return[s]},getClass:function(){return A}}),A.X=0,A.Y=1,A.Z=2,A.M=3,D.arraycopy=function(t,e,n,i,r){for(var o=0,s=e;s0},interfaces_:function(){return[j]},getClass:function(){return V}}),e(X.prototype,{isInBoundary:function(t){return t>1},interfaces_:function(){return[j]},getClass:function(){return X}}),e(Y.prototype,{isInBoundary:function(t){return 1===t},interfaces_:function(){return[j]},getClass:function(){return Y}}),j.Mod2BoundaryNodeRule=z,j.EndPointBoundaryNodeRule=V,j.MultiValentEndPointBoundaryNodeRule=X,j.MonoValentEndPointBoundaryNodeRule=Y,j.MOD2_BOUNDARY_RULE=new z,j.ENDPOINT_BOUNDARY_RULE=new V,j.MULTIVALENT_ENDPOINT_BOUNDARY_RULE=new X,j.MONOVALENT_ENDPOINT_BOUNDARY_RULE=new Y,j.OGC_SFS_BOUNDARY_RULE=j.MOD2_BOUNDARY_RULE,e(U.prototype,{interfaces_:function(){return[]},getClass:function(){return U}}),U.isRing=function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))},U.ptNotInList=function(t,e){for(var n=0;n=t?e:[]},U.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e},U.extract=function(t,e,n){e=L.clamp(e,0,t.length),n=L.clamp(n,-1,t.length);var i=n-e+1;n<0&&(i=0),e>=t.length&&(i=0),ni.length)return 1;if(0===n.length)return 0;var r=U.compare(n,i);return U.isEqualReversed(n,i)?0:r},OLDcompare:function(t,e){var n=t,i=e;if(n.lengthi.length)return 1;if(0===n.length)return 0;for(var r=U.increasingDirection(n),o=U.increasingDirection(i),s=r>0?0:n.length-1,a=o>0?0:n.length-1,u=0;u0))return e.value;e=e.right}}return null},rt.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:$o,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var o=r.value;return r.value=e,o}r=r.right}}while(null!==r);var s={key:t,left:null,right:null,value:e,parent:n,color:$o,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null},rt.prototype.fixAfterInsertion=function(t){for(t.color=1;null!=t&&t!=this.root_&&1==t.parent.color;)if(tt(t)==nt(tt(tt(t)))){var e=it(tt(tt(t)));1==$(e)?(et(tt(t),$o),et(e,$o),et(tt(tt(t)),1),t=tt(tt(t))):(t==it(tt(t))&&(t=tt(t),this.rotateLeft(t)),et(tt(t),$o),et(tt(tt(t)),1),this.rotateRight(tt(tt(t))))}else{var e=nt(tt(tt(t)));1==$(e)?(et(tt(t),$o),et(e,$o),et(tt(tt(t)),1),t=tt(tt(t))):(t==nt(tt(t))&&(t=tt(t),this.rotateRight(t)),et(tt(t),$o),et(tt(tt(t)),1),this.rotateLeft(tt(tt(t))))}this.root_.color=$o},rt.prototype.values=function(){var t=new I,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=rt.successor(e));)t.add(e.value);return t},rt.prototype.entrySet=function(){var t=new Q,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=rt.successor(e));)t.add(e);return t},rt.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left==t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},rt.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right==t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},rt.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},rt.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var e=t.parent,n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e},rt.prototype.size=function(){return this.size_},e(ot.prototype,{interfaces_:function(){return[]},getClass:function(){return ot}}),st.prototype=new K,at.prototype=new st,at.prototype.contains=function(t){for(var e=0,n=this.array_.length;e=0;){var s=r.substring(0,o);i.add(s),r=r.substring(o+n),o=r.indexOf(e)}r.length>0&&i.add(r);for(var a=new Array(i.size()).fill(null),u=0;u0)for(var o=r;o0&&i.append(" ");for(var o=0;o0&&i.append(","),i.append(wt.toString(t.getOrdinate(r,o)))}return i.append(")"),i.toString()}},Nt.ensureValidRing=function(t,e){var n=e.size();return 0===n?e:n<=3?Nt.createClosedRing(t,e,4):e.getOrdinate(0,A.X)===e.getOrdinate(n-1,A.X)&&e.getOrdinate(0,A.Y)===e.getOrdinate(n-1,A.Y)?e:Nt.createClosedRing(t,e,n+1)},Nt.createClosedRing=function(t,e,n){var i=t.create(n,e.getDimension()),r=e.size();Nt.copy(e,0,i,0,r);for(var o=r;o0&&Nt.reverse(this.points),null}},getCoordinate:function(){return this.isEmpty()?null:this.points.getCoordinate(0)},getBoundaryDimension:function(){return this.isClosed()?lt.FALSE:0},isClosed:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},getEndPoint:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},getDimension:function(){return 1},getLength:function(){return le.computeLength(this.points)},getNumPoints:function(){return this.points.size()},reverse:function(){var t=this.points.copy();return Nt.reverse(t),this.getFactory().createLineString(t)},compareToSameClass:function(){if(1===arguments.length){for(var t=arguments[0],e=t,n=0,i=0;n= 2)");this.points=t},isCoordinate:function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)")},getGeometryType:function(){return"LinearRing"},copy:function(){return new Pt(this.points.copy(),this.factory)},interfaces_:function(){return[]},getClass:function(){return Pt}}),Pt.MINIMUM_VALID_SIZE=4,Pt.serialVersionUID=-0x3b229e262367a600,c(Tt,ft),e(Tt.prototype,{getSortIndex:function(){return k.SORTINDEX_MULTIPOLYGON},equalsExact:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return!!this.isEquivalentClass(t)&&ft.prototype.equalsExact.call(this,t,e)}return ft.prototype.equalsExact.apply(this,arguments)},getBoundaryDimension:function(){return 1},getDimension:function(){return 2},reverse:function(){for(var t=this.geometries.length,e=new Array(t).fill(null),n=0;n0?e.createPoint(n[0]):e.createPoint():t},interfaces_:function(){return[_t]},getClass:function(){return Dt}}),e(Ft.prototype,{edit:function(t,e){return t instanceof Pt?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof bt?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof St?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},interfaces_:function(){return[_t]},getClass:function(){return Ft}}),Ot.NoOpGeometryOperation=At,Ot.CoordinateOperation=Dt,Ot.CoordinateSequenceOperation=Ft,e(Gt.prototype,{setOrdinate:function(t,e,n){switch(e){case A.X:this.coordinates[t].x=n;break;case A.Y:this.coordinates[t].y=n;break;case A.Z:this.coordinates[t].z=n;break;default:throw new i("invalid ordinateIndex")}},size:function(){return this.coordinates.length},getOrdinate:function(t,e){switch(e){case A.X:return this.coordinates[t].x;case A.Y:return this.coordinates[t].y;case A.Z:return this.coordinates[t].z}return r.NaN},getCoordinate:function(){if(1===arguments.length){var t=arguments[0];return this.coordinates[t]}if(2===arguments.length){var e=arguments[0],n=arguments[1];n.x=this.coordinates[e].x,n.y=this.coordinates[e].y,n.z=this.coordinates[e].z}},getCoordinateCopy:function(t){return new p(this.coordinates[t])},getDimension:function(){return this.dimension},getX:function(t){return this.coordinates[t].x},clone:function(){for(var t=new Array(this.size()).fill(null),e=0;e0){var t=new R(17*this.coordinates.length);t.append("("),t.append(this.coordinates[0]);for(var e=1;e3&&(e=3),e<2?new Gt(t):new Gt(t,e)}},interfaces_:function(){return[G,u]},getClass:function(){return qt}}),qt.instance=function(){return qt.instanceObject},qt.serialVersionUID=-0x38e49fa6cf6f2e00,qt.instanceObject=new qt;var es,ns=Object.defineProperty,is=function(t,e){function n(t){return this&&this.constructor===n?(this._keys=[],this._values=[],this._itp=[],this.objectOnly=e,void(t&&Bt.call(this,t))):new n(t)}return e||ns(t,"size",{get:Kt}),t.constructor=n,n.prototype=t,n}({delete:jt,has:Xt,get:zt,set:Yt,keys:Wt,values:Ht,entries:Jt,forEach:Qt,clear:Ut}),rs="undefined"!=typeof Map&&Map.prototype.values?Map:is;$t.prototype=new J,$t.prototype.get=function(t){return this.map_.get(t)||null},$t.prototype.put=function(t,e){return this.map_.set(t,e),e},$t.prototype.values=function(){for(var t=new I,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},$t.prototype.entrySet=function(){var t=new Q;return this.map_.entries().forEach(function(e){return t.add(e)}),t},$t.prototype.size=function(){return this.map_.size()},e(te.prototype,{equals:function(t){if(!(t instanceof te))return!1;var e=t;return this.modelType===e.modelType&&this.scale===e.scale},compareTo:function(t){var e=t,n=this.getMaximumSignificantDigits(),i=e.getMaximumSignificantDigits();return new P(n).compareTo(new P(i))},getScale:function(){return this.scale},isFloating:function(){return this.modelType===te.FLOATING||this.modelType===te.FLOATING_SINGLE},getType:function(){return this.modelType},toString:function(){var t="UNKNOWN";return this.modelType===te.FLOATING?t="Floating":this.modelType===te.FLOATING_SINGLE?t="Floating-Single":this.modelType===te.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},makePrecise:function(){if("number"==typeof arguments[0]){var t=arguments[0];if(r.isNaN(t))return t;if(this.modelType===te.FLOATING_SINGLE){return t}return this.modelType===te.FIXED?Math.round(t*this.scale)/this.scale:t}if(arguments[0]instanceof p){var e=arguments[0];if(this.modelType===te.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},getMaximumSignificantDigits:function(){var t=16;return this.modelType===te.FLOATING?t=16:this.modelType===te.FLOATING_SINGLE?t=6:this.modelType===te.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},setScale:function(t){this.scale=Math.abs(t)},interfaces_:function(){return[u,o]},getClass:function(){return te}}),te.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},e(ee.prototype,{readResolve:function(){return ee.nameToTypeMap.get(this.name)},toString:function(){return this.name},interfaces_:function(){return[u]},getClass:function(){return ee}}),ee.serialVersionUID=-552860263173159e4,ee.nameToTypeMap=new $t,te.Type=ee,te.serialVersionUID=0x6bee6404e9a25c00,te.FIXED=new ee("FIXED"),te.FLOATING=new ee("FLOATING"),te.FLOATING_SINGLE=new ee("FLOATING SINGLE"),te.maximumPreciseValue=9007199254740992,e(ne.prototype,{toGeometry:function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new p(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new p(t.getMinX(),t.getMinY()),new p(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new p(t.getMinX(),t.getMinY()),new p(t.getMinX(),t.getMaxY()),new p(t.getMaxX(),t.getMaxY()),new p(t.getMaxX(),t.getMinY()),new p(t.getMinX(),t.getMinY())]),null)},createLineString:function(){if(0===arguments.length)return this.createLineString(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLineString(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(M(arguments[0],A)){return new bt(arguments[0],this)}}},createMultiLineString:function(){if(0===arguments.length)return new pt(null,this);if(1===arguments.length){return new pt(arguments[0],this)}},buildGeometry:function(t){for(var e=null,n=!1,i=!1,r=t.iterator();r.hasNext();){var o=r.next(),s=o.getClass();null===e&&(e=s),s!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(i=!0)}if(null===e)return this.createGeometryCollection();if(n||i)return this.createGeometryCollection(ne.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof Lt)return this.createMultiPolygon(ne.toPolygonArray(t));if(a instanceof bt)return this.createMultiLineString(ne.toLineStringArray(t));if(a instanceof St)return this.createMultiPoint(ne.toPointArray(t));f.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},createMultiPointFromCoords:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},createPoint:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof p){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(M(arguments[0],A)){return new St(arguments[0],this)}}},getCoordinateSequenceFactory:function(){return this.coordinateSequenceFactory},createPolygon:function(){if(0===arguments.length)return new Lt(null,null,this);if(1===arguments.length){if(M(arguments[0],A)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Pt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return new Lt(i,r,this)}},getSRID:function(){return this.SRID},createGeometryCollection:function(){if(0===arguments.length)return new ft(null,this);if(1===arguments.length){return new ft(arguments[0],this)}},createGeometry:function(t){return new Ot(this).edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return arguments[1],this.coordinateSequenceFactory.create(t)}}})},getPrecisionModel:function(){return this.precisionModel},createLinearRing:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(M(arguments[0],A)){return new Pt(arguments[0],this)}}},createMultiPolygon:function(){if(0===arguments.length)return new Tt(null,this);if(1===arguments.length){return new Tt(arguments[0],this)}},createMultiPoint:function(){if(0===arguments.length)return new Rt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new Rt(arguments[0],this)}if(arguments[0]instanceof Array){var t=arguments[0];return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(M(arguments[0],A)){var e=arguments[0];if(null===e)return this.createMultiPoint(new Array(0).fill(null));for(var n=new Array(e.size()).fill(null),i=0;in?(this.intLineIndex[t][0]=0,this.intLineIndex[t][1]=1):(this.intLineIndex[t][0]=1,this.intLineIndex[t][1]=0)}},isProper:function(){return this.hasIntersection()&&this._isProper},setPrecisionModel:function(t){this.precisionModel=t},isInteriorIntersection:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;er?i:r;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=i>r?s:a)||t.equals(e)||(o=Math.max(s,a))}return f.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},oe.nonRobustComputeEdgeDistance=function(t,e,n){var i=t.x-e.x,r=t.y-e.y,o=Math.sqrt(i*i+r*r);return f.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},oe.DONT_INTERSECT=0,oe.DO_INTERSECT=1,oe.COLLINEAR=2,oe.NO_INTERSECTION=0,oe.POINT_INTERSECTION=1,oe.COLLINEAR_INTERSECTION=2,c(se,oe),e(se.prototype,{isInSegmentEnvelopes:function(t){var e=new N(this.inputLines[0][0],this.inputLines[0][1]),n=new N(this.inputLines[1][0],this.inputLines[1][1]);return e.contains(t)&&n.contains(t)},computeIntersection:function(){if(3!==arguments.length)return oe.prototype.computeIntersection.apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];return this._isProper=!1,N.intersects(e,n,t)&&0===le.orientationIndex(e,n,t)&&0===le.orientationIndex(n,e,t)?(this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this.result=oe.POINT_INTERSECTION,null):void(this.result=oe.NO_INTERSECTION)},normalizeToMinimum:function(t,e,n,i,r){r.x=this.smallestInAbsValue(t.x,e.x,n.x,i.x),r.y=this.smallestInAbsValue(t.y,e.y,n.y,i.y),t.x-=r.x,t.y-=r.y,e.x-=r.x,e.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},safeHCoordinateIntersection:function(t,e,n,i){var r=null;try{r=F.intersection(t,e,n,i)}catch(o){if(!(o instanceof C))throw o;r=se.nearestEndpoint(t,e,n,i)}return r},intersection:function(t,e,n,i){var r=this.intersectionWithNormalization(t,e,n,i);return this.isInSegmentEnvelopes(r)||(r=new p(se.nearestEndpoint(t,e,n,i))),null!==this.precisionModel&&this.precisionModel.makePrecise(r),r},smallestInAbsValue:function(t,e,n,i){var r=t,o=Math.abs(r);return Math.abs(e)1e-4&&D.out.println("Distance = "+r.distance(o))},intersectionWithNormalization:function(t,e,n,i){var r=new p(t),o=new p(e),s=new p(n),a=new p(i),u=new p;this.normalizeToEnvCentre(r,o,s,a,u);var l=this.safeHCoordinateIntersection(r,o,s,a);return l.x+=u.x,l.y+=u.y,l},computeCollinearIntersection:function(t,e,n,i){var r=N.intersects(t,e,n),o=N.intersects(t,e,i),s=N.intersects(n,i,t),a=N.intersects(n,i,e);return r&&o?(this.intPt[0]=n,this.intPt[1]=i,oe.COLLINEAR_INTERSECTION):s&&a?(this.intPt[0]=t,this.intPt[1]=e,oe.COLLINEAR_INTERSECTION):r&&s?(this.intPt[0]=n,this.intPt[1]=t,!n.equals(t)||o||a?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):r&&a?(this.intPt[0]=n,this.intPt[1]=e,!n.equals(e)||o||s?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):o&&s?(this.intPt[0]=i,this.intPt[1]=t,!i.equals(t)||r||a?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):o&&a?(this.intPt[0]=i,this.intPt[1]=e,!i.equals(e)||r||s?oe.COLLINEAR_INTERSECTION:oe.POINT_INTERSECTION):oe.NO_INTERSECTION},normalizeToEnvCentre:function(t,e,n,i,r){var o=t.xe.x?t.x:e.x,u=t.y>e.y?t.y:e.y,l=n.xi.x?n.x:i.x,f=n.y>i.y?n.y:i.y,p=o>l?o:l,d=ac?s:c,v=u0&&o>0||r<0&&o<0)return oe.NO_INTERSECTION;var s=le.orientationIndex(n,i,t),a=le.orientationIndex(n,i,e);return s>0&&a>0||s<0&&a<0?oe.NO_INTERSECTION:0===r&&0===o&&0===s&&0===a?this.computeCollinearIntersection(t,e,n,i):(0===r||0===o||0===s||0===a?(this._isProper=!1,t.equals2D(n)||t.equals2D(i)?this.intPt[0]=t:e.equals2D(n)||e.equals2D(i)?this.intPt[0]=e:0===r?this.intPt[0]=new p(n):0===o?this.intPt[0]=new p(i):0===s?this.intPt[0]=new p(t):0===a&&(this.intPt[0]=new p(e))):(this._isProper=!0,this.intPt[0]=this.intersection(t,e,n,i)),oe.POINT_INTERSECTION)},interfaces_:function(){return[]},getClass:function(){return se}}),se.nearestEndpoint=function(t,e,n,i){var r=t,o=le.distancePointLine(t,n,i),s=le.distancePointLine(e,n,i);return s0?n>0?-r:r:n>0?r:-r;if(0===e||0===n)return i>0?t>0?r:-r:t>0?-r:r;if(0=i?(t=-t,e=-e,n=-n,i=-i):(r=-r,o=-t,t=-n,n=o,o=-e,e=-i,i=o),0=n))return-r;r=-r,t=-t,n=-n}for(;;){if(a+=1,s=Math.floor(n/t),n-=s*t,(i-=s*e)<0)return-r;if(i>e)return r;if(t>n+n){if(ei+i)return-r;n=t-n,i=e-i,r=-r}if(0===i)return 0===n?0:-r;if(0===n)return r;if(s=Math.floor(t/n),t-=s*n,(e-=s*i)<0)return r;if(e>i)return-r;if(n>t+t){if(ie+e)return r;t=n-t,e=i-e,r=-r}if(0===e)return 0===t?0:r;if(0===t)return-r}},e(ue.prototype,{countSegment:function(t,e){if(t.xi&&(n=e.x,i=t.x),this.p.x>=n&&this.p.x<=i&&(this.isPointOnSegment=!0),null}if(t.y>this.p.y&&e.y<=this.p.y||e.y>this.p.y&&t.y<=this.p.y){var r=t.x-this.p.x,o=t.y-this.p.y,s=e.x-this.p.x,a=e.y-this.p.y,u=ae.signOfDet2x2(r,o,s,a);if(0===u)return this.isPointOnSegment=!0,null;a0&&this.crossingCount++}},isPointInPolygon:function(){return this.getLocation()!==S.EXTERIOR},getLocation:function(){return this.isPointOnSegment?S.BOUNDARY:this.crossingCount%2==1?S.INTERIOR:S.EXTERIOR},isOnSegment:function(){return this.isPointOnSegment},interfaces_:function(){return[]},getClass:function(){return ue}}),ue.locatePointInRing=function(){if(arguments[0]instanceof p&&M(arguments[1],A)){for(var t=arguments[0],e=arguments[1],n=new ue(t),i=new p,r=new p,o=1;o1||u<0||u>1)&&(r=!0)}}else r=!0;return r?L.min(le.distancePointLine(t,n,i),le.distancePointLine(e,n,i),le.distancePointLine(n,t,e),le.distancePointLine(i,t,e)):0},le.isPointInRing=function(t,e){return le.locatePointInRing(t,e)!==S.EXTERIOR},le.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,i=new p;t.getCoordinate(0,i);for(var r=i.x,o=i.y,s=1;sn.y&&(n=s,r=o)}var a=r;do{(a-=1)<0&&(a=e)}while(t[a].equals2D(n)&&a!==r);var u=r;do{u=(u+1)%e}while(t[u].equals2D(n)&&u!==r);var l=t[a],c=t[u];if(l.equals2D(n)||c.equals2D(n)||l.equals2D(c))return!1;var h=le.computeOrientation(l,n,c);return 0===h?l.x>c.x:h>0},le.locatePointInRing=function(t,e){return ue.locatePointInRing(t,e)},le.distancePointLinePerpendicular=function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)},le.computeOrientation=function(t,e,n){return le.orientationIndex(t,e,n)},le.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new i("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r=1)return s.distance(u);var h=((a.y-s.y)*(u.x-a.x)-(a.x-s.x)*(u.y-a.y))/l;return Math.abs(h)*Math.sqrt(l)}},le.isOnLine=function(t,e){for(var n=new se,i=1;i=0&&n>=0?Math.max(e,n):e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof p){var i=arguments[0];return le.orientationIndex(this.p0,this.p1,i)}},toGeometry:function(t){return t.createLineString([this.p0,this.p1])},isVertical:function(){return this.p0.x===this.p1.x},equals:function(t){if(!(t instanceof ce))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},intersection:function(t){var e=new se;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},project:function(){if(arguments[0]instanceof p){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new p(t);var e=this.projectionFactor(t),n=new p;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof ce){var i=arguments[0],r=this.projectionFactor(i.p0),o=this.projectionFactor(i.p1);if(r>=1&&o>=1)return null;if(r<=0&&o<=0)return null;var s=this.project(i.p0);r<0&&(s=this.p0),r>1&&(s=this.p1);var a=this.project(i.p1);return o<0&&(a=this.p0),o>1&&(a=this.p1),new ce(s,a)}},normalize:function(){this.p1.compareTo(this.p0)<0&&this.reverse()},angle:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},getCoordinate:function(t){return 0===t?this.p0:this.p1},distancePerpendicular:function(t){return le.distancePointLinePerpendicular(t,this.p0,this.p1)},minY:function(){return Math.min(this.p0.y,this.p1.y)},midPoint:function(){return ce.midPoint(this.p0,this.p1)},projectionFactor:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?r.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i},closestPoints:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=r.MAX_VALUE,o=null,s=this.closestPoint(t.p0);i=s.distance(t.p0),n[0]=s,n[1]=t.p0;var a=this.closestPoint(t.p1);(o=a.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||r.isNaN(e))&&(e=1),e},toString:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},isHorizontal:function(){return this.p0.y===this.p1.y},distance:function(){if(arguments[0]instanceof ce){var t=arguments[0];return le.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof p){var e=arguments[0];return le.distancePointLine(e,this.p0,this.p1)}},pointAlong:function(t){var e=new p;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},hashCode:function(){var t=java.lang.Double.doubleToLongBits(this.p0.x);t^=31*java.lang.Double.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=java.lang.Double.doubleToLongBits(this.p1.x);return n^=31*java.lang.Double.doubleToLongBits(this.p1.y),e^Math.trunc(n)^Math.trunc(n>>32)},interfaces_:function(){return[o,u]},getClass:function(){return ce}}),ce.midPoint=function(t,e){return new p((t.x+e.x)/2,(t.y+e.y)/2)},ce.serialVersionUID=0x2d2172135f411c00,e(he.prototype,{isIntersects:function(){return!this.isDisjoint()},isCovers:function(){return(he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])||he.isTrue(this.matrix[S.INTERIOR][S.BOUNDARY])||he.isTrue(this.matrix[S.BOUNDARY][S.INTERIOR])||he.isTrue(this.matrix[S.BOUNDARY][S.BOUNDARY]))&&this.matrix[S.EXTERIOR][S.INTERIOR]===lt.FALSE&&this.matrix[S.EXTERIOR][S.BOUNDARY]===lt.FALSE},isCoveredBy:function(){return(he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])||he.isTrue(this.matrix[S.INTERIOR][S.BOUNDARY])||he.isTrue(this.matrix[S.BOUNDARY][S.INTERIOR])||he.isTrue(this.matrix[S.BOUNDARY][S.BOUNDARY]))&&this.matrix[S.INTERIOR][S.EXTERIOR]===lt.FALSE&&this.matrix[S.BOUNDARY][S.EXTERIOR]===lt.FALSE},set:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e=0&&e>=0&&this.setAtLeast(t,e,n)},isWithin:function(){return he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])&&this.matrix[S.INTERIOR][S.EXTERIOR]===lt.FALSE&&this.matrix[S.BOUNDARY][S.EXTERIOR]===lt.FALSE},isTouches:function(t,e){return t>e?this.isTouches(e,t):(t===lt.A&&e===lt.A||t===lt.L&&e===lt.L||t===lt.L&&e===lt.A||t===lt.P&&e===lt.A||t===lt.P&&e===lt.L)&&this.matrix[S.INTERIOR][S.INTERIOR]===lt.FALSE&&(he.isTrue(this.matrix[S.INTERIOR][S.BOUNDARY])||he.isTrue(this.matrix[S.BOUNDARY][S.INTERIOR])||he.isTrue(this.matrix[S.BOUNDARY][S.BOUNDARY]))},isOverlaps:function(t,e){return t===lt.P&&e===lt.P||t===lt.A&&e===lt.A?he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])&&he.isTrue(this.matrix[S.INTERIOR][S.EXTERIOR])&&he.isTrue(this.matrix[S.EXTERIOR][S.INTERIOR]):t===lt.L&&e===lt.L&&1===this.matrix[S.INTERIOR][S.INTERIOR]&&he.isTrue(this.matrix[S.INTERIOR][S.EXTERIOR])&&he.isTrue(this.matrix[S.EXTERIOR][S.INTERIOR])},isEquals:function(t,e){return t===e&&he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])&&this.matrix[S.INTERIOR][S.EXTERIOR]===lt.FALSE&&this.matrix[S.BOUNDARY][S.EXTERIOR]===lt.FALSE&&this.matrix[S.EXTERIOR][S.INTERIOR]===lt.FALSE&&this.matrix[S.EXTERIOR][S.BOUNDARY]===lt.FALSE},toString:function(){for(var t=new R("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,lt.toDimensionSymbol(this.matrix[e][n]));return t.toString()},setAll:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.matrix[e][n]=t},get:function(t,e){return this.matrix[t][e]},transpose:function(){var t=this.matrix[1][0];return this.matrix[1][0]=this.matrix[0][1],this.matrix[0][1]=t,t=this.matrix[2][0],this.matrix[2][0]=this.matrix[0][2],this.matrix[0][2]=t,t=this.matrix[2][1],this.matrix[2][1]=this.matrix[1][2],this.matrix[1][2]=t,this},matches:function(t){if(9!==t.length)throw new i("Should be length 9: "+t);for(var e=0;e<3;e++)for(var n=0;n<3;n++)if(!he.matches(this.matrix[e][n],t.charAt(3*e+n)))return!1;return!0},add:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))},isDisjoint:function(){return this.matrix[S.INTERIOR][S.INTERIOR]===lt.FALSE&&this.matrix[S.INTERIOR][S.BOUNDARY]===lt.FALSE&&this.matrix[S.BOUNDARY][S.INTERIOR]===lt.FALSE&&this.matrix[S.BOUNDARY][S.BOUNDARY]===lt.FALSE},isCrosses:function(t,e){return t===lt.P&&e===lt.L||t===lt.P&&e===lt.A||t===lt.L&&e===lt.A?he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])&&he.isTrue(this.matrix[S.INTERIOR][S.EXTERIOR]):t===lt.L&&e===lt.P||t===lt.A&&e===lt.P||t===lt.A&&e===lt.L?he.isTrue(this.matrix[S.INTERIOR][S.INTERIOR])&&he.isTrue(this.matrix[S.EXTERIOR][S.INTERIOR]):t===lt.L&&e===lt.L&&0===this.matrix[S.INTERIOR][S.INTERIOR]},interfaces_:function(){return[s]},getClass:function(){return he}}),he.matches=function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],e=arguments[1];return e===lt.SYM_DONTCARE||e===lt.SYM_TRUE&&(t>=0||t===lt.TRUE)||e===lt.SYM_FALSE&&t===lt.FALSE||e===lt.SYM_P&&t===lt.P||e===lt.SYM_L&&t===lt.L||e===lt.SYM_A&&t===lt.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var n=arguments[0],i=arguments[1];return new he(n).matches(i)}},he.isTrue=function(t){return t>=0||t===lt.TRUE};var us=Object.freeze({Coordinate:p,CoordinateList:w,Envelope:N,LineSegment:ce,GeometryFactory:ne,Geometry:k,Point:St,LineString:bt,LinearRing:Pt,Polygon:Lt,GeometryCollection:ft,MultiPoint:Rt,MultiLineString:pt,MultiPolygon:Tt,Dimension:lt,IntersectionMatrix:he,PrecisionModel:te});e(fe.prototype,{addPoint:function(t){this.ptCount+=1,this.ptCentSum.x+=t.x,this.ptCentSum.y+=t.y},setBasePoint:function(t){null===this.areaBasePt&&(this.areaBasePt=t)},addLineSegments:function(t){for(var e=0,n=0;n0&&this.addPoint(t[0])},addHole:function(t){for(var e=le.isCCW(t),n=0;n0)t.x=this.cg3.x/3/this.areasum2,t.y=this.cg3.y/3/this.areasum2;else if(this.totalLength>0)t.x=this.lineCentSum.x/this.totalLength,t.y=this.lineCentSum.y/this.totalLength;else{if(!(this.ptCount>0))return null;t.x=this.ptCentSum.x/this.ptCount,t.y=this.ptCentSum.y/this.ptCount}return t},addShell:function(t){t.length>0&&this.setBasePoint(t[0]);for(var e=!le.isCCW(t),n=0;n=this.size())throw new IndexOutOfBoundsException;return this.array_[t]},de.prototype.push=function(t){return this.array_.push(t),t},de.prototype.pop=function(t){if(0===this.array_.length)throw new pe;return this.array_.pop()},de.prototype.peek=function(){if(0===this.array_.length)throw new pe;return this.array_[this.array_.length-1]},de.prototype.empty=function(){return 0===this.array_.length},de.prototype.isEmpty=function(){return this.empty()},de.prototype.search=function(t){return this.array_.indexOf(t)},de.prototype.size=function(){return this.array_.length},de.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e50&&(t=this.reduce(this.inputPts));var e=this.preSort(t),n=this.grahamScan(e),i=this.toCoordinateArray(n);return this.lineOrPolygon(i)},padArray3:function(t){for(var e=new Array(3).fill(null),n=0;ne[2].y&&(e[2]=t[i]),t[i].x+t[i].y>e[3].x+e[3].y&&(e[3]=t[i]),t[i].x>e[4].x&&(e[4]=t[i]),t[i].x-t[i].y>e[5].x-e[5].y&&(e[5]=t[i]),t[i].y0;)e=n.pop();e=n.push(e),e=n.push(t[i])}return e=n.push(t[0]),n},interfaces_:function(){return[]},getClass:function(){return ve}}),ve.extractCoordinates=function(t){var e=new ge;return t.apply(e),e.getCoordinates()},e(ye.prototype,{compare:function(t,e){var n=t,i=e;return ye.polarCompare(this.origin,n,i)},interfaces_:function(){return[a]},getClass:function(){return ye}}),ye.polarCompare=function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=n.x-t.x,s=n.y-t.y,a=le.computeOrientation(t,e,n);if(a===le.COUNTERCLOCKWISE)return 1;if(a===le.CLOCKWISE)return-1;var u=i*i+r*r,l=o*o+s*s;return ul?1:0},ve.RadialComparator=ye,e(me.prototype,{transformPoint:function(t,e){return this.factory.createPoint(this.transformCoordinates(t.getCoordinateSequence(),t))},transformPolygon:function(t,e){var n=!0,i=this.transformLinearRing(t.getExteriorRing(),t);null!==i&&i instanceof Pt&&!i.isEmpty()||(n=!1);for(var r=new I,o=0;o0&&i<4&&!this.preserveType?this.factory.createLineString(n):this.factory.createLinearRing(n)},interfaces_:function(){return[]},getClass:function(){return me}}),e(xe.prototype,{snapVertices:function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),i=0;i=0&&t.add(o+1,new p(r),!1)}},findSegmentIndexToSnap:function(t,e){for(var n=r.MAX_VALUE,i=-1,o=0;oe&&(e=i)}return e}if(2===arguments.length){var r=arguments[0],o=arguments[1];return Math.min(Ee.computeOverlaySnapTolerance(r),Ee.computeOverlaySnapTolerance(o))}},Ee.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*Ee.SNAP_PRECISION_FACTOR},Ee.snapToSelf=function(t,e,n){return new Ee(t).snapToSelf(e,n)},Ee.SNAP_PRECISION_FACTOR=1e-9,c(Ie,me),e(Ie.prototype,{snapLine:function(t,e){var n=new xe(t,this.snapTolerance);return n.setAllowSnappingToSourceVertices(this.isSelfSnap),n.snapTo(e)},transformCoordinates:function(t,e){var n=t.toCoordinateArray(),i=this.snapLine(n,this.snapPts);return this.factory.getCoordinateSequenceFactory().create(i)},interfaces_:function(){return[]},getClass:function(){return Ie}}),e(we.prototype,{getCommon:function(){return r.longBitsToDouble(this.commonBits)},add:function(t){var e=r.doubleToLongBits(t);return this.isFirst?(this.commonBits=e,this.commonSignExp=we.signExpBits(this.commonBits),this.isFirst=!1,null):we.signExpBits(e)!==this.commonSignExp?(this.commonBits=0,null):(this.commonMantissaBitsCount=we.numCommonMostSigMantissaBits(this.commonBits,e),void(this.commonBits=we.zeroLowerBits(this.commonBits,64-(12+this.commonMantissaBitsCount))))},toString:function(){if(1===arguments.length){var t=arguments[0],e=r.longBitsToDouble(t),n=Long.toBinaryString(t),i="0000000000000000000000000000000000000000000000000000000000000000"+n,o=i.substring(i.length-64);return o.substring(0,1)+" "+o.substring(1,12)+"(exp) "+o.substring(12)+" [ "+e+" ]"}},interfaces_:function(){return[]},getClass:function(){return we}}),we.getBit=function(t,e){return 0!=(t&1<>52},we.zeroLowerBits=function(t,e){return t&~((1<=0;i--){if(we.getBit(t,i)!==we.getBit(e,i))return n;n++}return 52},e(Ne.prototype,{addCommonBits:function(t){var e=new Ce(this.commonCoord);t.apply(e),t.geometryChanged()},removeCommonBits:function(t){if(0===this.commonCoord.x&&0===this.commonCoord.y)return t;var e=new p(this.commonCoord);e.x=-e.x,e.y=-e.y;var n=new Ce(e);return t.apply(n),t.geometryChanged(),t},getCommonCoordinate:function(){return this.commonCoord},add:function(t){t.apply(this.ccFilter),this.commonCoord=this.ccFilter.getCommonCoordinate()},interfaces_:function(){return[]},getClass:function(){return Ne}}),e(be.prototype,{filter:function(t){this.commonBitsX.add(t.x),this.commonBitsY.add(t.y)},getCommonCoordinate:function(){return new p(this.commonBitsX.getCommon(),this.commonBitsY.getCommon())},interfaces_:function(){return[B]},getClass:function(){return be}}),e(Ce.prototype,{filter:function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,i=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,i)},isDone:function(){return!1},isGeometryChanged:function(){return!0},interfaces_:function(){return[ht]},getClass:function(){return Ce}}),Ne.CommonCoordinateFilter=be,Ne.Translater=Ce,e(Se.prototype,{next:function(){if(this.atStart)return this.atStart=!1,Se.isAtomic(this.parent)&&this.index++,this.parent;if(null!==this.subcollectionIterator){if(this.subcollectionIterator.hasNext())return this.subcollectionIterator.next();this.subcollectionIterator=null}if(this.index>=this.max)throw new x;var t=this.parent.getGeometryN(this.index++);return t instanceof ft?(this.subcollectionIterator=new Se(t),this.subcollectionIterator.next()):t},remove:function(){throw new UnsupportedOperationException(this.getClass().getName())},hasNext:function(){if(this.atStart)return!0;if(null!==this.subcollectionIterator){if(this.subcollectionIterator.hasNext())return!0;this.subcollectionIterator=null}return!(this.index>=this.max)},interfaces_:function(){return[g]},getClass:function(){return Se}}),Se.isAtomic=function(t){return!(t instanceof ft)},e(Me.prototype,{locateInternal:function(){if(arguments[0]instanceof p&&arguments[1]instanceof Lt){var t=arguments[0],e=arguments[1];if(e.isEmpty())return S.EXTERIOR;var n=e.getExteriorRing(),i=this.locateInPolygonRing(t,n);if(i===S.EXTERIOR)return S.EXTERIOR;if(i===S.BOUNDARY)return S.BOUNDARY;for(var r=0;r0||this.isIn?S.INTERIOR:S.EXTERIOR)},interfaces_:function(){return[]},getClass:function(){return Me}}),e(Le.prototype,{interfaces_:function(){return[]},getClass:function(){return Le}}),Le.octant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new i("Cannot compute the octant for point ( "+t+", "+e+" )");var n=Math.abs(t),r=Math.abs(e);return t>=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof p&&arguments[1]instanceof p){var o=arguments[0],s=arguments[1],a=s.x-o.x,u=s.y-o.y;if(0===a&&0===u)throw new i("Cannot compute the octant for two identical points "+o);return Le.octant(a,u)}},e(Re.prototype,{getCoordinates:function(){},size:function(){},getCoordinate:function(t){},isClosed:function(){},setData:function(t){},getData:function(){},interfaces_:function(){return[]},getClass:function(){return Re}}),e(Pe.prototype,{getCoordinates:function(){return this.pts},size:function(){return this.pts.length},getCoordinate:function(t){return this.pts[t]},isClosed:function(){return this.pts[0].equals(this.pts[this.pts.length-1])},getSegmentOctant:function(t){return t===this.pts.length-1?-1:Le.octant(this.getCoordinate(t),this.getCoordinate(t+1))},setData:function(t){this.data=t},getData:function(){return this.data},toString:function(){return re.toLineString(new Gt(this.pts))},interfaces_:function(){return[Re]},getClass:function(){return Pe}}),e(Te.prototype,{getBounds:function(){},interfaces_:function(){return[]},getClass:function(){return Te}}),e(Oe.prototype,{getItem:function(){return this.item},getBounds:function(){return this.bounds},interfaces_:function(){return[Te,u]},getClass:function(){return Oe}}),e(_e.prototype,{poll:function(){if(this.isEmpty())return null;var t=this.items.get(1);return this.items.set(1,this.items.get(this._size)),this._size-=1,this.reorder(1),t},size:function(){return this._size},reorder:function(t){for(var e=null,n=this.items.get(t);2*t<=this._size&&(e=2*t,e!==this._size&&this.items.get(e+1).compareTo(this.items.get(e))<0&&e++,this.items.get(e).compareTo(n)<0);t=e)this.items.set(t,this.items.get(e));this.items.set(t,n)},clear:function(){this._size=0,this.items.clear()},isEmpty:function(){return 0===this._size},add:function(t){this.items.add(null),this._size+=1;var e=this._size;for(this.items.set(0,t);t.compareTo(this.items.get(Math.trunc(e/2)))<0;e/=2)this.items.set(e,this.items.get(Math.trunc(e/2)));this.items.set(e,t)},interfaces_:function(){return[]},getClass:function(){return _e}}),e(Ae.prototype,{visitItem:function(t){},interfaces_:function(){return[]},getClass:function(){return Ae}}),e(De.prototype,{insert:function(t,e){},remove:function(t,e){},query:function(){1===arguments.length?arguments[0]:2===arguments.length&&(arguments[0],arguments[1])},interfaces_:function(){return[]},getClass:function(){return De}}),e(Fe.prototype,{getLevel:function(){return this.level},size:function(){return this.childBoundables.size()},getChildBoundables:function(){return this.childBoundables},addChildBoundable:function(t){f.isTrue(null===this.bounds),this.childBoundables.add(t)},isEmpty:function(){return this.childBoundables.isEmpty()},getBounds:function(){return null===this.bounds&&(this.bounds=this.computeBounds()),this.bounds},interfaces_:function(){return[Te,u]},getClass:function(){return Fe}}),Fe.serialVersionUID=0x5a1e55ec41369800;var ls={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return ls.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?ut.sort(n,e):ut.sort(n);for(var i=t.iterator(),r=0,o=n.length;rGe.area(this.boundable2)?(this.expand(this.boundable1,this.boundable2,t,e),null):(this.expand(this.boundable2,this.boundable1,t,e),null);if(n)return this.expand(this.boundable1,this.boundable2,t,e),null;if(r)return this.expand(this.boundable2,this.boundable1,t,e),null;throw new i("neither boundable is composite")},isLeaves:function(){return!(Ge.isComposite(this.boundable1)||Ge.isComposite(this.boundable2))},compareTo:function(t){var e=t;return this._distancee._distance?1:0},expand:function(t,e,n,i){for(var r=t.getChildBoundables(),o=r.iterator();o.hasNext();){var s=o.next(),a=new Ge(s,e,this.itemDistance);a.getDistance()-2),i.getLevel()===n)return r.add(i),null;for(var o=i.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof Fe?this.boundablesAtLevel(n,s,r):(f.isTrue(s instanceof Oe),-1===n&&r.add(s))}return null}},query:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new I;return this.isEmpty()?e:(this.getIntersectsOp().intersects(this.root.getBounds(),t)&&this.query(t,this.root,e),e)}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this.root.getBounds(),n)&&this.query(n,this.root,i)}else if(3===arguments.length)if(M(arguments[2],Ae)&&arguments[0]instanceof Object&&arguments[1]instanceof Fe)for(var r=arguments[0],o=arguments[1],s=arguments[2],a=o.getChildBoundables(),u=0;ue&&(e=r)}}return e+1}},createParentBoundables:function(t,e){f.isTrue(!t.isEmpty());var n=new I;n.add(this.createNode(e));var i=new I(t);ls.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var o=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n},isEmpty:function(){return this.built?this.root.isEmpty():this.itemBoundables.isEmpty()},interfaces_:function(){return[u]},getClass:function(){return qe}}),qe.compareDoubles=function(t,e){return t>e?1:t0);for(var n=new I,i=0;i0;){var h=c.poll(),f=h.getDistance();if(f>=u)break;h.isLeaves()?(u=f,l=h):h.expandToQueue(c,u)}return[l.getBoundable(0).getItem(),l.getBoundable(1).getItem()]}}else if(3===arguments.length){var p=arguments[0],d=arguments[1],g=arguments[2],v=new Oe(p,d),e=new Ge(this.getRoot(),v,g);return this.nearestNeighbour(e)[0]}},interfaces_:function(){return[De,u]},getClass:function(){return je}}),je.centreX=function(t){return je.avg(t.getMinX(),t.getMaxX())},je.avg=function(t,e){return(t+e)/2},je.centreY=function(t){return je.avg(t.getMinY(),t.getMaxY())},c(ze,Fe),e(ze.prototype,{computeBounds:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new N(n.getBounds()):t.expandToInclude(n.getBounds())}return t},interfaces_:function(){return[]},getClass:function(){return ze}}),je.STRtreeNode=ze,je.serialVersionUID=0x39920f7d5f261e0,je.xComparator={interfaces_:function(){return[a]},compare:function(t,e){return qe.compareDoubles(je.centreX(t.getBounds()),je.centreX(e.getBounds()))}},je.yComparator={interfaces_:function(){return[a]},compare:function(t,e){return qe.compareDoubles(je.centreY(t.getBounds()),je.centreY(e.getBounds()))}},je.intersectsOp={interfaces_:function(){return[IntersectsOp]},intersects:function(t,e){return t.intersects(e)}},je.DEFAULT_NODE_CAPACITY=10,e(Ve.prototype,{interfaces_:function(){return[]},getClass:function(){return Ve}}),Ve.relativeSign=function(t,e){return te?1:0},Ve.compare=function(t,e,n){if(e.equals2D(n))return 0;var i=Ve.relativeSign(e.x,n.x),r=Ve.relativeSign(e.y,n.y);switch(t){case 0:return Ve.compareValue(i,r);case 1:return Ve.compareValue(r,i);case 2:return Ve.compareValue(r,-i);case 3:return Ve.compareValue(-i,r);case 4:return Ve.compareValue(-i,-r);case 5:return Ve.compareValue(-r,-i);case 6:return Ve.compareValue(-r,i);case 7:return Ve.compareValue(i,-r)}return f.shouldNeverReachHere("invalid octant value"),0},Ve.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0},e(Xe.prototype,{getCoordinate:function(){return this.coord},print:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},compareTo:function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:Ve.compare(this.segmentOctant,this.coord,e.coord)},isEndPoint:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},isInterior:function(){return this._isInterior},interfaces_:function(){return[o]},getClass:function(){return Xe}}),e(Ye.prototype,{getSplitCoordinates:function(){var t=new w;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()},addCollapsedNodes:function(){var t=new I;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this.edge.getCoordinate(n),n)}},print:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t)}},findCollapsesFromExistingVertices:function(t){for(var e=0;ee?t:e;return 0===n&&3===i?3:n},Ke.isInHalfPlane=function(t,e){return e===Ke.SE?t===Ke.SE||t===Ke.SW:t===e||t===e+1},Ke.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new i("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?Ke.NE:Ke.SE:e>=0?Ke.NW:Ke.SW}if(arguments[0]instanceof p&&arguments[1]instanceof p){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new i("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?Ke.NE:Ke.SE:r.y>=n.y?Ke.NW:Ke.SW}},Ke.NE=0,Ke.NW=1,Ke.SW=2,Ke.SE=3,e(Qe.prototype,{interfaces_:function(){return[]},getClass:function(){return Qe}}),Qe.getChainStartIndices=function(t){var e=0,n=new I;n.add(new P(e));do{var i=Qe.findChainEnd(t,e);n.add(new P(i)),e=i}while(e=t.length-1)return t.length-1;for(var i=Ke.quadrant(t[n],t[n+1]),r=e+1;rn.getId()&&(n.computeOverlaps(o,t),this.nOverlaps++),this.segInt.isDone())return null}},interfaces_:function(){return[]},getClass:function(){return en}}),c(nn,Je),e(nn.prototype,{overlap:function(){if(4!==arguments.length)return Je.prototype.overlap.apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3],r=t.getContext(),o=n.getContext();this.si.processIntersections(r,e,o,i)},interfaces_:function(){return[]},getClass:function(){return nn}}),en.SegmentOverlapAction=nn,c(rn,l),e(rn.prototype,{getCoordinate:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return rn}}),rn.msgWithCoord=function(t,e){return null!==e?t+" [ "+e+" ]":t},e(on.prototype,{processIntersections:function(t,e,n,i){},isDone:function(){},interfaces_:function(){return[]},getClass:function(){return on}}),e(sn.prototype,{getInteriorIntersection:function(){return this.interiorIntersection},setCheckEndSegmentsOnly:function(t){this.isCheckEndSegmentsOnly=t},getIntersectionSegments:function(){return this.intSegments},count:function(){return this.intersectionCount},getIntersections:function(){return this.intersections},setFindAllIntersections:function(t){this.findAllIntersections=t},setKeepIntersections:function(t){this.keepIntersections=t},processIntersections:function(t,e,n,i){if(!this.findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===i)return null;if(this.isCheckEndSegmentsOnly){if(!(this.isEndSegment(t,e)||this.isEndSegment(n,i)))return null}var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this.li.computeIntersection(r,o,s,a),this.li.hasIntersection()&&this.li.isInteriorIntersection()&&(this.intSegments=new Array(4).fill(null),this.intSegments[0]=r,this.intSegments[1]=o,this.intSegments[2]=s,this.intSegments[3]=a,this.interiorIntersection=this.li.getIntersection(0),this.keepIntersections&&this.intersections.add(this.interiorIntersection),this.intersectionCount++)},isEndSegment:function(t,e){return 0===e||e>=t.size()-2},hasIntersection:function(){return null!==this.interiorIntersection},isDone:function(){return!this.findAllIntersections&&null!==this.interiorIntersection},interfaces_:function(){return[on]},getClass:function(){return sn}}),sn.createAllIntersectionsFinder=function(t){var e=new sn(t);return e.setFindAllIntersections(!0),e},sn.createAnyIntersectionFinder=function(t){return new sn(t)},sn.createIntersectionCounter=function(t){var e=new sn(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e},e(an.prototype,{execute:function(){return null!==this.segInt?null:void this.checkInteriorIntersections()},getIntersections:function(){return this.segInt.getIntersections()},isValid:function(){return this.execute(),this._isValid},setFindAllIntersections:function(t){this.findAllIntersections=t},checkInteriorIntersections:function(){this._isValid=!0,this.segInt=new sn(this.li),this.segInt.setFindAllIntersections(this.findAllIntersections);var t=new en;if(t.setSegmentIntersector(this.segInt),t.computeNodes(this.segStrings),this.segInt.hasIntersection())return this._isValid=!1,null},checkValid:function(){if(this.execute(),!this._isValid)throw new rn(this.getErrorMessage(),this.segInt.getInteriorIntersection())},getErrorMessage:function(){if(this._isValid)return"no intersections found";var t=this.segInt.getIntersectionSegments();return"found non-noded intersection between "+re.toLineString(t[0],t[1])+" and "+re.toLineString(t[2],t[3])},interfaces_:function(){return[]},getClass:function(){return an}}),an.computeIntersections=function(t){var e=new an(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()},e(un.prototype,{checkValid:function(){this.nv.checkValid()},interfaces_:function(){return[]},getClass:function(){return un}}),un.toSegmentStrings=function(t){for(var e=new I,n=t.iterator();n.hasNext();){var i=n.next();e.add(new Pe(i.getCoordinates(),i))}return e},un.checkValid=function(t){new un(t).checkValid()},e(ln.prototype,{map:function(t){for(var e=new I,n=0;nthis.location.length){var e=new Array(3).fill(null);e[cn.ON]=this.location[cn.ON],e[cn.LEFT]=S.NONE,e[cn.RIGHT]=S.NONE,this.location=e}for(var n=0;n1&&t.append(S.toLocationSymbol(this.location[cn.LEFT])),t.append(S.toLocationSymbol(this.location[cn.ON])),this.location.length>1&&t.append(S.toLocationSymbol(this.location[cn.RIGHT])),t.toString()},setLocations:function(t,e,n){this.location[cn.ON]=t,this.location[cn.LEFT]=e,this.location[cn.RIGHT]=n},get:function(t){return t1},isAnyNull:function(){for(var t=0;tthis.maxNodeDegree&&(this.maxNodeDegree=n),t=this.getNext(t)}while(t!==this.startDe);this.maxNodeDegree*=2},addPoints:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var o=r;o=0;o--)this.pts.add(i[o])}},isHole:function(){return this._isHole},setInResult:function(){var t=this.startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this.startDe)},containsPoint:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!le.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this.holes.iterator();n.hasNext();){if(n.next().containsPoint(t))return!1}return!0},addHole:function(t){this.holes.add(t)},isShell:function(){return null===this.shell},getLabel:function(){return this.label},getEdges:function(){return this.edges},getMaxNodeDegree:function(){return this.maxNodeDegree<0&&this.computeMaxNodeDegree(),this.maxNodeDegree},getShell:function(){return this.shell},mergeLabel:function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=e.getLocation(n,cn.RIGHT);if(i===S.NONE)return null;if(this.label.getLocation(n)===S.NONE)return this.label.setLocation(n,i),null}},setShell:function(t){this.shell=t,null!==t&&t.addHole(this)},toPolygon:function(t){for(var e=new Array(this.holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)},isInResult:function(){return this._isInResult},isVisited:function(){return this._isVisited},interfaces_:function(){return[]},getClass:function(){return vn}}),c(yn,vn),e(yn.prototype,{isIncidentEdgeInResult:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();){if(t.next().getEdge().isInResult())return!0}return!1},isIsolated:function(){return 1===this.label.getGeometryCount()},getCoordinate:function(){return this.coord},print:function(t){t.println("node "+this.coord+" lbl: "+this.label)},computeIM:function(t){},computeMergedLocation:function(t,e){var n=S.NONE;if(n=this.label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==S.BOUNDARY&&(n=i)}return n},setLabel:function(){if(2!==arguments.length)return vn.prototype.setLabel.apply(this,arguments);var t=arguments[0],e=arguments[1];null===this.label?this.label=new fn(t,e):this.label.setLocation(t,e)},getEdges:function(){return this.edges},mergeLabel:function(){if(arguments[0]instanceof yn){var t=arguments[0];this.mergeLabel(t.label)}else if(arguments[0]instanceof fn)for(var e=arguments[0],n=0;n<2;n++){var i=this.computeMergedLocation(e,n),r=this.label.getLocation(n);r===S.NONE&&this.label.setLocation(n,i)}},add:function(t){this.edges.insert(t),t.setNode(this)},setLabelBoundary:function(t){if(null===this.label)return null;var e=S.NONE;null!==this.label&&(e=this.label.getLocation(t));var n=null;switch(e){case S.BOUNDARY:n=S.INTERIOR;break;case S.INTERIOR:n=S.BOUNDARY;break;default:n=S.BOUNDARY}this.label.setLocation(t,n)},interfaces_:function(){return[]},getClass:function(){return yn}}),e(mn.prototype,{find:function(t){return this.nodeMap.get(t)},addNode:function(){if(arguments[0]instanceof p){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof yn){var n=arguments[0],e=this.nodeMap.get(n.getCoordinate());return null===e?(this.nodeMap.put(n.getCoordinate(),n),n):(e.mergeLabel(n),e)}},print:function(t){for(var e=this.iterator();e.hasNext();){e.next().print(t)}},iterator:function(){return this.nodeMap.values().iterator()},values:function(){return this.nodeMap.values()},getBoundaryNodes:function(t){for(var e=new I,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===S.BOUNDARY&&e.add(i)}return e},add:function(t){var e=t.getCoordinate();this.addNode(e).add(t)},interfaces_:function(){return[]},getClass:function(){return mn}}),e(xn.prototype,{compareDirection:function(t){return this.dx===t.dx&&this.dy===t.dy?0:this.quadrant>t.quadrant?1:this.quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else i.add(o)}return i},containsPoint:function(t){for(var e=this.shellList.iterator();e.hasNext();){if(e.next().containsPoint(t))return!0}return!1},buildMaximalEdgeRings:function(t){for(var e=new I,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new gn(i,this.geometryFactory);e.add(r),r.setInResult()}}return e},placePolygonHoles:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}},getPolygons:function(){return this.computePolygons(this.shellList)},findEdgeRingContaining:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),c=l.getEnvelopeInternal();null!==o&&(s=o.getLinearRing().getEnvelopeInternal());var h=!1;c.contains(i)&&le.isPointInRing(r,l.getCoordinates())&&(h=!0),h&&(null===o||s.contains(c))&&(o=u)}return o},findShell:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return f.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},add:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];wn.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new I,o=this.buildMinimalEdgeRings(i,this.shellList,r);this.sortShellsAndHoles(o,this.shellList,r),this.placeFreeHoles(this.shellList,r)}},interfaces_:function(){return[]},getClass:function(){return Nn}}),e(bn.prototype,{collectLines:function(t){for(var e=this.op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next();this.collectLineEdge(n,t,this.lineEdgesList),this.collectBoundaryTouchEdge(n,t,this.lineEdgesList)}},labelIsolatedLine:function(t,e){var n=this.ptLocator.locate(t.getCoordinate(),this.op.getArgGeometry(e));t.getLabel().setLocation(e,n)},build:function(t){return this.findCoveredLineEdges(),this.collectLines(t),this.buildLines(t),this.resultLineList},collectLineEdge:function(t,e,n){var i=t.getLabel(),r=t.getEdge();t.isLineEdge()&&(t.isVisited()||!ni.isResultOfOp(i,e)||r.isCovered()||(n.add(r),t.setVisitedEdge(!0)))},findCoveredLineEdges:function(){for(var t=this.op.getGraph().getNodes().iterator();t.hasNext();){t.next().getEdges().findCoveredLineEdges()}for(var e=this.op.getGraph().getEdgeEnds().iterator();e.hasNext();){var n=e.next(),i=n.getEdge();if(n.isLineEdge()&&!i.isCoveredSet()){var r=this.op.isCoveredByA(n.getCoordinate());i.setCovered(r)}}},labelIsolatedLines:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getLabel();n.isIsolated()&&(i.isNull(0)?this.labelIsolatedLine(n,0):this.labelIsolatedLine(n,1))}},buildLines:function(t){for(var e=this.lineEdgesList.iterator();e.hasNext();){var n=e.next(),i=(n.getLabel(),this.geometryFactory.createLineString(n.getCoordinates()));this.resultLineList.add(i),n.setInResult(!0)}},collectBoundaryTouchEdge:function(t,e,n){var i=t.getLabel();return t.isLineEdge()?null:t.isVisited()?null:t.isInteriorAreaEdge()?null:t.getEdge().isInResult()?null:(f.isTrue(!(t.isInResult()||t.getSym().isInResult())||!t.getEdge().isInResult()),void(ni.isResultOfOp(i,e)&&e===ni.INTERSECTION&&(n.add(t.getEdge()),t.setVisitedEdge(!0))))},interfaces_:function(){return[]},getClass:function(){return bn}}),e(Cn.prototype,{filterCoveredNodeToPoint:function(t){var e=t.getCoordinate();if(!this.op.isCoveredByLA(e)){var n=this.geometryFactory.createPoint(e);this.resultPointList.add(n)}},extractNonCoveredResultNodes:function(t){for(var e=this.op.getGraph().getNodes().iterator();e.hasNext();){var n=e.next();if(!(n.isInResult()||n.isIncidentEdgeInResult()||0!==n.getEdges().getDegree()&&t!==ni.INTERSECTION)){var i=n.getLabel();ni.isResultOfOp(i,t)&&this.filterCoveredNodeToPoint(n)}}},build:function(t){return this.extractNonCoveredResultNodes(t),this.resultPointList},interfaces_:function(){return[]},getClass:function(){return Cn}}),e(Sn.prototype,{locate:function(t){},interfaces_:function(){return[]},getClass:function(){return Sn}}),e(Mn.prototype,{locate:function(t){return Mn.locate(t,this.geom)},interfaces_:function(){return[Sn]},getClass:function(){return Mn}}),Mn.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&le.isPointInRing(t,e.getCoordinates())},Mn.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Mn.isPointInRing(t,n))return!1;for(var i=0;i=0;n--){var i=this.edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)},computeDepths:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=(t.getLabel(),t.getDepth(cn.LEFT)),i=t.getDepth(cn.RIGHT),r=this.computeDepths(e+1,this.edgeList.size(),n);if(this.computeDepths(0,e,r)!==i)throw new rn("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[0],s=arguments[1],a=arguments[2],u=a,l=o;l=0;r--){var o=this.resultAreaEdgeList.get(r),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),i){case this.SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,i=this.LINKING_TO_OUTGOING;break;case this.LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),i=this.SCANNING_FOR_INCOMING}}i===this.LINKING_TO_OUTGOING&&(f.isTrue(null!==e,"found null for first outgoing dirEdge"),f.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))},getOutgoingDegree:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){var n=e.next();n.isInResult()&&t++}return t}if(1===arguments.length){for(var i=arguments[0],t=0,e=this.iterator();e.hasNext();){var n=e.next();n.getEdgeRing()===i&&t++}return t}},getLabel:function(){return this.label},findCoveredLineEdges:function(){for(var t=S.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=S.INTERIOR;break}if(i.isInResult()){t=S.EXTERIOR;break}}}if(t===S.NONE)return null;for(var r=t,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();n.isLineEdge()?n.getEdge().setCovered(r===S.INTERIOR):(n.isInResult()&&(r=S.EXTERIOR),i.isInResult()&&(r=S.INTERIOR))}},computeLabelling:function(t){Ln.prototype.computeLabelling.call(this,t),this.label=new fn(S.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next(),i=n.getEdge(),r=i.getLabel(),o=0;o<2;o++){var s=r.getLocation(o);s!==S.INTERIOR&&s!==S.BOUNDARY||this.label.setLocation(o,S.INTERIOR)}},interfaces_:function(){return[]},getClass:function(){return Rn}}),c(Pn,In),e(Pn.prototype,{createNode:function(t){return new yn(t,new Rn)},interfaces_:function(){return[]},getClass:function(){return Pn}}),e(Tn.prototype,{computeIntersections:function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},interfaces_:function(){return[]},getClass:function(){return Tn}}),e(On.prototype,{isDelete:function(){return this.eventType===On.DELETE},setDeleteEventIndex:function(t){this.deleteEventIndex=t},getObject:function(){return this.obj},compareTo:function(t){var e=t;return this.xValuee.xValue?1:this.eventTypee.eventType?1:0},getInsertEvent:function(){return this.insertEvent},isInsert:function(){return this.eventType===On.INSERT},isSameLabel:function(t){return null!==this.label&&this.label===t.label},getDeleteEventIndex:function(){return this.deleteEventIndex},interfaces_:function(){return[o]},getClass:function(){return On}}),On.INSERT=1,On.DELETE=2,e(_n.prototype,{interfaces_:function(){return[]},getClass:function(){return _n}}),e(An.prototype,{isTrivialIntersection:function(t,e,n,i){if(t===n&&1===this.li.getIntersectionNum()){if(An.isAdjacentSegments(e,i))return!0;if(t.isClosed()){var r=t.getNumPoints()-1;if(0===e&&i===r||0===i&&e===r)return!0}}return!1},getProperIntersectionPoint:function(){return this.properIntersectionPoint},setIsDoneIfProperInt:function(t){this.isDoneWhenProperInt=t},hasProperInteriorIntersection:function(){return this.hasProperInterior},isBoundaryPointInternal:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next(),r=i.getCoordinate();if(t.isIntersection(r))return!0}return!1},hasProperIntersection:function(){return this.hasProper},hasIntersection:function(){return this._hasIntersection},isDone:function(){return this._isDone},isBoundaryPoint:function(t,e){return!(null===e||!this.isBoundaryPointInternal(t,e[0])&&!this.isBoundaryPointInternal(t,e[1]))},setBoundaryNodes:function(t,e){this.bdyNodes=new Array(2).fill(null),this.bdyNodes[0]=t,this.bdyNodes[1]=e},addIntersections:function(t,e,n,i){if(t===n&&e===i)return null;this.numTests++;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];this.li.computeIntersection(r,o,s,a),this.li.hasIntersection()&&(this.recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this.numIntersections++,this.isTrivialIntersection(t,e,n,i)||(this._hasIntersection=!0,!this.includeProper&&this.li.isProper()||(t.addIntersections(this.li,e,0),n.addIntersections(this.li,i,1)),this.li.isProper()&&(this.properIntersectionPoint=this.li.getIntersection(0).copy(),this.hasProper=!0,this.isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this.li,this.bdyNodes)||(this.hasProperInterior=!0))))},interfaces_:function(){return[]},getClass:function(){return An}}),An.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)},c(Dn,_n),e(Dn.prototype,{prepareEvents:function(){ls.sort(this.events);for(var t=0;te||this.maxo?1:0},interfaces_:function(){return[a]},getClass:function(){return Gn}}),Fn.NodeComparator=Gn,c(qn,Fn),e(qn.prototype,{query:function(t,e,n){return this.intersects(t,e)?void n.visitItem(this.item):null},interfaces_:function(){return[]},getClass:function(){return qn}}),c(kn,Fn),e(kn.prototype,{buildExtent:function(t,e){this.min=Math.min(t.min,e.min),this.max=Math.max(t.max,e.max)},query:function(t,e,n){return this.intersects(t,e)?(null!==this.node1&&this.node1.query(t,e,n),void(null!==this.node2&&this.node2.query(t,e,n))):null},interfaces_:function(){return[]},getClass:function(){return kn}}),e(Bn.prototype,{buildTree:function(){ls.sort(this.leaves,new IntervalRTreeNode.NodeComparator);for(var t=this.leaves,e=null,n=new I;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},insert:function(t,e,n){if(null!==this.root)throw new IllegalStateException("Index cannot be added to once it has been queried");this.leaves.add(new qn(t,e,n))},query:function(t,e,n){this.init(),this.root.query(t,e,n)},buildRoot:function(){return null!==this.root?null:void(this.root=this.buildTree())},printNode:function(t){D.out.println(re.toLineString(new p(t.min,this.level),new p(t.max,this.level)))},init:function(){return null!==this.root?null:void this.buildRoot()},buildLevel:function(t,e){this.level++,e.clear();for(var n=0;n0||!e.coord.equals2D(i);r||n--;var o=new Array(n).fill(null),s=0;o[s++]=new p(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return r&&(o[s]=e.coord),new Kn(o,new fn(this.edge.label))},add:function(t,e,n){var i=new Un(t,e,n),r=this.nodeMap.get(i);return null!==r?r:(this.nodeMap.put(i,i),i)},isIntersection:function(t){for(var e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0}return!1},interfaces_:function(){return[]},getClass:function(){return Wn}}),e(Hn.prototype,{getChainStartIndices:function(t){var e=0,n=new I;n.add(new P(e));do{var i=this.findChainEnd(t,e);n.add(new P(i)),e=i}while(en?e:n},getMinX:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return ee&&(i=1),this.depth[t][n]=i}}},getDelta:function(t){return this.depth[t][cn.RIGHT]-this.depth[t][cn.LEFT]},getLocation:function(t,e){return this.depth[t][e]<=0?S.EXTERIOR:S.INTERIOR},toString:function(){return"A: "+this.depth[0][1]+","+this.depth[0][2]+" B: "+this.depth[1][1]+","+this.depth[1][2]},add:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<2;e++)for(var n=1;n<3;n++){var i=t.getLocation(e,n);i!==S.EXTERIOR&&i!==S.INTERIOR||(this.isNull(e,n)?this.depth[e][n]=Zn.depthAtLocation(i):this.depth[e][n]+=Zn.depthAtLocation(i))}else if(3===arguments.length){var r=arguments[0],o=arguments[1],s=arguments[2];s===S.INTERIOR&&this.depth[r][o]++}},interfaces_:function(){return[]},getClass:function(){return Zn}}),Zn.depthAtLocation=function(t){return t===S.EXTERIOR?0:t===S.INTERIOR?1:Zn.NULL_VALUE},Zn.NULL_VALUE=-1,c(Kn,vn),e(Kn.prototype,{getDepth:function(){return this.depth},getCollapsedEdge:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new Kn(t,fn.toLineLabel(this.label))},isIsolated:function(){return this._isIsolated},getCoordinates:function(){return this.pts},setIsolated:function(t){this._isIsolated=t},setName:function(t){this.name=t},equals:function(t){if(!(t instanceof Kn))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,i=!0,r=this.pts.length,o=0;o0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}},print:function(t){t.print("edge "+this.name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this.label+" "+this.depthDelta)},computeIM:function(t){Kn.updateIM(this.label,t)},isCollapsed:function(){return!!this.label.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},isClosed:function(){return this.pts[0].equals(this.pts[this.pts.length-1])},getMaximumSegmentIndex:function(){return this.pts.length-1},getDepthDelta:function(){return this.depthDelta},getNumPoints:function(){return this.pts.length},printReverse:function(t){t.print("edge "+this.name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},getMonotoneChainEdge:function(){return null===this.mce&&(this.mce=new Jn(this)),this.mce},getEnvelope:function(){if(null===this.env){this.env=new N;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this.label+" "+this.depthDelta),t.toString()},isPointwiseEqual:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;e=2,"found LineString with single point"),this.insertBoundaryPoint(this.argIndex,e[0]),this.insertBoundaryPoint(this.argIndex,e[e.length-1])},getInvalidPoint:function(){return this.invalidPoint},getBoundaryPoints:function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,i=t.iterator();i.hasNext();){var r=i.next();e[n++]=r.getCoordinate().copy()}return e},getBoundaryNodes:function(){return null===this.boundaryNodes&&(this.boundaryNodes=this.nodes.getBoundaryNodes(this.argIndex)),this.boundaryNodes},addSelfIntersectionNode:function(t,e,n){return this.isBoundaryNode(t,e)?null:void(n===S.BOUNDARY&&this.useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n))},addPolygonRing:function(t,e,n){if(t.isEmpty())return null;var i=U.removeRepeatedPoints(t.getCoordinates());if(i.length<4)return this._hasTooFewPoints=!0,this.invalidPoint=i[0],null;var r=e,o=n;le.isCCW(i)&&(r=n,o=e);var s=new Kn(i,new fn(this.argIndex,S.BOUNDARY,r,o));this.lineEdgeMap.put(t,s),this.insertEdge(s),this.insertPoint(this.argIndex,i[0],S.BOUNDARY)},insertPoint:function(t,e,n){var i=this.nodes.addNode(e),r=i.getLabel();null===r?i.label=new fn(t,n):r.setLocation(t,n)},createEdgeSetIntersector:function(){return new Dn},addSelfIntersectionNodes:function(t){for(var e=this.edges.iterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.eiList.iterator();r.hasNext();){var o=r.next();this.addSelfIntersectionNode(t,o.coord,i)}},add:function(){if(1!==arguments.length)return wn.prototype.add.apply(this,arguments);var t=arguments[0];if(t.isEmpty())return null;if(t instanceof Tt&&(this.useBoundaryDeterminationRule=!1),t instanceof Lt)this.addPolygon(t);else if(t instanceof bt)this.addLineString(t);else if(t instanceof St)this.addPoint(t);else if(t instanceof Rt)this.addCollection(t);else if(t instanceof pt)this.addCollection(t);else if(t instanceof Tt)this.addCollection(t);else{if(!(t instanceof ft))throw new UnsupportedOperationException(t.getClass().getName());this.addCollection(t)}},addCollection:function(t){for(var e=0;e50?(null===this.areaPtLocator&&(this.areaPtLocator=new Vn(this.parentGeom)),this.areaPtLocator.locate(t)):this.ptLocator.locate(t,this.parentGeom)},findEdge:function(){if(1===arguments.length){var t=arguments[0];return this.lineEdgeMap.get(t)}return wn.prototype.findEdge.apply(this,arguments)},interfaces_:function(){return[]},getClass:function(){return Qn}}),Qn.determineBoundary=function(t,e){return t.isInBoundary(e)?S.BOUNDARY:S.INTERIOR},e($n.prototype,{getArgGeometry:function(t){return this.arg[t].getGeometry()},setComputationPrecision:function(t){this.resultPrecisionModel=t,this.li.setPrecisionModel(this.resultPrecisionModel)},interfaces_:function(){return[]},getClass:function(){return $n}}),e(ti.prototype,{compareTo:function(t){var e=t;return ti.compareOriented(this.pts,this._orientation,e.pts,e._orientation)},interfaces_:function(){return[o]},getClass:function(){return ti}}),ti.orientation=function(t){return 1===U.increasingDirection(t)},ti.compareOriented=function(t,e,n,i){for(var r=e?1:-1,o=i?1:-1,s=e?t.length:-1,a=i?n.length:-1,u=e?0:t.length-1,l=i?0:n.length-1;;){var c=t[u].compareTo(n[l]);if(0!==c)return c;u+=r,l+=o;var h=u===s,f=l===a;if(h&&!f)return-1;if(!h&&f)return 1;if(h&&f)return 0}},e(ei.prototype,{print:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")},addAll:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},findEdgeIndex:function(t){for(var e=0;ethis.maxWidth)&&(this.interiorPoint=e,this.maxWidth=n)},getInteriorPoint:function(){return this.interiorPoint},widestGeometry:function(){if(arguments[0]instanceof ft){var t=arguments[0];if(t.isEmpty())return t;for(var e=t.getGeometryN(0),n=1;ne.getEnvelopeInternal().getWidth()&&(e=t.getGeometryN(n));return e}if(arguments[0]instanceof k){var i=arguments[0];return i instanceof ft?this.widestGeometry(i):i}},horizontalBisector:function(t){var e=t.getEnvelopeInternal(),n=si.getBisectorY(t);return this.factory.createLineString([new p(e.getMinX(),n),new p(e.getMaxX(),n)])},add:function(t){if(t instanceof Lt)this.addPolygon(t);else if(t instanceof ft)for(var e=t,n=0;nthis.loY&&(this.loY=t):t>this.centreY&&tt&&(t=n)}return t+1},nodeSize:function(){for(var t=0,e=0;e<2;e++)null!==this.subnode[e]&&(t+=this.subnode[e].nodeSize());return t+1},add:function(t){this.items.add(t)},interfaces_:function(){return[]},getClass:function(){return ci}}),ci.getSubnodeIndex=function(t,e){var n=-1;return t.min>=e&&(n=1),t.max<=e&&(n=0),n},e(hi.prototype,{expandToInclude:function(t){t.max>this.max&&(this.max=t.max),t.minn||this.max=this.min&&e<=this.max}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return n>=this.min&&i<=this.max}},init:function(t,e){this.min=t,this.max=e,t>e&&(this.min=e,this.max=t)},getMax:function(){return this.max},interfaces_:function(){return[]},getClass:function(){return hi}}),fi.exponent=function(t){return pi(64,t)-1023},fi.powerOf2=function(t){return Math.pow(2,t)},e(di.prototype,{getInterval:function(){return this.interval},getLevel:function(){return this.level},computeKey:function(t){for(this.level=di.computeLevel(t),this.interval=new hi,this.computeInterval(this.level,t);!this.interval.contains(t);)this.level+=1,this.computeInterval(this.level,t)},computeInterval:function(t,e){var n=fi.powerOf2(t);this.pt=Math.floor(e.getMin()/n)*n,this.interval.init(this.pt,this.pt+n)},getPoint:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return di}}),di.computeLevel=function(t){var e=t.getWidth();return fi.exponent(e)+1},c(gi,ci),e(gi.prototype,{getInterval:function(){return this.interval},find:function(t){var e=ci.getSubnodeIndex(t,this.centre);if(-1===e)return this;if(null!==this.subnode[e]){return this.subnode[e].find(t)}return this},insert:function(t){f.isTrue(null===this.interval||this.interval.contains(t.interval));var e=ci.getSubnodeIndex(t.interval,this.centre);if(t.level===this.level-1)this.subnode[e]=t;else{var n=this.createSubnode(e);n.insert(t),this.subnode[e]=n}},isSearchMatch:function(t){return t.overlaps(this.interval)},getSubnode:function(t){return null===this.subnode[t]&&(this.subnode[t]=this.createSubnode(t)),this.subnode[t]},getNode:function(t){var e=ci.getSubnodeIndex(t,this.centre);if(-1!==e){return this.getSubnode(e).getNode(t)}return this},createSubnode:function(t){var e=0,n=0;switch(t){case 0:e=this.interval.getMin(),n=this.centre;break;case 1:e=this.centre,n=this.interval.getMax()}return new gi(new hi(e,n),this.level-1)},interfaces_:function(){return[]},getClass:function(){return gi}}),gi.createNode=function(t){var e=new di(t);return new gi(e.getInterval(),e.getLevel())},gi.createExpanded=function(t,e){var n=new hi(e);null!==t&&n.expandToInclude(t.interval);var i=gi.createNode(n);return null!==t&&i.insert(t),i},e(vi.prototype,{interfaces_:function(){return[]},getClass:function(){return vi}});vi.isZeroWidth=function(t,e){var n=e-t;if(0===n)return!0;var i=Math.max(Math.abs(t),Math.abs(e)),r=n/i;return fi.exponent(r)<=vi.MIN_BINARY_EXPONENT},vi.MIN_BINARY_EXPONENT=-50,c(yi,ci),e(yi.prototype,{insert:function(t,e){var n=ci.getSubnodeIndex(t,yi.origin);if(-1===n)return this.add(e),null;var i=this.subnode[n];if(null===i||!i.getInterval().contains(t)){var r=gi.createExpanded(i,t);this.subnode[n]=r}this.insertContained(this.subnode[n],t,e)},isSearchMatch:function(t){return!0},insertContained:function(t,e,n){f.isTrue(t.getInterval().contains(e));var i=vi.isZeroWidth(e.getMin(),e.getMax()),r=null;r=i?t.find(e):t.getNode(e),r.add(n)},interfaces_:function(){return[]},getClass:function(){return yi}}),yi.origin=0,e(mi.prototype,{size:function(){return null!==this.root?this.root.size():0},insert:function(t,e){this.collectStats(t);var n=mi.ensureExtent(t,this.minExtent);this.root.insert(n,e)},query:function(){if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];return this.query(new hi(t,t))}if(arguments[0]instanceof hi){var e=arguments[0],n=new I;return this.query(e,n),n}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.root.addAllItemsFromOverlapping(i,r)}},iterator:function(){var t=new I;return this.root.addAllItems(t),t.iterator()},remove:function(t,e){var n=mi.ensureExtent(t,this.minExtent);return this.root.remove(n,e)},collectStats:function(t){var e=t.getWidth();e0&&(this.minExtent=e)},depth:function(){return null!==this.root?this.root.depth():0},nodeSize:function(){return null!==this.root?this.root.nodeSize():0},interfaces_:function(){return[]},getClass:function(){return mi}}),mi.ensureExtent=function(t,e){var n=t.getMin(),i=t.getMax();return n!==i?t:(n===i&&(n-=e/2,i=n+e/2),new hi(n,i))},e(xi.prototype,{isInside:function(t){},interfaces_:function(){return[]},getClass:function(){return xi}}),e(Ei.prototype,{testLineSegment:function(t,e){var n=null,i=null,r=null,o=null,s=e.p0,a=e.p1;n=s.x-t.x,i=s.y-t.y,r=a.x-t.x,o=a.y-t.y,(i>0&&o<=0||o>0&&i<=0)&&0Math.PI;)t-=wi.PI_TIMES_2;for(;t<=-Math.PI;)t+=wi.PI_TIMES_2;return t},wi.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}},wi.isAcute=function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)>0},wi.isObtuse=function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)<0},wi.interiorAngle=function(t,e,n){var i=wi.angle(e,t),r=wi.angle(e,n);return Math.abs(r-i)},wi.normalizePositive=function(t){if(t<0){for(;t<0;)t+=wi.PI_TIMES_2;t>=wi.PI_TIMES_2&&(t=0)}else{for(;t>=wi.PI_TIMES_2;)t-=wi.PI_TIMES_2;t<0&&(t=0)}return t},wi.angleBetween=function(t,e,n){var i=wi.angle(e,t),r=wi.angle(e,n);return wi.diff(i,r)},wi.diff=function(t,e){var n=null;return n=tMath.PI&&(n=2*Math.PI-n),n},wi.toRadians=function(t){return t*Math.PI/180},wi.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?wi.COUNTERCLOCKWISE:n<0?wi.CLOCKWISE:wi.NONE},wi.angleBetweenOriented=function(t,e,n){var i=wi.angle(e,t),r=wi.angle(e,n),o=r-i;return o<=-Math.PI?o+wi.PI_TIMES_2:o>Math.PI?o-wi.PI_TIMES_2:o},wi.PI_TIMES_2=2*Math.PI,wi.PI_OVER_2=Math.PI/2,wi.PI_OVER_4=Math.PI/4,wi.COUNTERCLOCKWISE=le.COUNTERCLOCKWISE,wi.CLOCKWISE=le.CLOCKWISE,wi.NONE=le.COLLINEAR,e(Ni.prototype,{area:function(){return Ni.area(this.p0,this.p1,this.p2)},signedArea:function(){return Ni.signedArea(this.p0,this.p1,this.p2)},interpolateZ:function(t){if(null===t)throw new i("Supplied point is null.");return Ni.interpolateZ(t,this.p0,this.p1,this.p2)},longestSideLength:function(){return Ni.longestSideLength(this.p0,this.p1,this.p2)},isAcute:function(){return Ni.isAcute(this.p0,this.p1,this.p2)},circumcentre:function(){return Ni.circumcentre(this.p0,this.p1,this.p2)},area3D:function(){return Ni.area3D(this.p0,this.p1,this.p2)},centroid:function(){return Ni.centroid(this.p0,this.p1,this.p2)},inCentre:function(){return Ni.inCentre(this.p0,this.p1,this.p2)},interfaces_:function(){return[]},getClass:function(){return Ni}}),Ni.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},Ni.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},Ni.det=function(t,e,n,i){return t*i-e*n},Ni.interpolateZ=function(t,e,n,i){var r=e.x,o=e.y,s=n.x-r,a=i.x-r,u=n.y-o,l=i.y-o,c=s*l-a*u,h=t.x-r,f=t.y-o,p=(l*h-a*f)/c,d=(-u*h+s*f)/c;return e.z+p*(n.z-e.z)+d*(i.z-e.z)},Ni.longestSideLength=function(t,e,n){var i=t.distance(e),r=e.distance(n),o=n.distance(t),s=i;return r>s&&(s=r),o>s&&(s=o),s},Ni.isAcute=function(t,e,n){return!!wi.isAcute(t,e,n)&&!!wi.isAcute(e,n,t)&&!!wi.isAcute(n,t,e)},Ni.circumcentre=function(t,e,n){var i=n.x,r=n.y,o=t.x-i,s=t.y-r,a=e.x-i,u=e.y-r,l=2*Ni.det(o,s,a,u);return new p(i-Ni.det(s,o*o+s*s,u,a*a+u*u)/l,r+Ni.det(o,o*o+s*s,a,a*a+u*u)/l)},Ni.perpendicularBisector=function(t,e){var n=e.x-t.x,i=e.y-t.y;return new F(new F(t.x+n/2,t.y+i/2,1),new F(t.x-i+n/2,t.y+n+i/2,1))},Ni.angleBisector=function(t,e,n){var i=e.distance(t),r=e.distance(n),o=i/(i+r),s=n.x-t.x,a=n.y-t.y;return new p(t.x+o*s,t.y+o*a)},Ni.area3D=function(t,e,n){var i=e.x-t.x,r=e.y-t.y,o=e.z-t.z,s=n.x-t.x,a=n.y-t.y,u=n.z-t.z,l=r*u-o*a,c=o*s-i*u,h=i*a-r*s,f=l*l+c*c+h*h;return Math.sqrt(f)/2},Ni.centroid=function(t,e,n){return new p((t.x+e.x+n.x)/3,(t.y+e.y+n.y)/3)},Ni.inCentre=function(t,e,n){var i=e.distance(n),r=t.distance(n),o=t.distance(e),s=i+r+o;return new p((i*t.x+r*e.x+o*n.x)/s,(i*t.y+r*e.y+o*n.y)/s)},e(bi.prototype,{getRadius:function(){return this.compute(),this.radius},getDiameter:function(){switch(this.compute(),this.extremalPts.length){case 0:return this.input.getFactory().createLineString();case 1:return this.input.getFactory().createPoint(this.centre)}var t=this.extremalPts[0],e=this.extremalPts[1];return this.input.getFactory().createLineString([t,e])},getExtremalPoints:function(){return this.compute(),this.extremalPts},computeCirclePoints:function(){if(this.input.isEmpty())return this.extremalPts=new Array(0).fill(null),null;if(1===this.input.getNumPoints()){var t=this.input.getCoordinates();return this.extremalPts=[new p(t[0])],null}var e=this.input.convexHull(),n=e.getCoordinates(),t=n;if(n[0].equals2D(n[n.length-1])&&(t=new Array(n.length-1).fill(null),U.copyDeep(n,0,t,0,n.length-1)),t.length<=2)return this.extremalPts=U.copyDeep(t),null;for(var i=bi.lowestPoint(t),r=bi.pointWitMinAngleWithX(t,i),o=0;o=i;)i=r,o=s,s=Ci.nextIndex(t,o),r=e.distancePerpendicular(t[s]);return ii&&(i=u),us&&(s=l),l=t.length&&(e=0),e},Ci.computeC=function(t,e,n){return t*n.y-e*n.x},Ci.getMinimumDiameter=function(t){return new Ci(t).getDiameter()},Ci.getMinimumRectangle=function(t){return new Ci(t).getMinimumRectangle()},Ci.computeSegmentForLine=function(t,e,n){var i=null,r=null;return Math.abs(e)>Math.abs(t)?(i=new p(0,n/e),r=new p(1,n/e-t/e)):(i=new p(n/t,0),r=new p(n/t-e/t,1)),new ce(i,r)};var cs=Object.freeze({Centroid:fe,CGAlgorithms:le,ConvexHull:ve,InteriorPointArea:oi,InteriorPointLine:ai,InteriorPointPoint:ui,RobustLineIntersector:se,MCPointInRing:Ei,MinimumBoundingCircle:bi,MinimumDiameter:Ci});e(Si.prototype,{getResultGeometry:function(){return new Mi(this.distanceTolerance).transform(this.inputGeom)},setDistanceTolerance:function(t){if(t<=0)throw new i("Tolerance must be positive");this.distanceTolerance=t},interfaces_:function(){return[]},getClass:function(){return Si}}),Si.densifyPoints=function(t,e,n){for(var i=new ce,r=new w,o=0;o1)for(var u=s/a,l=1;ls?1:ot&&(t=n)}return t+1},isEmpty:function(){var t=!0;this.items.isEmpty()||(t=!1);for(var e=0;e<4;e++)null!==this.subnode[e]&&(this.subnode[e].isEmpty()||(t=!1));return t},add:function(t){this.items.add(t)},interfaces_:function(){return[u]},getClass:function(){return Ai}}),Ai.getSubnodeIndex=function(t,e,n){var i=-1;return t.getMinX()>=e&&(t.getMinY()>=n&&(i=3),t.getMaxY()<=n&&(i=1)),t.getMaxX()<=e&&(t.getMinY()>=n&&(i=2),t.getMaxY()<=n&&(i=0)),i},e(Di.prototype,{getLevel:function(){return this.level},computeKey:function(){if(1===arguments.length){var t=arguments[0];for(this.level=Di.computeQuadLevel(t),this.env=new N,this.computeKey(this.level,t);!this.env.contains(t);)this.level+=1,this.computeKey(this.level,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=fi.powerOf2(e);this.pt.x=Math.floor(n.getMinX()/i)*i,this.pt.y=Math.floor(n.getMinY()/i)*i,this.env.init(this.pt.x,this.pt.x+i,this.pt.y,this.pt.y+i)}},getEnvelope:function(){return this.env},getCentre:function(){return new p((this.env.getMinX()+this.env.getMaxX())/2,(this.env.getMinY()+this.env.getMaxY())/2)},getPoint:function(){return this.pt},interfaces_:function(){return[]},getClass:function(){return Di}}),Di.computeQuadLevel=function(t){var e=t.getWidth(),n=t.getHeight(),i=e>n?e:n;return fi.exponent(i)+1},c(Fi,Ai),e(Fi.prototype,{find:function(t){var e=Ai.getSubnodeIndex(t,this.centrex,this.centrey);if(-1===e)return this;if(null!==this.subnode[e]){return this.subnode[e].find(t)}return this},isSearchMatch:function(t){return this.env.intersects(t)},getSubnode:function(t){return null===this.subnode[t]&&(this.subnode[t]=this.createSubnode(t)),this.subnode[t]},getEnvelope:function(){return this.env},getNode:function(t){var e=Ai.getSubnodeIndex(t,this.centrex,this.centrey);if(-1!==e){return this.getSubnode(e).getNode(t)}return this},createSubnode:function(t){var e=0,n=0,i=0,r=0;switch(t){case 0:e=this.env.getMinX(),n=this.centrex,i=this.env.getMinY(),r=this.centrey;break;case 1:e=this.centrex,n=this.env.getMaxX(),i=this.env.getMinY(),r=this.centrey;break;case 2:e=this.env.getMinX(),n=this.centrex,i=this.centrey,r=this.env.getMaxY();break;case 3:e=this.centrex,n=this.env.getMaxX(),i=this.centrey,r=this.env.getMaxY()}return new Fi(new N(e,n,i,r),this.level-1)},insertNode:function(t){f.isTrue(null===this.env||this.env.contains(t.env));var e=Ai.getSubnodeIndex(t.env,this.centrex,this.centrey);if(t.level===this.level-1)this.subnode[e]=t;else{var n=this.createSubnode(e);n.insertNode(t),this.subnode[e]=n}},interfaces_:function(){return[]},getClass:function(){return Fi}}),Fi.createNode=function(t){var e=new Di(t);return new Fi(e.getEnvelope(),e.getLevel())},Fi.createExpanded=function(t,e){var n=new N(e);null!==t&&n.expandToInclude(t.env);var i=Fi.createNode(n);return null!==t&&i.insertNode(t),i},c(Gi,Ai),e(Gi.prototype,{insert:function(t,e){var n=Ai.getSubnodeIndex(t,Gi.origin.x,Gi.origin.y);if(-1===n)return this.add(e),null;var i=this.subnode[n];if(null===i||!i.getEnvelope().contains(t)){var r=Fi.createExpanded(i,t);this.subnode[n]=r}this.insertContained(this.subnode[n],t,e)},isSearchMatch:function(t){return!0},insertContained:function(t,e,n){f.isTrue(t.getEnvelope().contains(e));var i=vi.isZeroWidth(e.getMinX(),e.getMaxX()),r=vi.isZeroWidth(e.getMinY(),e.getMaxY()),o=null;o=i||r?t.find(e):t.getNode(e),o.add(n)},interfaces_:function(){return[]},getClass:function(){return Gi}}),Gi.origin=new p(0,0),e(qi.prototype,{size:function(){return null!==this.root?this.root.size():0},insert:function(t,e){this.collectStats(t);var n=qi.ensureExtent(t,this.minExtent);this.root.insert(n,e)},query:function(){if(1===arguments.length){var t=arguments[0],e=new zn;return this.query(t,e),e.getItems()}if(2===arguments.length){var n=arguments[0],i=arguments[1];this.root.visit(n,i)}},queryAll:function(){var t=new I;return this.root.addAllItems(t),t},remove:function(t,e){var n=qi.ensureExtent(t,this.minExtent);return this.root.remove(n,e)},collectStats:function(t){var e=t.getWidth();e0&&(this.minExtent=e);var n=t.getHeight();n0&&(this.minExtent=n)},depth:function(){return null!==this.root?this.root.depth():0},isEmpty:function(){return null===this.root},interfaces_:function(){return[De,u]},getClass:function(){return qi}}),qi.ensureExtent=function(t,e){var n=t.getMinX(),i=t.getMaxX(),r=t.getMinY(),o=t.getMaxY();return n!==i&&r!==o?t:(n===i&&(n-=e/2,i=n+e/2),r===o&&(r-=e/2,o=r+e/2),new N(n,i,r,o))},qi.serialVersionUID=-0x678b60c967a25400;var ds=Object.freeze({Quadtree:qi}),gs=Object.freeze({STRtree:je}),vs=Object.freeze({quadtree:ds,strtree:gs}),ys=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];e(ki.prototype,{read:function(t){var e=void 0;e="string"==typeof t?JSON.parse(t):t;var n=e.type;if(!ms[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==ys.indexOf(n)?ms[n].apply(this,[e.coordinates]):"GeometryCollection"===n?ms[n].apply(this,[e.geometries]):ms[n].apply(this,[e])},write:function(t){var e=t.getGeometryType();if(!xs[e])throw new Error("Geometry is not supported");return xs[e].apply(this,[t])}});var ms={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!ms[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=ms.bbox.apply(this,[t.bbox])),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n0&&this.minIndexthis.minCoord.y&&n.y>this.minCoord.y&&i===le.CLOCKWISE&&(r=!0),r&&(this.minIndex=this.minIndex-1)},getRightmostSideOfSegment:function(t,e){var n=t.getEdge(),i=n.getCoordinates();if(e<0||e+1>=i.length)return-1;if(i[e].y===i[e+1].y)return-1;var r=cn.LEFT;return i[e].ythis.minCoord.x)&&(this.minDe=t,this.minIndex=n,this.minCoord=e[n])},findRightmostEdgeAtNode:function(){var t=this.minDe.getNode(),e=t.getEdges();this.minDe=e.getRightmostEdge(),this.minDe.isForward()||(this.minDe=this.minDe.getSym(),this.minIndex=this.minDe.getEdge().getCoordinates().length-1)},findEdge:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}f.isTrue(0!==this.minIndex||this.minCoord.equals(this.minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this.minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this.orientedDe=this.minDe,this.getRightmostSide(this.minDe,this.minIndex)===cn.LEFT&&(this.orientedDe=this.minDe.getSym())},interfaces_:function(){return[]},getClass:function(){return Ji}}),Zi.prototype.addLast=function(t){this.array_.push(t)},Zi.prototype.removeFirst=function(){return this.array_.shift()},Zi.prototype.isEmpty=function(){return 0===this.array_.length},e(Ki.prototype,{clearVisitedEdges:function(){for(var t=this.dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1)}},getRightmostCoordinate:function(){return this.rightMostCoord},computeNodeDepth:function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){e=i;break}}if(null===e)throw new rn("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var n=t.getEdges().iterator();n.hasNext();){var i=n.next();i.setVisited(!0),this.copySymDepths(i)}},computeDepth:function(t){this.clearVisitedEdges();var e=this.finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(cn.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},create:function(t){this.addReachable(t),this.finder.findEdge(this.dirEdgeList),this.rightMostCoord=this.finder.getCoordinate()},findResultEdges:function(){for(var t=this.dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(cn.RIGHT)>=1&&e.getDepth(cn.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},computeDepths:function(t){var e=new Q,n=new Zi,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var o=r.getEdges().iterator();o.hasNext();){var s=o.next(),a=s.getSym();if(!a.isVisited()){var u=a.getNode();e.contains(u)||(n.addLast(u),e.add(u))}}}},compareTo:function(t){var e=t;return this.rightMostCoord.xe.rightMostCoord.x?1:0},getEnvelope:function(){if(null===this.env){for(var t=new N,e=this.dirEdgeList.iterator();e.hasNext();)for(var n=e.next(),i=n.getEdge().getCoordinates(),r=0;r=0;n--)this.addPt(t[n])},isRedundant:function(t){if(this.ptList.size()<1)return!1;var e=this.ptList.get(this.ptList.size()-1);return t.distance(e)=2&&this.ptList.get(this.ptList.size()-2),t.equals(e)?null:void this.ptList.add(t)},setMinimumVertexDistance:function(t){this.minimimVertexDistance=t},interfaces_:function(){return[]},getClass:function(){return $i}}),$i.COORDINATE_ARRAY_TYPE=new Array(0).fill(null),e(tr.prototype,{addNextSegment:function(t,e){if(this.s0=this.s1,this.s1=this.s2,this.s2=t,this.seg0.setCoordinates(this.s0,this.s1),this.computeOffsetSegment(this.seg0,this.side,this.distance,this.offset0),this.seg1.setCoordinates(this.s1,this.s2),this.computeOffsetSegment(this.seg1,this.side,this.distance,this.offset1),this.s1.equals(this.s2))return null;var n=le.computeOrientation(this.s0,this.s1,this.s2),i=n===le.CLOCKWISE&&this.side===cn.LEFT||n===le.COUNTERCLOCKWISE&&this.side===cn.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},addLineEndCap:function(t,e){var n=new ce(t,e),i=new ce;this.computeOffsetSegment(n,cn.LEFT,this.distance,i);var r=new ce;this.computeOffsetSegment(n,cn.RIGHT,this.distance,r);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this.bufParams.getEndCapStyle()){case Hi.CAP_ROUND:this.segList.addPt(i.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,le.CLOCKWISE,this.distance),this.segList.addPt(r.p1);break;case Hi.CAP_FLAT:this.segList.addPt(i.p1),this.segList.addPt(r.p1);break;case Hi.CAP_SQUARE:var u=new p;u.x=Math.abs(this.distance)*Math.cos(a),u.y=Math.abs(this.distance)*Math.sin(a);var l=new p(i.p1.x+u.x,i.p1.y+u.y),c=new p(r.p1.x+u.x,r.p1.y+u.y);this.segList.addPt(l),this.segList.addPt(c)}},getCoordinates:function(){return this.segList.getCoordinates()},addMitreJoin:function(t,e,n,i){var r=!0,o=null;try{o=F.intersection(e.p0,e.p1,n.p0,n.p1);(i<=0?1:o.distance(t)/Math.abs(i))>this.bufParams.getMitreLimit()&&(r=!1)}catch(t){if(!(t instanceof C))throw t;o=new p(0,0),r=!1}r?this.segList.addPt(o):this.addLimitedMitreJoin(e,n,i,this.bufParams.getMitreLimit())},addFilletCorner:function(t,e,n,i,r){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),u=n.x-t.x,l=n.y-t.y,c=Math.atan2(l,u);i===le.CLOCKWISE?a<=c&&(a+=2*Math.PI):a>=c&&(a-=2*Math.PI),this.segList.addPt(e),this.addFilletArc(t,a,c,i,r),this.segList.addPt(n)},addOutsideTurn:function(t,e){return this.offset0.p1.distance(this.offset1.p0)0){var n=new p((this.closingSegLengthFactor*this.offset0.p1.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset0.p1.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(n);var i=new p((this.closingSegLengthFactor*this.offset1.p0.x+this.s1.x)/(this.closingSegLengthFactor+1),(this.closingSegLengthFactor*this.offset1.p0.y+this.s1.y)/(this.closingSegLengthFactor+1));this.segList.addPt(i)}else this.segList.addPt(this.s1);this.segList.addPt(this.offset1.p0)}},createCircle:function(t){var e=new p(t.x+this.distance,t.y);this.segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this.distance),this.segList.closeRing()},addBevelJoin:function(t,e){this.segList.addPt(t.p1),this.segList.addPt(e.p0)},init:function(t){this.distance=t,this.maxCurveSegmentError=t*(1-Math.cos(this.filletAngleQuantum/2)),this.segList=new $i,this.segList.setPrecisionModel(this.precisionModel),this.segList.setMinimumVertexDistance(t*tr.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},addCollinear:function(t){this.li.computeIntersection(this.s0,this.s1,this.s1,this.s2),this.li.getIntersectionNum()>=2&&(this.bufParams.getJoinStyle()===Hi.JOIN_BEVEL||this.bufParams.getJoinStyle()===Hi.JOIN_MITRE?(t&&this.segList.addPt(this.offset0.p1),this.segList.addPt(this.offset1.p0)):this.addFilletCorner(this.s1,this.offset0.p1,this.offset1.p0,le.CLOCKWISE,this.distance))},closeRing:function(){this.segList.closeRing()},hasNarrowConcaveAngle:function(){return this._hasNarrowConcaveAngle},interfaces_:function(){return[]},getClass:function(){return tr}}),tr.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,tr.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,tr.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,tr.MAX_CLOSING_SEG_LEN_FACTOR=80,e(er.prototype,{getOffsetCurve:function(t,e){if(this.distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var o=r.getCoordinates();return n&&U.reverse(o),o},computeSingleSidedBufferCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);if(e){n.addSegments(t,!0);var r=Qi.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],cn.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{n.addSegments(t,!1);var a=Qi.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],cn.LEFT),n.addFirstSegment();for(var s=2;s<=u;s++)n.addNextSegment(a[s],!0)}n.addLastSegment(),n.closeRing()},computeRingBufferCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);e===cn.RIGHT&&(i=-i);var r=Qi.simplify(t,i),o=r.length-1;n.initSideSegments(r[o-1],r[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(r[s],a)}n.closeRing()},computeLineBufferCurve:function(t,e){var n=this.simplifyTolerance(this.distance),i=Qi.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],cn.LEFT);for(var o=2;o<=r;o++)e.addNextSegment(i[o],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var s=Qi.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],cn.LEFT);for(var o=a-2;o>=0;o--)e.addNextSegment(s[o],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()},computePointCurve:function(t,e){switch(this.bufParams.getEndCapStyle()){case Hi.CAP_ROUND:e.createCircle(t);break;case Hi.CAP_SQUARE:e.createSquare(t)}},getLineCurve:function(t,e){if(this.distance=e,e<0&&!this.bufParams.isSingleSided())return null;if(0===e)return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this.bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);return i.getCoordinates()},getBufferParameters:function(){return this.bufParams},simplifyTolerance:function(t){return t*this.bufParams.getSimplifyFactor()},getRingCurve:function(t,e,n){if(this.distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return er.copyCoordinates(t);var i=this.getSegGen(n);return this.computeRingBufferCurve(t,e,i),i.getCoordinates()},computeOffsetCurve:function(t,e,n){var i=this.simplifyTolerance(this.distance);if(e){var r=Qi.simplify(t,-i),o=r.length-1;n.initSideSegments(r[o],r[o-1],cn.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{var a=Qi.simplify(t,i),u=a.length-1;n.initSideSegments(a[0],a[1],cn.LEFT),n.addFirstSegment();for(var s=2;s<=u;s++)n.addNextSegment(a[s],!0)}n.addLastSegment()},getSegGen:function(t){return new tr(this.precisionModel,this.bufParams,t)},interfaces_:function(){return[]},getClass:function(){return er}}),er.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;nr.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(M(arguments[2],m)&&arguments[0]instanceof p&&arguments[1]instanceof En)for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getEdge().getCoordinates(),n=0;nthis.seg.p1.y&&this.seg.reverse();var l=Math.max(this.seg.p0.x,this.seg.p1.x);if(!(lthis.seg.p1.y||le.computeOrientation(this.seg.p0,this.seg.p1,o)===le.RIGHT)){var c=s.getDepth(cn.LEFT);this.seg.p0.equals(u[n])||(c=s.getDepth(cn.RIGHT));var h=new ir(this.seg,c);a.add(h)}}else if(M(arguments[2],m)&&arguments[0]instanceof p&&M(arguments[1],m))for(var f=arguments[0],d=arguments[1],g=arguments[2],n=d.iterator();n.hasNext();){var v=n.next();v.isForward()&&this.findStabbedSegments(f,v,g)}},getDepth:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:ls.min(e).leftDepth},interfaces_:function(){return[]},getClass:function(){return nr}}),e(ir.prototype,{compareTo:function(t){var e=t;if(this.upwardSeg.minX()>=e.upwardSeg.maxX())return 1;if(this.upwardSeg.maxX()<=e.upwardSeg.minX())return-1;var n=this.upwardSeg.orientationIndex(e.upwardSeg);return 0!==n?n:(n=-1*e.upwardSeg.orientationIndex(this.upwardSeg),0!==n?n:this.upwardSeg.compareTo(e.upwardSeg))},compareX:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},toString:function(){return this.upwardSeg.toString()},interfaces_:function(){return[o]},getClass:function(){return ir}}),nr.DepthSegment=ir,e(rr.prototype,{addPoint:function(t){if(this.distance<=0)return null;var e=t.getCoordinates(),n=this.curveBuilder.getLineCurve(e,this.distance);this.addCurve(n,S.EXTERIOR,S.INTERIOR)},addPolygon:function(t){var e=this.distance,n=cn.LEFT;this.distance<0&&(e=-this.distance,n=cn.RIGHT);var i=t.getExteriorRing(),r=U.removeRepeatedPoints(i.getCoordinates());if(this.distance<0&&this.isErodedCompletely(i,this.distance))return null;if(this.distance<=0&&r.length<3)return null;this.addPolygonRing(r,e,n,S.EXTERIOR,S.INTERIOR);for(var o=0;o0&&this.isErodedCompletely(s,-this.distance)||this.addPolygonRing(a,e,cn.opposite(n),S.INTERIOR,S.EXTERIOR)}},isTriangleErodedCompletely:function(t,e){var n=new Ni(t[0],t[1],t[2]),i=n.inCentre();return le.distancePointLine(i,n.p0,n.p1)=Pt.MINIMUM_VALID_SIZE&&le.isCCW(t)&&(o=r,s=i,n=cn.opposite(n));var a=this.curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)},add:function(t){if(t.isEmpty())return null;if(t instanceof Lt)this.addPolygon(t);else if(t instanceof bt)this.addLineString(t);else if(t instanceof St)this.addPoint(t);else if(t instanceof Rt)this.addCollection(t);else if(t instanceof pt)this.addCollection(t);else if(t instanceof Tt)this.addCollection(t);else{if(!(t instanceof ft))throw new UnsupportedOperationException(t.getClass().getName());this.addCollection(t)}},isErodedCompletely:function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var i=t.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return e<0&&2*Math.abs(e)>r},addCollection:function(t){for(var e=0;ei||this.maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return f.isTrue(!(s&&a),"Found bad envelope test"),a},initCorners:function(t){this.minx=t.x-.5,this.maxx=t.x+.5,this.miny=t.y-.5,this.maxy=t.y+.5,this.corner[0]=new p(this.maxx,this.maxy),this.corner[1]=new p(this.minx,this.maxy),this.corner[2]=new p(this.minx,this.miny),this.corner[3]=new p(this.maxx,this.miny)},intersects:function(t,e){return 1===this.scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this.p0Scaled),this.copyScaled(e,this.p1Scaled),this.intersectsScaled(this.p0Scaled,this.p1Scaled))},scale:function(t){return Math.round(t*this.scaleFactor)},getCoordinate:function(){return this.originalPt},copyScaled:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},getSafeEnvelope:function(){if(null===this.safeEnv){var t=ur.SAFE_ENV_EXPANSION_FACTOR/this.scaleFactor;this.safeEnv=new N(this.originalPt.x-t,this.originalPt.x+t,this.originalPt.y-t,this.originalPt.y+t)}return this.safeEnv},intersectsPixelClosure:function(t,e){return this.li.computeIntersection(t,e,this.corner[0],this.corner[1]),!!(this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[1],this.corner[2]),this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[2],this.corner[3]),this.li.hasIntersection()||(this.li.computeIntersection(t,e,this.corner[3],this.corner[0]),this.li.hasIntersection()))))},intersectsToleranceSquare:function(t,e){var n=!1,i=!1;return this.li.computeIntersection(t,e,this.corner[0],this.corner[1]),!!(this.li.isProper()||(this.li.computeIntersection(t,e,this.corner[1],this.corner[2]),this.li.isProper()||(this.li.hasIntersection()&&(n=!0),this.li.computeIntersection(t,e,this.corner[2],this.corner[3]),this.li.isProper()||(this.li.hasIntersection()&&(i=!0),this.li.computeIntersection(t,e,this.corner[3],this.corner[0]),this.li.isProper()||n&&i||t.equals(this.pt)||e.equals(this.pt)))))},addSnappedNode:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!0)},interfaces_:function(){return[]},getClass:function(){return ur}}),ur.SAFE_ENV_EXPANSION_FACTOR=.75,e(lr.prototype,{snap:function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],n=arguments[1],i=arguments[2],r=e.getSafeEnvelope(),o=new cr(e,n,i);return this.index.query(r,{interfaces_:function(){return[Ae]},visitItem:function(t){t.select(r,o)}}),o.isNodeAdded()}},interfaces_:function(){return[]},getClass:function(){return lr}}),c(cr,li),e(cr.prototype,{isNodeAdded:function(){return this._isNodeAdded},select:function(){if(2!==arguments.length)return li.prototype.select.apply(this,arguments);var t=arguments[0],e=arguments[1],n=t.getContext();return null!==this.parentEdge&&n===this.parentEdge&&e===this.hotPixelVertexIndex?null:void(this._isNodeAdded=this.hotPixel.addSnappedNode(n,e))},interfaces_:function(){return[]},getClass:function(){return cr}}),lr.HotPixelSnapAction=cr,e(hr.prototype,{processIntersections:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[i],a=n.getCoordinates()[i+1];if(this.li.computeIntersection(r,o,s,a),this.li.hasIntersection()&&this.li.isInteriorIntersection()){for(var u=0;u=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof rn))throw t;this.saveException=t}if(null!==this.resultGeometry)return null}throw this.saveException}if(1===arguments.length){var e=arguments[0],n=pr.precisionScaleFactor(this.argGeom,this.distance,e),i=new te(n);this.bufferFixedPrecision(i)}},computeGeometry:function(){if(this.bufferOriginalPrecision(),null!==this.resultGeometry)return null;var t=this.argGeom.getFactory().getPrecisionModel();t.getType()===te.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},setQuadrantSegments:function(t){this.bufParams.setQuadrantSegments(t)},bufferOriginalPrecision:function(){try{var t=new sr(this.bufParams);this.resultGeometry=t.buffer(this.argGeom,this.distance)}catch(t){if(!(t instanceof l))throw t;this.saveException=t}},getResultGeometry:function(t){return this.distance=t,this.computeGeometry(),this.resultGeometry},setEndCapStyle:function(t){this.bufParams.setEndCapStyle(t)},interfaces_:function(){return[]},getClass:function(){return pr}}),pr.bufferOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=new pr(t),i=n.getResultGeometry(e);return i}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof k&&"number"==typeof arguments[1]){var r=arguments[0],o=arguments[1],s=arguments[2],a=new pr(r);a.setQuadrantSegments(s);var i=a.getResultGeometry(o);return i}if(arguments[2]instanceof Hi&&arguments[0]instanceof k&&"number"==typeof arguments[1]){var u=arguments[0],l=arguments[1],c=arguments[2],a=new pr(u,c),i=a.getResultGeometry(l);return i}}else if(4===arguments.length){var h=arguments[0],f=arguments[1],p=arguments[2],d=arguments[3],a=new pr(h);a.setQuadrantSegments(p),a.setEndCapStyle(d);var i=a.getResultGeometry(f);return i}},pr.precisionScaleFactor=function(t,e,n){var i=t.getEnvelopeInternal(),r=L.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY())),o=e>0?e:0,s=r+2*o,a=Math.trunc(Math.log(s)/Math.log(10)+1),u=n-a;return Math.pow(10,u)},pr.CAP_ROUND=Hi.CAP_ROUND,pr.CAP_BUTT=Hi.CAP_FLAT,pr.CAP_FLAT=Hi.CAP_FLAT,pr.CAP_SQUARE=Hi.CAP_SQUARE,pr.MAX_PRECISION_DIGITS=12;var ws=Object.freeze({BufferOp:pr,BufferParameters:Hi});e(dr.prototype,{filter:function(t){t instanceof Lt&&this.comps.add(t)},interfaces_:function(){return[ct]},getClass:function(){return dr}}),dr.getPolygons=function(){if(1===arguments.length){var t=arguments[0];return dr.getPolygons(t,new I)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof Lt?n.add(e):e instanceof ft&&e.apply(new dr(n)),n}},e(gr.prototype,{isInsideArea:function(){return this.segIndex===gr.INSIDE_AREA},getCoordinate:function(){return this.pt},getGeometryComponent:function(){return this.component},getSegmentIndex:function(){return this.segIndex},interfaces_:function(){return[]},getClass:function(){return gr}}),gr.INSIDE_AREA=-1,e(vr.prototype,{filter:function(t){t instanceof St&&this.pts.add(t)},interfaces_:function(){return[ct]},getClass:function(){return vr}}),vr.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof St?ls.singletonList(t):vr.getPoints(t,new I)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof St?n.add(e):e instanceof ft&&e.apply(new vr(n)),n}},e(yr.prototype,{filter:function(t){(t instanceof St||t instanceof bt||t instanceof Lt)&&this.locations.add(new gr(t,0,t.getCoordinate()))},interfaces_:function(){return[ct]},getClass:function(){return yr}}),yr.getLocations=function(t){var e=new I;return t.apply(new yr(e)),e},e(mr.prototype,{computeContainmentDistance:function(){if(0===arguments.length){var t=new Array(2).fill(null);if(this.computeContainmentDistance(0,t),this.minDistance<=this.terminateDistance)return null;this.computeContainmentDistance(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],i=1-e,r=dr.getPolygons(this.geom[e]);if(r.size()>0){var o=yr.getLocations(this.geom[i]);if(this.computeContainmentDistance(o,r,n),this.minDistance<=this.terminateDistance)return this.minDistanceLocation[i]=n[0],this.minDistanceLocation[e]=n[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&M(arguments[0],m)&&M(arguments[1],m)){for(var s=arguments[0],a=arguments[1],u=arguments[2],l=0;lthis.minDistance)return null;for(var i=t.getCoordinates(),r=e.getCoordinate(),o=0;othis.minDistance)return null;for(var i=l.getCoordinates(),f=c.getCoordinates(),o=0;ot&&U.reverse(this.coordinates)}return this.coordinates},toLineString:function(){return this.factory.createLineString(this.getCoordinates())},add:function(t){this.directedEdges.add(t)},interfaces_:function(){return[]},getClass:function(){return xr}}),e(Er.prototype,{setVisited:function(t){this._isVisited=t},isMarked:function(){return this._isMarked},setData:function(t){this.data=t},getData:function(){return this.data},setMarked:function(t){this._isMarked=t},getContext:function(){return this.data},isVisited:function(){return this._isVisited},setContext:function(t){this.data=t},interfaces_:function(){return[]},getClass:function(){return Er}}),Er.getComponentWithVisitedState=function(t,e){for(;t.hasNext();){var n=t.next();if(n.isVisited()===e)return n}return null},Er.setVisited=function(t,e){for(;t.hasNext();){t.next().setVisited(e)}},Er.setMarked=function(t,e){for(;t.hasNext();){t.next().setMarked(e)}},c(Ir,Er),e(Ir.prototype,{isRemoved:function(){return null===this.parentEdge},compareDirection:function(t){return this.quadrant>t.quadrant?1:this.quadrant=t.getNumPoints()&&null===i)return null;var o=t.getCoordinate(r);null!==i&&i.segmentIndex===n.segmentIndex&&(o=i.coord);var s=new xn(t,n.coord,o,new fn(t.getLabel()));e.add(s)},createEdgeEndForPrev:function(t,e,n,i){var r=n.segmentIndex;if(0===n.dist){if(0===r)return null;r--}var o=t.getCoordinate(r);null!==i&&i.segmentIndex>=r&&(o=i.coord);var s=new fn(t.getLabel());s.flip();var a=new xn(t,n.coord,o,s);e.add(a)},computeEdgeEnds:function(){if(1===arguments.length){for(var t=arguments[0],e=new I,n=t;n.hasNext();){var i=n.next();this.computeEdgeEnds(i,e)}return e}if(2===arguments.length){var r=arguments[0],o=arguments[1],s=r.getEdgeIntersectionList();s.addEndpoints();var a=s.iterator(),u=null,l=null;if(!a.hasNext())return null;var c=a.next();do{u=l,l=c,c=null,a.hasNext()&&(c=a.next()),null!==l&&(this.createEdgeEndForPrev(r,o,l,u),this.createEdgeEndForNext(r,o,l,c))}while(null!==l)}},interfaces_:function(){return[]},getClass:function(){return Ar}}),c(Dr,xn),e(Dr.prototype,{insert:function(t){this.edgeEnds.add(t)},print:function(t){t.println("EdgeEndBundle--\x3e Label: "+this.label);for(var e=this.iterator();e.hasNext();){e.next().print(t),t.println()}},iterator:function(){return this.edgeEnds.iterator()},getEdgeEnds:function(){return this.edgeEnds},computeLabelOn:function(t,e){for(var n=0,i=!1,r=this.iterator();r.hasNext();){var o=r.next(),s=o.getLabel().getLocation(t);s===S.BOUNDARY&&n++,s===S.INTERIOR&&(i=!0)}var s=S.NONE;i&&(s=S.INTERIOR),n>0&&(s=Qn.determineBoundary(e,n)),this.label.setLocation(t,s)},computeLabelSide:function(t,e){for(var n=this.iterator();n.hasNext();){var i=n.next();if(i.getLabel().isArea()){var r=i.getLabel().getLocation(t,e);if(r===S.INTERIOR)return this.label.setLocation(t,e,S.INTERIOR),null;r===S.EXTERIOR&&this.label.setLocation(t,e,S.EXTERIOR)}}},getLabel:function(){return this.label},computeLabelSides:function(t){this.computeLabelSide(t,cn.LEFT),this.computeLabelSide(t,cn.RIGHT)},updateIM:function(t){Kn.updateIM(this.label,t)},computeLabel:function(t){for(var e=!1,n=this.iterator();n.hasNext();){n.next().getLabel().isArea()&&(e=!0)}this.label=e?new fn(S.NONE,S.NONE,S.NONE):new fn(S.NONE);for(var i=0;i<2;i++)this.computeLabelOn(i,t),e&&this.computeLabelSides(i)},interfaces_:function(){return[]},getClass:function(){return Dr}}),c(Fr,Ln),e(Fr.prototype,{updateIM:function(t){for(var e=this.iterator();e.hasNext();){e.next().updateIM(t)}},insert:function(t){var e=this.edgeMap.get(t);null===e?(e=new Dr(t),this.insertEdgeEnd(t,e)):e.insert(t)},interfaces_:function(){return[]},getClass:function(){return Fr}}),c(Gr,yn),e(Gr.prototype,{updateIMFromEdges:function(t){this.edges.updateIM(t)},computeIM:function(t){t.setAtLeastIfValid(this.label.getLocation(0),this.label.getLocation(1),0)},interfaces_:function(){return[]},getClass:function(){return Gr}}),c(qr,In),e(qr.prototype,{createNode:function(t){return new Gr(t,new Fr)},interfaces_:function(){return[]},getClass:function(){return qr}}),e(kr.prototype,{insertEdgeEnds:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.nodes.add(n)}},getNodeIterator:function(){return this.nodes.iterator()},copyNodesAndLabels:function(t,e){for(var n=t.getNodeIterator();n.hasNext();){var i=n.next();this.nodes.addNode(i.getCoordinate()).setLabel(e,i.getLabel().getLocation(e))}},build:function(t){this.computeIntersectionNodes(t,0),this.copyNodesAndLabels(t,0);var e=new Ar,n=e.computeEdgeEnds(t.getEdgeIterator());this.insertEdgeEnds(n)},computeIntersectionNodes:function(t,e){for(var n=t.getEdgeIterator();n.hasNext();)for(var i=n.next(),r=i.getLabel().getLocation(e),o=i.getEdgeIntersectionList().iterator();o.hasNext();){var s=o.next(),a=this.nodes.addNode(s.coord);r===S.BOUNDARY?a.setLabelBoundary(e):a.getLabel().isNull(e)&&a.setLabel(e,S.INTERIOR)}},interfaces_:function(){return[]},getClass:function(){return kr}}),e(Br.prototype,{isNodeEdgeAreaLabelsConsistent:function(){for(var t=this.nodeGraph.getNodeIterator();t.hasNext();){var e=t.next();if(!e.getEdges().isAreaLabelsConsistent(this.geomGraph))return this.invalidPoint=e.getCoordinate().copy(),!1}return!0},getInvalidPoint:function(){return this.invalidPoint},hasDuplicateRings:function(){for(var t=this.nodeGraph.getNodeIterator();t.hasNext();)for(var e=t.next(),n=e.getEdges().iterator();n.hasNext();){var i=n.next();if(i.getEdgeEnds().size()>1)return this.invalidPoint=i.getEdge().getCoordinate(0),!0}return!1},isNodeConsistentArea:function(){var t=this.geomGraph.computeSelfNodes(this.li,!0,!0);return t.hasProperIntersection()?(this.invalidPoint=t.getProperIntersectionPoint(),!1):(this.nodeGraph.build(this.geomGraph),this.isNodeEdgeAreaLabelsConsistent())},interfaces_:function(){return[]},getClass:function(){return Br}}),e(jr.prototype,{buildIndex:function(){this.index=new je;for(var t=0;t=1&&(e=t.getCoordinateN(0)),this.validErr=new zr(zr.RING_NOT_CLOSED,e)}},checkShellsNotNested:function(t,e){for(var n=0;n=0;i--)n.add(t[i],!1)},Xr.findEdgeRingContaining=function(t,e){for(var n=t.getRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getRing(),c=l.getEnvelopeInternal();if(!c.equals(i)&&c.contains(i)){r=U.ptNotInList(n.getCoordinates(),l.getCoordinates());var h=!1;le.isPointInRing(r,l.getCoordinates())&&(h=!0),h&&(null===o||s.contains(c))&&(o=u,s=o.getRing().getEnvelopeInternal())}}return o},e(Yr.prototype,{compare:function(t,e){var n=t,i=e;return n.getRing().getEnvelope().compareTo(i.getRing().getEnvelope())},interfaces_:function(){return[a]},getClass:function(){return Yr}}),Xr.EnvelopeComparator=Yr,c(Ur,Lr),e(Ur.prototype,{findEdgeRing:function(t){var e=new Xr(this.factory);return e.build(t),e},computeDepthParity:function(){if(0===arguments.length)for(;;){return null}else 1===arguments.length&&arguments[0]},computeNextCWEdges:function(){for(var t=this.nodeIterator();t.hasNext();){var e=t.next();Ur.computeNextCWEdges(e)}},addEdge:function(t){if(t.isEmpty())return null;var e=U.removeRepeatedPoints(t.getCoordinates());if(e.length<2)return null;var n=e[0],i=e[e.length-1],r=this.getNode(n),o=this.getNode(i),s=new Tr(r,o,e[1],!0),a=new Tr(o,r,e[e.length-2],!1),u=new Or(t);u.setDirectedEdges(s,a),this.add(u)},deleteCutEdges:function(){this.computeNextCWEdges(),Ur.findLabeledEdgeRings(this.dirEdges);for(var t=new I,e=this.dirEdges.iterator();e.hasNext();){var n=e.next();if(!n.isMarked()){var i=n.getSym();if(n.getLabel()===i.getLabel()){n.setMarked(!0),i.setMarked(!0);var r=n.getEdge();t.add(r.getLine())}}}return t},getEdgeRings:function(){this.computeNextCWEdges(),Ur.label(this.dirEdges,-1);var t=Ur.findLabeledEdgeRings(this.dirEdges);this.convertMaximalToMinimalEdgeRings(t);for(var e=new I,n=this.dirEdges.iterator();n.hasNext();){var i=n.next();if(!i.isMarked()&&!i.isInRing()){var r=this.findEdgeRing(i);e.add(r)}}return e},getNode:function(t){var e=this.findNode(t);return null===e&&(e=new Cr(t),this.add(e)),e},convertMaximalToMinimalEdgeRings:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getLabel(),r=Ur.findIntersectionNodes(n,i);if(null!==r)for(var o=r.iterator();o.hasNext();){var s=o.next();Ur.computeNextCCWEdges(s,i)}}},deleteDangles:function(){for(var t=this.findNodesOfDegree(1),e=new Q,n=new de,i=t.iterator();i.hasNext();)n.push(i.next());for(;!n.isEmpty();){var r=n.pop();Ur.deleteAllEdges(r);for(var o=r.getOutEdges().getEdges(),i=o.iterator();i.hasNext();){var s=i.next();s.setMarked(!0);var a=s.getSym();null!==a&&a.setMarked(!0);var u=s.getEdge();e.add(u.getLine());var l=s.getToNode();1===Ur.getDegreeNonDeleted(l)&&n.push(l)}}return e},interfaces_:function(){return[]},getClass:function(){return Ur}}),Ur.findLabeledEdgeRings=function(t){for(var e=new I,n=1,i=t.iterator();i.hasNext();){var r=i.next();if(!(r.isMarked()||r.getLabel()>=0)){e.add(r);var o=Xr.findDirEdgesInRing(r);Ur.label(o,n),n++}}return e},Ur.getDegreeNonDeleted=function(t){for(var e=t.getOutEdges().getEdges(),n=0,i=e.iterator();i.hasNext();){i.next().isMarked()||n++}return n},Ur.deleteAllEdges=function(t){for(var e=t.getOutEdges().getEdges(),n=e.iterator();n.hasNext();){var i=n.next();i.setMarked(!0);var r=i.getSym();null!==r&&r.setMarked(!0)}},Ur.label=function(t,e){for(var n=t.iterator();n.hasNext();){n.next().setLabel(e)}},Ur.computeNextCWEdges=function(t){for(var e=t.getOutEdges(),n=null,i=null,r=e.getEdges().iterator();r.hasNext();){var o=r.next();if(!o.isMarked()){if(null===n&&(n=o),null!==i){var s=i.getSym();s.setNext(o)}i=o}}if(null!==i){var s=i.getSym();s.setNext(n)}},Ur.computeNextCCWEdges=function(t,e){for(var n=t.getOutEdges(),i=null,r=null,o=n.getEdges(),s=o.size()-1;s>=0;s--){var a=o.get(s),u=a.getSym(),l=null;a.getLabel()===e&&(l=a);var c=null;u.getLabel()===e&&(c=u),null===l&&null===c||(null!==c&&(r=c),null!==l&&(null!==r&&(r.setNext(l),r=null),null===i&&(i=l)))}null!==r&&(f.isTrue(null!==i),r.setNext(i))},Ur.getDegree=function(t,e){for(var n=t.getOutEdges().getEdges(),i=0,r=n.iterator();r.hasNext();){r.next().getLabel()===e&&i++}return i},Ur.findIntersectionNodes=function(t,e){var n=t,i=null;do{var r=n.getFromNode();Ur.getDegree(r,e)>1&&(null===i&&(i=new I),i.add(r)),n=n.getNext(),f.isTrue(null!==n,"found null DE in ring"),f.isTrue(n===t||!n.isInRing(),"found DE already in ring")}while(n!==t);return i},e(Wr.prototype,{getGeometry:function(){return null===this.geomFactory&&(this.geomFactory=new ne),this.polygonize(),this.extractOnlyPolygonal?this.geomFactory.buildGeometry(this.polyList):this.geomFactory.createGeometryCollection(ne.toGeometryArray(this.polyList))},getInvalidRingLines:function(){return this.polygonize(),this.invalidRingLines},findValidRings:function(t,e,n){for(var i=t.iterator();i.hasNext();){var r=i.next();r.isValid()?e.add(r):n.add(r.getLineString())}},polygonize:function(){if(null!==this.polyList)return null;if(this.polyList=new I,null===this.graph)return null;this.dangles=this.graph.deleteDangles(),this.cutEdges=this.graph.deleteCutEdges();var t=this.graph.getEdgeRings(),e=new I;this.invalidRingLines=new I,this.isCheckingRingsValid?this.findValidRings(t,e,this.invalidRingLines):e=t,this.findShellsAndHoles(e),Wr.assignHolesToShells(this.holeList,this.shellList),ls.sort(this.shellList,new Xr.EnvelopeComparator);var n=!0;this.extractOnlyPolygonal&&(Wr.findDisjointShells(this.shellList),n=!1),this.polyList=Wr.extractPolygons(this.shellList,n)},getDangles:function(){return this.polygonize(),this.dangles},getCutEdges:function(){return this.polygonize(),this.cutEdges},getPolygons:function(){return this.polygonize(),this.polyList}, +add:function(){if(M(arguments[0],v))for(var t=arguments[0],e=t.iterator();e.hasNext();){var n=e.next();this.add(n)}else if(arguments[0]instanceof bt){var i=arguments[0];this.geomFactory=i.getFactory(),null===this.graph&&(this.graph=new Ur(this.geomFactory)),this.graph.addEdge(i)}else if(arguments[0]instanceof k){var r=arguments[0];r.apply(this.lineStringAdder)}},setCheckRingsValid:function(t){this.isCheckingRingsValid=t},findShellsAndHoles:function(t){this.holeList=new I,this.shellList=new I;for(var e=t.iterator();e.hasNext();){var n=e.next();n.computeHole(),n.isHole()?this.holeList.add(n):this.shellList.add(n)}},interfaces_:function(){return[]},getClass:function(){return Wr}}),Wr.findOuterShells=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next(),i=n.getOuterHole();null===i||i.isProcessed()||(n.setIncluded(!0),i.setProcessed(!0))}},Wr.extractPolygons=function(t,e){for(var n=new I,i=t.iterator();i.hasNext();){var r=i.next();(e||r.isIncluded())&&n.add(r.getPolygon())}return n},Wr.assignHolesToShells=function(t,e){for(var n=t.iterator();n.hasNext();){var i=n.next();Wr.assignHoleToShell(i,e)}},Wr.assignHoleToShell=function(t,e){var n=Xr.findEdgeRingContaining(t,e);null!==n&&n.addHole(t)},Wr.findDisjointShells=function(t){Wr.findOuterShells(t);var e=null;do{e=!1;for(var n=t.iterator();n.hasNext();){var i=n.next();i.isIncludedSet()||(i.updateIncluded(),i.isIncludedSet()||(e=!0))}}while(e)},e(Hr.prototype,{filter:function(t){t instanceof bt&&this.p.add(t)},interfaces_:function(){return[q]},getClass:function(){return Hr}}),Wr.LineStringAdder=Hr;var Ss=Object.freeze({Polygonizer:Wr});e(Jr.prototype,{insertEdgeEnds:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();this.nodes.add(n)}},computeProperIntersectionIM:function(t,e){var n=this.arg[0].getGeometry().getDimension(),i=this.arg[1].getGeometry().getDimension(),r=t.hasProperIntersection(),o=t.hasProperInteriorIntersection();2===n&&2===i?r&&e.setAtLeast("212101212"):2===n&&1===i?(r&&e.setAtLeast("FFF0FFFF2"),o&&e.setAtLeast("1FFFFF1FF")):1===n&&2===i?(r&&e.setAtLeast("F0FFFFFF2"),o&&e.setAtLeast("1F1FFFFFF")):1===n&&1===i&&o&&e.setAtLeast("0FFFFFFFF")},labelIsolatedEdges:function(t,e){for(var n=this.arg[t].getEdgeIterator();n.hasNext();){var i=n.next();i.isIsolated()&&(this.labelIsolatedEdge(i,e,this.arg[e].getGeometry()),this.isolatedEdges.add(i))}},labelIsolatedEdge:function(t,e,n){if(n.getDimension()>0){var i=this.ptLocator.locate(t.getCoordinate(),n);t.getLabel().setAllLocations(e,i)}else t.getLabel().setAllLocations(e,S.EXTERIOR)},computeIM:function(){var t=new he;if(t.set(S.EXTERIOR,S.EXTERIOR,2),!this.arg[0].getGeometry().getEnvelopeInternal().intersects(this.arg[1].getGeometry().getEnvelopeInternal()))return this.computeDisjointIM(t),t;this.arg[0].computeSelfNodes(this.li,!1),this.arg[1].computeSelfNodes(this.li,!1);var e=this.arg[0].computeEdgeIntersections(this.arg[1],this.li,!1);this.computeIntersectionNodes(0),this.computeIntersectionNodes(1),this.copyNodesAndLabels(0),this.copyNodesAndLabels(1),this.labelIsolatedNodes(),this.computeProperIntersectionIM(e,t);var n=new Ar,i=n.computeEdgeEnds(this.arg[0].getEdgeIterator());this.insertEdgeEnds(i);var r=n.computeEdgeEnds(this.arg[1].getEdgeIterator());return this.insertEdgeEnds(r),this.labelNodeEdges(),this.labelIsolatedEdges(0,1),this.labelIsolatedEdges(1,0),this.updateIM(t),t},labelNodeEdges:function(){for(var t=this.nodes.iterator();t.hasNext();){t.next().getEdges().computeLabelling(this.arg)}},copyNodesAndLabels:function(t){for(var e=this.arg[t].getNodeIterator();e.hasNext();){var n=e.next();this.nodes.addNode(n.getCoordinate()).setLabel(t,n.getLabel().getLocation(t))}},labelIntersectionNodes:function(t){for(var e=this.arg[t].getEdgeIterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.getEdgeIntersectionList().iterator();r.hasNext();){var o=r.next(),s=this.nodes.find(o.coord);s.getLabel().isNull(t)&&(i===S.BOUNDARY?s.setLabelBoundary(t):s.setLabel(t,S.INTERIOR))}},labelIsolatedNode:function(t,e){var n=this.ptLocator.locate(t.getCoordinate(),this.arg[e].getGeometry());t.getLabel().setAllLocations(e,n)},computeIntersectionNodes:function(t){for(var e=this.arg[t].getEdgeIterator();e.hasNext();)for(var n=e.next(),i=n.getLabel().getLocation(t),r=n.getEdgeIntersectionList().iterator();r.hasNext();){var o=r.next(),s=this.nodes.addNode(o.coord);i===S.BOUNDARY?s.setLabelBoundary(t):s.getLabel().isNull(t)&&s.setLabel(t,S.INTERIOR)}},labelIsolatedNodes:function(){for(var t=this.nodes.iterator();t.hasNext();){var e=t.next(),n=e.getLabel();f.isTrue(n.getGeometryCount()>0,"node with empty label found"),e.isIsolated()&&(n.isNull(0)?this.labelIsolatedNode(e,0):this.labelIsolatedNode(e,1))}},updateIM:function(t){for(var e=this.isolatedEdges.iterator();e.hasNext();){e.next().updateIM(t)}for(var n=this.nodes.iterator();n.hasNext();){var i=n.next();i.updateIM(t),i.updateIMFromEdges(t)}},computeDisjointIM:function(t){var e=this.arg[0].getGeometry();e.isEmpty()||(t.set(S.INTERIOR,S.EXTERIOR,e.getDimension()),t.set(S.BOUNDARY,S.EXTERIOR,e.getBoundaryDimension()));var n=this.arg[1].getGeometry();n.isEmpty()||(t.set(S.EXTERIOR,S.INTERIOR,n.getDimension()),t.set(S.EXTERIOR,S.BOUNDARY,n.getBoundaryDimension()))},interfaces_:function(){return[]},getClass:function(){return Jr}}),e(Zr.prototype,{isContainedInBoundary:function(t){if(t instanceof Lt)return!1;if(t instanceof St)return this.isPointContainedInBoundary(t);if(t instanceof bt)return this.isLineStringContainedInBoundary(t);for(var e=0;e0){var i=t;t=e,e=i}var r=!1;return e.y>t.y&&(r=!0),r?this.li.computeIntersection(t,e,this.diagDown0,this.diagDown1):this.li.computeIntersection(t,e,this.diagUp0,this.diagUp1),!!this.li.hasIntersection()},interfaces_:function(){return[]},getClass:function(){return Kr}}),e(Qr.prototype,{applyTo:function(t){for(var e=0;e=this.rectEnv.getMinX()&&e.getMaxX()<=this.rectEnv.getMaxX()?(this._intersects=!0,null):e.getMinY()>=this.rectEnv.getMinY()&&e.getMaxY()<=this.rectEnv.getMaxY()?(this._intersects=!0,null):void 0:null},intersects:function(){return this._intersects},interfaces_:function(){return[]},getClass:function(){return to}}),c(eo,Qr),e(eo.prototype,{isDone:function(){return!0===this._containsPoint},visit:function(t){if(!(t instanceof Lt))return null;var e=t.getEnvelopeInternal();if(!this.rectEnv.intersects(e))return null;for(var n=new p,i=0;i<4;i++)if(this.rectSeq.getCoordinate(i,n),e.contains(n)&&Mn.containsPointInPolygon(n,t))return this._containsPoint=!0,null},containsPoint:function(){return this._containsPoint},interfaces_:function(){return[]},getClass:function(){return eo}}),c(no,Qr),e(no.prototype,{intersects:function(){return this.hasIntersection},isDone:function(){return!0===this.hasIntersection},visit:function(t){var e=t.getEnvelopeInternal();if(!this.rectEnv.intersects(e))return null;var n=jn.getLines(t);this.checkIntersectionWithLineStrings(n)},checkIntersectionWithLineStrings:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();if(this.checkIntersectionWithSegments(n),this.hasIntersection)return null}},checkIntersectionWithSegments:function(t){for(var e=t.getCoordinateSequence(),n=1;n=t.size()?null:t.get(e)},ao.union=function(t){return new ao(t).union()},ao.STRTREE_NODE_CAPACITY=4,e(uo.prototype,{unionNoOpt:function(t){var e=this.geomFact.createPoint();return ri.overlayOp(t,e,ni.UNION)},unionWithNull:function(t,e){return null===t&&null===e?null:null===e?t:null===t?e:t.union(e)},extract:function(){if(M(arguments[0],v))for(var t=arguments[0],e=t.iterator();e.hasNext();){var n=e.next();this.extract(n)}else if(arguments[0]instanceof k){var i=arguments[0];null===this.geomFact&&(this.geomFact=i.getFactory()),so.extract(i,k.SORTINDEX_POLYGON,this.polygons),so.extract(i,k.SORTINDEX_LINESTRING,this.lines),so.extract(i,k.SORTINDEX_POINT,this.points)}},union:function(){if(null===this.geomFact)return null;var t=null;if(this.points.size()>0){var e=this.geomFact.buildGeometry(this.points);t=this.unionNoOpt(e)}var n=null;if(this.lines.size()>0){var i=this.geomFact.buildGeometry(this.lines);n=this.unionNoOpt(i)}var r=null;this.polygons.size()>0&&(r=ao.union(this.polygons));var o=this.unionWithNull(n,r),s=null;return s=null===t?o:null===o?t:oo.union(t,o),null===s?this.geomFact.createGeometryCollection():s},interfaces_:function(){return[]},getClass:function(){return uo}}),uo.union=function(){if(1===arguments.length){if(M(arguments[0],v)){var t=arguments[0],e=new uo(t);return e.union()}if(arguments[0]instanceof k){var n=arguments[0],e=new uo(n);return e.union()}}else if(2===arguments.length){var i=arguments[0],r=arguments[1],e=new uo(i,r);return e.union()}};var Ls=Object.freeze({UnaryUnionOp:uo}),Rs=Object.freeze({IsValidOp:Vr,ConsistentAreaTester:Br}),Ps=Object.freeze({BoundaryOp:dt,IsSimpleOp:Ui,buffer:ws,distance:Ns,linemerge:bs,overlay:Cs,polygonize:Ss,relate:Ms,union:Ls,valid:Rs});c(lo,Ot.CoordinateOperation),e(lo.prototype,{editCoordinates:function(t,e){if(0===t.length)return null;for(var n=new Array(t.length).fill(null),i=0;i=2&&(n=!0),e.edit(t,new lo(this.targetPM,n))},changePM:function(t,e){return this.createEditor(t.getFactory(),e).edit(t,new Ot.NoOpGeometryOperation)},setRemoveCollapsedComponents:function(t){this.removeCollapsed=t},createFactory:function(t,e){return new ne(e,t.getSRID(),t.getCoordinateSequenceFactory())},setChangePrecisionModel:function(t){this.changePrecisionModel=t},reduce:function(t){var e=this.reducePointwise(t);return this.isPointwise?e:M(e,Mt)?e.isValid()?e:this.fixPolygonalTopology(e):e},setPointwise:function(t){this.isPointwise=t},createEditor:function(t,e){return t.getPrecisionModel()===e?new Ot:new Ot(this.createFactory(t,e))},interfaces_:function(){return[]},getClass:function(){return co}}),co.reduce=function(t,e){return new co(e).reduce(t)},co.reducePointwise=function(t,e){var n=new co(e);return n.setPointwise(!0),n.reduce(t)};var Ts=Object.freeze({GeometryPrecisionReducer:co});e(ho.prototype,{simplifySection:function(t,e){if(t+1===e)return null;this.seg.p0=this.pts[t],this.seg.p1=this.pts[e];for(var n=-1,i=t,r=t+1;rn&&(n=o,i=r)}if(n<=this.distanceTolerance)for(var r=t+1;rthis.distanceTolerance&&(o=!1);var u=new ce;if(u.p0=this.linePts[t],u.p1=this.linePts[e],i[0]=t,i[1]=e,this.hasBadIntersection(this.line,i,u)&&(o=!1),o){var r=this.flatten(t,e);return this.line.addToResult(r),null}this.simplifySection(t,a,n),this.simplifySection(a,e,n)},hasBadOutputIntersection:function(t){for(var e=this.outputIndex.query(t),n=e.iterator();n.hasNext();){var i=n.next();if(this.hasInteriorIntersection(i,t))return!0}return!1},findFurthestPoint:function(t,e,n,i){var r=new ce;r.p0=t[e],r.p1=t[n];for(var o=-1,s=e,a=e+1;ao&&(o=l,s=a)}return i[0]=o,s},simplify:function(t){this.line=t,this.linePts=t.getParentCoordinates(),this.simplifySection(0,this.linePts.length-1,0)},remove:function(t,e,n){for(var i=e;i=e[0]&&ir&&(u=r),o.setMinimumLength(u),o.splitAt(s),o.getSplitPoint()},interfaces_:function(){return[Co]},getClass:function(){return So}}),So.projectedSplitPoint=function(t,e){return t.getLineSegment().project(e)},e(Mo.prototype,{interfaces_:function(){return[]},getClass:function(){return Mo}}),Mo.triArea=function(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)},Mo.isInCircleDDNormalized=function(t,e,n,i){var r=O.valueOf(t.x).selfSubtract(i.x),o=O.valueOf(t.y).selfSubtract(i.y),s=O.valueOf(e.x).selfSubtract(i.x),a=O.valueOf(e.y).selfSubtract(i.y),u=O.valueOf(n.x).selfSubtract(i.x),l=O.valueOf(n.y).selfSubtract(i.y),c=r.multiply(a).selfSubtract(s.multiply(o)),h=s.multiply(l).selfSubtract(u.multiply(a)),f=u.multiply(o).selfSubtract(r.multiply(l)),p=r.multiply(r).selfAdd(o.multiply(o)),d=s.multiply(s).selfAdd(a.multiply(a)),g=u.multiply(u).selfAdd(l.multiply(l));return p.selfMultiply(h).selfAdd(d.selfMultiply(f)).selfAdd(g.selfMultiply(c)).doubleValue()>0},Mo.checkRobustInCircle=function(t,e,n,i){var r=Mo.isInCircleNonRobust(t,e,n,i),o=Mo.isInCircleDDSlow(t,e,n,i),s=Mo.isInCircleCC(t,e,n,i),a=Ni.circumcentre(t,e,n);D.out.println("p radius diff a = "+Math.abs(i.distance(a)-t.distance(a))/t.distance(a)),r===o&&r===s||(D.out.println("inCircle robustness failure (double result = "+r+", DD result = "+o+", CC result = "+s+")"),D.out.println(re.toLineString(new Gt([t,e,n,i]))),D.out.println("Circumcentre = "+re.toPoint(a)+" radius = "+t.distance(a)),D.out.println("p radius diff a = "+Math.abs(i.distance(a)/t.distance(a)-1)),D.out.println("p radius diff b = "+Math.abs(i.distance(a)/e.distance(a)-1)),D.out.println("p radius diff c = "+Math.abs(i.distance(a)/n.distance(a)-1)),D.out.println())},Mo.isInCircleDDFast=function(t,e,n,i){var r=O.sqr(t.x).selfAdd(O.sqr(t.y)).selfMultiply(Mo.triAreaDDFast(e,n,i)),o=O.sqr(e.x).selfAdd(O.sqr(e.y)).selfMultiply(Mo.triAreaDDFast(t,n,i)),s=O.sqr(n.x).selfAdd(O.sqr(n.y)).selfMultiply(Mo.triAreaDDFast(t,e,i)),a=O.sqr(i.x).selfAdd(O.sqr(i.y)).selfMultiply(Mo.triAreaDDFast(t,e,n));return r.selfSubtract(o).selfAdd(s).selfSubtract(a).doubleValue()>0},Mo.isInCircleCC=function(t,e,n,i){var r=Ni.circumcentre(t,e,n),o=t.distance(r);return i.distance(r)-o<=0},Mo.isInCircleNormalized=function(t,e,n,i){var r=t.x-i.x,o=t.y-i.y,s=e.x-i.x,a=e.y-i.y,u=n.x-i.x,l=n.y-i.y;return(r*r+o*o)*(s*l-u*a)+(s*s+a*a)*(u*o-r*l)+(u*u+l*l)*(r*a-s*o)>0},Mo.isInCircleDDSlow=function(t,e,n,i){var r=O.valueOf(i.x),o=O.valueOf(i.y),s=O.valueOf(t.x),a=O.valueOf(t.y),u=O.valueOf(e.x),l=O.valueOf(e.y),c=O.valueOf(n.x),h=O.valueOf(n.y),f=s.multiply(s).add(a.multiply(a)).multiply(Mo.triAreaDDSlow(u,l,c,h,r,o)),p=u.multiply(u).add(l.multiply(l)).multiply(Mo.triAreaDDSlow(s,a,c,h,r,o)),d=c.multiply(c).add(h.multiply(h)).multiply(Mo.triAreaDDSlow(s,a,u,l,r,o)),g=r.multiply(r).add(o.multiply(o)).multiply(Mo.triAreaDDSlow(s,a,u,l,c,h));return f.subtract(p).add(d).subtract(g).doubleValue()>0},Mo.isInCircleNonRobust=function(t,e,n,i){return(t.x*t.x+t.y*t.y)*Mo.triArea(e,n,i)-(e.x*e.x+e.y*e.y)*Mo.triArea(t,n,i)+(n.x*n.x+n.y*n.y)*Mo.triArea(t,e,i)-(i.x*i.x+i.y*i.y)*Mo.triArea(t,e,n)>0},Mo.isInCircleRobust=function(t,e,n,i){return Mo.isInCircleNormalized(t,e,n,i)},Mo.triAreaDDSlow=function(t,e,n,i,r,o){ +return n.subtract(t).multiply(o.subtract(e)).subtract(i.subtract(e).multiply(r.subtract(t)))},Mo.triAreaDDFast=function(t,e,n){var i=O.valueOf(e.x).selfSubtract(t.x).selfMultiply(O.valueOf(n.y).selfSubtract(t.y)),r=O.valueOf(e.y).selfSubtract(t.y).selfMultiply(O.valueOf(n.x).selfSubtract(t.x));return i.selfSubtract(r)},e(Lo.prototype,{circleCenter:function(t,e){var n=new Lo(this.getX(),this.getY()),i=this.bisector(n,t),r=this.bisector(t,e),o=new F(i,r),s=null;try{s=new Lo(o.getX(),o.getY())}catch(i){if(!(i instanceof C))throw i;D.err.println("a: "+n+" b: "+t+" c: "+e),D.err.println(i)}return s},dot:function(t){return this.p.x*t.getX()+this.p.y*t.getY()},magn:function(){return Math.sqrt(this.p.x*this.p.x+this.p.y*this.p.y)},getZ:function(){return this.p.z},bisector:function(t,e){var n=e.getX()-t.getX(),i=e.getY()-t.getY();return new F(new F(t.getX()+n/2,t.getY()+i/2,1),new F(t.getX()-i+n/2,t.getY()+n+i/2,1))},equals:function(){if(1===arguments.length){var t=arguments[0];return this.p.x===t.getX()&&this.p.y===t.getY()}if(2===arguments.length){var e=arguments[0],n=arguments[1];return this.p.distance(e.getCoordinate())0},getX:function(){return this.p.x},crossProduct:function(t){return this.p.x*t.getY()-this.p.y*t.getX()},setZ:function(t){this.p.z=t},times:function(t){return new Lo(t*this.p.x,t*this.p.y)},cross:function(){return new Lo(this.p.y,-this.p.x)},leftOf:function(t){return this.isCCW(t.orig(),t.dest())},toString:function(){return"POINT ("+this.p.x+" "+this.p.y+")"},sub:function(t){return new Lo(this.p.x-t.getX(),this.p.y-t.getY())},getY:function(){return this.p.y},classify:function(t,e){var n=this,i=e.sub(t),r=n.sub(t),o=i.crossProduct(r);return o>0?Lo.LEFT:o<0?Lo.RIGHT:i.getX()*r.getX()<0||i.getY()*r.getY()<0?Lo.BEHIND:i.magn()n?10*e:10*n,this.frameVertex[0]=new Lo((t.getMaxX()+t.getMinX())/2,t.getMaxY()+i),this.frameVertex[1]=new Lo(t.getMinX()-i,t.getMinY()-i),this.frameVertex[2]=new Lo(t.getMaxX()+i,t.getMinY()-i),this.frameEnv=new N(this.frameVertex[0].getCoordinate(),this.frameVertex[1].getCoordinate()),this.frameEnv.expandToInclude(this.frameVertex[2].getCoordinate())},getTriangleCoordinates:function(t){var e=new Bo;return this.visitTriangles(e,t),e.getTriangles()},getVertices:function(t){for(var e=new Q,n=this.quadEdges.iterator();n.hasNext();){var i=n.next(),r=i.orig();!t&&this.isFrameVertex(r)||e.add(r);var o=i.dest();!t&&this.isFrameVertex(o)||e.add(o)}return e},fetchTriangleToVisit:function(t,e,n,i){var r=t,o=0,s=!1;do{this.triEdges[o]=r,this.isFrameEdge(r)&&(s=!0);var a=r.sym();i.contains(a)||e.push(a),i.add(r),o++,r=r.lNext()}while(r!==t);return s&&!n?null:this.triEdges},getEdges:function(){if(0===arguments.length)return this.quadEdges;if(1===arguments.length){for(var t=arguments[0],e=this.getPrimaryEdges(!1),n=new Array(e.size()).fill(null),i=0,r=e.iterator();r.hasNext();){var o=r.next();n[i++]=t.createLineString([o.orig().getCoordinate(),o.dest().getCoordinate()])}return t.createMultiLineString(n)}},getVertexUniqueEdges:function(t){for(var e=new I,n=new Q,i=this.quadEdges.iterator();i.hasNext();){var r=i.next(),o=r.orig();n.contains(o)||(n.add(o),!t&&this.isFrameVertex(o)||e.add(r));var s=r.sym(),a=s.orig();n.contains(a)||(n.add(a),!t&&this.isFrameVertex(a)||e.add(s))}return e},getTriangleEdges:function(t){var e=new qo;return this.visitTriangles(e,t),e.getTriangleEdges()},getPrimaryEdges:function(t){this.visitedKey++;var e=new I,n=new de;n.push(this.startingEdge);for(var i=new Q;!n.empty();){var r=n.pop();if(!i.contains(r)){var o=r.getPrimary();!t&&this.isFrameEdge(o)||e.add(o),n.push(r.oNext()),n.push(r.sym().oNext()),i.add(r),i.add(r.sym())}}return e},delete:function(t){Po.splice(t,t.oPrev()),Po.splice(t.sym(),t.sym().oPrev());var e=t.sym(),n=t.rot(),i=t.rot().sym();this.quadEdges.remove(t),this.quadEdges.remove(e),this.quadEdges.remove(n),this.quadEdges.remove(i),t.delete(),e.delete(),n.delete(),i.delete()},locateFromEdge:function(t,e){for(var n=0,i=this.quadEdges.size(),r=e;;){if(++n>i)throw new Ao(r.toLineSegment());if(t.equals(r.orig())||t.equals(r.dest()))break;if(t.rightOf(r))r=r.sym();else if(t.rightOf(r.oNext())){if(t.rightOf(r.dPrev()))break;r=r.dPrev()}else r=r.oNext()}return r},getTolerance:function(){return this.tolerance},getVoronoiCellPolygons:function(t){this.visitTriangles(new Go,!0);for(var e=new I,n=this.getVertexUniqueEdges(!1),i=n.iterator();i.hasNext();){var r=i.next();e.add(this.getVoronoiCellPolygon(r,t))}return e},getVoronoiDiagram:function(t){var e=this.getVoronoiCellPolygons(t);return t.createGeometryCollection(ne.toGeometryArray(e))},getTriangles:function(t){for(var e=this.getTriangleCoordinates(!1),n=new Array(e.size()).fill(null),i=0,r=e.iterator();r.hasNext();){var o=r.next();n[i++]=t.createPolygon(t.createLinearRing(o),null)}return t.createGeometryCollection(n)},insertSite:function(t){var e=this.locate(t);if(t.equals(e.orig(),this.tolerance)||t.equals(e.dest(),this.tolerance))return e;var n=this.makeEdge(e.orig(),t);Po.splice(n,e);var i=n;do{n=this.connect(e,n.sym()),e=n.oPrev()}while(e.lNext()!==i);return i},locate:function(){if(1===arguments.length){if(arguments[0]instanceof Lo){var t=arguments[0];return this.locator.locate(t)}if(arguments[0]instanceof p){var e=arguments[0];return this.locator.locate(new Lo(e))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=this.locator.locate(new Lo(n));if(null===r)return null;var o=r;r.dest().getCoordinate().equals2D(n)&&(o=r.sym());var s=o;do{if(s.dest().getCoordinate().equals2D(i))return s;s=s.oNext()}while(s!==o);return null}},interfaces_:function(){return[]},getClass:function(){return Fo}}),Fo.getTriangleEdges=function(t,e){if(e[0]=t,e[1]=e[0].lNext(),e[2]=e[1].lNext(),e[2].lNext()!==e[0])throw new i("Edges do not form a triangle")},e(Go.prototype,{visit:function(t){for(var e=t[0].orig().getCoordinate(),n=t[1].orig().getCoordinate(),i=t[2].orig().getCoordinate(),r=Ni.circumcentre(e,n,i),o=new Lo(r),s=0;s<3;s++)t[s].rot().setOrig(o)},interfaces_:function(){return[Do]},getClass:function(){return Go}}),e(qo.prototype,{getTriangleEdges:function(){return this.triList},visit:function(t){this.triList.add(t.clone())},interfaces_:function(){return[Do]},getClass:function(){return qo}}),e(ko.prototype,{visit:function(t){this.triList.add([t[0].orig(),t[1].orig(),t[2].orig()])},getTriangleVertices:function(){return this.triList},interfaces_:function(){return[Do]},getClass:function(){return ko}}),e(Bo.prototype,{checkTriangleSize:function(t){t.length>=2?re.toLineString(t[0],t[1]):t.length>=1&&re.toPoint(t[0])},visit:function(t){this.coordList.clear();for(var e=0;e<3;e++){var n=t[e].orig();this.coordList.add(n.getCoordinate())}if(this.coordList.size()>0){this.coordList.closeRing();var i=this.coordList.toCoordinateArray();if(4!==i.length)return null;this.triCoords.add(i)}},getTriangles:function(){return this.triCoords},interfaces_:function(){return[Do]},getClass:function(){return Bo}}),Fo.TriangleCircumcentreVisitor=Go,Fo.TriangleEdgesListVisitor=qo,Fo.TriangleVertexListVisitor=ko,Fo.TriangleCoordinatesVisitor=Bo,Fo.EDGE_COINCIDENCE_TOL_FACTOR=1e3,e(jo.prototype,{getLineSegment:function(){return this.ls},getEndZ:function(){return this.ls.getCoordinate(1).z},getStartZ:function(){return this.ls.getCoordinate(0).z},intersection:function(t){return this.ls.intersection(t.getLineSegment())},getStart:function(){return this.ls.getCoordinate(0)},getEnd:function(){return this.ls.getCoordinate(1)},getEndY:function(){return this.ls.getCoordinate(1).y},getStartX:function(){return this.ls.getCoordinate(0).x},equalsTopo:function(t){return this.ls.equalsTopo(t.getLineSegment())},getStartY:function(){return this.ls.getCoordinate(0).y},setData:function(t){this.data=t},getData:function(){return this.data},getEndX:function(){return this.ls.getCoordinate(1).x},toString:function(){return this.ls.toString()},interfaces_:function(){return[]},getClass:function(){return jo}}),e(zo.prototype,{visit:function(t){},interfaces_:function(){return[]},getClass:function(){return zo}}),e(Vo.prototype,{isRepeated:function(){return this.count>1},getRight:function(){return this.right},getCoordinate:function(){return this.p},setLeft:function(t){this.left=t},getX:function(){return this.p.x},getData:function(){return this.data},getCount:function(){return this.count},getLeft:function(){return this.left},getY:function(){return this.p.y},increment:function(){this.count=this.count+1},setRight:function(t){this.right=t},interfaces_:function(){return[]},getClass:function(){return Vo}}),e(Xo.prototype,{insert:function(){if(1===arguments.length){var t=arguments[0];return this.insert(t,null)}if(2===arguments.length){var e=arguments[0],n=arguments[1];if(null===this.root)return this.root=new Vo(e,n),this.root;if(this.tolerance>0){var i=this.findBestMatchNode(e);if(null!==i)return i.increment(),i}return this.insertExact(e,n)}},query:function(){var t=arguments,e=this;if(1===arguments.length){var n=arguments[0],i=new I;return this.query(n,i),i}if(2===arguments.length)if(arguments[0]instanceof N&&M(arguments[1],m))!function(){var n=t[0],i=t[1];e.queryNode(e.root,n,!0,{interfaces_:function(){return[zo]},visit:function(t){i.add(t)}})}();else if(arguments[0]instanceof N&&M(arguments[1],zo)){var r=arguments[0],o=arguments[1];this.queryNode(this.root,r,!0,o)}},queryNode:function(t,e,n,i){if(null===t)return null;var r=null,o=null,s=null;n?(r=e.getMinX(),o=e.getMaxX(),s=t.getX()):(r=e.getMinY(),o=e.getMaxY(),s=t.getY());var a=r0&&te)&&mr.isWithinDistance(this,t,e)},distance:function(t){return mr.distance(this,t)},isEquivalentClass:function(t){return this.getClass()===t.getClass()}});t.version="1.3.0 (6e65adb)",t.algorithm=cs,t.densify=hs,t.dissolve=fs,t.geom=us,t.geomgraph=ps,t.index=vs,t.io=Es,t.noding=Is,t.operation=Ps,t.precision=Ts,t.simplify=Os,t.triangulate=As,Object.defineProperty(t,"__esModule",{value:!0})})},{}],44:[function(t,e,n){function i(t,e){switch(t.geometry?t.geometry.type:t.type){case"Point":return r(u(t),e);case"Polygon":var n=[];l(t,function(t){n.push(t)});var c,h,f,p,d,g,v,y,m=a(t,e),x=m.geometry.coordinates,E=0,I=0,w=0,N=n.map(function(t){return[t[0]-x[0],t[1]-x[1]]});for(c=0;c=3){for(var s=[],a=0;a0)-(t<0)},n.abs=function(t){var e=t>>31;return(t^e)-e},n.min=function(t,e){return e^(t^e)&-(t65535)<<4,t>>>=e,n=(t>255)<<3,t>>>=n,e|=n,n=(t>15)<<2,t>>>=n,e|=n,n=(t>3)<<1,t>>>=n,(e|=n)|t>>1},n.log10=function(t){return t>=1e9?9:t>=1e8?8:t>=1e7?7:t>=1e6?6:t>=1e5?5:t>=1e4?4:t>=1e3?3:t>=100?2:t>=10?1:0},n.popCount=function(t){return t-=t>>>1&1431655765,16843009*((t=(858993459&t)+(t>>>2&858993459))+(t>>>4)&252645135)>>>24},n.countTrailingZeros=i,n.nextPow2=function(t){return t+=0===t,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)+1},n.prevPow2=function(t){return t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,(t|=t>>>16)-(t>>>1)},n.parity=function(t){return t^=t>>>16,t^=t>>>8,t^=t>>>4,27030>>>(t&=15)&1};var r=new Array(256);!function(t){for(var e=0;e<256;++e){var n=e,i=e,r=7;for(n>>>=1;n;n>>>=1)i<<=1,i|=1&n,--r;t[e]=i<>>8&255]<<16|r[t>>>16&255]<<8|r[t>>>24&255]},n.interleave2=function(t,e){return t&=65535,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e&=65535,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1},n.deinterleave2=function(t,e){return t=t>>>e&1431655765,t=858993459&(t|t>>>1),t=252645135&(t|t>>>2),t=16711935&(t|t>>>4),(t=65535&(t|t>>>16))<<16>>16},n.interleave3=function(t,e,n){return t&=1023,t=4278190335&(t|t<<16),t=251719695&(t|t<<8),t=3272356035&(t|t<<4),t=1227133513&(t|t<<2),e&=1023,e=4278190335&(e|e<<16),e=251719695&(e|e<<8),e=3272356035&(e|e<<4),e=1227133513&(e|e<<2),t|=e<<1,n&=1023,n=4278190335&(n|n<<16),n=251719695&(n|n<<8),n=3272356035&(n|n<<4),n=1227133513&(n|n<<2),t|n<<2},n.deinterleave3=function(t,e){return t=t>>>e&1227133513,t=3272356035&(t|t>>>2),t=251719695&(t|t>>>4),t=4278190335&(t|t>>>8),(t=1023&(t|t>>>16))<<22>>22},n.nextCombination=function(t){var e=t|t-1;return e+1|(~e&-~e)-1>>>i(t)+1}},{}],53:[function(t,e,n){"use strict";function i(t){var e=t.length;if(0===e)return[];if(1===e)return[[0]];var n=t[0].length;return 0===n?[]:1===n?r(t):2===n?o(t):s(t,n)}var r=t("./lib/ch1d"),o=t("./lib/ch2d"),s=t("./lib/chnd");e.exports=i},{"./lib/ch1d":54,"./lib/ch2d":55,"./lib/chnd":56}],54:[function(t,e,n){"use strict";function i(t){for(var e=0,n=0,i=1;it[n][0]&&(n=i);return en?[[n],[e]]:[[e]]}e.exports=i},{}],55:[function(t,e,n){"use strict";function i(t){var e=r(t),n=e.length;if(n<=2)return[];for(var i=new Array(n),o=e[n-1],s=0;s=e[u]&&(a+=1);o[s]=a}}return t}function o(t,e){try{return s(t,!0)}catch(l){var n=a(t);if(n.length<=e)return[];var o=i(t,n),u=s(o,!0);return r(u,n)}}e.exports=o;var s=t("incremental-convex-hull"),a=t("affine-hull")},{"affine-hull":51,"incremental-convex-hull":57}],57:[function(t,e,n){"use strict";function i(t,e,n){this.vertices=t,this.adjacent=e,this.boundary=n,this.lastVisited=-1}function r(t,e,n){this.vertices=t,this.cell=e,this.index=n}function o(t,e){return c(t.vertices,e.vertices)}function s(t){for(var e=["function orient(){var tuple=this.tuple;return test("],n=0;n<=t;++n)n>0&&e.push(","),e.push("tuple[",n,"]");e.push(")}return orient");var i=new Function("test",e.join("")),r=l[t+1];return r||(r=l),i(r)}function a(t,e,n){this.dimension=t,this.vertices=e,this.simplices=n,this.interior=n.filter(function(t){return!t.boundary}),this.tuple=new Array(t+1);for(var i=0;i<=t;++i)this.tuple[i]=this.vertices[i];var r=h[t];r||(r=h[t]=s(t)),this.orient=r}function u(t,e){var n=t.length;if(0===n)throw new Error("Must have at least d+1 points");var r=t[0].length;if(n<=r)throw new Error("Must input at least d+1 points");var o=t.slice(0,r+1),s=l.apply(void 0,o);if(0===s)throw new Error("Input not in general position");for(var u=new Array(r+1),c=0;c<=r;++c)u[c]=c;s<0&&(u[0]=1,u[1]=0);for(var h=new i(u,new Array(r+1),!1),f=h.adjacent,p=new Array(r+2),c=0;c<=r;++c){for(var d=u.slice(),g=0;g<=r;++g)g===c&&(d[g]=-1);var v=d[0];d[0]=d[1],d[1]=v;var y=new i(d,new Array(r+1),!0);f[c]=y,p[c]=y}p[r+1]=h;for(var c=0;c<=r;++c)for(var d=f[c].vertices,m=f[c].adjacent,g=0;g<=r;++g){var x=d[g];if(x<0)m[g]=h;else for(var E=0;E<=r;++E)f[E].vertices.indexOf(x)<0&&(m[g]=f[E])}for(var I=new a(r,o,p),w=!!e,c=r+1;c0;){t=s.pop();for(var a=(t.vertices,t.adjacent),u=0;u<=n;++u){var l=a[u];if(l.boundary&&!(l.lastVisited<=-i)){for(var c=l.vertices,h=0;h<=n;++h){var f=c[h];r[h]=f<0?e:o[f]}var p=this.orient();if(p>0)return l;l.lastVisited=-i,0===p&&s.push(l)}}}return null},f.walk=function(t,e){var n=this.vertices.length-1,i=this.dimension,r=this.vertices,o=this.tuple,s=e?this.interior.length*Math.random()|0:this.interior.length-1,a=this.interior[s];t:for(;!a.boundary;){for(var u=a.vertices,l=a.adjacent,c=0;c<=i;++c)o[c]=r[u[c]];a.lastVisited=n;for(var c=0;c<=i;++c){var h=l[c];if(!(h.lastVisited>=n)){var f=o[c];o[c]=t;var p=this.orient();if(o[c]=f,p<0){a=h;continue t}h.boundary?h.lastVisited=-n:h.lastVisited=n}}return}return a},f.addPeaks=function(t,e){var n=this.vertices.length-1,s=this.dimension,a=this.vertices,u=this.tuple,l=this.interior,c=this.simplices,h=[e];e.lastVisited=n,e.vertices[e.vertices.indexOf(-1)]=n,e.boundary=!1,l.push(e);for(var f=[];h.length>0;){var e=h.pop(),p=e.vertices,d=e.adjacent,g=p.indexOf(n);if(!(g<0))for(var v=0;v<=s;++v)if(v!==g){var y=d[v];if(y.boundary&&!(y.lastVisited>=n)){var m=y.vertices;if(y.lastVisited!==-n){for(var x=0,E=0;E<=s;++E)m[E]<0?(x=E,u[E]=t):u[E]=a[m[E]];var I=this.orient();if(I>0){m[x]=n,y.boundary=!1,l.push(y),h.push(y),y.lastVisited=n;continue}y.lastVisited=-n}var w=y.adjacent,N=p.slice(),b=d.slice(),C=new i(N,b,!0);c.push(C);var S=w.indexOf(e);if(!(S<0)){w[S]=C,b[g]=y,N[v]=-1,b[v]=e,d[v]=C,C.flip();for(var E=0;E<=s;++E){var M=N[E];if(!(M<0||M===n)){for(var L=new Array(s-1),R=0,P=0;P<=s;++P){var T=N[P];T<0||P===E||(L[R++]=T)}f.push(new r(L,C,E))}}}}}}f.sort(o);for(var v=0;v+1=0?s[u++]=a[c]:l=1&c;if(l===(1&t)){var h=s[0];s[0]=s[1],s[1]=h}e.push(s)}}return e}},{"robust-orientation":59,"simplicial-complex":63}],58:[function(t,e,n){"use strict";function i(t){var e=t.length;if(e<3){for(var n=new Array(e),i=0;i1&&r(t[s[c-2]],t[s[c-1]],l)<=0;)c-=1,s.pop();for(s.push(u),c=a.length;c>1&&r(t[a[c-2]],t[a[c-1]],l)>=0;)c-=1,a.pop();a.push(u)}for(var n=new Array(a.length+s.length-2),h=0,i=0,f=s.length;i0;--p)n[h++]=a[p];return n}e.exports=i;var r=t("robust-orientation")[3]},{"robust-orientation":59}],59:[function(t,e,n){"use strict";function i(t,e){for(var n=new Array(t.length-1),i=1;i>1;return["sum(",s(t.slice(0,e)),",",s(t.slice(e)),")"].join("")}function a(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var e=[],n=0;n0){if(o<=0)return s;i=r+o}else{if(!(r<0))return s;if(o>=0)return s;i=-(r+o)}var a=3.3306690738754716e-16*i;return s>=a||s<=-a?s:g(t,e,n)},function(t,e,n,i){var r=t[0]-i[0],o=e[0]-i[0],s=n[0]-i[0],a=t[1]-i[1],u=e[1]-i[1],l=n[1]-i[1],c=t[2]-i[2],h=e[2]-i[2],f=n[2]-i[2],p=o*l,d=s*u,g=s*a,y=r*l,m=r*u,x=o*a,E=c*(p-d)+h*(g-y)+f*(m-x),I=(Math.abs(p)+Math.abs(d))*Math.abs(c)+(Math.abs(g)+Math.abs(y))*Math.abs(h)+(Math.abs(m)+Math.abs(x))*Math.abs(f),w=7.771561172376103e-16*I;return E>w||-E>w?E:v(t,e,n,i)}];!function(){for(;y.length<=d;)y.push(u(y.length));for(var t=[],n=["slow"],i=0;i<=d;++i)t.push("a"+i),n.push("o"+i);for(var r=["function getOrientation(",t.join(),"){switch(arguments.length){case 0:case 1:return 0;"],i=2;i<=d;++i)r.push("case ",i,":return o",i,"(",t.slice(0,i).join(),");");r.push("}var s=new Array(arguments.length);for(var i=0;i=r?(o=p,(c+=1)=r?(o=p,(c+=1)>1,a=s(t[o],e);a<=0?(0===a&&(r=o),n=o+1):a>0&&(i=o-1)}return r}function h(t,e){for(var n=new Array(t.length),i=0,r=n.length;i=t.length||0!==s(t[g],o))break}return n}function f(t,e){if(!e)return h(l(d(t,0)),t,0);for(var n=new Array(e),i=0;i>>c&1&&l.push(r[c]);e.push(l)}return u(e)}function d(t,e){if(e<0)return[];for(var n=[],i=(1<t[1]!=l>t[1]&&t[0]<(u-s)*(t[1]-a)/(l-a)+s&&(i=!i)}return i}function r(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}var o=t("@turf/invariant"),s=o.getCoord,a=o.getCoords;e.exports=function(t,e,n){if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var o=s(t),u=a(e),l=e.geometry?e.geometry.type:e.type,c=e.bbox;if(c&&!1===r(o,c))return!1;"Polygon"===l&&(u=[u]);for(var h=0,f=!1;hn;){if(s-n>600){var u=s-n+1,l=e-n+1,c=Math.log(u),h=.5*Math.exp(2*c/3),f=.5*Math.sqrt(c*h*(u-h)/u)*(l-u/2<0?-1:1);i(t,e,Math.max(n,Math.floor(e-l*h/u+f)),Math.min(s,Math.floor(e+(u-l)*h/u+f)),a)}var p=t[e],d=n,g=s;for(r(t,n,e),a(t[s],p)>0&&r(t,n,s);d0;)g--}0===a(t[n],p)?r(t,n,g):(g++,r(t,g,s)),g<=e&&(n=g+1),e<=g&&(s=g-1)}}function r(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function o(t,e){return te?1:0}e.exports=i},{}],91:[function(t,e,n){"use strict";function i(t,e){if(!(this instanceof i))return new i(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function r(t,e,n){if(!n)return e.indexOf(t);for(var i=0;i=t.minX&&e.maxY>=t.minY}function v(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function y(t,e,n,i,r){for(var o,s=[e,n];s.length;)n=s.pop(),e=s.pop(),n-e<=i||(o=e+Math.ceil((n-e)/i/2)*i,m(t,o,e,n,r),s.push(e,o,o,n))}e.exports=i;var m=t("quickselect");i.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],i=this.toBBox;if(!g(t,e))return n;for(var r,o,s,a,u=[];e;){for(r=0,o=e.children.length;r=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(r,o,e)},_split:function(t,e){var n=t[e],i=n.children.length,r=this._minEntries;this._chooseSplitAxis(n,r,i);var s=this._chooseSplitIndex(n,r,i),a=v(n.children.splice(s,n.children.length-s));a.height=n.height,a.leaf=n.leaf,o(n,this.toBBox),o(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)},_splitRoot:function(t,e){this.data=v([t,e]),this.data.height=t.height+1,this.data.leaf=!1,o(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var i,r,o,a,u,l,h,f;for(l=h=1/0,i=e;i<=n-e;i++)r=s(t,0,i,this.toBBox),o=s(t,i,n,this.toBBox),a=p(r,o),u=c(r)+c(o),a=e;r--)o=t.children[r],a(c,t.leaf?u(o):o),f+=h(c);return f},_adjustParentBBoxes:function(t,e,n){for(var i=n;i>=0;i--)a(e[i],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children,e.splice(e.indexOf(t[n]),1)):this.clear():o(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}}},{quickselect:90}],92:[function(t,e,n){var i=t("@turf/meta");e.exports=function(t){function e(t,e,i){i?n[e].coordinates=n[e].coordinates.concat(t.geometry.coordinates):n[e].coordinates.push(t.geometry.coordinates),n[e].properties.push(t.properties)}var n={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}},r=Object.keys(n).reduce(function(t,e){return t[e.replace("Multi","")]=e,t},{});return i.featureEach(t,function(t){t.geometry&&(n[t.geometry.type]?e(t,t.geometry.type,!0):r[t.geometry.type]&&e(t,r[t.geometry.type],!1))}),{type:"FeatureCollection",features:Object.keys(n).filter(function(t){return n[t].coordinates.length}).sort().map(function(t){return{type:"Feature",properties:{collectedProperties:n[t].properties},geometry:{type:t,coordinates:n[t].coordinates}}})}}},{"@turf/meta":93}],93:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],94:[function(t,e,n){function i(t,e,n){function i(t){var i=t.geometry.coordinates[0][0],r=t.geometry.coordinates[0][1],o=t.geometry.coordinates[0][2],s=a(i,r,n),u=a(r,o,n),l=a(i,o,n);return s<=e&&u<=e&&l<=e}if("number"!=typeof e)throw new Error("maxEdge parameter is required");var s=o(t),u=s.features.filter(i);if(s.features=u,s.features.length<1)throw new Error("too few polygons found to compute concave hull");return r(s)}function r(t){for(var e=JSON.parse(JSON.stringify(t.features[0])),n=t.features,i=0,r=n.length;id&&(d=t[c].y);var g,v=f-h,y=d-p,m=v>y?v:y,x=.5*(f+h),E=.5*(d+p),I=[new i({x:x-20*m,y:E-m,__sentinel:!0},{x:x,y:E+20*m,__sentinel:!0},{x:x+20*m,y:E-m,__sentinel:!0})],w=[],N=[];for(c=t.length;c--;){for(N.length=0,g=I.length;g--;)v=t[c].x-I[g].x,v>0&&v*v>I[g].r?(w.push(I[g]),I.splice(g,1)):(y=t[c].y-I[g].y,v*v+y*y>I[g].r||(N.push(I[g].a,I[g].b,I[g].b,I[g].c,I[g].c,I[g].a),I.splice(g,1)));for(o(N),g=N.length;g;)n=N[--g],e=N[--g],s=t[c],a=n.x-e.x,u=n.y-e.y,l=2*(a*(s.y-n.y)-u*(s.x-n.x)),Math.abs(l)>1e-12&&I.push(new i(e,n,s))}for(Array.prototype.push.apply(w,I),c=w.length;c--;)(w[c].a.__sentinel||w[c].b.__sentinel||w[c].c.__sentinel)&&w.splice(c,1);return w}var a=t("@turf/helpers"),u=a.polygon,l=a.featureCollection;e.exports=function(t,e){if("FeatureCollection"!==t.type)throw new Error("points must be a FeatureCollection");var n=!1;return l(s(t.features.map(function(t){var i={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?i.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,i.z=t.geometry.coordinates[2]),i})).map(function(t){var e=[t.a.x,t.a.y],i=[t.b.x,t.b.y],r=[t.c.x,t.c.y],o={};return n?(e.push(t.a.z),i.push(t.b.z),r.push(t.c.z)):o={a:t.a.z,b:t.b.z,c:t.c.z},u([[e,i,r,e]],o)}))}},{"@turf/helpers":99}],99:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],100:[function(t,e,n){var i=t("jsts");e.exports=function(){for(var t=new i.io.GeoJSONReader,e=t.read(JSON.stringify(arguments[0].geometry)),n=1;n1)return t;return;case"MultiPolygon":var e=[];if(u(t,function(t){o(t)>1&&e.push(t.geometry.coordinates)}),e.length)return{type:"MultiPolygon",coordinates:e}}}var r=t("jsts"),o=t("@turf/area"),s=t("@turf/helpers").feature,a=t("@turf/invariant").getGeom,u=t("@turf/meta").flattenEach;e.exports=function(t,e){var n=a(t),o=a(e),u=t.properties||{};if(n=i(n),o=i(o),n){if(!o)return s(n,u);var l=new r.io.GeoJSONReader,c=l.read(n),h=l.read(o),f=c.difference(h);if(!f.isEmpty()){var p=new r.io.GeoJSONWriter,d=p.write(f);return s(d,u)}}}},{"@turf/area":125,"@turf/helpers":129,"@turf/invariant":130,"@turf/meta":131,jsts:132}],125:[function(t,e,n){arguments[4][12][0].apply(n,arguments)},{"@mapbox/geojson-area":126,"@turf/meta":127,dup:12}],126:[function(t,e,n){arguments[4][13][0].apply(n,arguments)},{dup:13,wgs84:128}],127:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],128:[function(t,e,n){arguments[4][15][0].apply(n,arguments)},{dup:15}],129:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],130:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],131:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],132:[function(t,e,n){arguments[4][43][0].apply(n,arguments)},{dup:43}],133:[function(t,e,n){function i(t){if(null===t||void 0===t)throw new Error("No polygon was passed");t.geometry.type="LineString";var e=[].concat.apply([],t.geometry.coordinates);return t.geometry.coordinates=e,t}var r=t("@turf/union"),o=t("turf-overlaps"),s=t("@turf/bbox"),a=t("rbush"),u=t("geojson-utils"),l=t("get-closest");e.exports=function(t,e){for(var n=[],c=[],h=new a,f=0;f0&&0!==w)if(w>n[n.length-1])w-=n.length;else{var N=l.greaterNumber(w,n);0!==N&&(w-=N)}if(w!==g){var b=t.features[w];if(void 0===typeof e||b.properties[e]===v.properties[e]){var C=o(v,b);if(!C){var S=JSON.stringify(v),M=JSON.stringify(b),L=i(JSON.parse(S)),R=i(JSON.parse(M));C=u.lineStringsIntersect(L.geometry,R.geometry)}C&&(t.features[g]=r(v,b),n.push(x[I].origIndexPosition),n.sort(function(t,e){return t-e}),h.remove(x[I]),t.features.splice(w,1),m.origIndexPosition=g,h.remove(m,function(t,e){return t.origIndexPosition===e.origIndexPosition}),E=!0)}}}if(E){var P=s(v);h.insert({minX:P[0],minY:P[1],maxX:P[2],maxY:P[3],origIndexPosition:g}),g--}}return t}},{"@turf/bbox":134,"@turf/union":136,"geojson-utils":138,"get-closest":139,rbush:141,"turf-overlaps":143}],134:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":135,dup:22}],135:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],136:[function(t,e,n){arguments[4][100][0].apply(n,arguments)},{dup:100,jsts:137}],137:[function(t,e,n){arguments[4][43][0].apply(n,arguments)},{dup:43}],138:[function(t,e,n){!function(){function t(t){for(var e=[],n=[],i=0;ie!=i[o][0]>e&&t<(i[o][1]-i[r][1])*(e-i[r][0])/(i[o][0]-i[r][0])+i[r][1]&&(s=!s);return s}var i=this.gju={};void 0!==e&&e.exports&&(e.exports=i),i.lineStringsIntersect=function(t,e){for(var n=[],i=0;i<=t.coordinates.length-2;++i)for(var r=0;r<=e.coordinates.length-2;++r){var o={x:t.coordinates[i][1],y:t.coordinates[i][0]},s={x:t.coordinates[i+1][1],y:t.coordinates[i+1][0]},a={x:e.coordinates[r][1],y:e.coordinates[r][0]},u={x:e.coordinates[r+1][1],y:e.coordinates[r+1][0]},l=(u.x-a.x)*(o.y-a.y)-(u.y-a.y)*(o.x-a.x),c=(s.x-o.x)*(o.y-a.y)-(s.y-o.y)*(o.x-a.x),h=(u.y-a.y)*(s.x-o.x)-(u.x-a.x)*(s.y-o.y);if(0!=h){var f=l/h,p=c/h;0<=f&&f<=1&&0<=p&&p<=1&&n.push({type:"Point",coordinates:[o.x+f*(s.x-o.x),o.y+f*(s.y-o.y)]})}}return 0==n.length&&(n=!1),n},i.pointInBoundingBox=function(t,e){return!(t.coordinates[1]e[1][0]||t.coordinates[0]e[1][1])},i.pointInPolygon=function(e,r){for(var o="Polygon"==r.type?[r.coordinates]:r.coordinates,s=!1,a=0;an)return!1}return!0},i.area=function(t){for(var e,n,i=0,r=t.coordinates[0],o=r.length-1,s=0;s0;)if(o=N[i-1],s=b[i-1],i--,s-o>1){for(f=t[s].lng()-t[o].lng(),p=t[s].lat()-t[o].lat(),Math.abs(f)>180&&(f=360-Math.abs(f)),f*=Math.cos(I*(t[s].lat()+t[o].lat())),d=f*f+p*p,a=o+1,u=o,c=-1;a180&&(g=360-Math.abs(g)),g*=Math.cos(I*(t[a].lat()+t[o].lat())),y=g*g+v*v,m=t[a].lng()-t[s].lng(),x=t[a].lat()-t[s].lat(),Math.abs(m)>180&&(m=360-Math.abs(m)),m*=Math.cos(I*(t[a].lat()+t[s].lat())),E=m*m+x*x,(l=y>=d+E?E:E>=d+y?y:(g*p-v*f)*(g*p-v*f)/d)>c&&(u=a,c=l);c=0&&(void 0===r||s0}},{}],143:[function(t,e,n){function i(t,e){var n=t[0],i=t[1],r=e[0],o=e[1];return s([n,r,o,n])!=s([i,r,o,i])&&s([n,i,r,n])!=s([n,i,o,n])}function r(t,e){for(var n=0;nd&&(y>f&&vf&&yc&&(c=m)}var x=[];if(l&&c0&&Math.abs(w-n[I-1][0])>d){var N=parseFloat(n[I-1][0]),b=parseFloat(n[I-1][1]),C=parseFloat(n[I][0]),S=parseFloat(n[I][1]);if(N>-180&&N-180&&n[I-1][0]f&&N<180&&-180===C&&I+1f&&n[I-1][0]<180){E.push([180,n[I][1]]),I++,E.push([n[I][0],n[I][1]]);continue}if(Nf){var M=N;N=C,C=M;var L=b;b=S,S=L}if(N>f&&C=180&&Nf?180:-180,P]),E=[],E.push([n[I-1][0]>f?-180:180,P]),x.push(E)}else E=[],x.push(E);E.push([w,n[I][1]])}else E.push([n[I][0],n[I][1]])}}else{var T=[];x.push(T);for(var O=0;OI/2;T&&(P-=I/4);for(var O=l([]),_=0;_t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]t[1]!=l>t[1]&&t[0]<(u-s)*(t[1]-a)/(l-a)+s&&(i=!i)}return i}var r=t("@turf/invariant");e.exports=function(t,e){var n=r.getCoord(t),o=e.geometry.coordinates;"Polygon"===e.geometry.type&&(o=[o]);for(var s=0,a=!1;s1&&"number"==typeof e[0]&&"number"==typeof e[1])return e;throw new Error("Coordinate is not a valid Point")}function r(t){if(!t)throw new Error("No obj passed");var e;if(t.length?e=t:t.coordinates?e=t.coordinates:t.geometry&&t.geometry.coordinates&&(e=t.geometry.coordinates),e)return o(e),e;throw new Error("No valid coordinates")}function o(t){if(t.length>1&&"number"==typeof t[0]&&"number"==typeof t[1])return!0;if(t[0].length)return o(t[0]);throw new Error("coordinates must only contain numbers")}function s(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function a(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function u(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var i=0;i-1}function i(t,n,i){for(var r=t.length-1,o=t[0].length-1,s={rows:r,cols:o,cells:[]},a=n+Math.abs(i),u=0;ua?128:64,c|=fa?32:16,c|=pa?8:4,c|=da?2:1;var g=+c,v=0;if(17===c||18===c||33===c||34===c||38===c||68===c||72===c||98===c||102===c||132===c||136===c||137===c||152===c||153===c){var y=(h+f+p+d)/4;v=y>a?2:y0?(c=156,v=4):c=152:33===c?v>0?(c=139,v=4):c=137:72===c?v>0?(c=99,v=4):c=98:132===c&&(v>0?(c=39,v=4):c=38)}if(0!=c&&170!=c){var m,x,E,I,w,N,b,C;m=x=E=I=w=N=b=C=.5;var S=[];1===c?(E=1-e(n,p,d),C=1-e(n,h,d),S.push(Rt[c])):169===c?(E=e(a,d,p),C=e(a,d,h),S.push(Rt[c])):4===c?(N=1-e(n,f,p),I=e(n,d,p),S.push(Mt[c])):166===c?(N=e(a,p,f),I=1-e(a,p,d),S.push(Mt[c])):16===c?(w=e(n,p,f),x=e(n,h,f),S.push(St[c])):154===c?(w=1-e(a,f,p),x=1-e(a,f,h),S.push(St[c])):64===c?(b=e(n,d,h),m=1-e(n,f,h),S.push(Tt[c])):106===c?(b=1-e(a,h,d),m=e(a,h,f),S.push(Tt[c])):168===c?(I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),S.push(Lt[c]),S.push(Rt[c])):2===c?(I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),S.push(Lt[c]),S.push(Rt[c])):162===c?(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),S.push(Lt[c]),S.push(Rt[c])):8===c?(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),S.push(St[c]),S.push(Mt[c])):138===c?(w=1-e(n,f,p),N=1-e(a,f,p),m=1-e(a,f,h),x=1-e(n,f,h),S.push(St[c]),S.push(Mt[c])):32===c?(w=e(a,p,f),N=e(n,p,f),m=e(n,h,f),x=e(a,h,f),S.push(St[c]),S.push(Mt[c])):42===c?(C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f),S.push(Pt[c]),S.push(Tt[c])):128===c&&(C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h),S.push(Pt[c]),S.push(Tt[c])),5===c?(N=1-e(n,f,p),C=1-e(n,h,d),S.push(Mt[c])):165===c?(N=e(a,p,f),C=e(a,d,h),S.push(Mt[c])):20===c?(I=e(n,d,p),x=e(n,h,f),S.push(Lt[c])):150===c?(I=1-e(a,p,d),x=1-e(a,f,h),S.push(Lt[c])):80===c?(w=e(n,p,f),b=e(n,d,h),S.push(St[c])):90===c?(w=1-e(a,f,p),b=1-e(a,h,d),S.push(St[c])):65===c?(E=1-e(n,p,d),m=1-e(n,f,h),S.push(Rt[c])):105===c?(E=e(a,d,p),m=e(a,h,f),S.push(Rt[c])):160===c?(w=e(a,p,f),N=e(n,p,f),C=e(n,d,h),b=e(a,d,h),S.push(St[c]),S.push(Mt[c])):10===c?(w=1-e(n,f,p),N=1-e(a,f,p),C=1-e(a,h,d),b=1-e(n,h,d),S.push(St[c]),S.push(Mt[c])):130===c?(I=1-e(n,p,d),E=1-e(a,p,d),m=1-e(a,f,h),x=1-e(n,f,h),S.push(Lt[c]),S.push(Rt[c])):40===c?(I=e(a,d,p),E=e(n,d,p),m=e(n,h,f),x=e(a,h,f),S.push(Lt[c]),S.push(Rt[c])):101===c?(N=e(a,p,f),m=e(a,h,f),S.push(Mt[c])):69===c?(N=1-e(n,f,p),m=1-e(n,f,h),S.push(Mt[c])):149===c?(C=e(a,d,h),x=1-e(a,f,h),S.push(Pt[c])):21===c?(C=1-e(n,h,d),x=e(n,h,f),S.push(Pt[c])):86===c?(I=1-e(a,p,d),b=1-e(a,h,d),S.push(Lt[c])):84===c?(I=e(n,d,p),b=e(n,d,h),S.push(Lt[c])):89===c?(w=1-e(a,f,p),E=e(a,d,p),S.push(Rt[c])):81===c?(w=e(n,p,f),E=1-e(n,p,d),S.push(Rt[c])):96===c?(w=e(a,p,f),N=e(n,p,f),b=e(n,d,h),m=e(a,h,f),S.push(St[c]),S.push(Mt[c])):74===c?(w=1-e(n,f,p),N=1-e(a,f,p),b=1-e(a,h,d),m=1-e(n,f,h),S.push(St[c]),S.push(Mt[c])):24===c?(w=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),x=e(n,h,f),S.push(St[c]),S.push(Rt[c])):146===c?(w=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),x=1-e(a,f,h),S.push(St[c]),S.push(Rt[c])):6===c?(N=1-e(n,f,p),I=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),S.push(Mt[c]),S.push(Lt[c])):164===c?(N=e(a,p,f),I=e(n,d,p),C=e(n,d,h),b=e(a,d,h),S.push(Mt[c]),S.push(Lt[c])):129===c?(E=1-e(n,p,d),C=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h),S.push(Rt[c]),S.push(Pt[c])):41===c?(E=e(a,d,p),C=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f),S.push(Rt[c]),S.push(Pt[c])):66===c?(I=1-e(n,p,d),E=1-e(a,p,d),b=1-e(a,h,d),m=1-e(n,f,h),S.push(Lt[c]),S.push(Rt[c])):104===c?(I=e(a,d,p),E=e(n,d,p),b=e(n,d,h),m=e(a,h,f),S.push(Rt[c]),S.push(Ot[c])):144===c?(w=e(n,p,f),C=e(n,d,h),b=e(a,d,h),x=1-e(a,f,h),S.push(St[c]),S.push(Tt[c])):26===c?(w=1-e(a,f,p),C=1-e(a,h,d),b=1-e(n,h,d),x=e(n,h,f),S.push(St[c]),S.push(Tt[c])):36===c?(N=e(a,p,f),I=e(n,d,p),m=e(n,h,f),x=e(a,h,f),S.push(Mt[c]),S.push(Lt[c])):134===c?(N=1-e(n,f,p),I=1-e(a,p,d),m=1-e(a,f,h),x=1-e(n,f,h),S.push(Mt[c]),S.push(Lt[c])):9===c?(w=1-e(n,f,p),N=1-e(a,f,p),E=e(a,d,p),C=1-e(n,h,d),S.push(St[c]),S.push(Mt[c])):161===c?(w=e(a,p,f),N=e(n,p,f),E=1-e(n,p,d),C=e(a,d,h),S.push(St[c]),S.push(Mt[c])):37===c?(N=e(a,p,f),C=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f),S.push(Mt[c]),S.push(Pt[c])):133===c?(N=1-e(n,f,p),C=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h),S.push(Mt[c]),S.push(Pt[c])):148===c?(I=e(n,d,p),C=e(n,d,h),b=e(a,d,h),x=1-e(a,f,h),S.push(Lt[c]),S.push(Tt[c])):22===c?(I=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),x=e(n,h,f),S.push(Lt[c]),S.push(Tt[c])):82===c?(w=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),b=1-e(a,h,d),S.push(St[c]),S.push(Rt[c])):88===c?(w=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),b=e(n,d,h),S.push(St[c]),S.push(Rt[c])):73===c?(w=1-e(n,f,p),N=1-e(a,f,p),E=e(a,d,p),m=1-e(n,f,h),S.push(St[c]),S.push(Mt[c])):97===c?(w=e(a,p,f),N=e(n,p,f),E=1-e(n,p,d),m=e(a,h,f),S.push(St[c]),S.push(Mt[c])):145===c?(w=e(n,p,f),E=1-e(n,p,d),C=e(a,d,h),x=1-e(a,f,h),S.push(St[c]),S.push(Pt[c])):25===c?(w=1-e(a,f,p),E=e(a,d,p),C=1-e(n,h,d),x=e(n,h,f),S.push(St[c]),S.push(Pt[c])):70===c?(N=1-e(n,f,p),I=1-e(a,p,d),b=1-e(a,h,d),m=1-e(n,f,h),S.push(Mt[c]),S.push(Lt[c])):100===c?(N=e(a,p,f),I=e(n,d,p),b=e(n,d,h),m=e(a,h,f),S.push(Mt[c]),S.push(Lt[c])):34===c?(0===v?(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)):(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)),S.push(St[c]),S.push(Mt[c]),S.push(Pt[c]),S.push(Tt[c])):35===c?(4===v?(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)):(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)),S.push(St[c]),S.push(Mt[c]),S.push(Rt[c]),S.push(Tt[c])):136===c?(0===v?(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)):(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)),S.push(St[c]),S.push(Mt[c]),S.push(Pt[c]),S.push(Tt[c])):153===c?(0===v?(w=e(n,p,f),E=1-e(n,p,d),C=1-e(n,h,d),x=e(n,h,f)):(w=1-e(a,f,p),E=e(a,d,p),C=e(a,d,h),x=1-e(a,f,h)),S.push(St[c]),S.push(Rt[c])):102===c?(0===v?(N=1-e(n,f,p),I=e(n,d,p),b=e(n,d,h),m=1-e(n,f,h)):(N=e(a,p,f),I=1-e(a,p,d),b=1-e(a,h,d),m=e(a,h,f)),S.push(Mt[c]),S.push(Tt[c])):155===c?(4===v?(w=e(n,p,f),E=1-e(n,p,d),C=1-e(n,h,d),x=e(n,h,f)):(w=1-e(a,f,p),E=e(a,d,p),C=e(a,d,h),x=1-e(a,f,h)),S.push(St[c]),S.push(Pt[c])):103===c?(4===v?(N=1-e(n,f,p),I=e(n,d,p),b=e(n,d,h),m=1-e(n,f,h)):(N=e(a,p,f),I=1-e(a,p,d),b=1-e(a,h,d),m=e(a,h,f)),S.push(Mt[c]),S.push(Lt[c])):152===c?(0===v?(w=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),x=e(n,h,f)):(w=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),x=1-e(a,f,h)),S.push(St[c]),S.push(Lt[c]),S.push(Rt[c])):156===c?(4===v?(w=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),x=e(n,h,f)):(w=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),C=e(n,d,h),b=e(a,d,h),x=1-e(a,f,h)),S.push(St[c]),S.push(Rt[c]),S.push(Tt[c])):137===c?(0===v?(w=e(a,p,f),N=e(n,p,f),E=1-e(n,p,d),C=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)):(w=1-e(n,f,p),N=1-e(a,f,p),E=e(a,d,p),C=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)),S.push(St[c]),S.push(Mt[c]),S.push(Rt[c])):139===c?(4===v?(w=e(a,p,f),N=e(n,p,f),E=1-e(n,p,d),C=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)):(w=1-e(n,f,p),N=1-e(a,f,p),E=e(a,d,p),C=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)),S.push(St[c]),S.push(Mt[c]),S.push(Pt[c])):98===c?(0===v?(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),b=e(n,d,h),m=1-e(n,f,h)):(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),b=1-e(a,h,d),m=e(a,h,f)),S.push(St[c]),S.push(Mt[c]),S.push(Tt[c])):99===c?(4===v?(w=1-e(n,f,p),N=1-e(a,f,p),I=e(a,d,p),E=e(n,d,p),b=e(n,d,h),m=1-e(n,f,h)):(w=e(a,p,f),N=e(n,p,f),I=1-e(n,p,d),E=1-e(a,p,d),b=1-e(a,h,d),m=e(a,h,f)),S.push(St[c]),S.push(Mt[c]),S.push(Rt[c])):38===c?(0===v?(N=1-e(n,f,p),I=e(n,d,p),C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)):(N=e(a,p,f),I=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)),S.push(Mt[c]),S.push(Pt[c]),S.push(Tt[c])):39===c?(4===v?(N=1-e(n,f,p),I=e(n,d,p),C=e(n,d,h),b=e(a,d,h),m=1-e(a,f,h),x=1-e(n,f,h)):(N=e(a,p,f),I=1-e(a,p,d),C=1-e(a,h,d),b=1-e(n,h,d),m=e(n,h,f),x=e(a,h,f)),S.push(Mt[c]),S.push(Lt[c]),S.push(Tt[c])):85===c&&(w=1,N=0,I=1,E=0,C=0,b=1,m=0,x=1),(m<0||m>1||x<0||x>1||w<0||w>1||I<0||I>1||C<0||C>1||b<0||b>1)&&console.log("MarchingSquaresJS-isoBands: "+c+" "+g+" "+h+","+f+","+p+","+d+" "+v+" "+m+" "+x+" "+w+" "+N+" "+I+" "+E+" "+C+" "+b),s.cells[u][l]={cval:c,cval_real:g,flipped:v,topleft:m,topright:x,righttop:w,rightbottom:N,bottomright:I,bottomleft:E,leftbottom:C,lefttop:b,edges:S}}}}}return s}function r(t){for(var e=[],n=t.rows,i=t.cols,r=[],s=0;s0){var c=t.cells[s][l],h=a(c),f=null,p=l,d=s;null!==h&&r.push([h.p[0]+p,h.p[1]+d]);do{if(null===(f=u(t.cells[d][p],h.x,h.y,h.o)))break;if(r.push([f.p[0]+p,f.p[1]+d]),p+=f.x,d+=f.y,h=f,d<0||d>=n||p<0||p>=i||void 0===t.cells[d][p]){p-=f.x,d-=f.y;var g=o(t,p,d,f.x,f.y,f.o);if(null===g)break;g.path.forEach(function(t){r.push(t)}),p=g.i,d=g.j,h=g}}while(void 0!==t.cells[d][p]&&t.cells[d][p].edges.length>0);e.push(r),r=[],t.cells[s][l].edges.length>0&&l--}return e}function o(t,e,n,i,r,o){for(var s=t.cells[n][e],a=s.cval_real,u=e+i,l=n+r,c=[],h=!1;!h;){if(void 0===t.cells[l]||void 0===t.cells[l][u])if(l-=r,u-=i,s=t.cells[l][u],a=s.cval_real,-1===r)if(0===o)if(a&g)c.push([u,l]),i=-1,r=0,o=0;else{if(!(a&d)){c.push([u+s.bottomright,l]),i=0,r=1,o=1,h=!0;break}c.push([u+1,l]),i=1,r=0,o=0}else{if(!(a&g)){if(a&d){c.push([u+s.bottomright,l]),i=0,r=1,o=1,h=!0;break}c.push([u+s.bottomleft,l]),i=0,r=1,o=0,h=!0;break}c.push([u,l]),i=-1,r=0,o=0}else if(1===r)if(0===o){if(!(a&p)){if(a&f){c.push([u+s.topleft,l+1]),i=0,r=-1,o=0,h=!0;break}c.push([u+s.topright,l+1]),i=0,r=-1,o=1,h=!0;break}c.push([u+1,l+1]),i=1,r=0,o=1}else c.push([u+1,l+1]),i=1,r=0,o=1;else if(-1===i)if(0===o){if(!(a&f)){if(a&g){c.push([u,l+s.leftbottom]),i=1,r=0,o=0,h=!0;break}c.push([u,l+s.lefttop]),i=1,r=0,o=1,h=!0;break}c.push([u,l+1]),i=0,r=1,o=0}else{if(!(a&f)){console.log("MarchingSquaresJS-isoBands: wtf");break}c.push([u,l+1]),i=0,r=1,o=0}else{if(1!==i){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break}if(0===o){if(!(a&d)){c.push([u+1,l+s.rightbottom]),i=-1,r=0,o=0,h=!0;break}c.push([u+1,l]),i=0,r=-1,o=1}else{if(!(a&d)){if(a&p){c.push([u+1,l+s.righttop]),i=-1,r=0,o=1;break}c.push([u+1,l+s.rightbottom]),i=-1,r=0,o=0,h=!0;break}c.push([u+1,l]),i=0,r=-1,o=1}}else if(s=t.cells[l][u],a=s.cval_real,-1===i)if(0===o)if(void 0!==t.cells[l-1]&&void 0!==t.cells[l-1][u])i=0,r=-1,o=1;else{if(!(a&g)){c.push([u+s.bottomright,l]),i=0,r=1,o=1,h=!0;break}c.push([u,l])}else{if(!(a&f)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+u+","+l);break}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!")}else if(1===i){if(0===o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[l+1]&&void 0!==t.cells[l+1][u])i=0,r=1,o=0;else{if(!(a&p)){c.push([u+s.topleft,l+1]),i=0,r=-1,o=0,h=!0;break}c.push([u+1,l+1]),i=1,r=0,o=1}}else if(-1===r){if(1!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[l][u+1])i=1,r=0,o=1;else{if(!(a&d)){c.push([u+1,l+s.righttop]),i=-1,r=0,o=1,h=!0;break}c.push([u+1,l]),i=0,r=-1,o=1}}else{if(1!==r){console.log("MarchingSquaresJS-isoBands: where did we came from???");break}if(0!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[l][u-1])i=-1,r=0,o=0;else{if(!(a&f)){c.push([u,l+s.leftbottom]),i=1,r=0,o=0,h=!0;break}c.push([u,l+1]),i=0,r=1,o=0}}if(u+=i,l+=r,u===e&&l===n)break}return{path:c,i:u,j:l,x:i,y:r,o:o}}function s(t,e){delete t.edges[e];for(var n=e+1;n0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&p?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return n&d?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return n&d?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return n&g?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&p?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return n&d?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return n&d?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return n&g?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return n&d?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return n&g?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return n&g?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&f?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return n&d?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return n&g?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return n&g?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&f?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return n&d?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&f?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return n&g?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&f?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&f?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&p?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&f?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&p?{p:[0,t.lefttop],x:1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};default:console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t)}}return null}function u(t,e,n,i){var r,o,a,u,l,c=t.cval;switch(e){case-1:switch(i){case 0:r=Mt[c],a=C[c],u=S[c],l=M[c];break;default:r=St[c],a=w[c],u=N[c],l=b[c]}break;case 1:switch(i){case 0:r=Pt[c],a=G[c],u=q[c],l=k[c];break;default:r=Tt[c],a=A[c],u=D[c],l=F[c]}break;default:switch(n){case-1:switch(i){case 0:r=Ot[c],a=v[c],u=y[c],l=m[c];break;default:r=_t[c],a=x[c],u=E[c],l=I[c]}break;case 1:switch(i){case 0:r=Rt[c],a=L[c],u=R[c],l=P[c];break;default:r=Lt[c],a=T[c],u=O[c],l=_[c]}}}if(o=t.edges.indexOf(r),void 0===t.edges[o])return null;switch(s(t,o),c=t.cval_real,r){case 0:c&p?(e=t.topleft,n=1):(e=1,n=t.righttop);break;case 1:c&d?(e=1,n=t.rightbottom):(e=t.topleft,n=1);break;case 2:c&d?(e=t.topleft,n=1):(e=t.bottomright,n=0);break;case 3:c&g?(e=t.bottomleft,n=0):(e=t.topleft,n=1);break;case 4:c&p?(e=t.topright,n=1):(e=1,n=t.righttop);break;case 5:c&d?(e=1,n=t.rightbottom):(e=t.topright,n=1);break;case 6:c&d?(e=t.topright,n=1):(e=t.bottomright,n=0);break;case 7:c&g?(e=t.bottomleft,n=0):(e=t.topright,n=1);break;case 8:c&d?(e=1,n=t.righttop):(e=t.bottomright,n=0);break;case 9:c&g?(e=t.bottomleft,n=0):(e=1,n=t.righttop);break;case 10:c&g?(e=1,n=t.righttop):(e=0,n=t.leftbottom);break;case 11:c&f?(e=0,n=t.lefttop):(e=1,n=t.righttop);break;case 12:c&d?(e=1,n=t.rightbottom):(e=t.bottomright,n=0);break;case 13:c&g?(e=t.bottomleft,n=0):(e=1,n=t.rightbottom);break;case 14:c&g?(e=1,n=t.rightbottom):(e=0,n=t.leftbottom);break;case 15:c&f?(e=0,n=t.lefttop):(e=1,n=t.rightbottom);break;case 16:c&d?(e=0,n=t.leftbottom):(e=t.bottomright,n=0);break;case 17:c&f?(e=0,n=t.lefttop):(e=t.bottomright,n=0);break;case 18:c&g?(e=t.bottomleft,n=0):(e=0,n=t.leftbottom);break;case 19:c&f?(e=0,n=t.lefttop):(e=t.bottomleft,n=0);break;case 20:c&f?(e=0,n=t.leftbottom):(e=t.topleft,n=1);break;case 21:c&p?(e=t.topright,n=1):(e=0,n=t.leftbottom);break;case 22:c&f?(e=0,n=t.lefttop):(e=t.topleft,n=1);break;case 23:c&p?(e=t.topright,n=1):(e=0,n=t.lefttop);break;default:return console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t),null}return void 0!==e&&void 0!==n&&void 0!==a&&void 0!==u&&void 0!==l||(console.log("MarchingSquaresJS-isoBands: undefined value!"),console.log(t),console.log(e+" "+n+" "+a+" "+u+" "+l)),{p:[e,n],x:a,y:u,o:l}}function l(t){var e=[],i=0;return t.cells.forEach(function(t,r){t.forEach(function(t,o){if(void 0!==t){var s=At[t.cval](t);"object"==typeof s&&n(s)?"object"==typeof s[0]&&n(s[0])?"object"==typeof s[0][0]&&n(s[0][0])?s.forEach(function(t){t.forEach(function(t){t[0]+=o,t[1]+=r}),e[i++]=t}):(s.forEach(function(t){t[0]+=o,t[1]+=r}),e[i++]=s):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates")}})}),e}var c={successCallback:null,verbose:!1,polygons:!1},h={},f=64,p=16,d=4,g=1,v=[],y=[],m=[],x=[],E=[],I=[],w=[],N=[],b=[],C=[],S=[],M=[],L=[],R=[],P=[],T=[],O=[],_=[],A=[],D=[],F=[],G=[],q=[],k=[];w[85]=C[85]=-1,N[85]=S[85]=0,b[85]=M[85]=1,A[85]=G[85]=1,D[85]=q[85]=0,F[85]=k[85]=1,v[85]=x[85]=0,y[85]=E[85]=-1,m[85]=P[85]=0,T[85]=L[85]=0,O[85]=R[85]=1,I[85]=_[85]=1,G[1]=G[169]=0,q[1]=q[169]=-1,k[1]=k[169]=0,L[1]=L[169]=-1,R[1]=R[169]=0,P[1]=P[169]=0,C[4]=C[166]=0,S[4]=S[166]=-1,M[4]=M[166]=1,T[4]=T[166]=1,O[4]=O[166]=0,_[4]=_[166]=0,w[16]=w[154]=0,N[16]=N[154]=1,b[16]=b[154]=1,x[16]=x[154]=1,E[16]=E[154]=0,I[16]=I[154]=1,A[64]=A[106]=0,D[64]=D[106]=1,F[64]=F[106]=0,v[64]=v[106]=-1,y[64]=y[106]=0,m[64]=m[106]=1,A[2]=A[168]=0,D[2]=D[168]=-1,F[2]=F[168]=1,G[2]=G[168]=0,q[2]=q[168]=-1,k[2]=k[168]=0,L[2]=L[168]=-1,R[2]=R[168]=0,P[2]=P[168]=0,T[2]=T[168]=-1,O[2]=O[168]=0,_[2]=_[168]=1,w[8]=w[162]=0,N[8]=N[162]=-1,b[8]=b[162]=0,C[8]=C[162]=0,S[8]=S[162]=-1,M[8]=M[162]=1,L[8]=L[162]=1,R[8]=R[162]=0,P[8]=P[162]=1,T[8]=T[162]=1,O[8]=O[162]=0,_[8]=_[162]=0,w[32]=w[138]=0,N[32]=N[138]=1,b[32]=b[138]=1,C[32]=C[138]=0,S[32]=S[138]=1,M[32]=M[138]=0,v[32]=v[138]=1,y[32]=y[138]=0,m[32]=m[138]=0,x[32]=x[138]=1,E[32]=E[138]=0,I[32]=I[138]=1,G[128]=G[42]=0,q[128]=q[42]=1,k[128]=k[42]=1,A[128]=A[42]=0,D[128]=D[42]=1,F[128]=F[42]=0,v[128]=v[42]=-1,y[128]=y[42]=0,m[128]=m[42]=1,x[128]=x[42]=-1,E[128]=E[42]=0,I[128]=I[42]=0,C[5]=C[165]=-1,S[5]=S[165]=0,M[5]=M[165]=0,G[5]=G[165]=1,q[5]=q[165]=0,k[5]=k[165]=0,T[20]=T[150]=0,O[20]=O[150]=1,_[20]=_[150]=1,x[20]=x[150]=0,E[20]=E[150]=-1,I[20]=I[150]=1,w[80]=w[90]=-1,N[80]=N[90]=0,b[80]=b[90]=1,A[80]=A[90]=1,D[80]=D[90]=0,F[80]=F[90]=1,L[65]=L[105]=0,R[65]=R[105]=1,P[65]=P[105]=0,v[65]=v[105]=0,y[65]=y[105]=-1,m[65]=m[105]=0,w[160]=w[10]=-1,N[160]=N[10]=0,b[160]=b[10]=1,C[160]=C[10]=-1,S[160]=S[10]=0,M[160]=M[10]=0,G[160]=G[10]=1,q[160]=q[10]=0,k[160]=k[10]=0,A[160]=A[10]=1,D[160]=D[10]=0,F[160]=F[10]=1,T[130]=T[40]=0,O[130]=O[40]=1,_[130]=_[40]=1,L[130]=L[40]=0,R[130]=R[40]=1,P[130]=P[40]=0,v[130]=v[40]=0,y[130]=y[40]=-1,m[130]=m[40]=0,x[130]=x[40]=0,E[130]=E[40]=-1,I[130]=I[40]=1,C[37]=C[133]=0,S[37]=S[133]=1,M[37]=M[133]=1,G[37]=G[133]=0,q[37]=q[133]=1,k[37]=k[133]=0,v[37]=v[133]=-1,y[37]=y[133]=0,m[37]=m[133]=0,x[37]=x[133]=1,E[37]=E[133]=0,I[37]=I[133]=0,T[148]=T[22]=-1,O[148]=O[22]=0,_[148]=_[22]=0,G[148]=G[22]=0,q[148]=q[22]=-1,k[148]=k[22]=1,A[148]=A[22]=0,D[148]=D[22]=1,F[148]=F[22]=1,x[148]=x[22]=-1,E[148]=E[22]=0,I[148]=I[22]=1,w[82]=w[88]=0,N[82]=N[88]=-1,b[82]=b[88]=1,T[82]=T[88]=1,O[82]=O[88]=0,_[82]=_[88]=1,L[82]=L[88]=-1,R[82]=R[88]=0,P[82]=P[88]=1,A[82]=A[88]=0,D[82]=D[88]=-1,F[82]=F[88]=0,w[73]=w[97]=0,N[73]=N[97]=1,b[73]=b[97]=0,C[73]=C[97]=0,S[73]=S[97]=-1,M[73]=M[97]=0,L[73]=L[97]=1,R[73]=R[97]=0,P[73]=P[97]=0,v[73]=v[97]=1,y[73]=y[97]=0,m[73]=m[97]=1,w[145]=w[25]=0,N[145]=N[25]=-1,b[145]=b[25]=0,L[145]=L[25]=1,R[145]=R[25]=0,P[145]=P[25]=1,G[145]=G[25]=0,q[145]=q[25]=1,k[145]=k[25]=1,x[145]=x[25]=-1,E[145]=E[25]=0,I[145]=I[25]=0,C[70]=C[100]=0,S[70]=S[100]=1,M[70]=M[100]=0,T[70]=T[100]=-1,O[70]=O[100]=0,_[70]=_[100]=1,A[70]=A[100]=0,D[70]=D[100]=-1;F[70]=F[100]=1,v[70]=v[100]=1,y[70]=y[100]=0,m[70]=m[100]=0,C[101]=C[69]=0,S[101]=S[69]=1,M[101]=M[69]=0,v[101]=v[69]=1,y[101]=y[69]=0,m[101]=m[69]=0,G[149]=G[21]=0,q[149]=q[21]=1,k[149]=k[21]=1,x[149]=x[21]=-1,E[149]=E[21]=0,I[149]=I[21]=0,T[86]=T[84]=-1,O[86]=O[84]=0,_[86]=_[84]=1,A[86]=A[84]=0,D[86]=D[84]=-1,F[86]=F[84]=1,w[89]=w[81]=0,N[89]=N[81]=-1,b[89]=b[81]=0,L[89]=L[81]=1,R[89]=R[81]=0,P[89]=P[81]=1,w[96]=w[74]=0,N[96]=N[74]=1,b[96]=b[74]=0,C[96]=C[74]=-1,S[96]=S[74]=0,M[96]=M[74]=1,A[96]=A[74]=1,D[96]=D[74]=0,F[96]=F[74]=0,v[96]=v[74]=1,y[96]=y[74]=0,m[96]=m[74]=1,w[24]=w[146]=0,N[24]=N[146]=-1,b[24]=b[146]=1,T[24]=T[146]=1,O[24]=O[146]=0,_[24]=_[146]=1,L[24]=L[146]=0,R[24]=R[146]=1,P[24]=P[146]=1,x[24]=x[146]=0,E[24]=E[146]=-1,I[24]=I[146]=0,C[6]=C[164]=-1,S[6]=S[164]=0,M[6]=M[164]=1,T[6]=T[164]=-1,O[6]=O[164]=0,_[6]=_[164]=0,G[6]=G[164]=0,q[6]=q[164]=-1,k[6]=k[164]=1,A[6]=A[164]=1,D[6]=D[164]=0,F[6]=F[164]=0,L[129]=L[41]=0,R[129]=R[41]=1,P[129]=P[41]=1,G[129]=G[41]=0,q[129]=q[41]=1,k[129]=k[41]=0,v[129]=v[41]=-1,y[129]=y[41]=0,m[129]=m[41]=0,x[129]=x[41]=0,E[129]=E[41]=-1,I[129]=I[41]=0,T[66]=T[104]=0,O[66]=O[104]=1,_[66]=_[104]=0,L[66]=L[104]=-1,R[66]=R[104]=0,P[66]=P[104]=1,A[66]=A[104]=0,D[66]=D[104]=-1,F[66]=F[104]=0,v[66]=v[104]=0,y[66]=y[104]=-1,m[66]=m[104]=1,w[144]=w[26]=-1,N[144]=N[26]=0,b[144]=b[26]=0,G[144]=G[26]=1,q[144]=q[26]=0,k[144]=k[26]=1,A[144]=A[26]=0,D[144]=D[26]=1,F[144]=F[26]=1,x[144]=x[26]=-1,E[144]=E[26]=0,I[144]=I[26]=1,C[36]=C[134]=0,S[36]=S[134]=1,M[36]=M[134]=1,T[36]=T[134]=0,O[36]=O[134]=1,_[36]=_[134]=0,v[36]=v[134]=0,y[36]=y[134]=-1,m[36]=m[134]=1,x[36]=x[134]=1,E[36]=E[134]=0,I[36]=I[134]=0,w[9]=w[161]=-1,N[9]=N[161]=0,b[9]=b[161]=0,C[9]=C[161]=0,S[9]=S[161]=-1,M[9]=M[161]=0,L[9]=L[161]=1,R[9]=R[161]=0,P[9]=P[161]=0,G[9]=G[161]=1,q[9]=q[161]=0,k[9]=k[161]=1,w[136]=0,N[136]=1,b[136]=1,C[136]=0,S[136]=1,M[136]=0,T[136]=-1,O[136]=0,_[136]=1,L[136]=-1,R[136]=0,P[136]=0,G[136]=0,q[136]=-1,k[136]=0,A[136]=0,D[136]=-1,F[136]=1,v[136]=1,y[136]=0,m[136]=0,x[136]=1,E[136]=0,I[136]=1,w[34]=0,N[34]=-1,b[34]=0,C[34]=0,S[34]=-1,M[34]=1,T[34]=1,O[34]=0,_[34]=0,L[34]=1,R[34]=0,P[34]=1,G[34]=0,q[34]=1,k[34]=1,A[34]=0,D[34]=1,F[34]=0,v[34]=-1,y[34]=0,m[34]=1,x[34]=-1,E[34]=0,I[34]=0,w[35]=0,N[35]=1,b[35]=1,C[35]=0,S[35]=-1,M[35]=1,T[35]=1,O[35]=0,_[35]=0,L[35]=-1,R[35]=0,P[35]=0,G[35]=0,q[35]=-1,k[35]=0,A[35]=0,D[35]=1,F[35]=0,v[35]=-1,y[35]=0,m[35]=1,x[35]=1,E[35]=0,I[35]=1,w[153]=0,N[153]=1,b[153]=1,L[153]=-1;R[153]=0,P[153]=0,G[153]=0,q[153]=-1,k[153]=0,x[153]=1,E[153]=0,I[153]=1,C[102]=0,S[102]=-1,M[102]=1,T[102]=1,O[102]=0,_[102]=0,A[102]=0,D[102]=1,F[102]=0,v[102]=-1,y[102]=0,m[102]=1,w[155]=0,N[155]=-1,b[155]=0,L[155]=1,R[155]=0,P[155]=1,G[155]=0,q[155]=1,k[155]=1,x[155]=-1,E[155]=0,I[155]=0,C[103]=0,S[103]=1,M[103]=0,T[103]=-1,O[103]=0,_[103]=1,A[103]=0,D[103]=-1,F[103]=1,v[103]=1,y[103]=0,m[103]=0,w[152]=0,N[152]=1,b[152]=1,T[152]=-1,O[152]=0,_[152]=1,L[152]=-1,R[152]=0,P[152]=0,G[152]=0,q[152]=-1,k[152]=0,A[152]=0,D[152]=-1,F[152]=1,x[152]=1,E[152]=0,I[152]=1,w[156]=0,N[156]=-1,b[156]=1,T[156]=1,O[156]=0,_[156]=1,L[156]=-1,R[156]=0,P[156]=0,G[156]=0,q[156]=-1,k[156]=0,A[156]=0,D[156]=1,F[156]=1,x[156]=-1,E[156]=0,I[156]=1,w[137]=0,N[137]=1,b[137]=1,C[137]=0,S[137]=1,M[137]=0,L[137]=-1,R[137]=0,P[137]=0,G[137]=0,q[137]=-1,k[137]=0,v[137]=1,y[137]=0,m[137]=0,x[137]=1,E[137]=0,I[137]=1,w[139]=0,N[139]=1,b[139]=1,C[139]=0,S[139]=-1,M[139]=0,L[139]=1,R[139]=0,P[139]=0,G[139]=0,q[139]=1,k[139]=0,v[139]=-1,y[139]=0,m[139]=0,x[139]=1,E[139]=0,I[139]=1,w[98]=0,N[98]=-1,b[98]=0,C[98]=0,S[98]=-1,M[98]=1,T[98]=1,O[98]=0,_[98]=0,L[98]=1,R[98]=0,P[98]=1,A[98]=0,D[98]=1,F[98]=0,v[98]=-1,y[98]=0,m[98]=1,w[99]=0,N[99]=1,b[99]=0,C[99]=0,S[99]=-1,M[99]=1,T[99]=1,O[99]=0,_[99]=0,L[99]=-1,R[99]=0,P[99]=1,A[99]=0,D[99]=-1,F[99]=0,v[99]=1,y[99]=0,m[99]=1,C[38]=0,S[38]=-1,M[38]=1,T[38]=1,O[38]=0,_[38]=0,G[38]=0,q[38]=1,k[38]=1,A[38]=0,D[38]=1,F[38]=0,v[38]=-1,y[38]=0,m[38]=1,x[38]=-1,E[38]=0,I[38]=0,C[39]=0,S[39]=1,M[39]=1,T[39]=-1,O[39]=0,_[39]=0,G[39]=0,q[39]=-1,k[39]=1,A[39]=0,D[39]=1,F[39]=0,v[39]=-1,y[39]=0,m[39]=1,x[39]=1,E[39]=0,I[39]=0;var B=function(t){return[[t.bottomleft,0],[0,0],[0,t.leftbottom]]},j=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0]]},z=function(t){return[[t.topright,1],[1,1],[1,t.righttop]]},V=function(t){return[[0,t.lefttop],[0,1],[t.topleft,1]]},X=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop]]},Y=function(t){return[[t.bottomright,0],[t.bottomleft,0],[1,t.righttop],[1,t.rightbottom]]},U=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.topleft,1],[t.topright,1]]},W=function(t){return[[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},H=function(t){return[[0,0],[0,t.leftbottom],[1,t.rightbottom],[1,0]]},J=function(t){return[[1,0],[t.bottomright,0],[t.topright,1],[1,1]]},Z=function(t){return[[1,1],[1,t.righttop],[0,t.lefttop],[0,1]]},K=function(t){return[[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},Q=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.leftbottom],[0,t.lefttop]]},$=function(t){return[[t.topleft,1],[t.topright,1],[t.bottomright,0],[t.bottomleft,0]]},tt=function(){return[[0,0],[0,1],[1,1],[1,0]]},et=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,1],[t.topleft,1]]},nt=function(t){return[[t.topright,1],[1,1],[1,0],[0,0],[0,t.leftbottom]]},it=function(t){return[[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[1,1]]},rt=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,1]]},ot=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.lefttop],[0,1],[t.topleft,1]]},st=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[t.topright,1]]},at=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop]]},ut=function(t){return[[t.topright,1],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1]]},lt=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},ct=function(t){return[[1,1],[1,t.righttop],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},ht=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[t.topleft,1],[t.topright,1]]},ft=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom]]},pt=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},dt=function(t){return[[1,1],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},gt=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1]]},vt=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},yt=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},mt=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},xt=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},Et=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},It=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},wt=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},Nt=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},bt=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},Ct=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},St=[],Mt=[],Lt=[],Rt=[],Pt=[],Tt=[],Ot=[],_t=[];Rt[1]=Pt[1]=18,Rt[169]=Pt[169]=18,Lt[4]=Mt[4]=12,Lt[166]=Mt[166]=12,St[16]=_t[16]=4,St[154]=_t[154]=4,Tt[64]=Ot[64]=22,Tt[106]=Ot[106]=22,Lt[2]=Tt[2]=17,Rt[2]=Pt[2]=18,Lt[168]=Tt[168]=17,Rt[168]=Pt[168]=18,St[8]=Rt[8]=9,Mt[8]=Lt[8]=12,St[162]=Rt[162]=9,Mt[162]=Lt[162]=12,St[32]=_t[32]=4,Mt[32]=Ot[32]=1,St[138]=_t[138]=4,Mt[138]=Ot[138]=1,Pt[128]=_t[128]=21,Tt[128]=Ot[128]=22,Pt[42]=_t[42]=21,Tt[42]=Ot[42]=22,Mt[5]=Pt[5]=14,Mt[165]=Pt[165]=14,Lt[20]=_t[20]=6,Lt[150]=_t[150]=6,St[80]=Tt[80]=11,St[90]=Tt[90]=11,Rt[65]=Ot[65]=3,Rt[105]=Ot[105]=3,St[160]=Tt[160]=11,Mt[160]=Pt[160]=14,St[10]=Tt[10]=11,Mt[10]=Pt[10]=14,Lt[130]=_t[130]=6,Rt[130]=Ot[130]=3,Lt[40]=_t[40]=6,Rt[40]=Ot[40]=3,Mt[101]=Ot[101]=1,Mt[69]=Ot[69]=1,Pt[149]=_t[149]=21,Pt[21]=_t[21]=21,Lt[86]=Tt[86]=17,Lt[84]=Tt[84]=17,St[89]=Rt[89]=9,St[81]=Rt[81]=9,St[96]=Ot[96]=0,Mt[96]=Tt[96]=15,St[74]=Ot[74]=0,Mt[74]=Tt[74]=15,St[24]=Lt[24]=8,Rt[24]=_t[24]=7,St[146]=Lt[146]=8,Rt[146]=_t[146]=7,Mt[6]=Tt[6]=15,Lt[6]=Pt[6]=16,Mt[164]=Tt[164]=15,Lt[164]=Pt[164]=16,Rt[129]=_t[129]=7,Pt[129]=Ot[129]=20,Rt[41]=_t[41]=7,Pt[41]=Ot[41]=20,Lt[66]=Ot[66]=2,Rt[66]=Tt[66]=19,Lt[104]=Ot[104]=2,Rt[104]=Tt[104]=19,St[144]=Pt[144]=10,Tt[144]=_t[144]=23,St[26]=Pt[26]=10,Tt[26]=_t[26]=23,Mt[36]=_t[36]=5,Lt[36]=Ot[36]=2,Mt[134]=_t[134]=5,Lt[134]=Ot[134]=2,St[9]=Pt[9]=10,Mt[9]=Rt[9]=13,St[161]=Pt[161]=10,Mt[161]=Rt[161]=13,Mt[37]=_t[37]=5,Pt[37]=Ot[37]=20,Mt[133]=_t[133]=5,Pt[133]=Ot[133]=20,Lt[148]=Pt[148]=16, +Tt[148]=_t[148]=23,Lt[22]=Pt[22]=16,Tt[22]=_t[22]=23,St[82]=Lt[82]=8,Rt[82]=Tt[82]=19,St[88]=Lt[88]=8,Rt[88]=Tt[88]=19,St[73]=Ot[73]=0,Mt[73]=Rt[73]=13,St[97]=Ot[97]=0,Mt[97]=Rt[97]=13,St[145]=Rt[145]=9,Pt[145]=_t[145]=21,St[25]=Rt[25]=9,Pt[25]=_t[25]=21,Mt[70]=Ot[70]=1,Lt[70]=Tt[70]=17,Mt[100]=Ot[100]=1,Lt[100]=Tt[100]=17,St[34]=Rt[34]=9,Mt[34]=Lt[34]=12,Pt[34]=_t[34]=21,Tt[34]=Ot[34]=22,St[136]=_t[136]=4,Mt[136]=Ot[136]=1,Lt[136]=Tt[136]=17,Rt[136]=Pt[136]=18,St[35]=_t[35]=4,Mt[35]=Lt[35]=12,Rt[35]=Pt[35]=18,Tt[35]=Ot[35]=22,St[153]=_t[153]=4,Rt[153]=Pt[153]=18,Mt[102]=Lt[102]=12,Tt[102]=Ot[102]=22,St[155]=Rt[155]=9,Pt[155]=_t[155]=23,Mt[103]=Ot[103]=1,Lt[103]=Tt[103]=17,St[152]=_t[152]=4,Lt[152]=Tt[152]=17,Rt[152]=Pt[152]=18,St[156]=Lt[156]=8,Rt[156]=Pt[156]=18,Tt[156]=_t[156]=23,St[137]=_t[137]=4,Mt[137]=Ot[137]=1,Rt[137]=Pt[137]=18,St[139]=_t[139]=4,Mt[139]=Rt[139]=13,Pt[139]=Ot[139]=20,St[98]=Rt[98]=9,Mt[98]=Lt[98]=12,Tt[98]=Ot[98]=22,St[99]=Ot[99]=0,Mt[99]=Lt[99]=12,Rt[99]=Tt[99]=19,Mt[38]=Lt[38]=12,Pt[38]=_t[38]=21,Tt[38]=Ot[38]=22,Mt[39]=_t[39]=5,Lt[39]=Pt[39]=16,Tt[39]=Ot[39]=22;var At=[];return At[1]=At[169]=B,At[4]=At[166]=j,At[16]=At[154]=z,At[64]=At[106]=V,At[168]=At[2]=X,At[162]=At[8]=Y,At[138]=At[32]=U,At[42]=At[128]=W,At[5]=At[165]=H,At[20]=At[150]=J,At[80]=At[90]=Z,At[65]=At[105]=K,At[160]=At[10]=Q,At[130]=At[40]=$,At[85]=tt,At[101]=At[69]=et,At[149]=At[21]=nt,At[86]=At[84]=it,At[89]=At[81]=rt,At[96]=At[74]=ot,At[24]=At[146]=st,At[6]=At[164]=at,At[129]=At[41]=ut,At[66]=At[104]=lt,At[144]=At[26]=ct,At[36]=At[134]=ht,At[9]=At[161]=ft,At[37]=At[133]=pt,At[148]=At[22]=dt,At[82]=At[88]=gt,At[73]=At[97]=vt,At[145]=At[25]=yt,At[70]=At[100]=mt,At[34]=function(t){return[W(t),Y(t)]},At[35]=xt,At[136]=function(t){return[U(t),X(t)]},At[153]=function(t){return[z(t),B(t)]},At[102]=function(t){return[j(t),V(t)]},At[155]=Et,At[103]=It,At[152]=function(t){return[z(t),X(t)]},At[156]=wt,At[137]=function(t){return[U(t),B(t)]},At[139]=Nt,At[98]=function(t){return[Y(t),V(t)]},At[99]=bt,At[38]=function(t){return[j(t),W(t)]},At[39]=Ct,t})},{}],203:[function(e,n,i){!function(e,i){"function"==typeof t&&t.amd?t([],function(){return{isoContours:i()}}):"object"==typeof n&&n.exports?n.exports={isoContours:i()}:e.MarchingSquaresJS={isoContours:i(),isoBands:e.MarchingSquaresJS?e.MarchingSquaresJS.isoBands:null}}(this,function(){function t(t,e,i){i=i||{};for(var r=Object.keys(l),o=0;o=n?8:0,u|=c>=n?4:0,u|=h>=n?2:0,u|=f>=n?1:0;var p=!1;if(5===u||10===u){var d=(l+c+h+f)/4;5===u&&d=0;p--)if(Math.abs(e[p][0][0]-h)<=1e-7&&Math.abs(e[p][0][1]-f)<=1e-7){for(var d=l.path.length-2;d>=0;--d)e[p].unshift(l.path[d]);c=!0;break}c||(e[n++]=l.path)}})}),e}function u(t,e,n){var i,r,a,u=t.length,l=[],c=[0,0,1,1,0,0,0,0,-1,0,1,1,-1,0,-1,0],h=[0,-1,0,0,1,1,1,1,0,-1,0,0,0,-1,0,0],f=["none","left","bottom","left","right","none","bottom","left","top","top","none","top","right","right","bottom","none"],p=["none","bottom","right","right","top","top","top","top","left","bottom","right","right","left","bottom","left","none"],d=(t[e][n],t[e][n]),g=d.cval,a=f[g],v=s(d,a);l.push([n+v[0],e+v[1]]),a=p[g],v=s(d,a),l.push([n+v[0],e+v[1]]),o(d);for(var y=n+c[g],m=e+h[g],x=g;y>=0&&m>=0&&m=i;P--)for(var T=e;T<=n-1;T++){var O,_;if(O=Math.min(t[T][P],t[T][P+1]),_=Math.min(t[T+1][P],t[T+1][P+1]),x=Math.min(O,_),O=Math.max(t[T][P],t[T][P+1]),_=Math.max(t[T+1][P],t[T+1][P+1]),(E=Math.max(O,_))>=l[0]&&x<=l[u-1])for(var A=0;A=x&&l[A]<=E){for(var D=4;D>=0;D--)D>0?(c[D]=t[T+M[D-1]][P+L[D-1]]-l[A],f[D]=o[T+M[D-1]],p[D]=s[P+L[D-1]]):(c[0]=.25*(c[1]+c[2]+c[3]+c[4]),f[0]=.5*(o[T]+o[T+1]),p[0]=.5*(s[P]+s[P+1])),c[D]>a?h[D]=1:c[D]<-a?h[D]=-1:h[D]=0;for(D=1;D<=4;D++)if(g=D,v=0,y=4!=D?D+1:1,0!=(m=R[h[g]+1][h[v]+1][h[y]+1])){switch(m){case 1:N=f[g],C=p[g],b=f[v],S=p[v];break;case 2:N=f[v],C=p[v],b=f[y],S=p[y];break;case 3:N=f[y],C=p[y],b=f[g],S=p[g];break;case 4:N=f[g],C=p[g],b=I(v,y),S=w(v,y);break;case 5:N=f[v],C=p[v],b=I(y,g),S=w(y,g);break;case 6:N=f[y],C=p[y],b=I(g,v),S=w(g,v);break;case 7:N=I(g,v),C=w(g,v),b=I(v,y),S=w(v,y);break;case 8:N=I(v,y),C=w(v,y),b=I(y,g),S=w(y,g);break;case 9:N=I(y,g),C=w(y,g),b=I(g,v),S=w(g,v)}d(N,C,b,S,l[A],A)}}}}},{}],207:[function(t,e,n){var i=t("@turf/tin"),r=t("@turf/bbox"),o=t("@turf/point-grid"),s=t("@turf/inside"),a=t("@turf/square"),u=t("@turf/helpers"),l=t("@turf/distance"),c=t("@turf/planepoint"),h=u.featureCollection,f=u.lineString,p=u.point,d=t("./conrec");e.exports=function(t,e,n,u){for(var g=i(t,e),v=r(t),y=a(v),m=l(p([y[0],y[1]]),p([y[2],y[1]]),"kilometers")/n,x=o(y,m,"kilometers"),E=[],I=0;I2){var n=[];t.forEach(function(t){n.push([t.x,t.y])});var i=f(n);i.properties={},i.properties[e]=t.level,F.features.push(i)}}),F}},{"./conrec":206,"@turf/bbox":208,"@turf/distance":210,"@turf/helpers":213,"@turf/inside":214,"@turf/planepoint":216,"@turf/point-grid":218,"@turf/square":225,"@turf/tin":229}],208:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":209,dup:22}],209:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],210:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":211,"@turf/invariant":212,dup:8}],211:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],212:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],213:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],214:[function(t,e,n){arguments[4][88][0].apply(n,arguments)},{"@turf/invariant":215,dup:88}],215:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],216:[function(t,e,n){var i=t("@turf/invariant"),r=i.getCoord,o=i.getGeom;e.exports=function(t,e){var n=r(t),i=o(e),s=i.coordinates,a=s[0];if(a.length<4)throw new Error("OuterRing of a Polygon must have 4 or more Positions.");var u=e.properties||{},l=u.a,c=u.b,h=u.c,f=n[0],p=n[1],d=a[0][0],g=a[0][1],v=void 0!==l?l:a[0][2],y=a[1][0],m=a[1][1],x=void 0!==c?c:a[1][2],E=a[2][0],I=a[2][1],w=void 0!==h?h:a[2][2];return(w*(f-d)*(p-m)+v*(f-y)*(p-I)+x*(f-E)*(p-g)-x*(f-d)*(p-I)-w*(f-y)*(p-g)-v*(f-E)*(p-m))/((f-d)*(p-m)+(f-y)*(p-I)+(f-E)*(p-g)-(f-d)*(p-I)-(f-y)*(p-g)-(f-E)*(p-m))}},{"@turf/invariant":217}],217:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],218:[function(t,e,n){var i=t("@turf/distance"),r=t("@turf/bbox"),o=t("@turf/helpers"),s=o.point,a=o.featureCollection;e.exports=function(t,e,n,o){var u=[];if(!t)throw new Error("bbox is required");if(Array.isArray(t)||(t=r(t)),4!==t.length)throw new Error("bbox must contain 4 numbers");var l=t[0],c=t[1],h=t[2],f=t[3],p=e/i(s([l,c]),s([h,c]),n),d=p*(h-l),g=e/i(s([l,c]),s([l,f]),n),v=g*(f-c);if(!0===o)var y=h-l,m=f-c,x=Math.floor(y/d),E=Math.floor(m/v),I=(y-x*d)/2,w=(m-E*v)/2;var N=l;for(!0===o&&(N+=I);N<=h;){var b=c;for(!0===o&&(b+=w);b<=f;)u.push(s([N,b])),b+=v;N+=d}return a(u)}},{"@turf/bbox":219,"@turf/distance":221,"@turf/helpers":224}],219:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":220,dup:22}],220:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],221:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":222,"@turf/invariant":223,dup:8}],222:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],223:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],224:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],225:[function(t,e,n){var i=t("@turf/distance");e.exports=function(t){var e=t[0],n=t[1],r=t[2],o=t[3];if(i(t.slice(0,2),[r,n])>=i(t.slice(0,2),[e,o])){var s=(n+o)/2;return[e,s-(r-e)/2,r,s+(r-e)/2]}var a=(e+r)/2;return[a-(o-n)/2,n,a+(o-n)/2,o]}},{"@turf/distance":226}],226:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":227,"@turf/invariant":228,dup:8}],227:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],228:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],229:[function(t,e,n){arguments[4][98][0].apply(n,arguments)},{"@turf/helpers":230,dup:98}],230:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],231:[function(t,e,n){function i(t,e,n,i,r,o,s,a){var u,l,c,h,f,p={x:null,y:null,onLine1:!1,onLine2:!1};return 0===(u=(a-o)*(n-t)-(s-r)*(i-e))?null!==p.x&&null!==p.y&&p:(l=e-o,c=t-r,h=(s-r)*l-(a-o)*c,f=(n-t)*l-(i-e)*c,l=h/u,c=f/u,p.x=t+l*(n-t),p.y=e+l*(i-e),l>=0&&l<=1&&(p.onLine1=!0),c>=0&&c<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y])}var r=t("@turf/helpers").point;e.exports=function(t){var e,n,o={type:"FeatureCollection",features:[]};if(n="Feature"===t.type?t.geometry:t,"LineString"===n.type)e=[n.coordinates];else if("MultiLineString"===n.type)e=n.coordinates;else if("MultiPolygon"===n.type)e=[].concat.apply([],n.coordinates);else{if("Polygon"!==n.type)throw new Error("Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry");e=n.coordinates}return e.forEach(function(t){e.forEach(function(e){for(var n=0;nd&&v.push(r(t,e,d,l).geometry.coordinates),s(v,f)}},{"@turf/circle":234,"@turf/destination":239,"@turf/helpers":242}],234:[function(t,e,n){arguments[4][34][0].apply(n,arguments)},{"@turf/destination":235,"@turf/helpers":238,dup:34}],235:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":236,"@turf/invariant":237,dup:5}],236:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],237:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],238:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],239:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":240,"@turf/invariant":241,dup:5}],240:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],241:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],242:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],243:[function(t,e,n){function i(t,e,n,i){var s=o(t,n);if(s<=e)return i(t);for(var a=Math.floor(s/e)+1,u=0;u=p&&d===u.length-1);d++){if(p>e&&0===l.length){if(!(c=e-p))return l.push(u[d]),s(l);h=i(u[d],u[d-1])-180,f=o(u[d],c,h,a),l.push(f.geometry.coordinates)}if(p>=n)return(c=n-p)?(h=i(u[d],u[d-1])-180,f=o(u[d],c,h,a),l.push(f.geometry.coordinates),s(l)):(l.push(u[d]),s(l));if(p>=e&&l.push(u[d]),d===u.length-1)return s(l);p+=r(u[d],u[d+1],a)}return s(u[u.length-1])}},{"@turf/bearing":255,"@turf/destination":257,"@turf/distance":260,"@turf/helpers":263}],255:[function(t,e,n){arguments[4][3][0].apply(n,arguments)},{"@turf/invariant":256,dup:3}],256:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],257:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":258,"@turf/invariant":259,dup:5}],258:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],259:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],260:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":261,"@turf/invariant":262,dup:8}],261:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],262:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],263:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],264:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],265:[function(t,e,n){arguments[4][245][0].apply(n,arguments)},{"@turf/distance":266,"@turf/flatten":269,"@turf/helpers":272,"@turf/meta":273,dup:245}],266:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":267,"@turf/invariant":268,dup:8}],267:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],268:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],269:[function(t,e,n){arguments[4][155][0].apply(n,arguments)},{"@turf/helpers":270,"@turf/meta":271,dup:155}],270:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],271:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],272:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],273:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],274:[function(t,e,n){function i(t,e){var n=a(t),i=a(e);if(2!==n.length)throw new Error(" line1 must only contain 2 coordinates");if(2!==i.length)throw new Error(" line2 must only contain 2 coordinates");var r=n[0][0],o=n[0][1],s=n[1][0],u=n[1][1],c=i[0][0],h=i[0][1],f=i[1][0],p=i[1][1],d=(p-h)*(s-r)-(f-c)*(u-o),g=(f-c)*(o-h)-(p-h)*(r-c),v=(s-r)*(o-h)-(u-o)*(r-c);if(0===d)return null;var y=g/d,m=v/d;if(y>=0&&y<=1&&m>=0&&m<=1){return l([r+y*(s-r),o+y*(u-o)])}return null}var r=t("@turf/meta"),o=t("geojson-rbush"),s=t("@turf/helpers"),a=t("@turf/invariant").getCoords,u=t("@turf/line-segment"),l=s.point,c=r.featureEach,h=s.featureCollection;e.exports=function(t,e){var n={},r=[];if("LineString"===t.type&&(t=s.feature(t)),"LineString"===e.type&&(e=s.feature(e)),"Feature"===t.type&&"Feature"===e.type&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var l=i(t,e);return l&&r.push(l),h(r)}var f=o();return f.load(u(e)),c(u(t),function(t){c(f.search(t),function(e){var o=i(t,e);if(o){var s=a(o).join(",");n[s]||(n[s]=!0,r.push(o))}})}),h(r)}},{"@turf/helpers":276,"@turf/invariant":277,"@turf/line-segment":278,"@turf/meta":282,"geojson-rbush":283}],275:[function(t,e,n){arguments[4][193][0].apply(n,arguments)},{"@turf/meta":282,dup:193}],276:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],277:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],278:[function(t,e,n){function i(t,e){var n=[],i=t.geometry;switch(i.type){case"Polygon":n=a(i);break;case"LineString":n=[a(i)]}n.forEach(function(n){r(n,t.properties).forEach(function(t){t.id=e.length,e.push(t)})})}function r(t,e){var n=[];return t.reduce(function(t,i){var r=l([t,i],e);return r.bbox=o(t,i),n.push(r),i}),n}function o(t,e){var n=t[0],i=t[1],r=e[0],o=e[1];return[nr?n:r,i>o?i:o]}var s=t("@turf/helpers"),a=t("@turf/invariant").getCoords,u=t("@turf/meta").flattenEach,l=s.lineString,c=s.featureCollection;e.exports=function(t){if(!t)throw new Error("geojson is required");var e=[];return u(t,function(t){i(t,e)}),c(e)}},{"@turf/helpers":279,"@turf/invariant":280,"@turf/meta":281}],279:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],280:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],281:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],282:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],283:[function(t,e,n){var i=t("@turf/bbox"),r=t("@turf/helpers").featureCollection,o=t("@turf/meta").featureEach,s=t("rbush");e.exports=function(t){var e=s(t);return e.insert=function(t){return t.bbox=t.bbox?t.bbox:i(t),s.prototype.insert.call(this,t)},e.load=function(t){var e=[];return o(t,function(t){t.bbox=t.bbox?t.bbox:i(t),e.push(t)}),s.prototype.load.call(this,e)},e.remove=function(t){return s.prototype.remove.call(this,t)},e.clear=function(){return s.prototype.clear.call(this)},e.search=function(t){var e=s.prototype.search.call(this,this.toBBox(t));return r(e)},e.collides=function(t){return s.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=s.prototype.all.call(this);return r(t)},e.toJSON=function(){return s.prototype.toJSON.call(this)},e.fromJSON=function(t){return s.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e=t.bbox?t.bbox:i(t);return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}},{"@turf/bbox":275,"@turf/helpers":276,"@turf/meta":282,rbush:285}],284:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],285:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:284}],286:[function(t,e,n){function i(t,e,n){var i=[],o=f(e,n),s=a(t),l=[];return s.forEach(function(t,e){if(e!==s.length-1){var n=r(t,s[e+1],o);if(i.push(n),e>0){var a=i[e-1],c=u(n,a);!1!==c&&(a[1]=c,n[0]=c),l.push(a[0]),e===s.length-2&&(l.push(n[0]),l.push(n[1]))}2===s.length&&(l.push(n[0]),l.push(n[1]))}}),c(l,t.properties)}function r(t,e,n){var i=Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])),r=t[0]+n*(e[1]-t[1])/i,o=e[0]+n*(e[1]-t[1])/i;return[[r,t[1]+n*(t[0]-e[0])/i],[o,e[1]+n*(t[0]-e[0])/i]]}var o=t("@turf/meta"),s=t("@turf/helpers"),a=t("@turf/invariant").getCoords,u=t("./intersection"),l=o.flattenEach,c=s.lineString,h=s.multiLineString,f=s.distanceToDegrees;e.exports=function(t,e,n){if(!t)throw new Error("geojson is required");if(void 0===e||null===e||isNaN(e))throw new Error("distance is required");var r="Feature"===t.type?t.geometry.type:t.type,o=t.properties;switch(r){case"LineString":return i(t,e,n);case"MultiLineString":var s=[];return l(t,function(t){s.push(i(t,e,n).geometry.coordinates)}),h(s,o);default:throw new Error("geometry "+r+" is not supported")}}},{"./intersection":287,"@turf/helpers":288,"@turf/invariant":289,"@turf/meta":290}],287:[function(t,e,n){function i(t){var e=t[0],n=t[1];return[n[0]-e[0],n[1]-e[1]]}function r(t,e){return t[0]*e[1]-e[0]*t[1]}function o(t,e){return[t[0]+e[0],t[1]+e[1]]}function s(t,e){return[t[0]-e[0],t[1]-e[1]]}function a(t,e){return[t*e[0],t*e[1]]}function u(t,e){var n=t[0],u=i(t),l=e[0],c=i(e),h=r(u,c);return o(n,a(r(s(l,n),c)/h,u))}function l(t,e){return 0===r(i(t),i(e))}function c(t,e){return!l(t,e)&&u(t,e)}e.exports=c},{}],288:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],289:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],290:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],291:[function(t,e,n){function i(t,e){var n=o(e),i=o(t),r=i[0],s=i[i.length-1];return a(n[0],r)?t.geometry.coordinates.unshift(n[1]):a(n[0],s)?t.geometry.coordinates.push(n[1]):a(n[1],r)?t.geometry.coordinates.unshift(n[0]):a(n[1],s)&&t.geometry.coordinates.push(n[0]),t}var r=t("@turf/line-segment"),o=t("@turf/invariant").getCoords,s=t("geojson-rbush"),a=t("deep-equal"),u=t("@turf/helpers").featureCollection,l=t("@turf/meta").featureEach;e.exports=function(t,e){var n=[],c=s();c.load(r(t));var h;return l(r(e),function(t){var e=!1;l(c.search(t),function(n){if(!1===e){var r=o(t).sort(),s=o(n).sort();a(r,s)&&(e=!0,h=h?i(h,t):t)}}),!1===e&&h&&(n.push(h),h=void 0)}),h&&n.push(h),u(n)}},{"@turf/helpers":293,"@turf/invariant":294,"@turf/line-segment":295,"@turf/meta":299,"deep-equal":300,"geojson-rbush":303}],292:[function(t,e,n){arguments[4][193][0].apply(n,arguments)},{"@turf/meta":299,dup:193}],293:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],294:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],295:[function(t,e,n){arguments[4][278][0].apply(n,arguments)},{"@turf/helpers":296,"@turf/invariant":297,"@turf/meta":298,dup:278}],296:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],297:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],298:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],299:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],300:[function(t,e,n){function i(t){return null===t||void 0===t}function r(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}function o(t,e,n){var o,c;if(i(t)||i(e))return!1;if(t.prototype!==e.prototype)return!1;if(u(t))return!!u(e)&&(t=s.call(t),e=s.call(e),l(t,e,n));if(r(t)){if(!r(e))return!1;if(t.length!==e.length)return!1;for(o=0;o=0;o--)if(h[o]!=f[o])return!1;for(o=h.length-1;o>=0;o--)if(c=h[o],!l(t[c],e[c],n))return!1;return typeof t==typeof e}var s=Array.prototype.slice,a=t("./lib/keys.js"),u=t("./lib/is_arguments.js"),l=e.exports=function(t,e,n){return n||(n={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?n.strict?t===e:t==e:o(t,e,n))}},{"./lib/is_arguments.js":301,"./lib/keys.js":302}],301:[function(t,e,n){function i(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function r(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}var o="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();n=e.exports=o?i:r,n.supported=i,n.unsupported=r},{}],302:[function(t,e,n){function i(t){var e=[];for(var n in t)e.push(n);return e}n=e.exports="function"==typeof Object.keys?Object.keys:i,n.shim=i},{}],303:[function(t,e,n){arguments[4][283][0].apply(n,arguments)},{"@turf/bbox":292,"@turf/helpers":293,"@turf/meta":299,dup:283,rbush:305}],304:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],305:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:304}],306:[function(t,e,n){arguments[4][278][0].apply(n,arguments)},{"@turf/helpers":307,"@turf/invariant":308,"@turf/meta":309,dup:278}],307:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],308:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],309:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],310:[function(t,e,n){arguments[4][254][0].apply(n,arguments)},{"@turf/bearing":311,"@turf/destination":313,"@turf/distance":316,"@turf/helpers":319,dup:254}],311:[function(t,e,n){arguments[4][3][0].apply(n,arguments)},{"@turf/invariant":312,dup:3}],312:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],313:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":314,"@turf/invariant":315,dup:5}],314:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],315:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],316:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":317,"@turf/invariant":318,dup:8}],317:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],318:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],319:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],320:[function(t,e,n){var i=t("@turf/helpers").lineString,r=t("@turf/point-on-line");e.exports=function(t,e,n){var o;if("Feature"===n.type)o=n.geometry.coordinates;else{if("LineString"!==n.type)throw new Error("input must be a LineString Feature or Geometry");o=n.coordinates}var s,a=r(n,t),u=r(n,e);s=a.properties.index<=u.properties.index?[a,u]:[u,a];for(var l=[s[0].geometry.coordinates],c=s[0].properties.index+1;c0&&(I=E.features[0],I.properties.dist=i(e,I,n),I.properties.location=h+i(p,I,n)),p.properties.dist1&&n.push(g(h)),d(n)}function s(t,e){var n,i;if(!e.features)throw new Error(" must contain features");return 1===e.features.length?e.features[0]:(y(e,function(e){var r=u(e,t),o=r.properties.dist;void 0===n?(i=e,n=o):o must be LineString");if("FeatureCollection"===i(e))throw new Error(" cannot be a FeatureCollection");switch(i(e)){case"Point":return o(t,e);case"MultiPoint":return r(t,a(e));case"LineString":case"MultiLineString":case"Polygon":case"MultiPolygon":return r(t,h(t,e));default:throw new Error(" geometry type is not supported")}}},{"@turf/flatten":346,"@turf/helpers":349,"@turf/invariant":350,"@turf/line-intersect":351,"@turf/line-segment":363,"@turf/meta":367,"@turf/point-on-line":368,"geojson-rbush":390}],345:[function(t,e,n){arguments[4][193][0].apply(n,arguments)},{"@turf/meta":367,dup:193}],346:[function(t,e,n){arguments[4][155][0].apply(n,arguments)},{"@turf/helpers":347,"@turf/meta":348,dup:155}],347:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],348:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],349:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],350:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],351:[function(t,e,n){arguments[4][274][0].apply(n,arguments)},{"@turf/helpers":353,"@turf/invariant":354,"@turf/line-segment":355,"@turf/meta":359,dup:274,"geojson-rbush":360}],352:[function(t,e,n){arguments[4][193][0].apply(n,arguments)},{"@turf/meta":359,dup:193}],353:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],354:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],355:[function(t,e,n){arguments[4][278][0].apply(n,arguments)},{"@turf/helpers":356,"@turf/invariant":357,"@turf/meta":358,dup:278}],356:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],357:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],358:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],359:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],360:[function(t,e,n){arguments[4][283][0].apply(n,arguments)},{"@turf/bbox":352,"@turf/helpers":353,"@turf/meta":359,dup:283,rbush:362}],361:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],362:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:361}],363:[function(t,e,n){arguments[4][278][0].apply(n,arguments)},{"@turf/helpers":364,"@turf/invariant":365,"@turf/meta":366,dup:278}],364:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],365:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],366:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],367:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],368:[function(t,e,n){arguments[4][322][0].apply(n,arguments)},{"@turf/bearing":369,"@turf/destination":371,"@turf/distance":374,"@turf/helpers":377,"@turf/line-intersect":378,dup:322}],369:[function(t,e,n){arguments[4][3][0].apply(n,arguments)},{"@turf/invariant":370,dup:3}],370:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],371:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":372,"@turf/invariant":373,dup:5}],372:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],373:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],374:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":375,"@turf/invariant":376,dup:8}],375:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],376:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],377:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],378:[function(t,e,n){arguments[4][274][0].apply(n,arguments)},{"@turf/helpers":380,"@turf/invariant":381,"@turf/line-segment":382,"@turf/meta":386,dup:274,"geojson-rbush":387}],379:[function(t,e,n){arguments[4][193][0].apply(n,arguments)},{"@turf/meta":386,dup:193}],380:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],381:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],382:[function(t,e,n){arguments[4][278][0].apply(n,arguments)},{"@turf/helpers":383,"@turf/invariant":384,"@turf/meta":385,dup:278}],383:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],384:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],385:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],386:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],387:[function(t,e,n){arguments[4][283][0].apply(n,arguments)},{"@turf/bbox":379,"@turf/helpers":380,"@turf/meta":386,dup:283,rbush:389}],388:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],389:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:388}],390:[function(t,e,n){arguments[4][283][0].apply(n,arguments)},{"@turf/bbox":345,"@turf/helpers":349,"@turf/meta":367,dup:283,rbush:392}],391:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],392:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:391}],393:[function(t,e,n){function i(t,e,n,i){e=e||t.properties||{};var l=u(t),h=r(t);if(!l.length)throw new Error("line must contain coordinates");switch(h){case"LineString":return n&&(l=o(l)),c([l],e);case"MultiLineString":var p=[],d=0;return l.forEach(function(t){if(n&&(t=o(t)),i){var e=s(a(f(t)));e>d?(p.unshift(t),d=e):p.push(t)}else p.push(t)}),c(p,e);default:throw new Error("geometry type "+h+" is not supported")}}function r(t){return t.geometry?t.geometry.type:t.type}function o(t){var e=t[0],n=e[0],i=e[1],r=t[t.length-1],o=r[0],s=r[1];return n===o&&i===s||t.push(e),t}function s(t){var e=t[0],n=t[1],i=t[2],r=t[3];return Math.abs(e-i)*Math.abs(n-r)}var a=t("@turf/bbox"),u=t("@turf/invariant").getCoords,l=t("@turf/helpers"),c=l.polygon,h=l.multiPolygon,f=l.lineString;e.exports=function(t,e,n,o){if(!t)throw new Error("lines is required");switch(n=void 0===n||n,o=void 0===o||o,r(t)){case"FeatureCollection":case"GeometryCollection":var s=[];return(t.features?t.features:t.geometries).forEach(function(t){s.push(u(i(t,{},n,o)))}),h(s,e)}return i(t,e,n,o)}},{"@turf/bbox":394,"@turf/helpers":396,"@turf/invariant":397}],394:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":395,dup:22}],395:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],396:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],397:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],398:[function(t,e,n){function i(t,e,n){var i=[];return i.push(t.geometry.coordinates[0]),d(e,function(t){i.push(t.geometry.coordinates[0])}),d(n,function(t){i.push(t.geometry.coordinates[0])}),f.polygon(i)}function r(t){var e=[],n=[];return d(t,function(t){"MultiPolygon"===t.geometry.type&&(t=o(t)),d(t,function(t){var i=t.geometry.coordinates,r=i[0],o=i.slice(1);e.push(f.polygon([r])),o.forEach(function(t){n.push(f.polygon([t]))})})}),[f.featureCollection(e),f.featureCollection(n)]}function o(t){var e=[];return t.geometry.coordinates.forEach(function(t){e.push(f.polygon(t))}),f.featureCollection(e)}function s(t){var e=[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]],n=t&&t.geometry.coordinates||e;return f.polygon(n)}function a(t){if(t.features.length<=1)return t;var e=l(t),n=[],i={};return d(t,function(t,r){if(i[r])return!0;for(e.remove({index:r},u),i[r]=!0;;){var o=p(t),s=e.search({minX:o[0],minY:o[1],maxX:o[2],maxY:o[3]});if(s.length>0){var a=s.map(function(t){return i[t.index]=!0,e.remove({index:t.index},u),t.geojson});a.push(t),t=h.apply(this,a)}if(0===s.length)break}n.push(t)}),f.featureCollection(n)}function u(t,e){return t.index===e.index}function l(t){var e=c(),n=[];return d(t,function(t,e){var i=p(t);n.push({minX:i[0],minY:i[1],maxX:i[2],maxY:i[3],geojson:t,index:e})}),e.load(n),e}var c=t("rbush"),h=t("@turf/union"),f=t("@turf/helpers"),p=t("@turf/bbox"),d=t("@turf/meta").featureEach;e.exports=function(t,e){var n=s(e),o=r(t),u=o[0],l=o[1];return u=a(u),l=a(l),i(n,u,l)}},{"@turf/bbox":399,"@turf/helpers":401,"@turf/meta":402,"@turf/union":403,rbush:406}],399:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":400,dup:22}],400:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],401:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],402:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],403:[function(t,e,n){arguments[4][100][0].apply(n,arguments)},{dup:100,jsts:404}],404:[function(t,e,n){arguments[4][43][0].apply(n,arguments)},{dup:43}],405:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],406:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:405}],407:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],408:[function(t,e,n){var i=t("@turf/bearing"),r=t("@turf/destination"),o=t("@turf/distance");e.exports=function(t,e){var n=o(t,e,"miles"),s=i(t,e);return r(t,n/2,s,"miles")}},{"@turf/bearing":409,"@turf/destination":411,"@turf/distance":414}],409:[function(t,e,n){arguments[4][3][0].apply(n,arguments)},{"@turf/invariant":410,dup:3}],410:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],411:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":412,"@turf/invariant":413,dup:5}],412:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],413:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],414:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":415,"@turf/invariant":416,dup:8}],415:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],416:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],417:[function(t,e,n){var i=t("@turf/distance");e.exports=function(t,e){for(var n,r=1/0,o=0;o0&&(o(e,c,a)||(a=t[l])),n>0&&i<=0&&(r(e,c,u)||(u=t[l])),n=i}return[a,u]}function r(t,e,n){return s(t,e,n)>=0}function o(t,e,n){return s(t,e,n)<=0}function s(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function a(t){return t.geometry?t.geometry.type:t.type}var u=t("@turf/invariant").getCoords,l=t("@turf/helpers"),c=l.featureCollection;e.exports=function(t,e){var n,r,o,h=u(t),f=u(e);switch(a(e)){case"Polygon":r=f[0][0],o=f[0][0],n=s(f[0][0],f[0][1],h);var p=i(f[0],h,n,void 0,r,o);r=p[0],o=p[1];break;case"MultiPolygon":r=f[0][0][0],o=f[0][0][0],n=s(f[0][0][0],f[0][0][1],h),f.forEach(function(t){var e=i(t[0],h,n,void 0,r,o);r=e[0],o=e[1]})}return c([l.point(r),l.point(o)])}},{"@turf/helpers":467,"@turf/invariant":468}],467:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],468:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],469:[function(t,e,n){function i(t,e){return t.length>1?u(t,e):a(t[0],e)}function r(t){return t.geometry?t.geometry.type:t.type}var o=t("@turf/invariant").getCoords,s=t("@turf/helpers"),a=s.lineString,u=s.multiLineString,l=s.featureCollection;e.exports=function(t,e){var n=r(t),s=o(t);if(e=e||t.properties||{},!s.length)throw new Error("polygon must contain coordinates");switch(n){case"Polygon":return i(s,e);case"MultiPolygon":var a=[];return s.forEach(function(t){a.push(i(t,e))}),l(a);default:throw new Error("geom "+n+" not supported")}}},{"@turf/helpers":470,"@turf/invariant":471}],470:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],471:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],472:[function(t,e,n){var i=t("polygonize");e.exports=function(t){return i(t)}},{polygonize:484}],473:[function(t,e,n){arguments[4][20][0].apply(n,arguments)},{"@turf/helpers":476,dup:20}],474:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":479,dup:22}],475:[function(t,e,n){arguments[4][147][0].apply(n,arguments)},{"@turf/bbox":474,"@turf/bbox-polygon":473,dup:147}],476:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],477:[function(t,e,n){arguments[4][88][0].apply(n,arguments)},{"@turf/invariant":478,dup:88}],478:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],479:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],480:[function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n "+this.to.id+" }"}},{key:"toLineString",value:function(){return s([this.from.coordinates,this.to.coordinates])}},{key:"compareTo",value:function(t){return u(t.from.coordinates,t.to.coordinates,this.to.coordinates)}}]),t}();e.exports=l},{"./util":485,"@turf/helpers":476}],481:[function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;nt.edges[e].from.coordinates[1]&&(e=i),e},0),n=(0===e?this.length:e)-1,i=(e+1)%this.length,r=s(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[i].from.coordinates);return 0===r?this.edges[n].from.coordinates[0]>this.edges[i].from.coordinates[0]:r>0}},{key:"toMultiPoint",value:function(){return h(this.edges.map(function(t){return t.from.coordinates}))}},{key:"toPolygon",value:function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(t){return t.from.coordinates});return t.push(this.edges[0].from.coordinates),this.polygon=f([t])}},{key:"getEnvelope",value:function(){return this.envelope?this.envelope:this.envelope=d(this.toPolygon())}},{key:"inside",value:function(t){return g(t,this.toPolygon())}},{key:"length",get:function(){return this.edges.length}}],[{key:"findEdgeRingContaining",value:function(t,e){var n=t.getEnvelope(),i=void 0,r=void 0;return e.forEach(function(e){var o=e.getEnvelope();if(r&&(i=r.getEnvelope()),!a(o,n)&&u(o,n)){var s=t.map(function(t){return t.from.coordinates}).find(function(t){return!e.some(function(e){return l(t,e.from.coordinates)})});s&&e.inside(p(s))&&(r&&!u(i,o)||(r=e))}}),r}}]),t}();e.exports=v},{"./util":485,"@turf/envelope":475,"@turf/helpers":476,"@turf/inside":477}],482:[function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t){if(!t)throw new Error("No geojson passed");if("FeatureCollection"!==t.type&&"GeometryCollection"!==t.type&&"MultiLineString"!==t.type&&"LineString"!==t.type&&"Feature"!==t.type)throw new Error("Invalid input type '"+t.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}var o=function(){function t(t,e){for(var n=0;n=0;--o){var s=n[o],a=s.symetric,u=void 0,l=void 0;s.label===e&&(u=s),a.label===e&&(l=a),u&&l&&(l&&(r=l),u&&(r&&(r.next=u,r=void 0),i||(i=u)))}r&&(r.next=i)}},{key:"_findLabeledEdgeRings",value:function(){var t=[],e=0;return this.edges.forEach(function(n){if(!(n.label>=0)){t.push(n);var i=n;do{i.label=e,i=i.next}while(!n.isEqual(i));e++}}),t}},{key:"getEdgeRings",value:function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(t){t.label=void 0}),this._findLabeledEdgeRings().forEach(function(e){t._findIntersectionNodes(e).forEach(function(n){t._computeNextCCWEdges(n,e.label)})});var e=[];return this.edges.forEach(function(n){n.ring||e.push(t._findEdgeRing(n))}),e}},{key:"_findIntersectionNodes",value:function(t){var e=[],n=t;do{!function(){var i=0;n.from.getOuterEdges().forEach(function(e){e.label===t.label&&++i}),i>1&&e.push(n.from),n=n.next}()}while(!t.isEqual(n));return e}},{key:"_findEdgeRing",value:function(t){var e=t,n=new u;do{n.push(e),e.ring=n,e=e.next}while(!t.isEqual(e));return n}},{key:"removeNode",value:function(t){var e=this;t.getOuterEdges().forEach(function(t){return e.removeEdge(t)}),t.innerEdges.forEach(function(t){return e.removeEdge(t)}),delete this.nodes[t.id]}},{key:"removeEdge",value:function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()}}]),t}();e.exports=d},{"./Edge":480,"./EdgeRing":481,"./Node":483,"@turf/invariant":478,"@turf/meta":479}],483:[function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var r=function(){function t(t,e){for(var n=0;n=0&&r.coordinates[0]-t.coordinates[0]<0)return 1;if(i.coordinates[0]-t.coordinates[0]<0&&r.coordinates[0]-t.coordinates[0]>=0)return-1;if(i.coordinates[0]-t.coordinates[0]==0&&r.coordinates[0]-t.coordinates[0]==0)return i.coordinates[1]-t.coordinates[1]>=0||r.coordinates[1]-t.coordinates[1]>=0?i.coordinates[1]-r.coordinates[1]:r.coordinates[1]-i.coordinates[1];var o=s(t.coordinates,i.coordinates,r.coordinates);return o<0?1:o>0?-1:Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2)-(Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2))}),this.outerEdgesSorted=!0)}},{key:"getOuterEdges",value:function(){return this.sortOuterEdges(),this.outerEdges}},{key:"getOuterEdge",value:function(t){return this.sortOuterEdges(),this.outerEdges[t]}},{key:"addInnerEdge",value:function(t){this.innerEdges.push(t)}}]),t}();e.exports=a},{"./util":485}],484:[function(t,e,n){"use strict";var i=t("./Graph"),r=t("./EdgeRing"),o=t("@turf/helpers"),s=o.featureCollection;e.exports=function(t){var e=i.fromGeoJson(t);e.deleteDangles(),e.deleteCutEdges();var n=[],o=[];return e.getEdgeRings().filter(function(t){return t.isValid()}).forEach(function(t){t.isHole()?n.push(t):o.push(t)}),n.forEach(function(t){r.findEdgeRingContaining(t,o)&&o.push(t)}),s(o.map(function(t){return t.toPolygon()}))}},{ +"./EdgeRing":481,"./Graph":482,"@turf/helpers":476}],485:[function(t,e,n){"use strict";function i(t,e,n){var i=e[0]-t[0],r=e[1]-t[1],o=n[0]-e[0],s=n[1]-e[1];return Math.sign(i*s-o*r)}function r(t,e){var n=t.geometry.coordinates.map(function(t){return t[0]}),i=t.geometry.coordinates.map(function(t){return t[1]}),r=e.geometry.coordinates.map(function(t){return t[0]}),o=e.geometry.coordinates.map(function(t){return t[1]});return Math.max(null,n)===Math.max(null,r)&&Math.max(null,i)===Math.max(null,o)&&Math.min(null,n)===Math.min(null,r)&&Math.min(null,i)===Math.min(null,o)}function o(t,e){return e.geometry.coordinates[0].every(function(e){return a(l(e),t)})}function s(t,e){return t[0]===e[0]&&t[1]===e[1]}var a=t("@turf/inside"),u=t("@turf/helpers"),l=u.point;e.exports={orientationIndex:i,envelopeIsEqual:r,envelopeContains:o,coordinatesEqual:s}},{"@turf/helpers":476,"@turf/inside":477}],486:[function(t,e,n){var i=t("geojson-random");e.exports=function(t,e,n){switch(n=n||{},e=e||1,t){case"point":case"points":case void 0:return i.point(e,n.bbox);case"polygon":case"polygons":return i.polygon(e,n.num_vertices,n.max_radial_length,n.bbox);default:throw new Error("Unknown type given: valid options are points and polygons")}}},{"geojson-random":487}],487:[function(t,e,n){function r(t){return t?c(t):[a(),u()]}function o(t){return function(e,n){return[e[0]+t[0],e[1]+t[1]]}}function s(){return Math.random()-.5}function a(){return 360*s()}function u(){return 180*s()}function l(t){return{type:"Point",coordinates:t||[a(),u()]}}function c(t){return[Math.random()*(t[2]-t[0])+t[0],Math.random()*(t[3]-t[1])+t[1]]}function h(t){return{type:"Polygon",coordinates:t}}function f(t){return{type:"Feature",geometry:t,properties:{}}}function p(t){return{type:"FeatureCollection",features:t}}e.exports=function(){throw new Error("call .point() or .polygon() instead")},e.exports.position=r,e.exports.point=function(t,e){var n=[];for(i=0;i0?t+n[e-1]:t}function u(t,e){t=2*t*Math.PI/d[d.length-1];var i=Math.random();c.push([i*n*Math.sin(t),i*n*Math.cos(t)])}"number"!=typeof e&&(e=10),"number"!=typeof n&&(n=10);var l=[];for(i=0;i is required");if("boolean"!=typeof e)throw new Error(" must be a boolean");if("boolean"!=typeof n)throw new Error(" must be a boolean");!1!==n&&void 0!==n||(t=JSON.parse(JSON.stringify(t)));var r=[];switch(t.type){case"GeometryCollection":return c(t,function(t){i(t,e)}),t;case"FeatureCollection":return h(t,function(t){h(i(t,e),function(t){r.push(t)})}),l(r)}return i(t,e)}},{"@turf/helpers":489,"@turf/invariant":490,"@turf/meta":491,"turf-is-clockwise":492}],489:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],490:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],491:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],492:[function(t,e,n){arguments[4][142][0].apply(n,arguments)},{dup:142}],493:[function(t,e,n){var i=t("@turf/invariant").getCoord,r=t("geodesy").LatLonSpherical;e.exports=function(t,e,n){if(!t)throw new Error("start point is required");if(!e)throw new Error("end point is required");var o,s=i(t),a=i(e),u=new r(s[1],s[0]),l=new r(a[1],a[0]);return o=n?l.rhumbBearingTo(u):u.rhumbBearingTo(l),o>180?-(360-o):o}},{"@turf/invariant":494,geodesy:501}],494:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],495:[function(t,e,n){"use strict";var i={};i.parseDMS=function(t){if("number"==typeof t&&isFinite(t))return Number(t);var e=String(t).trim().replace(/^-/,"").replace(/[NSEW]$/i,"").split(/[^0-9.,]+/);if(""==e[e.length-1]&&e.splice(e.length-1),""==e)return NaN;var n;switch(e.length){case 3:n=e[0]/1+e[1]/60+e[2]/3600;break;case 2:n=e[0]/1+e[1]/60;break;case 1:n=e[0];break;default:return NaN}return/^-|[WS]$/i.test(t.trim())&&(n=-n),Number(n)},i.separator="",i.toDMS=function(t,e,n){if(isNaN(t))return null;if(void 0===e&&(e="dms"),void 0===n)switch(e){case"d":case"deg":n=4;break;case"dm":case"deg+min":n=2;break;case"dms":case"deg+min+sec":n=0;break;default:e="dms",n=0}t=Math.abs(t);var r,o,s,a;switch(e){default:case"d":case"deg":o=t.toFixed(n),o<100&&(o="0"+o),o<10&&(o="0"+o),r=o+"°";break;case"dm":case"deg+min":var u=(60*t).toFixed(n);o=Math.floor(u/60),s=(u%60).toFixed(n),o<100&&(o="0"+o),o<10&&(o="0"+o),s<10&&(s="0"+s),r=o+"°"+i.separator+s+"′";break;case"dms":case"deg+min+sec":var l=(3600*t).toFixed(n);o=Math.floor(l/3600),s=Math.floor(l/60)%60,a=(l%60).toFixed(n),o<100&&(o="0"+o),o<10&&(o="0"+o),s<10&&(s="0"+s),a<10&&(a="0"+a),r=o+"°"+i.separator+s+"′"+i.separator+a+"″"}return r},i.toLat=function(t,e,n){var r=i.toDMS(t,e,n);return null===r?"–":r.slice(1)+i.separator+(t<0?"S":"N")},i.toLon=function(t,e,n){var r=i.toDMS(t,e,n);return null===r?"–":r+i.separator+(t<0?"W":"E")},i.toBrng=function(t,e,n){t=(Number(t)+360)%360;var r=i.toDMS(t,e,n);return null===r?"–":r.replace("360","0")},i.compassPoint=function(t,e){void 0===e&&(e=3),t=(t%360+360)%360;var n;switch(e){case 1:switch(Math.round(4*t/360)%4){case 0:n="N";break;case 1:n="E";break;case 2:n="S";break;case 3:n="W"}break;case 2:switch(Math.round(8*t/360)%8){case 0:n="N";break;case 1:n="NE";break;case 2:n="E";break;case 3:n="SE";break;case 4:n="S";break;case 5:n="SW";break;case 6:n="W";break;case 7:n="NW"}break;case 3:switch(Math.round(16*t/360)%16){case 0:n="N";break;case 1:n="NNE";break;case 2:n="NE";break;case 3:n="ENE";break;case 4:n="E";break;case 5:n="ESE";break;case 6:n="SE";break;case 7:n="SSE";break;case 8:n="S";break;case 9:n="SSW";break;case 10:n="SW";break;case 11:n="WSW";break;case 12:n="W";break;case 13:n="WNW";break;case 14:n="NW";break;case 15:n="NNW"}break;default:throw new RangeError("Precision must be between 1 and 3")}return n},void 0===String.prototype.trim&&(String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")}),void 0!==e&&e.exports&&(e.exports=i)},{}],496:[function(t,e,n){"use strict";function i(t,e,n){if(!(this instanceof i))return new i(t,e,n);void 0===n&&(n=i.datum.WGS84),this.lat=Number(t),this.lon=Number(e),this.datum=n}if(void 0!==e&&e.exports)var r=t("./vector3d.js");if(void 0!==e&&e.exports)var o=t("./dms.js");i.ellipsoid={WGS84:{a:6378137,b:6356752.31425,f:1/298.257223563},GRS80:{a:6378137,b:6356752.31414,f:1/298.257222101},Airy1830:{a:6377563.396,b:6356256.909,f:1/299.3249646},AiryModified:{a:6377340.189,b:6356034.448,f:1/299.3249646},Intl1924:{a:6378388,b:6356911.946,f:1/297},Bessel1841:{a:6377397.155,b:6356078.963,f:1/299.152815351}},i.datum={WGS84:{ellipsoid:i.ellipsoid.WGS84,transform:{tx:0,ty:0,tz:0,rx:0,ry:0,rz:0,s:0}},ITRF90:{ellipsoid:i.ellipsoid.GRS80,transform:{tx:-.06,ty:.517,tz:.223,rx:-.0183,ry:3e-4,rz:-.007,s:.011}},NAD83:{ellipsoid:i.ellipsoid.GRS80,transform:{tx:1.004,ty:-1.91,tz:-.515,rx:.0267,ry:34e-5,rz:.011,s:-.0015}},OSGB36:{ellipsoid:i.ellipsoid.Airy1830,transform:{tx:-446.448,ty:125.157,tz:-542.06,rx:-.1502,ry:-.247,rz:-.8421,s:20.4894}},ED50:{ellipsoid:i.ellipsoid.Intl1924,transform:{tx:89.5,ty:93.8,tz:123.1,rx:0,ry:0,rz:.156,s:-1.2}},Irl1975:{ellipsoid:i.ellipsoid.AiryModified,transform:{tx:-482.53,ty:130.596,tz:-564.557,rx:-1.042,ry:-.214,rz:-.631,s:-8.15}},TokyoJapan:{ellipsoid:i.ellipsoid.Bessel1841,transform:{tx:148,ty:-507,tz:-685,rx:0,ry:0,rz:0,s:0}}},i.prototype.convertDatum=function(t){var e,n=this;if(n.datum==i.datum.WGS84&&(e=t.transform),t==i.datum.WGS84){e={};for(var r in n.datum.transform)n.datum.transform.hasOwnProperty(r)&&(e[r]=-n.datum.transform[r])}return void 0===e&&(n=this.convertDatum(i.datum.WGS84),e=t.transform),n.toCartesian().applyTransform(e).toLatLonE(t)},i.prototype.toCartesian=function(){var t=this.lat.toRadians(),e=this.lon.toRadians(),n=this.datum.ellipsoid.a,i=this.datum.ellipsoid.f,o=Math.sin(t),s=Math.cos(t),a=Math.sin(e),u=Math.cos(e),l=2*i-i*i,c=n/Math.sqrt(1-l*o*o);return new r((c+0)*s*u,(c+0)*s*a,(c*(1-l)+0)*o)},r.prototype.toLatLonE=function(t){var e=this.x,n=this.y,r=this.z,o=t.ellipsoid.a,s=t.ellipsoid.b,a=t.ellipsoid.f,u=2*a-a*a,l=u/(1-u),c=Math.sqrt(e*e+n*n),h=Math.sqrt(c*c+r*r),f=s*r/(o*c)*(1+l*s/h),p=f/Math.sqrt(1+f*f),d=p/f,g=isNaN(d)?0:Math.atan2(r+l*s*p*p*p,c-u*o*d*d*d),v=Math.atan2(n,e),y=Math.sin(g);Math.cos(g),Math.sqrt(1-u*y*y);return new i(g.toDegrees(),v.toDegrees(),t)},r.prototype.applyTransform=function(t){var e=this.x,n=this.y,i=this.z,o=t.tx,s=t.ty,a=t.tz,u=(t.rx/3600).toRadians(),l=(t.ry/3600).toRadians(),c=(t.rz/3600).toRadians(),h=t.s/1e6+1;return new r(o+e*h-n*c+i*l,s+e*c+n*h-i*u,a-e*l+n*u+i*h)},i.prototype.toString=function(t,e){return o.toLat(this.lat,t,e)+", "+o.toLon(this.lon,t,e)},void 0===Number.prototype.toRadians&&(Number.prototype.toRadians=function(){return this*Math.PI/180}),void 0===Number.prototype.toDegrees&&(Number.prototype.toDegrees=function(){return 180*this/Math.PI}),void 0!==e&&e.exports&&(e.exports=i,e.exports.Vector3d=r)},{"./dms.js":495,"./vector3d.js":504}],497:[function(t,e,n){"use strict";function i(t,e){if(!(this instanceof i))return new i(t,e);this.lat=Number(t),this.lon=Number(e)}if(void 0!==e&&e.exports)var r=t("./dms");i.prototype.distanceTo=function(t,e){if(!(t instanceof i))throw new TypeError("point is not LatLon object");e=void 0===e?6371e3:Number(e);var n=e,r=this.lat.toRadians(),o=this.lon.toRadians(),s=t.lat.toRadians(),a=t.lon.toRadians(),u=s-r,l=a-o,c=Math.sin(u/2)*Math.sin(u/2)+Math.cos(r)*Math.cos(s)*Math.sin(l/2)*Math.sin(l/2);return n*(2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c)))},i.prototype.bearingTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),n=t.lat.toRadians(),r=(t.lon-this.lon).toRadians(),o=Math.sin(r)*Math.cos(n),s=Math.cos(e)*Math.sin(n)-Math.sin(e)*Math.cos(n)*Math.cos(r);return(Math.atan2(o,s).toDegrees()+360)%360},i.prototype.finalBearingTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");return(t.bearingTo(this)+180)%360},i.prototype.midpointTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),n=this.lon.toRadians(),r=t.lat.toRadians(),o=(t.lon-this.lon).toRadians(),s=Math.cos(r)*Math.cos(o),a=Math.cos(r)*Math.sin(o),u=Math.sqrt((Math.cos(e)+s)*(Math.cos(e)+s)+a*a),l=Math.sin(e)+Math.sin(r),c=Math.atan2(l,u),h=n+Math.atan2(a,Math.cos(e)+s);return new i(c.toDegrees(),(h.toDegrees()+540)%360-180)},i.prototype.intermediatePointTo=function(t,e){if(!(t instanceof i))throw new TypeError("point is not LatLon object");var n=this.lat.toRadians(),r=this.lon.toRadians(),o=t.lat.toRadians(),s=t.lon.toRadians(),a=Math.sin(n),u=Math.cos(n),l=Math.sin(r),c=Math.cos(r),h=Math.sin(o),f=Math.cos(o),p=Math.sin(s),d=Math.cos(s),g=o-n,v=s-r,y=Math.sin(g/2)*Math.sin(g/2)+Math.cos(n)*Math.cos(o)*Math.sin(v/2)*Math.sin(v/2),m=2*Math.atan2(Math.sqrt(y),Math.sqrt(1-y)),x=Math.sin((1-e)*m)/Math.sin(m),E=Math.sin(e*m)/Math.sin(m),I=x*u*c+E*f*d,w=x*u*l+E*f*p,N=x*a+E*h,b=Math.atan2(N,Math.sqrt(I*I+w*w)),C=Math.atan2(w,I);return new i(b.toDegrees(),(C.toDegrees()+540)%360-180)},i.prototype.destinationPoint=function(t,e,n){n=void 0===n?6371e3:Number(n);var r=Number(t)/n,o=Number(e).toRadians(),s=this.lat.toRadians(),a=this.lon.toRadians(),u=Math.sin(s),l=Math.cos(s),c=Math.sin(r),h=Math.cos(r),f=Math.sin(o),p=Math.cos(o),d=u*h+l*c*p,g=Math.asin(d),v=f*c*l,y=h-u*d,m=a+Math.atan2(v,y);return new i(g.toDegrees(),(m.toDegrees()+540)%360-180)},i.intersection=function(t,e,n,r){if(!(t instanceof i))throw new TypeError("p1 is not LatLon object");if(!(n instanceof i))throw new TypeError("p2 is not LatLon object");var o=t.lat.toRadians(),s=t.lon.toRadians(),a=n.lat.toRadians(),u=n.lon.toRadians(),l=Number(e).toRadians(),c=Number(r).toRadians(),h=a-o,f=u-s,p=2*Math.asin(Math.sqrt(Math.sin(h/2)*Math.sin(h/2)+Math.cos(o)*Math.cos(a)*Math.sin(f/2)*Math.sin(f/2)));if(0==p)return null;var d=Math.acos((Math.sin(a)-Math.sin(o)*Math.cos(p))/(Math.sin(p)*Math.cos(o)));isNaN(d)&&(d=0);var g=Math.acos((Math.sin(o)-Math.sin(a)*Math.cos(p))/(Math.sin(p)*Math.cos(a))),v=Math.sin(u-s)>0?d:2*Math.PI-d,y=Math.sin(u-s)>0?2*Math.PI-g:g,m=(l-v+Math.PI)%(2*Math.PI)-Math.PI,x=(y-c+Math.PI)%(2*Math.PI)-Math.PI;if(0==Math.sin(m)&&0==Math.sin(x))return null;if(Math.sin(m)*Math.sin(x)<0)return null;var E=Math.acos(-Math.cos(m)*Math.cos(x)+Math.sin(m)*Math.sin(x)*Math.cos(p)),I=Math.atan2(Math.sin(p)*Math.sin(m)*Math.sin(x),Math.cos(x)+Math.cos(m)*Math.cos(E)),w=Math.asin(Math.sin(o)*Math.cos(I)+Math.cos(o)*Math.sin(I)*Math.cos(l)),N=Math.atan2(Math.sin(l)*Math.sin(I)*Math.cos(o),Math.cos(I)-Math.sin(o)*Math.sin(w)),b=s+N;return new i(w.toDegrees(),(b.toDegrees()+540)%360-180)},i.prototype.crossTrackDistanceTo=function(t,e,n){if(!(t instanceof i))throw new TypeError("pathStart is not LatLon object");if(!(e instanceof i))throw new TypeError("pathEnd is not LatLon object");n=void 0===n?6371e3:Number(n);var r=t.distanceTo(this,n)/n,o=t.bearingTo(this).toRadians(),s=t.bearingTo(e).toRadians();return Math.asin(Math.sin(r)*Math.sin(o-s))*n},i.prototype.maxLatitude=function(t){var e=Number(t).toRadians(),n=this.lat.toRadians();return Math.acos(Math.abs(Math.sin(e)*Math.cos(n))).toDegrees()},i.crossingParallels=function(t,e,n){var i=Number(n).toRadians(),r=t.lat.toRadians(),o=t.lon.toRadians(),s=e.lat.toRadians(),a=e.lon.toRadians(),u=a-o,l=Math.sin(r)*Math.cos(s)*Math.cos(i)*Math.sin(u),c=Math.sin(r)*Math.cos(s)*Math.cos(i)*Math.cos(u)-Math.cos(r)*Math.sin(s)*Math.cos(i),h=Math.cos(r)*Math.cos(s)*Math.sin(i)*Math.sin(u);if(h*h>l*l+c*c)return null;var f=Math.atan2(-c,l),p=Math.acos(h/Math.sqrt(l*l+c*c)),d=o+f-p,g=o+f+p;return{lon1:(d.toDegrees()+540)%360-180,lon2:(g.toDegrees()+540)%360-180}},i.prototype.rhumbDistanceTo=function(t,e){if(!(t instanceof i))throw new TypeError("point is not LatLon object");e=void 0===e?6371e3:Number(e);var n=e,r=this.lat.toRadians(),o=t.lat.toRadians(),s=o-r,a=Math.abs(t.lon-this.lon).toRadians();Math.abs(a)>Math.PI&&(a=a>0?-(2*Math.PI-a):2*Math.PI+a);var u=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),l=Math.abs(u)>1e-11?s/u:Math.cos(r);return Math.sqrt(s*s+l*l*a*a)*n},i.prototype.rhumbBearingTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),n=t.lat.toRadians(),r=(t.lon-this.lon).toRadians();Math.abs(r)>Math.PI&&(r=r>0?-(2*Math.PI-r):2*Math.PI+r);var o=Math.log(Math.tan(n/2+Math.PI/4)/Math.tan(e/2+Math.PI/4));return(Math.atan2(r,o).toDegrees()+360)%360},i.prototype.rhumbDestinationPoint=function(t,e,n){n=void 0===n?6371e3:Number(n);var r=Number(t)/n,o=this.lat.toRadians(),s=this.lon.toRadians(),a=Number(e).toRadians(),u=r*Math.cos(a),l=o+u;Math.abs(l)>Math.PI/2&&(l=l>0?Math.PI-l:-Math.PI-l);var c=Math.log(Math.tan(l/2+Math.PI/4)/Math.tan(o/2+Math.PI/4)),h=Math.abs(c)>1e-11?u/c:Math.cos(o),f=r*Math.sin(a)/h,p=s+f;return new i(l.toDegrees(),(p.toDegrees()+540)%360-180)},i.prototype.rhumbMidpointTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");var e=this.lat.toRadians(),n=this.lon.toRadians(),r=t.lat.toRadians(),o=t.lon.toRadians();Math.abs(o-n)>Math.PI&&(n+=2*Math.PI);var s=(e+r)/2,a=Math.tan(Math.PI/4+e/2),u=Math.tan(Math.PI/4+r/2),l=Math.tan(Math.PI/4+s/2),c=((o-n)*Math.log(l)+n*Math.log(u)-o*Math.log(a))/Math.log(u/a);return isFinite(c)||(c=(n+o)/2),i(s.toDegrees(),(c.toDegrees()+540)%360-180)},i.areaOf=function(t,e){var n=void 0===e?6371e3:Number(e),i=t[0].equals(t[t.length-1]);i||t.push(t[0]);for(var r=t.length-1,o=0,s=0;s0?f:h}break;case"bearing+endpoint":d=Math.sign(o.cross(l).dot(h)),p=d>0?h:f;break;case"endpoint+bearing":g=Math.sign(s.cross(c).dot(h)),p=g>0?h:f;break;case"endpoint+endpoint":p=l.plus(c).plus(e.toVector()).plus(r.toVector()).dot(h)>0?h:f}return p.toLatLonS()},i.prototype.crossTrackDistanceTo=function(t,e,n){if(!(t instanceof i))throw new TypeError("pathStart is not LatLon object");var r=void 0===n?6371e3:Number(n),o=this.toVector();return((e instanceof i?t.toVector().cross(e.toVector()):t.greatCircle(Number(e))).angleTo(o)-Math.PI/2)*r},i.prototype.nearestPointOnSegment=function(t,e){var n=null;if(this.isBetween(t,e)){var i=this.toVector(),r=t.toVector(),o=e.toVector(),s=r.cross(o),a=i.cross(s);n=s.cross(a).toLatLonS()}else{n=this.distanceTo(t)=0&&c>=0},i.prototype.enclosedBy=function(t){var e=t[0].equals(t[t.length-1]);e||t.push(t[0]);for(var n=t.length-1,i=this.toVector(),r=[],o=0;oMath.PI;return e||t.pop(),a},i.areaOf=function(t,e){var n=void 0===e?6371e3:Number(e);t[0].equals(t[t.length-1])||t.push(t[0]);var i=t.length-1;console.log("n",i);for(var r=[],o=0;o0?1:-1}),void 0!==e&&e.exports&&(e.exports=i,e.exports.Vector3d=r)},{"./dms.js":495,"./vector3d.js":504}],499:[function(t,e,n){"use strict";if(void 0!==e&&e.exports)var i=t("./latlon-ellipsoidal.js");i.prototype.distanceTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");try{return this.inverse(t).distance}catch(t){return NaN}},i.prototype.initialBearingTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");try{return this.inverse(t).initialBearing}catch(t){return NaN}},i.prototype.finalBearingTo=function(t){if(!(t instanceof i))throw new TypeError("point is not LatLon object");try{return this.inverse(t).finalBearing}catch(t){return NaN}},i.prototype.destinationPoint=function(t,e){return this.direct(Number(t),Number(e)).point},i.prototype.finalBearingOn=function(t,e){return this.direct(Number(t),Number(e)).finalBearing},i.prototype.direct=function(t,e){var n,r,o,s,a,u=this.lat.toRadians(),l=this.lon.toRadians(),c=e.toRadians(),h=t,f=this.datum.ellipsoid.a,p=this.datum.ellipsoid.b,d=this.datum.ellipsoid.f,g=Math.sin(c),v=Math.cos(c),y=(1-d)*Math.tan(u),m=1/Math.sqrt(1+y*y),x=y*m,E=Math.atan2(y,v),I=m*g,w=1-I*I,N=w*(f*f-p*p)/(p*p),b=1+N/16384*(4096+N*(N*(320-175*N)-768)),C=N/1024*(256+N*(N*(74-47*N)-128)),S=h/(p*b),M=0;do{n=Math.cos(2*E+S),r=Math.sin(S),o=Math.cos(S),s=C*r*(n+C/4*(o*(2*n*n-1)-C/6*n*(4*r*r-3)*(4*n*n-3))),a=S,S=h/(p*b)+s}while(Math.abs(S-a)>1e-12&&++M<200);if(M>=200)throw new Error("Formula failed to converge");var L=x*r-m*o*v,R=Math.atan2(x*o+m*r*v,(1-d)*Math.sqrt(I*I+L*L)),P=Math.atan2(r*g,m*o-x*r*v),T=d/16*w*(4+d*(4-3*w)),O=P-(1-T)*d*I*(S+T*r*(n+T*o*(2*n*n-1))),_=(l+O+3*Math.PI)%(2*Math.PI)-Math.PI,A=Math.atan2(I,-L);return A=(A+2*Math.PI)%(2*Math.PI),{point:new i(R.toDegrees(),_.toDegrees(),this.datum),finalBearing:A.toDegrees()}},i.prototype.inverse=function(t){var e,n,i,r,o,s,a,u,l,c,h,f=this,p=t,d=f.lat.toRadians(),g=f.lon.toRadians(),v=p.lat.toRadians(),y=p.lon.toRadians(),m=this.datum.ellipsoid.a,x=this.datum.ellipsoid.b,E=this.datum.ellipsoid.f,I=y-g,w=(1-E)*Math.tan(d),N=1/Math.sqrt(1+w*w),b=w*N,C=(1-E)*Math.tan(v),S=1/Math.sqrt(1+C*C),M=C*S,L=I,R=0;do{if(e=Math.sin(L),n=Math.cos(L),i=S*e*(S*e)+(N*M-b*S*n)*(N*M-b*S*n),0==(r=Math.sqrt(i)))return 0;o=b*M+N*S*n,s=Math.atan2(r,o),a=N*S*e/r,u=1-a*a,l=o-2*b*M/u,isNaN(l)&&(l=0),c=E/16*u*(4+E*(4-3*u)),h=L,L=I+(1-c)*E*a*(s+c*r*(l+c*o*(2*l*l-1)))}while(Math.abs(L-h)>1e-12&&++R<200);if(R>=200)throw new Error("Formula failed to converge");var P=u*(m*m-x*x)/(x*x),T=1+P/16384*(4096+P*(P*(320-175*P)-768)),O=P/1024*(256+P*(P*(74-47*P)-128)),_=O*r*(l+O/4*(o*(2*l*l-1)-O/6*l*(4*r*r-3)*(4*l*l-3))),A=x*T*(s-_),D=Math.atan2(S*e,N*M-b*S*n),F=Math.atan2(N*e,-b*S+N*M*n);return D=(D+2*Math.PI)%(2*Math.PI),F=(F+2*Math.PI)%(2*Math.PI),A=Number(A.toFixed(3)),{distance:A,initialBearing:D.toDegrees(),finalBearing:F.toDegrees()}},void 0===Number.prototype.toRadians&&(Number.prototype.toRadians=function(){return this*Math.PI/180}),void 0===Number.prototype.toDegrees&&(Number.prototype.toDegrees=function(){return 180*this/Math.PI}),void 0!==e&&e.exports&&(e.exports=i)},{"./latlon-ellipsoidal.js":496}],500:[function(t,e,n){"use strict";function i(t,e,n,r,s,a,u){if(!(this instanceof i))return new i(t,e,n,r,s,a,u);if(void 0===u&&(u=o.datum.WGS84),!(1<=t&&t<=60))throw new Error("Invalid MGRS grid reference (zone ‘"+t+"’)");if(1!=e.length)throw new Error("Invalid MGRS grid reference (band ‘"+e+"’)");if(-1==i.latBands.indexOf(e))throw new Error("Invalid MGRS grid reference (band ‘"+e+"’)");if(1!=n.length)throw new Error("Invalid MGRS grid reference (e100k ‘"+n+"’)");if(1!=r.length)throw new Error("Invalid MGRS grid reference (n100k ‘"+r+"’)");this.zone=Number(t),this.band=e,this.e100k=n,this.n100k=r,this.easting=Number(s),this.northing=Number(a),this.datum=u}if(void 0!==e&&e.exports)var r=t("./utm.js");if(void 0!==e&&e.exports)var o=t("./latlon-ellipsoidal.js");i.latBands="CDEFGHJKLMNPQRSTUVWXX",i.e100kLetters=["ABCDEFGH","JKLMNPQR","STUVWXYZ"],i.n100kLetters=["ABCDEFGHJKLMNPQRSTUV","FGHJKLMNPQRSTUVABCDE"],r.prototype.toMgrs=function(){if(isNaN(this.zone+this.easting+this.northing))throw new Error("Invalid UTM coordinate ‘"+this.toString()+"’");var t=this.zone,e=this.toLatLonE(),n=i.latBands.charAt(Math.floor(e.lat/8+10)),r=Math.floor(this.easting/1e5),o=i.e100kLetters[(t-1)%3].charAt(r-1),s=Math.floor(this.northing/1e5)%20,a=i.n100kLetters[(t-1)%2].charAt(s),u=this.easting%1e5,l=this.northing%1e5;return u=Number(u.toFixed(6)),l=Number(l.toFixed(6)),new i(t,n,o,a,u,l)},i.prototype.toUtm=function(){for(var t=this.zone,e=this.band,n=this.e100k,s=this.n100k,a=this.easting,u=this.northing,l=e>="N"?"N":"S",c=i.e100kLetters[(t-1)%3].indexOf(n)+1,h=1e5*c,f=i.n100kLetters[(t-1)%2].indexOf(s),p=1e5*f,d=8*(i.latBands.indexOf(e)-10),g=1e5*Math.floor(new o(d,0).toUtm().northing/1e5),v=0;v+p+u=5?l:(l+"00000").slice(0,5),c=c.length>=5?c:(c+"00000").slice(0,5),new i(r,o,a,u,l,c)},i.prototype.toString=function(t){if(t=void 0===t?10:Number(t),-1==[2,4,6,8,10].indexOf(t))throw new Error("Invalid precision ‘"+t+"’");var e=this.zone.pad(2),n=this.band,i=this.e100k,r=this.n100k,o=Math.floor(this.easting/Math.pow(10,5-t/2)),s=Math.floor(this.northing/Math.pow(10,5-t/2));return o=o.pad(t/2),s=s.pad(t/2),e+n+" "+i+r+" "+o+" "+s},void 0===Number.prototype.pad&&(Number.prototype.pad=function(t){for(var e=this.toString();e.length=1e-5);var y=Math.cos(g),m=Math.sin(g),x=s*u/Math.sqrt(1-h*m*m),E=s*u*(1-h)/Math.pow(1-h*m*m,1.5),I=x/E-1,w=Math.tan(g),N=w*w,b=N*N,C=b*N,S=1/y,M=x*x*x,L=M*x*x,R=L*x*x,P=w/(2*E*x),T=w/(24*E*M)*(5+3*N+I-9*N*I),O=w/(720*E*L)*(61+90*N+45*b),_=S/x,A=S/(6*M)*(x/E+2*N),D=S/(120*L)*(5+28*N+24*b),F=S/(5040*R)*(61+662*N+1320*b+720*C),G=n-4e5,q=G*G,k=q*G,B=q*q,j=k*q,z=B*q,V=j*q;g=g-P*q+T*B-O*z;var X=c+_*G-A*k+D*j-F*V,Y=new r(g.toDegrees(),X.toDegrees(),r.datum.OSGB36);return e!=r.datum.OSGB36&&(Y=Y.convertDatum(e)),Y},i.parse=function(t){t=String(t).trim();var e=t.match(/^(\d+),\s*(\d+)$/);if(e)return new i(e[1],e[2]);if(!(e=t.match(/^[A-Z]{2}\s*[0-9]+\s*[0-9]+$/i)))throw new Error("Invalid grid reference");var n=t.toUpperCase().charCodeAt(0)-"A".charCodeAt(0),r=t.toUpperCase().charCodeAt(1)-"A".charCodeAt(0);n>7&&n--,r>7&&r--;var o=(n-2)%5*5+r%5,s=19-5*Math.floor(n/5)-Math.floor(r/5),a=t.slice(2).trim().split(/\s+/);if(1==a.length&&(a=[a[0].slice(0,a[0].length/2),a[0].slice(a[0].length/2)]),o<0||o>6||s<0||s>12)throw new Error("Invalid grid reference");if(2!=a.length)throw new Error("Invalid grid reference");if(a[0].length!=a[1].length)throw new Error("Invalid grid reference");return a[0]=(a[0]+"00000").slice(0,5),a[1]=(a[1]+"00000").slice(0,5),new i(o+a[0],s+a[1])},i.prototype.toString=function(t){if(t=void 0===t?10:Number(t), +isNaN(t))throw new Error("Invalid precision");var e=this.easting,n=this.northing;if(isNaN(e)||isNaN(n))throw new Error("Invalid grid reference");if(0==t)return e.pad(6)+","+n.pad(6);var i=Math.floor(e/1e5),r=Math.floor(n/1e5);if(i<0||i>6||r<0||r>12)return"";var o=19-r-(19-r)%5+Math.floor((i+10)/5),s=5*(19-r)%25+i%5;o>7&&o++,s>7&&s++;var a=String.fromCharCode(o+"A".charCodeAt(0),s+"A".charCodeAt(0));return e=Math.floor(e%1e5/Math.pow(10,5-t/2)),n=Math.floor(n%1e5/Math.pow(10,5-t/2)),a+" "+e.pad(t/2)+" "+n.pad(t/2)},void 0===String.prototype.trim&&(String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")}),void 0===Number.prototype.pad&&(Number.prototype.pad=function(t){for(var e=this.toString();e.length=3&&(t++,e+=6..toRadians()),32==t&&"X"==r&&this.lon<9&&(t--,e-=6..toRadians()),32==t&&"X"==r&&this.lon>=9&&(t++,e+=6..toRadians()),34==t&&"X"==r&&this.lon<21&&(t--,e-=6..toRadians()),34==t&&"X"==r&&this.lon>=21&&(t++,e+=6..toRadians()),36==t&&"X"==r&&this.lon<33&&(t--,e-=6..toRadians()),36==t&&"X"==r&&this.lon>=33&&(t++,e+=6..toRadians());for(var o=this.lat.toRadians(),s=this.lon.toRadians()-e,a=this.datum.ellipsoid.a,u=this.datum.ellipsoid.f,l=Math.sqrt(u*(2-u)),c=u/(2-u),h=c*c,f=c*h,p=c*f,d=c*p,g=c*d,v=Math.cos(s),y=Math.sin(s),m=Math.tan(s),x=Math.tan(o),E=Math.sinh(l*Math.atanh(l*x/Math.sqrt(1+x*x))),I=x*Math.sqrt(1+E*E)-E*Math.sqrt(1+x*x),w=Math.atan2(I,v),N=Math.asinh(y/Math.sqrt(I*I+v*v)),b=a/(1+c)*(1+.25*h+1/64*p+1/256*g),C=[null,.5*c-2/3*h+5/16*f+41/180*p-127/288*d+7891/37800*g,13/48*h-.6*f+557/1440*p+281/630*d-1983433/1935360*g,61/240*f-103/140*p+15061/26880*d+167603/181440*g,49561/161280*p-179/168*d+6601661/7257600*g,34729/80640*d-3418889/1995840*g,.6650675310896665*g],S=w,M=1;M<=6;M++)S+=C[M]*Math.sin(2*M*w)*Math.cosh(2*M*N);for(var L=N,M=1;M<=6;M++)L+=C[M]*Math.cos(2*M*w)*Math.sinh(2*M*N);for(var R=.9996*b*L,P=.9996*b*S,T=1,M=1;M<=6;M++)T+=2*M*C[M]*Math.cos(2*M*w)*Math.cosh(2*M*N);for(var O=0,M=1;M<=6;M++)O+=2*M*C[M]*Math.sin(2*M*w)*Math.sinh(2*M*N);var _=Math.atan(I/Math.sqrt(1+I*I)*m),A=Math.atan2(O,T),D=_+A,F=Math.sin(o),G=Math.sqrt(1-l*l*F*F)*Math.sqrt(1+x*x)/Math.sqrt(I*I+v*v),q=b/a*Math.sqrt(T*T+O*O),k=.9996*G*q;R+=5e5,P<0&&(P+=1e7),R=Number(R.toFixed(6)),P=Number(P.toFixed(6));var B=Number(D.toDegrees().toFixed(9)),j=Number(k.toFixed(12));return new i(t,this.lat>=0?"N":"S",R,P,this.datum,B,j)},i.prototype.toLatLonE=function(){var t=this.zone,e=this.hemisphere,n=this.easting,i=this.northing;if(isNaN(t)||isNaN(n)||isNaN(i))throw new Error("Invalid coordinate");var o=this.datum.ellipsoid.a,s=this.datum.ellipsoid.f;n-=5e5,i="S"==e?i-1e7:i;for(var a=Math.sqrt(s*(2-s)),u=s/(2-s),l=u*u,c=u*l,h=u*c,f=u*h,p=u*f,d=o/(1+u)*(1+.25*l+1/64*h+1/256*p),g=n/(.9996*d),v=i/(.9996*d),y=[null,.5*u-2/3*l+37/96*c-1/360*h-81/512*f+96199/604800*p,1/48*l+1/15*c-437/1440*h+46/105*f-1118711/3870720*p,17/480*c-37/840*h-209/4480*f+5569/90720*p,4397/161280*h-11/504*f-830251/7257600*p,4583/161280*f-108847/3991680*p,.03233083094085698*p],m=v,x=1;x<=6;x++)m-=y[x]*Math.sin(2*x*v)*Math.cosh(2*x*g);for(var E=g,x=1;x<=6;x++)E-=y[x]*Math.cos(2*x*v)*Math.sinh(2*x*g);var I=Math.sinh(E),w=Math.sin(m),N=Math.cos(m),b=w/Math.sqrt(I*I+N*N),C=b;do{var S=Math.sinh(a*Math.atanh(a*C/Math.sqrt(1+C*C))),M=C*Math.sqrt(1+S*S)-S*Math.sqrt(1+C*C),L=(b-M)/Math.sqrt(1+M*M)*(1+(1-a*a)*C*C)/((1-a*a)*Math.sqrt(1+C*C));C+=L}while(Math.abs(L)>1e-12);for(var R=C,P=Math.atan(R),T=Math.atan2(I,N),O=1,x=1;x<=6;x++)O-=2*x*y[x]*Math.cos(2*x*v)*Math.cosh(2*x*g);for(var _=0,x=1;x<=6;x++)_+=2*x*y[x]*Math.sin(2*x*v)*Math.sinh(2*x*g);var A=Math.atan(Math.tan(m)*Math.tanh(E)),D=Math.atan2(_,O),F=A+D,G=Math.sin(P),q=Math.sqrt(1-a*a*G*G)*Math.sqrt(1+R*R)*Math.sqrt(I*I+N*N),k=d/o/Math.sqrt(O*O+_*_),B=.9996*q*k;T+=(6*(t-1)-180+3).toRadians();var j=Number(P.toDegrees().toFixed(11)),z=Number(T.toDegrees().toFixed(11)),V=Number(F.toDegrees().toFixed(9)),X=Number(B.toFixed(12)),Y=new r(j,z,this.datum);return Y.convergence=V,Y.scale=X,Y},i.parse=function(t,e){if(void 0===e&&(e=r.datum.WGS84),null==(t=t.trim().match(/\S+/g))||4!=t.length)throw new Error("Invalid UTM coordinate ‘"+t+"’");return new i(t[0],t[1],t[2],t[3],e)},i.prototype.toString=function(t){t=Number(t||0);var e=this.zone<10?"0"+this.zone:this.zone,n=this.hemisphere,i=this.easting,r=this.northing;return isNaN(e)||!n.match(/[NS]/)||isNaN(i)||isNaN(r)?"":e+" "+n+" "+i.toFixed(t)+" "+r.toFixed(t)},void 0===Math.sinh&&(Math.sinh=function(t){return(Math.exp(t)-Math.exp(-t))/2}),void 0===Math.cosh&&(Math.cosh=function(t){return(Math.exp(t)+Math.exp(-t))/2}),void 0===Math.tanh&&(Math.tanh=function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))}),void 0===Math.asinh&&(Math.asinh=function(t){return Math.log(t+Math.sqrt(1+t*t))}),void 0===Math.atanh&&(Math.atanh=function(t){return Math.log((1+t)/(1-t))/2}),void 0===String.prototype.trim&&(String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")}),void 0!==e&&e.exports&&(e.exports=i)},{"./latlon-ellipsoidal.js":496}],504:[function(t,e,n){"use strict";function i(t,e,n){if(!(this instanceof i))return new i(t,e,n);this.x=Number(t),this.y=Number(e),this.z=Number(n)}i.prototype.plus=function(t){if(!(t instanceof i))throw new TypeError("v is not Vector3d object");return new i(this.x+t.x,this.y+t.y,this.z+t.z)},i.prototype.minus=function(t){if(!(t instanceof i))throw new TypeError("v is not Vector3d object");return new i(this.x-t.x,this.y-t.y,this.z-t.z)},i.prototype.times=function(t){return t=Number(t),new i(this.x*t,this.y*t,this.z*t)},i.prototype.dividedBy=function(t){return t=Number(t),new i(this.x/t,this.y/t,this.z/t)},i.prototype.dot=function(t){if(!(t instanceof i))throw new TypeError("v is not Vector3d object");return this.x*t.x+this.y*t.y+this.z*t.z},i.prototype.cross=function(t){if(!(t instanceof i))throw new TypeError("v is not Vector3d object");return new i(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x)},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z)},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.prototype.unit=function(){var t=this.length();return 1==t?this:0==t?this:new i(this.x/t,this.y/t,this.z/t)},i.prototype.angleTo=function(t,e){if(!(t instanceof i))throw new TypeError("v is not Vector3d object");var n=this.cross(t).length(),r=this.dot(t);if(void 0!==e){if(!(e instanceof i))throw new TypeError("vSign is not Vector3d object");n=this.cross(t).dot(e)<0?-n:n}return Math.atan2(n,r)},i.prototype.rotateAround=function(t,e){if(!(t instanceof i))throw new TypeError("axis is not Vector3d object");for(var n=this.unit(),r=[n.x,n.y,n.z],o=t.unit(),s=Math.sin(e),a=Math.cos(e),u=[[o.x*o.x*(1-a)+a,o.x*o.y*(1-a)-o.z*s,o.x*o.z*(1-a)+o.y*s],[o.y*o.x*(1-a)+o.z*s,o.y*o.y*(1-a)+a,o.y*o.z*(1-a)-o.x*s],[o.z*o.x*(1-a)-o.y*s,o.z*o.y*(1-a)+o.x*s,o.z*o.z*(1-a)+a]],l=[0,0,0],c=0;c<3;c++)for(var h=0;h<3;h++)l[c]+=u[c][h]*r[h];return new i(l[0],l[1],l[2])},i.prototype.toString=function(t){var e=void 0===t?3:Number(t);return"["+this.x.toFixed(e)+","+this.y.toFixed(e)+","+this.z.toFixed(e)+"]"},void 0!==e&&e.exports&&(e.exports=i)},{}],505:[function(t,e,n){var i=t("@turf/helpers"),r=t("@turf/invariant").getCoord,o=t("geodesy").LatLonSpherical,s=i.point,a=i.radiansToDistance,u=i.distanceToRadians;e.exports=function(t,e,n,i){if(!t)throw new Error("origin is required");if(void 0===e||null===e)throw new Error("distance is required");if(void 0===n||null===n)throw new Error("bearing is required");if(!(e>=0))throw new Error("distance must be greater than 0");i=i||"kilometers";var l=a(u(e,i),"meters"),c=r(t),h=new o(c[1],c[0]),f=h.rhumbDestinationPoint(l,n);return f.lon+=f.lon-c[0]>180?-360:c[0]-f.lon>180?360:0,s([f.lon,f.lat])}},{"@turf/helpers":506,"@turf/invariant":507,geodesy:514}],506:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],507:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],508:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],509:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":508,"./vector3d.js":517,dup:496}],510:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":508,dup:497}],511:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":508,"./vector3d.js":517,dup:498}],512:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":509,dup:499}],513:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":509,"./utm.js":516,dup:500}],514:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":508,"./latlon-ellipsoidal.js":509,"./latlon-spherical.js":510,"./latlon-vectors.js":511,"./latlon-vincenty.js":512,"./mgrs.js":513,"./osgridref.js":515,"./utm.js":516,"./vector3d.js":517,dup:501}],515:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":509,dup:502}],516:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":509,dup:503}],517:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],518:[function(t,e,n){var i=t("@turf/helpers"),r=t("@turf/invariant").getCoord,o=t("geodesy").LatLonSpherical,s=i.radiansToDistance,a=i.distanceToRadians;e.exports=function(t,e,n){if(!t)throw new Error("from point is required");if(!e)throw new Error("to point is required");n=n||"kilometers";var i=r(t),u=r(e),l=new o(i[1],i[0]),c=new o(u[1],u[0]);c[0]+=c[0]-l[0]>180?-360:l[0]-c[0]>180?360:0;var h=l.rhumbDistanceTo(c);return s(a(h,"meters"),n)}},{"@turf/helpers":519,"@turf/invariant":520,geodesy:527}],519:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],520:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],521:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],522:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":521,"./vector3d.js":530,dup:496}],523:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":521,dup:497}],524:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":521,"./vector3d.js":530,dup:498}],525:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":522,dup:499}],526:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":522,"./utm.js":529,dup:500}],527:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":521,"./latlon-ellipsoidal.js":522,"./latlon-spherical.js":523,"./latlon-vectors.js":524,"./latlon-vincenty.js":525,"./mgrs.js":526,"./osgridref.js":528,"./utm.js":529,"./vector3d.js":530,dup:501}],528:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":522,dup:502}],529:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":522,dup:503}],530:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],531:[function(t,e,n){function i(t,e){for(var n,i,r=t.slice(0),o=t.length,s=o-e;o-- >s;)i=Math.floor((o+1)*Math.random()),n=r[i],r[i]=r[o],r[o]=n;return r.slice(s)}var r=t("@turf/helpers").featureCollection;e.exports=function(t,e){return r(i(t.features,e))}},{"@turf/helpers":532}],532:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],533:[function(t,e,n){function i(t){var e=t%360;return e<0&&(e+=360),e}var r=t("@turf/circle"),o=t("@turf/meta").coordEach,s=t("@turf/helpers"),a=t("@turf/invariant").getCoords,u=s.polygon,l=t("@turf/line-arc");e.exports=function(t,e,n,s,c,h){if(!t)throw new Error("center is required");if(void 0===n||null===n)throw new Error("bearing1 is required");if(void 0===s||null===s)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if(c=c||64,i(n)===i(s))return r(t,e,c,h);var f=a(t),p=l(t,e,n,s,c,h),d=[[f]];return o(p,function(t){d[0].push(t)}),d[0].push(f),u(d)}},{"@turf/circle":534,"@turf/helpers":539,"@turf/invariant":540,"@turf/line-arc":541,"@turf/meta":551}],534:[function(t,e,n){arguments[4][34][0].apply(n,arguments)},{"@turf/destination":535,"@turf/helpers":538,dup:34}],535:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":536,"@turf/invariant":537,dup:5}],536:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],537:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],538:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],539:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],540:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],541:[function(t,e,n){arguments[4][233][0].apply(n,arguments)},{"@turf/circle":542,"@turf/destination":547,"@turf/helpers":550,dup:233}],542:[function(t,e,n){arguments[4][34][0].apply(n,arguments)},{"@turf/destination":543,"@turf/helpers":546,dup:34}],543:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":544,"@turf/invariant":545,dup:5}],544:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],545:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],546:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],547:[function(t,e,n){arguments[4][5][0].apply(n,arguments)},{"@turf/helpers":548,"@turf/invariant":549,dup:5}],548:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],549:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],550:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],551:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],552:[function(t,e,n){function i(t,e,n){return"LineString"===t.geometry.type?{type:"LineString",coordinates:s(t.geometry.coordinates,e,n)}:"MultiLineString"===t.geometry.type?{type:"MultiLineString",coordinates:t.geometry.coordinates.map(function(t){return s(t,e,n)})}:"Polygon"===t.geometry.type?{type:"Polygon",coordinates:a(t.geometry.coordinates,e,n)}:"MultiPolygon"===t.geometry.type?{type:"MultiPolygon",coordinates:t.geometry.coordinates.map(function(t){return a(t,e,n)})}:t}function r(t){return!(t.length<3)&&(3!==t.length||t[2][0]!==t[0][0]||t[2][1]!==t[0][1])}function o(t,e){return{type:"Feature",geometry:t,properties:e}}function s(t,e,n){return u(t.map(function(t){return{x:t[0],y:t[1],z:t[2]}}),e,n).map(function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y]})}function a(t,e,n){return t.map(function(t){var i=t.map(function(t){return{x:t[0],y:t[1]}});if(i.length<4)throw new Error("Invalid polygon");for(var o=u(i,e,n).map(function(t){return[t.x,t.y]});!r(o);)e-=.01*e,o=u(i,e,n).map(function(t){return[t.x,t.y]});return o[o.length-1][0]===o[0][0]&&o[o.length-1][1]===o[0][1]||o.push(o[0]),o})}var u=t("simplify-js"),l=["LineString","MultiLineString","Polygon","MultiPolygon"];e.exports=function(t,e,n){return"Feature"===t.type?o(i(t,e,n),t.properties):"FeatureCollection"===t.type?{type:"FeatureCollection",features:t.features.map(function(t){var r=i(t,e,n);return l.indexOf(r.type)>-1?o(r,t.properties):r})}:"GeometryCollection"===t.type?{type:"GeometryCollection",geometries:t.geometries.map(function(t){return l.indexOf(t.type)>-1?i({type:"Feature",geometry:t},e,n):t})}:t}},{"simplify-js":553}],553:[function(e,n,i){!function(){"use strict";function e(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i}function i(t,e,n){var i=e.x,r=e.y,o=n.x-i,s=n.y-r;if(0!==o||0!==s){var a=((t.x-i)*o+(t.y-r)*s)/(o*o+s*s);a>1?(i=n.x,r=n.y):a>0&&(i+=o*a,r+=s*a)}return o=t.x-i,s=t.y-r,o*o+s*s}function r(t,n){for(var i,r=t[0],o=[r],s=1,a=t.length;sn&&(o.push(i),r=i);return r!==i&&o.push(i),o}function o(t,e){var n,r,o,s,a=t.length,u="undefined"!=typeof Uint8Array?Uint8Array:Array,l=new u(a),c=0,h=a-1,f=[],p=[];for(l[c]=l[h]=1;h;){for(r=0,n=c+1;nr&&(s=n,r=o);r>e&&(l[s]=1,f.push(c,s,s,h)),h=f.pop(),c=f.pop()}for(n=0;n0&&(i+=t[r-1].length,n.holes.push(i))}return n}var o=t("@turf/helpers").polygon,s=t("earcut");e.exports=function(t){if(!t.geometry||"Polygon"!==t.geometry.type&&"MultiPolygon"!==t.geometry.type)throw new Error("input must be a Polygon or MultiPolygon");var e={type:"FeatureCollection",features:[]};return"Polygon"===t.geometry.type?e.features=i(t.geometry.coordinates):t.geometry.coordinates.forEach(function(t){e.features=e.features.concat(i(t))}),e}},{"@turf/helpers":569,earcut:570}],569:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],570:[function(t,e,n){"use strict";function i(t,e,n){n=n||2;var i=e&&e.length,o=i?e[0]*n:t.length,a=r(t,0,o,n,!0),u=[];if(!a)return u;var l,c,f,p,d,g,v;if(i&&(a=h(t,e,a,n)),t.length>80*n){l=f=t[0],c=p=t[1];for(var y=n;yf&&(f=d),g>p&&(p=g);v=Math.max(f-l,p-c)}return s(a,u,n,l,c,v),u}function r(t,e,n,i,r){var o,s;if(r===T(t,e,n,i)>0)for(o=e;o=e;o-=i)s=L(o,t[o],t[o+1],s);return s&&w(s,s.next)&&(R(s),s=s.next),s}function o(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!w(i,i.next)&&0!==I(i.prev,i,i.next))i=i.next;else{if(R(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function s(t,e,n,i,r,h,f){if(t){!f&&h&&g(t,i,r,h);for(var p,d,v=t;t.prev!==t.next;)if(p=t.prev,d=t.next,h?u(t,i,r,h):a(t))e.push(p.i/n),e.push(t.i/n),e.push(d.i/n),R(t),t=d.next,v=d.next;else if((t=d)===v){f?1===f?(t=l(t,e,n),s(t,e,n,i,r,h,2)):2===f&&c(t,e,n,i,r,h):s(o(t),e,n,i,r,h,1);break}}}function a(t){var e=t.prev,n=t,i=t.next;if(I(e,n,i)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(x(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&I(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function u(t,e,n,i){var r=t.prev,o=t,s=t.next;if(I(r,o,s)>=0)return!1;for(var a=r.xo.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,c=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,h=y(a,u,e,n,i),f=y(l,c,e,n,i),p=t.nextZ;p&&p.z<=f;){if(p!==t.prev&&p!==t.next&&x(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&I(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=h;){if(p!==t.prev&&p!==t.next&&x(r.x,r.y,o.x,o.y,s.x,s.y,p.x,p.y)&&I(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}function l(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!w(r,o)&&N(r,i,i.next,o)&&C(r,o)&&C(o,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(o.i/n),R(i),R(i.next),i=t=o),i=i.next}while(i!==t);return i}function c(t,e,n,i,r,a){var u=t;do{for(var l=u.next.next;l!==u.prev;){if(u.i!==l.i&&E(u,l)){var c=M(u,l);return u=o(u,u.next),c=o(c,c.next),s(u,e,n,i,r,a),void s(c,e,n,i,r,a)}l=l.next}u=u.next}while(u!==t)}function h(t,e,n,i){var s,a,u,l,c,h=[];for(s=0,a=e.length;s=i.next.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s){if(s=a,a===r){if(o===i.y)return i;if(o===i.next.y)return i.next}n=i.x=i.x&&i.x>=c&&x(on.x)&&C(i,t)&&(n=i,f=u),i=i.next;return n}function g(t,e,n,i){var r=t;do{null===r.z&&(r.z=y(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,v(r)}function v(t){var e,n,i,r,o,s,a,u,l=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e0||u>0&&i;)0===a?(r=i,i=i.nextZ,u--):0!==u&&i?n.z<=i.z?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,u--):(r=n,n=n.nextZ,a--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,l*=2}while(s>1);return t}function y(t,e,n,i,r){return t=32767*(t-n)/r,e=32767*(e-i)/r,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function m(t){var e=t,n=t;do{e.x=0&&(t-s)*(i-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(r-s)*(i-a)>=0}function E(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!b(t,e)&&C(t,e)&&C(e,t)&&S(t,e)}function I(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function w(t,e){return t.x===e.x&&t.y===e.y}function N(t,e,n,i){return!!(w(t,e)&&w(n,i)||w(t,i)&&w(n,e))||I(t,e,n)>0!=I(t,e,i)>0&&I(n,i,t)>0!=I(n,i,e)>0}function b(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&N(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function C(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function S(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}function M(t,e){var n=new P(t.i,t.x,t.y),i=new P(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function L(t,e,n,i){var r=new P(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function R(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function P(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(t,e,n,i){for(var r=0,o=e,s=n-i;o0&&(i+=t[r-1].length,n.holes.push(i))}return n}},{}],571:[function(t,e,n){arguments[4][98][0].apply(n,arguments)},{"@turf/helpers":572,dup:98}],572:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],573:[function(t,e,n){var i=t("@turf/meta"),r=t("@turf/centroid"),o=t("@turf/invariant"),s=t("@turf/rhumb-bearing"),a=t("@turf/rhumb-distance"),u=t("@turf/rhumb-destination"),l=i.coordEach,c=o.getCoords;e.exports=function(t,e,n,i){if(!t)throw new Error("geojson is required");if(void 0===e||null===e||isNaN(e))throw new Error("angle is required");return 0===e?t:(n||(n=r(t)),!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t))),l(t,function(t){var i=s(n,t),r=i+e,o=a(n,t),l=c(u(n,o,r));t[0]=l[0],t[1]=l[1]}),t)}},{"@turf/centroid":574,"@turf/invariant":577,"@turf/meta":578,"@turf/rhumb-bearing":579,"@turf/rhumb-destination":591,"@turf/rhumb-distance":604}],574:[function(t,e,n){arguments[4][45][0].apply(n,arguments)},{"@turf/helpers":575,"@turf/meta":576,dup:45}],575:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],576:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],577:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],578:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],579:[function(t,e,n){arguments[4][493][0].apply(n,arguments)},{"@turf/invariant":580,dup:493,geodesy:587}],580:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],581:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],582:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":581,"./vector3d.js":590,dup:496}],583:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":581,dup:497}],584:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":581,"./vector3d.js":590,dup:498}],585:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":582,dup:499}],586:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":582,"./utm.js":589,dup:500}],587:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":581,"./latlon-ellipsoidal.js":582,"./latlon-spherical.js":583,"./latlon-vectors.js":584,"./latlon-vincenty.js":585,"./mgrs.js":586,"./osgridref.js":588,"./utm.js":589,"./vector3d.js":590,dup:501}],588:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":582,dup:502}],589:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":582,dup:503}],590:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],591:[function(t,e,n){arguments[4][505][0].apply(n,arguments)},{"@turf/helpers":592,"@turf/invariant":593,dup:505,geodesy:600}],592:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],593:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],594:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],595:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":594,"./vector3d.js":603,dup:496}],596:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":594,dup:497}],597:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":594,"./vector3d.js":603,dup:498}],598:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":595,dup:499}],599:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":595,"./utm.js":602,dup:500}],600:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":594,"./latlon-ellipsoidal.js":595,"./latlon-spherical.js":596,"./latlon-vectors.js":597,"./latlon-vincenty.js":598,"./mgrs.js":599,"./osgridref.js":601,"./utm.js":602,"./vector3d.js":603,dup:501}],601:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":595,dup:502}],602:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":595,dup:503}],603:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],604:[function(t,e,n){arguments[4][518][0].apply(n,arguments)},{"@turf/helpers":605,"@turf/invariant":606,dup:518,geodesy:613}],605:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],606:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],607:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],608:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":607,"./vector3d.js":616,dup:496}],609:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":607,dup:497}],610:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":607,"./vector3d.js":616,dup:498}],611:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":608,dup:499}],612:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":608,"./utm.js":615,dup:500}],613:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":607,"./latlon-ellipsoidal.js":608,"./latlon-spherical.js":609,"./latlon-vectors.js":610,"./latlon-vincenty.js":611,"./mgrs.js":612,"./osgridref.js":614,"./utm.js":615,"./vector3d.js":616,dup:501}],614:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":608,dup:502}],615:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":608,dup:503}],616:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],617:[function(t,e,n){function i(t,e,n){var i="Point"===t.type||t.geometry&&"Point"===t.geometry.type;return n=r(t,n),1===e||i?t:(g(t,function(t){var i=f(n,t),r=h(n,t),o=i*e,s=m(p(n,o,r));t[0]=s[0],t[1]=s[1],3===t.length&&(t[2]*=e)}),t)}function r(t,e){if(void 0!==e&&null!==e||(e="centroid"),Array.isArray(e)||"object"==typeof e)return y(e);var n=t.bbox?t.bbox:l(t),i=n[0],r=n[1],o=n[2],a=n[3];switch(e){case"sw":case"southwest":case"westsouth":case"bottomleft":return d([i,r]);case"se":case"southeast":case"eastsouth":case"bottomright":return d([o,r]);case"nw":case"northwest":case"westnorth":case"topleft":return d([i,a]);case"ne":case"northeast":case"eastnorth":case"topright":return d([o,a]);case"center":return s(t);case void 0:case null:case"centroid":return u(t);default:throw new Error("invalid origin")}}var o=t("@turf/meta"),s=t("@turf/center"),a=t("@turf/helpers"),u=t("@turf/centroid"),l=t("@turf/bbox"),c=t("@turf/invariant"),h=t("@turf/rhumb-bearing"),f=t("@turf/rhumb-distance"),p=t("@turf/rhumb-destination"),d=a.point,g=o.coordEach,v=o.featureEach,y=c.getCoord,m=c.getCoords;e.exports=function(t,e,n,r){if(!t)throw new Error("geojson required");if("number"!=typeof e||0===e)throw new Error("invalid factor");var o=Array.isArray(n)||"object"==typeof n;return!0!==r&&(t=JSON.parse(JSON.stringify(t))),"FeatureCollection"!==t.type||o?i(t,e,n):(v(t,function(r,o){t.features[o]=i(r,e,n)}),t)}},{"@turf/bbox":618,"@turf/center":620,"@turf/centroid":624, +"@turf/helpers":627,"@turf/invariant":628,"@turf/meta":629,"@turf/rhumb-bearing":630,"@turf/rhumb-destination":642,"@turf/rhumb-distance":655}],618:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":619,dup:22}],619:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],620:[function(t,e,n){arguments[4][30][0].apply(n,arguments)},{"@turf/bbox":621,"@turf/helpers":623,dup:30}],621:[function(t,e,n){arguments[4][22][0].apply(n,arguments)},{"@turf/meta":622,dup:22}],622:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],623:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],624:[function(t,e,n){arguments[4][45][0].apply(n,arguments)},{"@turf/helpers":625,"@turf/meta":626,dup:45}],625:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],626:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],627:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],628:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],629:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],630:[function(t,e,n){arguments[4][493][0].apply(n,arguments)},{"@turf/invariant":631,dup:493,geodesy:638}],631:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],632:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],633:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":632,"./vector3d.js":641,dup:496}],634:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":632,dup:497}],635:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":632,"./vector3d.js":641,dup:498}],636:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":633,dup:499}],637:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":633,"./utm.js":640,dup:500}],638:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":632,"./latlon-ellipsoidal.js":633,"./latlon-spherical.js":634,"./latlon-vectors.js":635,"./latlon-vincenty.js":636,"./mgrs.js":637,"./osgridref.js":639,"./utm.js":640,"./vector3d.js":641,dup:501}],639:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":633,dup:502}],640:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":633,dup:503}],641:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],642:[function(t,e,n){arguments[4][505][0].apply(n,arguments)},{"@turf/helpers":643,"@turf/invariant":644,dup:505,geodesy:651}],643:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],644:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],645:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],646:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":645,"./vector3d.js":654,dup:496}],647:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":645,dup:497}],648:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":645,"./vector3d.js":654,dup:498}],649:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":646,dup:499}],650:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":646,"./utm.js":653,dup:500}],651:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":645,"./latlon-ellipsoidal.js":646,"./latlon-spherical.js":647,"./latlon-vectors.js":648,"./latlon-vincenty.js":649,"./mgrs.js":650,"./osgridref.js":652,"./utm.js":653,"./vector3d.js":654,dup:501}],652:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":646,dup:502}],653:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":646,dup:503}],654:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],655:[function(t,e,n){arguments[4][518][0].apply(n,arguments)},{"@turf/helpers":656,"@turf/invariant":657,dup:518,geodesy:664}],656:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],657:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],658:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],659:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":658,"./vector3d.js":667,dup:496}],660:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":658,dup:497}],661:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":658,"./vector3d.js":667,dup:498}],662:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":659,dup:499}],663:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":659,"./utm.js":666,dup:500}],664:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":658,"./latlon-ellipsoidal.js":659,"./latlon-spherical.js":660,"./latlon-vectors.js":661,"./latlon-vincenty.js":662,"./mgrs.js":663,"./osgridref.js":665,"./utm.js":666,"./vector3d.js":667,dup:501}],665:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":659,dup:502}],666:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":659,dup:503}],667:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],668:[function(t,e,n){var i=t("@turf/meta"),r=t("@turf/invariant"),o=t("@turf/rhumb-destination"),s=i.coordEach,a=r.getCoords;e.exports=function(t,e,n,i,r,u){if(!t)throw new Error("geojson is required");if(void 0===e||null===e||isNaN(e))throw new Error("distance is required");if(r&&"number"!=typeof r&&isNaN(r))throw new Error("zTranslation is not a number");if(r=void 0!==r?r:0,0===e&&0===r)return t;if(void 0===n||null===n||isNaN(n))throw new Error("direction is required");return e<0&&(e=-e,n=-n),!1!==u&&void 0!==u||(t=JSON.parse(JSON.stringify(t))),s(t,function(t){var s=a(o(t,e,n,i));t[0]=s[0],t[1]=s[1],r&&3===t.length&&(t[2]+=r)}),t}},{"@turf/invariant":669,"@turf/meta":670,"@turf/rhumb-destination":671}],669:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],670:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],671:[function(t,e,n){arguments[4][505][0].apply(n,arguments)},{"@turf/helpers":672,"@turf/invariant":673,dup:505,geodesy:680}],672:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],673:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],674:[function(t,e,n){arguments[4][495][0].apply(n,arguments)},{dup:495}],675:[function(t,e,n){arguments[4][496][0].apply(n,arguments)},{"./dms.js":674,"./vector3d.js":683,dup:496}],676:[function(t,e,n){arguments[4][497][0].apply(n,arguments)},{"./dms":674,dup:497}],677:[function(t,e,n){arguments[4][498][0].apply(n,arguments)},{"./dms.js":674,"./vector3d.js":683,dup:498}],678:[function(t,e,n){arguments[4][499][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":675,dup:499}],679:[function(t,e,n){arguments[4][500][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":675,"./utm.js":682,dup:500}],680:[function(t,e,n){arguments[4][501][0].apply(n,arguments)},{"./dms.js":674,"./latlon-ellipsoidal.js":675,"./latlon-spherical.js":676,"./latlon-vectors.js":677,"./latlon-vincenty.js":678,"./mgrs.js":679,"./osgridref.js":681,"./utm.js":682,"./vector3d.js":683,dup:501}],681:[function(t,e,n){arguments[4][502][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":675,dup:502}],682:[function(t,e,n){arguments[4][503][0].apply(n,arguments)},{"./latlon-ellipsoidal.js":675,dup:503}],683:[function(t,e,n){arguments[4][504][0].apply(n,arguments)},{dup:504}],684:[function(t,e,n){var i=t("@turf/distance"),r=t("@turf/helpers"),o=r.polygon,s=r.featureCollection;e.exports=function(t,e,n){for(var r=s([]),a=e/i([t[0],t[1]],[t[2],t[1]],n),u=a*(t[2]-t[0]),l=e/i([t[0],t[1]],[t[0],t[3]],n),c=l*(t[3]-t[1]),h=0,f=t[0];f<=t[2];){for(var p=0,d=t[1];d<=t[3];)h%2==0&&p%2==0?r.features.push(o([[[f,d],[f,d+c],[f+u,d],[f,d]]]),o([[[f,d+c],[f+u,d+c],[f+u,d],[f,d+c]]])):h%2==0&&p%2==1?r.features.push(o([[[f,d],[f+u,d+c],[f+u,d],[f,d]]]),o([[[f,d],[f,d+c],[f+u,d+c],[f,d]]])):p%2==0&&h%2==1?r.features.push(o([[[f,d],[f,d+c],[f+u,d+c],[f,d]]]),o([[[f,d],[f+u,d+c],[f+u,d],[f,d]]])):p%2==1&&h%2==1&&r.features.push(o([[[f,d],[f,d+c],[f+u,d],[f,d]]]),o([[[f,d+c],[f+u,d+c],[f+u,d],[f,d+c]]])),d+=c,p++;h++,f+=u}return r}},{"@turf/distance":685,"@turf/helpers":688}],685:[function(t,e,n){arguments[4][8][0].apply(n,arguments)},{"@turf/helpers":686,"@turf/invariant":687,dup:8}],686:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],687:[function(t,e,n){arguments[4][4][0].apply(n,arguments)},{dup:4}],688:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],689:[function(t,e,n){function i(t,e,n){t.length>n&&t.splice(n,t.length);for(var i=0;i is required");if("number"!=typeof e)throw new Error(" must be a number");if("number"!=typeof n)throw new Error(" must be a number");!1!==o&&void 0!==o||(t=JSON.parse(JSON.stringify(t)));var s=Math.pow(10,e);return r(t,function(t){i(t,s,n)}),t}},{"@turf/meta":690}],690:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],691:[function(t,e,n){arguments[4][100][0].apply(n,arguments)},{dup:100,jsts:692}],692:[function(t,e,n){arguments[4][43][0].apply(n,arguments)},{dup:43}],693:[function(t,e,n){var i=t("simplepolygon"),r=t("@turf/flatten"),o=t("@turf/meta").featureEach,s=t("@turf/helpers").featureCollection;e.exports=function(t){var e=s([]);return o(t,function(t){"MultiPolygon"===t.geometry.type&&(t=r(t)),o(t,function(t){var n=i(t);o(n,function(n){n.properties=t.properties?t.properties:{},e.features.push(n)})})}),e}},{"@turf/flatten":696,"@turf/helpers":699,"@turf/meta":702,simplepolygon:710}],694:[function(t,e,n){arguments[4][13][0].apply(n,arguments)},{dup:13,wgs84:711}],695:[function(t,e,n){arguments[4][192][0].apply(n,arguments)},{"@mapbox/geojson-area":694,"@turf/meta":702,dup:192}],696:[function(t,e,n){arguments[4][155][0].apply(n,arguments)},{"@turf/helpers":697,"@turf/meta":698,dup:155}],697:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],698:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],699:[function(t,e,n){arguments[4][6][0].apply(n,arguments)},{dup:6}],700:[function(t,e,n){arguments[4][196][0].apply(n,arguments)},{"@turf/invariant":701,dup:196}],701:[function(t,e,n){arguments[4][197][0].apply(n,arguments)},{dup:197}],702:[function(t,e,n){arguments[4][14][0].apply(n,arguments)},{dup:14}],703:[function(t,e,n){var i=t("@turf/inside"),r=t("@turf/helpers").featureCollection;e.exports=function(t,e){for(var n=r([]),o=0;o=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))}function o(t){var e=this.useColors;if(t[0]=(e?"%c":"")+this.namespace+(e?" %c":" ")+t[0]+(e?"%c ":" ")+"+"+n.humanize(this.diff),e){var i="color: "+this.color;t.splice(1,0,i,"color: inherit");var r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,function(t){"%%"!==t&&(r++,"%c"===t&&(o=r))}),t.splice(o,0,i)}}function s(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)}function a(t){try{null==t?n.storage.removeItem("debug"):n.storage.debug=t}catch(t){}}function u(){var t;try{t=n.storage.debug}catch(t){}return!t&&void 0!==i&&"env"in i&&(t=i.env.DEBUG),t}n=e.exports=t("./debug"),n.log=s,n.formatArgs=o,n.save=a,n.load=u,n.useColors=r,n.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(t){}}(),n.colors=["lightseagreen","forestgreen","goldenrod","dodgerblue","darkorchid","crimson"],n.formatters.j=function(t){try{return JSON.stringify(t)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}},n.enable(u())}).call(this,t("_process"))},{"./debug":705,_process:716}],705:[function(t,e,n){function i(t){var e,i=0;for(e in t)i=(i<<5)-i+t.charCodeAt(e),i|=0;return n.colors[Math.abs(i)%n.colors.length]}function r(t){function e(){if(e.enabled){var t=e,i=+new Date,r=i-(l||i);t.diff=r,t.prev=l,t.curr=i,l=i;for(var o=new Array(arguments.length),s=0;s=1||d<=0||g>=1||g<=0)){var v=p,y=!l[v];y&&(l[v]=!0),e?u.push(e(p,t,n,s,c,d,r,o,h,f,g,y)):u.push(p)}}}function s(t,e){var n=a[t][e],i=a[t][e+1];if(n[0]100)){var e=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(t);if(e){var n=parseFloat(e[1]);switch((e[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*h;case"days":case"day":case"d":return n*c;case"hours":case"hour":case"hrs":case"hr":case"h":return n*l;case"minutes":case"minute":case"mins":case"min":case"m":return n*u;case"seconds":case"second":case"secs":case"sec":case"s":return n*a;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}function r(t){return t>=c?Math.round(t/c)+"d":t>=l?Math.round(t/l)+"h":t>=u?Math.round(t/u)+"m":t>=a?Math.round(t/a)+"s":t+"ms"}function o(t){return s(t,c,"day")||s(t,l,"hour")||s(t,u,"minute")||s(t,a,"second")||t+" ms"}function s(t,e,n){if(!(t0)return i(t);if("number"===n&&!1===isNaN(t))return e.long?o(t):r(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))}},{}],708:[function(t,e,n){arguments[4][90][0].apply(n,arguments)},{dup:90}],709:[function(t,e,n){arguments[4][91][0].apply(n,arguments)},{dup:91,quickselect:708}],710:[function(t,e,n){function i(t,e){if(void 0===e&&(e=!0),3!=t.length)throw new Error("This function requires an array of three points [x,y]");return(t[1][0]-t[0][0])*(t[2][1]-t[0][1])-(t[1][1]-t[0][1])*(t[2][0]-t[0][0])>=0==e}function r(t){for(var e=0,n=0;n1)for(var e=0;eM[e.isect].coord?-1:1}),p("Initial state of the queue: "+JSON.stringify(D)),f("Setting up queue");for(var b=[];D.length>0;){var B=D.pop(),j=B.isect,z=B.parent,V=B.winding,X=b.length,Y=[M[j].coord];p("# Starting output ring number "+b.length+" with winding "+V+" from intersection "+j),j must be a Feature or Geometry Object") expect_error(lawn_erase(poly1, "{}", lint = TRUE), "\"type\" member required") expect_error(lawn_erase(poly1, '{"type": "Feature"}', lint = TRUE), '"properties" member required \nLine 1 - "geometry" member required') diff --git a/tests/testthat/test-hex_grid.R b/tests/testthat/test-hex_grid.R index 2838812..25a0c02 100644 --- a/tests/testthat/test-hex_grid.R +++ b/tests/testthat/test-hex_grid.R @@ -24,11 +24,15 @@ test_that("cellWidth parameter works as expected", { test_that("lawn_hex_grid fails correctly", { # missing arguments - expect_error(lawn_hex_grid(), "argument \"extent\" is missing, with no default") + expect_error(lawn_hex_grid(), + "argument \"extent\" is missing, with no default") # empty featurecollection if bbox is not correct - expect_equal(length(lawn_hex_grid(c(-96, 31, -84), 10, 'miles')$features), 0) + expect_error(lawn_hex_grid(c(-96, 31, -84), 10, 'miles'), + "Coordinates must numbers") # can't pass in a character string to cellWidth - expect_error(lawn_hex_grid(c(-96, 31, -84, 40), "the", 'miles'), "the is not defined") + expect_error(lawn_hex_grid(c(-96, 31, -84, 40), "the", 'miles'), + "the is not defined") # can't pass in a character string to cellWidth - expect_error(lawn_hex_grid(c(-96, 31, -84, 40), 50, 'doesntexist'), "Invalid unit") + expect_error(lawn_hex_grid(c(-96, 31, -84, 40), 50, 'doesntexist'), + "units is invalid") }) diff --git a/tests/testthat/test-inside.R b/tests/testthat/test-inside.R index 5ff191d..8d77e9c 100644 --- a/tests/testthat/test-inside.R +++ b/tests/testthat/test-inside.R @@ -57,6 +57,8 @@ test_that("lawn_inside returns correct values", { test_that("lawn_inside fails correctly", { expect_error(lawn_inside(), "argument \"point\" is missing, with no default") - expect_error(lawn_inside("{}", poly), "A coordinate, feature, or point geometry is required") - expect_error(lawn_inside(point1, point2), "Cannot read property '0' of undefined") + expect_error(lawn_inside("{}", poly), + "No valid coordinates") + expect_error(lawn_inside(point1, point2), + "Cannot read property '0' of undefined") }) diff --git a/tests/testthat/test-line_distance.R b/tests/testthat/test-line_distance.R index 40f4624..16aac58 100644 --- a/tests/testthat/test-line_distance.R +++ b/tests/testthat/test-line_distance.R @@ -36,10 +36,12 @@ test_that("right dimensions", { test_that("lawn_line_distance fails correctly", { # missing arguments - expect_error(lawn_line_distance(), "argument \"line\" is missing, with no default") + expect_error(lawn_line_distance(), + "argument \"line\" is missing, with no default") # can't pass in a character string to cellWidth - expect_error(lawn_line_distance(line, 'stuff'), "Invalid unit") + expect_error(lawn_line_distance(line, 'stuff'), "units is invalid") # can't pass in a character string to cellWidth - expect_error(lawn_line_distance("{}", "miles"), - "input must be a LineString, MultiLineString, Polygon, or MultiPolygon") + expect_error( + lawn_line_distance("{}", "miles"), + "Unknown Geometry Type") }) diff --git a/tests/testthat/test-lint.R b/tests/testthat/test-lint.R index b259e8d..c95c8f5 100644 --- a/tests/testthat/test-lint.R +++ b/tests/testthat/test-lint.R @@ -9,9 +9,9 @@ poly1 <- '{ "type": "Polygon", "coordinates": [[ [-46.738586, -23.596711], - [-46.738586, -23.458207], - [-46.560058, -23.458207], [-46.560058, -23.596711], + [-46.560058, -23.458207], + [-46.738586, -23.458207], [-46.738586, -23.596711] ]] } diff --git a/tests/testthat/test-point_grid.R b/tests/testthat/test-point_grid.R index cc1933a..54694b3 100644 --- a/tests/testthat/test-point_grid.R +++ b/tests/testthat/test-point_grid.R @@ -27,5 +27,5 @@ test_that("lawn_point_grid fails correctly", { expect_error(lawn_point_grid(), "argument \"extent\" is missing, with no default") # units value not allowed expect_error(lawn_point_grid(c(-77.3876, 38.7198, -76.9482, 39.0277), 3, 'adf'), - "Invalid unit") + "units is invalid") }) diff --git a/tests/testthat/test-square.R b/tests/testthat/test-square.R index 28bc834..796039d 100644 --- a/tests/testthat/test-square.R +++ b/tests/testthat/test-square.R @@ -12,7 +12,7 @@ test_that("lawn_square fails correctly", { # missing arguments expect_error(lawn_square(), "argument \"bbox\" is missing, with no default") # only length 3 gives error message - expect_error(lawn_square(c(1, 2, 4)), "A coordinate, feature, or point geometry is required") + expect_error(lawn_square(c(1, 2, 4)), "coordinates must only contain numbers") # can't pass in a character string to cellWidth expect_error(lawn_square(c(1, 2, 4, "a")), "TypeError: Object 1 has no method 'slice'") }) diff --git a/tests/testthat/test-square_grid.R b/tests/testthat/test-square_grid.R index 42bd833..e9ce5d5 100644 --- a/tests/testthat/test-square_grid.R +++ b/tests/testthat/test-square_grid.R @@ -39,10 +39,10 @@ test_that("lawn_square_grid fails correctly", { expect_error(lawn_square_grid(), "argument \"extent\" is missing, with no default") # empty featurecollection if bbox is not correct expect_error(lawn_square_grid(c(-77.3876, 38.7198, -76.9482, 39.0277), 30, 'stuff'), - "Invalid unit") + "units is invalid") # can't pass in a character string to cellWidth expect_error(lawn_square_grid(c(-96, 31, -84, 40), "the", 'miles'), "the is not defined") # can't pass in a character string to cellWidth expect_error(lawn_square_grid(c(-96, 31, -84, 40), 50, 'doesntexist'), - "Invalid unit") + "units is invalid") }) diff --git a/tests/testthat/test-tin.R b/tests/testthat/test-tin.R index a9593e9..bff91ce 100644 --- a/tests/testthat/test-tin.R +++ b/tests/testthat/test-tin.R @@ -34,5 +34,5 @@ test_that("lawn_tin fails correctly", { # missing arguments expect_error(lawn_tin(), "argument \"pt\" is missing, with no default") # bad geojson input - expect_error(lawn_tin("{}"), "Cannot call method") + expect_error(lawn_tin("{}"), "points must be a FeatureCollection") }) diff --git a/tests/testthat/test-triangle_grid.R b/tests/testthat/test-triangle_grid.R index b8ea3b1..a0e259c 100644 --- a/tests/testthat/test-triangle_grid.R +++ b/tests/testthat/test-triangle_grid.R @@ -31,10 +31,10 @@ test_that("lawn_triangle_grid fails correctly", { expect_error(lawn_triangle_grid(), "argument \"extent\" is missing, with no default") # empty featurecollection if bbox is not correct expect_error(lawn_triangle_grid(c(-96, 31, -84), 10, 'miles'), - "A coordinate, feature, or point geometry is required") + "coordinates must only contain numbers") # can't pass in a character string to cellWidth expect_error(lawn_triangle_grid(c(-96, 31, -84, 40), "the", 'miles'), "the is not defined") # can't pass in a character string to cellWidth expect_error(lawn_triangle_grid(c(-96, 31, -84, 40), 50, 'doesntexist'), - "Invalid unit") + "units is invalid") })