@loaders.gl/flatgeobuf
Advanced tools
Comparing version 3.0.0-beta.7 to 3.0.0-beta.8
@@ -1,2 +0,2 @@ | ||
!function(t){var e={};function s(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=t,s.c=e,s.d=function(t,e,r){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(r,i,function(e){return t[e]}.bind(null,i));return r},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){"use strict";(function(e){var r=s(2),i="undefined"==typeof window?e:window;i.loaders=i.loaders||{},t.exports=Object.assign(i.loaders,r)}).call(this,s(1))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"FlatGeobufLoader",{enumerable:!0,get:function(){return r.FlatGeobufLoader}});var r=s(3)},function(t,e,s){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.FlatGeobufLoader=e.FlatGeobufWorkerLoader=void 0;var i=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==r(t)&&"function"!=typeof t)return{default:t};var s=n(e);if(s&&s.has(t))return s.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var b=o?Object.getOwnPropertyDescriptor(t,a):null;b&&(b.get||b.set)?Object.defineProperty(i,a,b):i[a]=t[a]}i.default=t,s&&s.set(t,i);return i}(s(4));function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,s=new WeakMap;return(n=function(t){return t?s:e})(t)}function o(t,e,s,r,i,n,o){try{var a=t[n](o),b=a.value}catch(t){return void s(t)}a.done?e(b):Promise.resolve(b).then(r,i)}function a(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}function b(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){h(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var c={id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.7",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}};e.FlatGeobufWorkerLoader=c;var d,u,l=b(b({},c),{},{parse:(d=regeneratorRuntime.mark((function t(e,s){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(0,i.default)(e,s));case 1:case"end":return t.stop()}}),t)})),u=function(){var t=this,e=arguments;return new Promise((function(s,r){var i=d.apply(t,e);function n(t){o(i,s,r,n,a,"next",t)}function a(t){o(i,s,r,n,a,"throw",t)}n(void 0)}))},function(t,e){return u.apply(this,arguments)}),parseSync:i.default,parseInBatchesFromStream:i.parseFlatGeobufInBatches,binary:!0});e.FlatGeobufLoader=l},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(0===t.byteLength)return[];var s=new Uint8Array(t);return(0,r.deserialize)(s).features},e.parseFlatGeobufInBatches=function(t,e){return(0,r.deserializeStream)(t)};var r=s(5)},function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,r,i,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=r,this.width=i,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class r{constructor(t,e,s,r,i,n){this.org=t,this.code=e,this.name=s,this.description=r,this.wkt=i,this.code_string=n}}const i=new Int32Array(2),n=new Float32Array(i.buffer),o=new Float64Array(i.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return i[0]=this.readInt32(t),n[0]}readFloat64(t){return i[a?0:1]=this.readInt32(t),i[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,i[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,i[a?0:1]),this.writeInt32(t+4,i[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let r="",i=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;i<s;){let e;const s=this.readUint8(t+i++);if(s<192)e=s;else{const r=this.readUint8(t+i++);if(s<224)e=(31&s)<<6|63&r;else{const n=this.readUint8(t+i++);e=s<240?(15&s)<<12|(63&r)<<6|63&n:(7&s)<<18|(63&r)<<12|(63&n)<<6|63&this.readUint8(t+i++)}}e<65536?r+=String.fromCharCode(e):(e-=65536,r+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return r}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let r=0;r<e;++r)null!==t(r)&&s.push(t(r));return s}createObjList(t,e){const s=[];for(let r=0;r<e;++r){const e=t(r);null!==e&&s.push(e.unpack())}return s}}class u{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=u.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,r=d.allocate(s);return r.setPosition(s-e),r.bytes().set(t.bytes(),s-e),r}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const r=2*(s+2);this.addInt16(r);let i=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(t)){for(let e=2;e<r;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const r=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+r),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,r=s-this.bb.readInt32(s);if(0==this.bb.readInt16(r+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let r;const i=t.charCodeAt(s++);r=i<55296||i>=56320?i:(i<<10)+t.charCodeAt(s++)+-56613888,r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,r=this.bb.bytes();t<e.length;t++)r[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const r=t[s];if(null===r)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(r))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class l{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new l).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,r,i,n,o,a,b,h,c,d){return l.startColumn(t),l.addName(t,e),l.addType(t,s),l.addTitle(t,r),l.addDescription(t,i),l.addWidth(t,n),l.addPrecision(t,o),l.addScale(t,a),l.addNullable(t,b),l.addUnique(t,h),l.addPrimaryKey(t,c),l.addMetadata(t,d),l.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,r,i,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,r),f.addDescription(t,i),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,r,i,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=r,this.crs=i,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),i=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const r=s.columns(t);if(!r)throw new Error("Column unexpectedly missing");if(!r.name())throw new Error("Column name unexpectedly missing");o.push(new e(r.name(),r.type(),r.title(),r.description(),r.width(),r.precision(),r.scale(),r.nullable(),r.unique(),r.primaryKey()))}const a=s.crs(),b=a?new r(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,i,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,r,i,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,r),g.addM(t,i),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const r of t)y(r,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let r=0;r<t.length;r+=2){const i=[t[r],t[r+1]];e&&i.push(e[r>>1]),s.push(i)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],r=[];let i,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,r);break;case"MultiPoint":case"LineString":y(e,s,r);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,r),t.length>1&&(i=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:r.length>0?r:void 0,ends:i,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const r=t.parts(e),i=r.type();s.push(I(r,i))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),r=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return r&&t.push(r[0]),t}case c.MultiPoint:case c.LineString:return w(s,r);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let r=0;const i=Array.from(s).map(e=>t.slice(r,r=e<<1));let n;return e&&(r=0,n=Array.from(s).map(t=>e.slice(r,r=t))),i.map((t,e)=>w(t,n?n[e]:void 0))}(s,r,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,r){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,r),F.endFeature(t)}}const O=new TextEncoder,U=new TextDecoder;function S(t,e,r){const i=r.columns,n=new u;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(i)for(let t=0;t<i.length;t++){const r=i[t],n=e[r.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,r.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=O.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+r.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const l=function t(e,s){const{xy:r,z:i,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),r=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,r),g.endGeometry(e)}const b=g.createXyVector(e,r);let h,c;return i&&(h=g.createZVector(e,i)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,l),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function P(t,e){const r=e.columns,i={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return r&&r.length>0&&(i.properties=function(t,e){const r={};if(!e||0===e.length)return r;const i=t.propertiesArray();if(!i)return r;const n=new DataView(i.buffer,i.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:r[b]=!!n.getUint8(a),a+=1;break;case s.Byte:r[b]=n.getInt8(a),a+=1;break;case s.UByte:r[b]=n.getUint8(a),a+=1;break;case s.Short:r[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:r[b]=n.getUint16(a,!0),a+=2;break;case s.Int:r[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:r[b]=n.getUint32(a,!0),a+=4;break;case s.Long:r[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:r[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:r[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,r[b]=U.decode(i.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return r}(t,r)),i}var C,A=new Uint8Array(0);function V(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function B(t){this._source=t,this._array=A,this._index=0}B.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=A,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:V(e,s.value)}}))},B.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var r=new Uint8Array(t);return r.set(this._array.subarray(this._index)),function i(){return e._source.read().then((function(n){return n.done?(e._array=A,e._index=0,s>0?r.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,r.set(n.value.subarray(0,t-s),s),r):(r.set(n.value,s),s+=n.value.length,i())}))}()},B.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(C||(C={}));class x{static debug(...t){this.log(C.Debug,...t)}static info(...t){this.log(C.Info,...t)}static warn(...t){this.log(C.Warn,...t)}static error(...t){this.log(C.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case C.Debug:console.debug(...e);break;case C.Info:console.info(...e);break;case C.Warn:console.warn(...e);break;case C.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,r=s;do{s=Math.ceil(s/e),r+=s}while(1!==s);return 40*r}function j(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}x.logLevel=C.Info;const T=new Uint8Array([102,103,98,3,102,103,98,0]);class k{constructor(t,e,s,r){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=r}static async open(t){const e=new E(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),r=2024+s;x.debug(`fetching header. minReqLength: ${r} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,r,"header"));if(!t.every((t,e)=>T[e]===t))throw x.error(`bytes: ${t} != ${T}`),new Error("Not a FlatGeobuf file");x.debug("magic bytes look good")}let i;{const t=await e.getRange(8,4,r,"header");if(i=new DataView(t).getUint32(0,!0),i>10485760||i<8)throw new Error("Invalid header size");x.debug("headerLength: "+i)}const n=await e.getRange(12,i,r,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return x.debug("completed: opening http reader"),new k(e,a,i,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;x.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,r){class i{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,r=s;const i=[s];do{s=Math.ceil(s/e),r+=s,i.push(s)}while(1!==s);const n=[];s=r;for(const t of i)n.push(s-t),s-=t;n.reverse(),i.reverse();const o=[];for(let t=0;t<i.length;t++)o.push([n[t],n[t]+i[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new i([0,1],t)})()];for(x.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();x.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const u=s>=c,[,l]=h[t.level()],f=Math.min(t.endNode()+e,l),_=f-s,p=await r(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const r=5*(e-s);if(a<g[r+0])continue;if(b<g[r+1])continue;if(n>g[r+2])continue;if(o>g[r+3])continue;const h=y[8+(r<<1)],l=j(y[9+(r<<1)],h);if(u){x.debug("yielding feature"),yield[l,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&l<_.endNode()+f){x.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${l}`),_.extendEndNodeToNewOffset(l);continue}let p=(()=>{let e=t.level()-1;return new i([l,l+1],e)})();void 0!==_&&_.level()==p.level()?x.debug(`Same level, but too far away. Pushing new request at offset: ${l} rather than merging with distant ${_}`):x.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,r){return s.getRange(e+t,r,0,"index")}))}lengthBeforeTree(){return T.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let r;{const t=await this.featureClient().getRange(s,4,e,"feature length");r=new DataView(t).getUint32(0,!0)}x.debug(`featureOffset: ${s}, featureLength: ${r}`);const i=await this.featureClient().getRange(s+4,r,e,"feature data"),n=new Uint8Array(i),o=new Uint8Array(r+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class E{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new N(t):t}clone(){const t=new E(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,r){x.debug(`need Range: ${t}-${t+e-1}`);const i=t-this.head,n=i+e;if(i>=0&&n<this.buffer.byteLength)return x.debug(`slicing existing Range: ${i}-${n-1}`),this.buffer.slice(i,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,r),this.head=t,this.buffer.slice(0,e)}}class N{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const r=`bytes=${t}-${t+e-1}`;return x.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${r}`),(await fetch(this.url,{headers:{Range:r}})).arrayBuffer()}}async function M(t,e,s){let r=new Uint8Array(await t(4,"feature length"));if(0===r.byteLength)return;let i=new d(r);const n=i.readUint32(0);r=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(r,4),i=new d(o),i.setPosition(4),s(F.getRootAsFeature(i),e)}function R(t){const e=new u;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return l.startColumn(t),l.addName(t,s),l.addType(t,e.type),l.endColumn(t)}(e,t))));const r=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,r);const i=_.endHeader(e);return e.finishSizePrefixed(i),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");const r=new d(t),i=r.readUint32(T.length);r.setPosition(T.length+4);const n=p.fromByteBuffer(r);s&&s(n);let o=T.length+4+i;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<r.capacity();){const t=r.readUint32(o);r.setPosition(o+4);const s=F.getRootAsFeature(r);h.push(e(s,n)),o+=4+t}return h}(t,P,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const r="function"==typeof(i=t).slice?i:new B("function"==typeof i.read?i:i.getReader());var i;const n=async t=>await r.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:u}=h;if(c>0){const t=L(u,c);await n(t)}let l;for(;l=await M(n,h,e);)yield l}(t,P,e)}(t,s):function(t,e,s){return async function*(t,e,s,r){const i=await k.open(t);x.debug("opened reader"),r&&r(i.header);for await(const t of i.selectBbox(e)){const e=await i.readFeature(t[0]);yield s(e,i.header)}}(t,e,P,s)}(t,e,s)},t.serialize=function(t){return function(t){const r=function(t){const r=t.features[0],i=r.properties;let n=null;return i&&(n=Object.keys(i).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(i[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(r.geometry.type),n,t.features.length,0,null,null,null,null)}(t),i=R(r),n=t.features.map(t=>S(v(t.geometry),t.properties,r)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(T.length+i.length+o);a.set(i,T.length);let b=T.length+i.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(T),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}]); | ||
!function(t){var e={};function s(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=t,s.c=e,s.d=function(t,e,r){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(r,i,function(e){return t[e]}.bind(null,i));return r},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){"use strict";(function(e){var r=s(2),i="undefined"==typeof window?e:window;i.loaders=i.loaders||{},t.exports=Object.assign(i.loaders,r)}).call(this,s(1))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"FlatGeobufLoader",{enumerable:!0,get:function(){return r.FlatGeobufLoader}});var r=s(3)},function(t,e,s){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(e,"__esModule",{value:!0}),e.FlatGeobufLoader=e.FlatGeobufWorkerLoader=void 0;var i=function(t,e){if(!e&&t&&t.__esModule)return t;if(null===t||"object"!==r(t)&&"function"!=typeof t)return{default:t};var s=n(e);if(s&&s.has(t))return s.get(t);var i={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if("default"!==a&&Object.prototype.hasOwnProperty.call(t,a)){var b=o?Object.getOwnPropertyDescriptor(t,a):null;b&&(b.get||b.set)?Object.defineProperty(i,a,b):i[a]=t[a]}i.default=t,s&&s.set(t,i);return i}(s(4));function n(t){if("function"!=typeof WeakMap)return null;var e=new WeakMap,s=new WeakMap;return(n=function(t){return t?s:e})(t)}function o(t,e,s,r,i,n,o){try{var a=t[n](o),b=a.value}catch(t){return void s(t)}a.done?e(b):Promise.resolve(b).then(r,i)}function a(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,r)}return s}function b(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?a(Object(s),!0).forEach((function(e){h(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):a(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var c={id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.8",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}};e.FlatGeobufWorkerLoader=c;var d,u,l=b(b({},c),{},{parse:(d=regeneratorRuntime.mark((function t(e,s){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",(0,i.default)(e,s));case 1:case"end":return t.stop()}}),t)})),u=function(){var t=this,e=arguments;return new Promise((function(s,r){var i=d.apply(t,e);function n(t){o(i,s,r,n,a,"next",t)}function a(t){o(i,s,r,n,a,"throw",t)}n(void 0)}))},function(t,e){return u.apply(this,arguments)}),parseSync:i.default,parseInBatchesFromStream:i.parseFlatGeobufInBatches,binary:!0});e.FlatGeobufLoader=l},function(t,e,s){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e){if(0===t.byteLength)return[];var s=new Uint8Array(t);return(0,r.deserialize)(s).features},e.parseFlatGeobufInBatches=function(t,e){return(0,r.deserializeStream)(t)};var r=s(5)},function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,r,i,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=r,this.width=i,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class r{constructor(t,e,s,r,i,n){this.org=t,this.code=e,this.name=s,this.description=r,this.wkt=i,this.code_string=n}}const i=new Int32Array(2),n=new Float32Array(i.buffer),o=new Float64Array(i.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return i[0]=this.readInt32(t),n[0]}readFloat64(t){return i[a?0:1]=this.readInt32(t),i[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,i[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,i[a?0:1]),this.writeInt32(t+4,i[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let r="",i=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;i<s;){let e;const s=this.readUint8(t+i++);if(s<192)e=s;else{const r=this.readUint8(t+i++);if(s<224)e=(31&s)<<6|63&r;else{const n=this.readUint8(t+i++);e=s<240?(15&s)<<12|(63&r)<<6|63&n:(7&s)<<18|(63&r)<<12|(63&n)<<6|63&this.readUint8(t+i++)}}e<65536?r+=String.fromCharCode(e):(e-=65536,r+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return r}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let r=0;r<e;++r)null!==t(r)&&s.push(t(r));return s}createObjList(t,e){const s=[];for(let r=0;r<e;++r){const e=t(r);null!==e&&s.push(e.unpack())}return s}}class u{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=u.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,r=d.allocate(s);return r.setPosition(s-e),r.bytes().set(t.bytes(),s-e),r}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const r=2*(s+2);this.addInt16(r);let i=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(r==this.bb.readInt16(t)){for(let e=2;e<r;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;i=this.vtables[e];break}}return i?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,i-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const r=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+r),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+r),this.addOffset(t),r&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,r=s-this.bb.readInt32(s);if(0==this.bb.readInt16(r+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let r;const i=t.charCodeAt(s++);r=i<55296||i>=56320?i:(i<<10)+t.charCodeAt(s++)+-56613888,r<128?e.push(r):(r<2048?e.push(r>>6&31|192):(r<65536?e.push(r>>12&15|224):e.push(r>>18&7|240,r>>12&63|128),e.push(r>>6&63|128)),e.push(63&r|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,r=this.bb.bytes();t<e.length;t++)r[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const r=t[s];if(null===r)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(r))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class l{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new l).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new l).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,r,i,n,o,a,b,h,c,d){return l.startColumn(t),l.addName(t,e),l.addType(t,s),l.addTitle(t,r),l.addDescription(t,i),l.addWidth(t,n),l.addPrecision(t,o),l.addScale(t,a),l.addNullable(t,b),l.addUnique(t,h),l.addPrimaryKey(t,c),l.addMetadata(t,d),l.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,r,i,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,r),f.addDescription(t,i),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,r,i,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=r,this.crs=i,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),i=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const r=s.columns(t);if(!r)throw new Error("Column unexpectedly missing");if(!r.name())throw new Error("Column name unexpectedly missing");o.push(new e(r.name(),r.type(),r.title(),r.description(),r.width(),r.precision(),r.scale(),r.nullable(),r.unique(),r.primaryKey()))}const a=s.crs(),b=a?new r(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,i,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,r,i,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,r),g.addM(t,i),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const r of t)y(r,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let r=0;r<t.length;r+=2){const i=[t[r],t[r+1]];e&&i.push(e[r>>1]),s.push(i)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],r=[];let i,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,r);break;case"MultiPoint":case"LineString":y(e,s,r);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,r),t.length>1&&(i=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:r.length>0?r:void 0,ends:i,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const r=t.parts(e),i=r.type();s.push(I(r,i))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),r=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return r&&t.push(r[0]),t}case c.MultiPoint:case c.LineString:return w(s,r);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let r=0;const i=Array.from(s).map(e=>t.slice(r,r=e<<1));let n;return e&&(r=0,n=Array.from(s).map(t=>e.slice(r,r=t))),i.map((t,e)=>w(t,n?n[e]:void 0))}(s,r,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new l).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,r){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,r),F.endFeature(t)}}const O=new TextEncoder,U=new TextDecoder;function S(t,e,r){const i=r.columns,n=new u;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(i)for(let t=0;t<i.length;t++){const r=i[t],n=e[r.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,r.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=O.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+r.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const l=function t(e,s){const{xy:r,z:i,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),r=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,r),g.endGeometry(e)}const b=g.createXyVector(e,r);let h,c;return i&&(h=g.createZVector(e,i)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,l),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function P(t,e){const r=e.columns,i={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return r&&r.length>0&&(i.properties=function(t,e){const r={};if(!e||0===e.length)return r;const i=t.propertiesArray();if(!i)return r;const n=new DataView(i.buffer,i.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:r[b]=!!n.getUint8(a),a+=1;break;case s.Byte:r[b]=n.getInt8(a),a+=1;break;case s.UByte:r[b]=n.getUint8(a),a+=1;break;case s.Short:r[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:r[b]=n.getUint16(a,!0),a+=2;break;case s.Int:r[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:r[b]=n.getUint32(a,!0),a+=4;break;case s.Long:r[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:r[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:r[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,r[b]=U.decode(i.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return r}(t,r)),i}var C,A=new Uint8Array(0);function V(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function B(t){this._source=t,this._array=A,this._index=0}B.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=A,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:V(e,s.value)}}))},B.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var r=new Uint8Array(t);return r.set(this._array.subarray(this._index)),function i(){return e._source.read().then((function(n){return n.done?(e._array=A,e._index=0,s>0?r.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,r.set(n.value.subarray(0,t-s),s),r):(r.set(n.value,s),s+=n.value.length,i())}))}()},B.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(C||(C={}));class x{static debug(...t){this.log(C.Debug,...t)}static info(...t){this.log(C.Info,...t)}static warn(...t){this.log(C.Warn,...t)}static error(...t){this.log(C.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case C.Debug:console.debug(...e);break;case C.Info:console.info(...e);break;case C.Warn:console.warn(...e);break;case C.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,r=s;do{s=Math.ceil(s/e),r+=s}while(1!==s);return 40*r}function j(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}x.logLevel=C.Info;const T=new Uint8Array([102,103,98,3,102,103,98,0]);class k{constructor(t,e,s,r){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=r}static async open(t){const e=new E(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),r=2024+s;x.debug(`fetching header. minReqLength: ${r} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,r,"header"));if(!t.every((t,e)=>T[e]===t))throw x.error(`bytes: ${t} != ${T}`),new Error("Not a FlatGeobuf file");x.debug("magic bytes look good")}let i;{const t=await e.getRange(8,4,r,"header");if(i=new DataView(t).getUint32(0,!0),i>10485760||i<8)throw new Error("Invalid header size");x.debug("headerLength: "+i)}const n=await e.getRange(12,i,r,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return x.debug("completed: opening http reader"),new k(e,a,i,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;x.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,r){class i{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,r=s;const i=[s];do{s=Math.ceil(s/e),r+=s,i.push(s)}while(1!==s);const n=[];s=r;for(const t of i)n.push(s-t),s-=t;n.reverse(),i.reverse();const o=[];for(let t=0;t<i.length;t++)o.push([n[t],n[t]+i[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new i([0,1],t)})()];for(x.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();x.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const u=s>=c,[,l]=h[t.level()],f=Math.min(t.endNode()+e,l),_=f-s,p=await r(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const r=5*(e-s);if(a<g[r+0])continue;if(b<g[r+1])continue;if(n>g[r+2])continue;if(o>g[r+3])continue;const h=y[8+(r<<1)],l=j(y[9+(r<<1)],h);if(u){x.debug("yielding feature"),yield[l,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&l<_.endNode()+f){x.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${l}`),_.extendEndNodeToNewOffset(l);continue}let p=(()=>{let e=t.level()-1;return new i([l,l+1],e)})();void 0!==_&&_.level()==p.level()?x.debug(`Same level, but too far away. Pushing new request at offset: ${l} rather than merging with distant ${_}`):x.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,r){return s.getRange(e+t,r,0,"index")}))}lengthBeforeTree(){return T.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let r;{const t=await this.featureClient().getRange(s,4,e,"feature length");r=new DataView(t).getUint32(0,!0)}x.debug(`featureOffset: ${s}, featureLength: ${r}`);const i=await this.featureClient().getRange(s+4,r,e,"feature data"),n=new Uint8Array(i),o=new Uint8Array(r+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class E{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new N(t):t}clone(){const t=new E(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,r){x.debug(`need Range: ${t}-${t+e-1}`);const i=t-this.head,n=i+e;if(i>=0&&n<this.buffer.byteLength)return x.debug(`slicing existing Range: ${i}-${n-1}`),this.buffer.slice(i,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,r),this.head=t,this.buffer.slice(0,e)}}class N{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const r=`bytes=${t}-${t+e-1}`;return x.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${r}`),(await fetch(this.url,{headers:{Range:r}})).arrayBuffer()}}async function M(t,e,s){let r=new Uint8Array(await t(4,"feature length"));if(0===r.byteLength)return;let i=new d(r);const n=i.readUint32(0);r=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(r,4),i=new d(o),i.setPosition(4),s(F.getRootAsFeature(i),e)}function R(t){const e=new u;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return l.startColumn(t),l.addName(t,s),l.addType(t,e.type),l.endColumn(t)}(e,t))));const r=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,r);const i=_.endHeader(e);return e.finishSizePrefixed(i),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");const r=new d(t),i=r.readUint32(T.length);r.setPosition(T.length+4);const n=p.fromByteBuffer(r);s&&s(n);let o=T.length+4+i;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<r.capacity();){const t=r.readUint32(o);r.setPosition(o+4);const s=F.getRootAsFeature(r);h.push(e(s,n)),o+=4+t}return h}(t,P,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const r="function"==typeof(i=t).slice?i:new B("function"==typeof i.read?i:i.getReader());var i;const n=async t=>await r.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>T[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:u}=h;if(c>0){const t=L(u,c);await n(t)}let l;for(;l=await M(n,h,e);)yield l}(t,P,e)}(t,s):function(t,e,s){return async function*(t,e,s,r){const i=await k.open(t);x.debug("opened reader"),r&&r(i.header);for await(const t of i.selectBbox(e)){const e=await i.readFeature(t[0]);yield s(e,i.header)}}(t,e,P,s)}(t,e,s)},t.serialize=function(t){return function(t){const r=function(t){const r=t.features[0],i=r.properties;let n=null;return i&&(n=Object.keys(i).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(i[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(r.geometry.type),n,t.features.length,0,null,null,null,null)}(t),i=R(r),n=t.features.map(t=>S(v(t.geometry),t.properties,r)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(T.length+i.length+o);a.set(i,T.length);let b=T.length+i.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(T),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}]); | ||
//# sourceMappingURL=dist.es5.min.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(window,(function(){return function(t){var e={};function s(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=1)}([function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,i,r,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=i,this.width=r,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class i{constructor(t,e,s,i,r,n){this.org=t,this.code=e,this.name=s,this.description=i,this.wkt=r,this.code_string=n}}const r=new Int32Array(2),n=new Float32Array(r.buffer),o=new Float64Array(r.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return r[0]=this.readInt32(t),n[0]}readFloat64(t){return r[a?0:1]=this.readInt32(t),r[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,r[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,r[a?0:1]),this.writeInt32(t+4,r[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let i="",r=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;r<s;){let e;const s=this.readUint8(t+r++);if(s<192)e=s;else{const i=this.readUint8(t+r++);if(s<224)e=(31&s)<<6|63&i;else{const n=this.readUint8(t+r++);e=s<240?(15&s)<<12|(63&i)<<6|63&n:(7&s)<<18|(63&i)<<12|(63&n)<<6|63&this.readUint8(t+r++)}}e<65536?i+=String.fromCharCode(e):(e-=65536,i+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return i}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let i=0;i<e;++i)null!==t(i)&&s.push(t(i));return s}createObjList(t,e){const s=[];for(let i=0;i<e;++i){const e=t(i);null!==e&&s.push(e.unpack())}return s}}class l{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=l.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,i=d.allocate(s);return i.setPosition(s-e),i.bytes().set(t.bytes(),s-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const i=2*(s+2);this.addInt16(i);let r=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(t)){for(let e=2;e<i;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;r=this.vtables[e];break}}return r?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,r-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const i=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+i),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,i=s-this.bb.readInt32(s);if(0==this.bb.readInt16(i+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let i;const r=t.charCodeAt(s++);i=r<55296||r>=56320?r:(r<<10)+t.charCodeAt(s++)+-56613888,i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,i=this.bb.bytes();t<e.length;t++)i[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const i=t[s];if(null===i)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(i))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class u{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new u).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new u).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,i,r,n,o,a,b,h,c,d){return u.startColumn(t),u.addName(t,e),u.addType(t,s),u.addTitle(t,i),u.addDescription(t,r),u.addWidth(t,n),u.addPrecision(t,o),u.addScale(t,a),u.addNullable(t,b),u.addUnique(t,h),u.addPrimaryKey(t,c),u.addMetadata(t,d),u.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,i,r,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,i),f.addDescription(t,r),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,i,r,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=i,this.crs=r,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),r=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const i=s.columns(t);if(!i)throw new Error("Column unexpectedly missing");if(!i.name())throw new Error("Column name unexpectedly missing");o.push(new e(i.name(),i.type(),i.title(),i.description(),i.width(),i.precision(),i.scale(),i.nullable(),i.unique(),i.primaryKey()))}const a=s.crs(),b=a?new i(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,r,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,i,r,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,i),g.addM(t,r),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const i of t)y(i,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let i=0;i<t.length;i+=2){const r=[t[i],t[i+1]];e&&r.push(e[i>>1]),s.push(r)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],i=[];let r,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,i);break;case"MultiPoint":case"LineString":y(e,s,i);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,i),t.length>1&&(r=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:i.length>0?i:void 0,ends:r,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const i=t.parts(e),r=i.type();s.push(I(i,r))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),i=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return i&&t.push(i[0]),t}case c.MultiPoint:case c.LineString:return w(s,i);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let i=0;const r=Array.from(s).map(e=>t.slice(i,i=e<<1));let n;return e&&(i=0,n=Array.from(s).map(t=>e.slice(i,i=t))),r.map((t,e)=>w(t,n?n[e]:void 0))}(s,i,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,i){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,i),F.endFeature(t)}}const U=new TextEncoder,O=new TextDecoder;function S(t,e,i){const r=i.columns,n=new l;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(r)for(let t=0;t<r.length;t++){const i=r[t],n=e[i.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,i.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=U.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+i.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const u=function t(e,s){const{xy:i,z:r,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),i=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,i),g.endGeometry(e)}const b=g.createXyVector(e,i);let h,c;return r&&(h=g.createZVector(e,r)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,u),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function C(t,e){const i=e.columns,r={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return i&&i.length>0&&(r.properties=function(t,e){const i={};if(!e||0===e.length)return i;const r=t.propertiesArray();if(!r)return i;const n=new DataView(r.buffer,r.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:i[b]=!!n.getUint8(a),a+=1;break;case s.Byte:i[b]=n.getInt8(a),a+=1;break;case s.UByte:i[b]=n.getUint8(a),a+=1;break;case s.Short:i[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:i[b]=n.getUint16(a,!0),a+=2;break;case s.Int:i[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:i[b]=n.getUint32(a,!0),a+=4;break;case s.Long:i[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:i[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:i[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,i[b]=O.decode(r.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return i}(t,i)),r}var A,V=new Uint8Array(0);function P(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function x(t){this._source=t,this._array=V,this._index=0}x.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=V,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:P(e,s.value)}}))},x.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var i=new Uint8Array(t);return i.set(this._array.subarray(this._index)),function r(){return e._source.read().then((function(n){return n.done?(e._array=V,e._index=0,s>0?i.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,i.set(n.value.subarray(0,t-s),s),i):(i.set(n.value,s),s+=n.value.length,r())}))}()},x.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(A||(A={}));class B{static debug(...t){this.log(A.Debug,...t)}static info(...t){this.log(A.Info,...t)}static warn(...t){this.log(A.Warn,...t)}static error(...t){this.log(A.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case A.Debug:console.debug(...e);break;case A.Info:console.info(...e);break;case A.Warn:console.warn(...e);break;case A.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,i=s;do{s=Math.ceil(s/e),i+=s}while(1!==s);return 40*i}function T(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}B.logLevel=A.Info;const N=new Uint8Array([102,103,98,3,102,103,98,0]);class E{constructor(t,e,s,i){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=i}static async open(t){const e=new k(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),i=2024+s;B.debug(`fetching header. minReqLength: ${i} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,i,"header"));if(!t.every((t,e)=>N[e]===t))throw B.error(`bytes: ${t} != ${N}`),new Error("Not a FlatGeobuf file");B.debug("magic bytes look good")}let r;{const t=await e.getRange(8,4,i,"header");if(r=new DataView(t).getUint32(0,!0),r>10485760||r<8)throw new Error("Invalid header size");B.debug("headerLength: "+r)}const n=await e.getRange(12,r,i,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return B.debug("completed: opening http reader"),new E(e,a,r,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;B.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,i){class r{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,i=s;const r=[s];do{s=Math.ceil(s/e),i+=s,r.push(s)}while(1!==s);const n=[];s=i;for(const t of r)n.push(s-t),s-=t;n.reverse(),r.reverse();const o=[];for(let t=0;t<r.length;t++)o.push([n[t],n[t]+r[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new r([0,1],t)})()];for(B.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();B.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const l=s>=c,[,u]=h[t.level()],f=Math.min(t.endNode()+e,u),_=f-s,p=await i(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const i=5*(e-s);if(a<g[i+0])continue;if(b<g[i+1])continue;if(n>g[i+2])continue;if(o>g[i+3])continue;const h=y[8+(i<<1)],u=T(y[9+(i<<1)],h);if(l){B.debug("yielding feature"),yield[u,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&u<_.endNode()+f){B.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${u}`),_.extendEndNodeToNewOffset(u);continue}let p=(()=>{let e=t.level()-1;return new r([u,u+1],e)})();void 0!==_&&_.level()==p.level()?B.debug(`Same level, but too far away. Pushing new request at offset: ${u} rather than merging with distant ${_}`):B.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,i){return s.getRange(e+t,i,0,"index")}))}lengthBeforeTree(){return N.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let i;{const t=await this.featureClient().getRange(s,4,e,"feature length");i=new DataView(t).getUint32(0,!0)}B.debug(`featureOffset: ${s}, featureLength: ${i}`);const r=await this.featureClient().getRange(s+4,i,e,"feature data"),n=new Uint8Array(r),o=new Uint8Array(i+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class k{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new j(t):t}clone(){const t=new k(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,i){B.debug(`need Range: ${t}-${t+e-1}`);const r=t-this.head,n=r+e;if(r>=0&&n<this.buffer.byteLength)return B.debug(`slicing existing Range: ${r}-${n-1}`),this.buffer.slice(r,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,i),this.head=t,this.buffer.slice(0,e)}}class j{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const i=`bytes=${t}-${t+e-1}`;return B.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${i}`),(await fetch(this.url,{headers:{Range:i}})).arrayBuffer()}}async function M(t,e,s){let i=new Uint8Array(await t(4,"feature length"));if(0===i.byteLength)return;let r=new d(i);const n=r.readUint32(0);i=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(i,4),r=new d(o),r.setPosition(4),s(F.getRootAsFeature(r),e)}function R(t){const e=new l;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return u.startColumn(t),u.addName(t,s),u.addType(t,e.type),u.endColumn(t)}(e,t))));const i=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,i);const r=_.endHeader(e);return e.finishSizePrefixed(r),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");const i=new d(t),r=i.readUint32(N.length);i.setPosition(N.length+4);const n=p.fromByteBuffer(i);s&&s(n);let o=N.length+4+r;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<i.capacity();){const t=i.readUint32(o);i.setPosition(o+4);const s=F.getRootAsFeature(i);h.push(e(s,n)),o+=4+t}return h}(t,C,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const i="function"==typeof(r=t).slice?r:new x("function"==typeof r.read?r:r.getReader());var r;const n=async t=>await i.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:l}=h;if(c>0){const t=L(l,c);await n(t)}let u;for(;u=await M(n,h,e);)yield u}(t,C,e)}(t,s):function(t,e,s){return async function*(t,e,s,i){const r=await E.open(t);B.debug("opened reader"),i&&i(r.header);for await(const t of r.selectBbox(e)){const e=await r.readFeature(t[0]);yield s(e,r.header)}}(t,e,C,s)}(t,e,s)},t.serialize=function(t){return function(t){const i=function(t){const i=t.features[0],r=i.properties;let n=null;return r&&(n=Object.keys(r).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(r[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(i.geometry.type),n,t.features.length,0,null,null,null,null)}(t),r=R(i),n=t.features.map(t=>S(v(t.geometry),t.properties,i)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(N.length+r.length+o);a.set(r,N.length);let b=N.length+r.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(N),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,s){(function(e){const i=s(3),r="undefined"==typeof window?e:window;r.loaders=r.loaders||{},t.exports=Object.assign(r.loaders,i)}).call(this,s(2))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";s.r(e),s.d(e,"FlatGeobufLoader",(function(){return n}));var i=s(0);function r(t,e){if(0===t.byteLength)return[];const s=new Uint8Array(t),{features:r}=Object(i.deserialize)(s);return r}const n={...{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.7",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}},parse:async(t,e)=>r(t),parseSync:r,parseInBatchesFromStream:function(t,e){return Object(i.deserializeStream)(t)},binary:!0}}])})); | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(window,(function(){return function(t){var e={};function s(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,s),r.l=!0,r.exports}return s.m=t,s.c=e,s.d=function(t,e,i){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(s.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)s.d(i,r,function(e){return t[e]}.bind(null,r));return i},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=1)}([function(t,e,s){!function(t){"use strict";class e{constructor(t,e,s,i,r,n,o,a,b,h){this.name=t,this.type=e,this.title=s,this.description=i,this.width=r,this.precision=n,this.scale=o,this.nullable=a,this.unique=b,this.primary_key=h}}var s;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(s||(s={}));class i{constructor(t,e,s,i,r,n){this.org=t,this.code=e,this.name=s,this.description=i,this.wkt=r,this.code_string=n}}const r=new Int32Array(2),n=new Float32Array(r.buffer),o=new Float64Array(r.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class b{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?b.ZERO:new b(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,c;b.ZERO=new b(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class d{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new d(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new b(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new b(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return r[0]=this.readInt32(t),n[0]}readFloat64(t){return r[a?0:1]=this.readInt32(t),r[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){n[0]=e,this.writeInt32(t,r[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,r[a?0:1]),this.writeInt32(t+4,r[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const s=t-this.readInt32(t);return e<this.readInt16(s)?this.readInt16(s+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const s=this.readInt32(t);let i="",r=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+s);for(;r<s;){let e;const s=this.readUint8(t+r++);if(s<192)e=s;else{const i=this.readUint8(t+r++);if(s<224)e=(31&s)<<6|63&i;else{const n=this.readUint8(t+r++);e=s<240?(15&s)<<12|(63&i)<<6|63&n:(7&s)<<18|(63&i)<<12|(63&n)<<6|63&this.readUint8(t+r++)}}e<65536?i+=String.fromCharCode(e):(e-=65536,i+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return i}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return b.create(t,e)}createScalarList(t,e){const s=[];for(let i=0;i<e;++i)null!==t(i)&&s.push(t(i));return s}createObjList(t,e){const s=[];for(let i=0;i<e;++i){const e=t(i);null!==e&&s.push(e.unpack())}return s}}class l{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=d.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const s=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<s+t+e;){const t=this.bb.capacity();this.bb=l.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(s)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,s){(this.force_defaults||e!=s)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,s){(this.force_defaults||e!=s)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,s){(this.force_defaults||e!=s)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,s){!this.force_defaults&&e.equals(s)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,s){(this.force_defaults||e!=s)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,s){(this.force_defaults||e!=s)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,s){e!=s&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const s=e<<1,i=d.allocate(s);return i.setPosition(s-e),i.bytes().set(t.bytes(),s-e),i}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const s=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const i=2*(s+2);this.addInt16(i);let r=0;const n=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(i==this.bb.readInt16(t)){for(let e=2;e<i;e+=2)if(this.bb.readInt16(n+e)!=this.bb.readInt16(t+e))continue t;r=this.vtables[e];break}}return r?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,r-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,s){const i=s?4:0;if(e){const t=e;if(this.prep(this.minalign,8+i),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+i),this.addOffset(t),i&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const s=this.bb.capacity()-t,i=s-this.bb.readInt32(s);if(0==this.bb.readInt16(i+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,s){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(s,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let s=0;for(;s<t.length;){let i;const r=t.charCodeAt(s++);i=r<55296||r>=56320?r:(r<<10)+t.charCodeAt(s++)+-56613888,i<128?e.push(i):(i<2048?e.push(i>>6&31|192):(i<65536?e.push(i>>12&15|224):e.push(i>>18&7|240,i>>12&63|128),e.push(i>>6&63|128)),e.push(63&i|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,s=this.space,i=this.bb.bytes();t<e.length;t++)i[s++]=e[t];return this.endVector()}createLong(t,e){return b.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let s=0;s<t.length;++s){const i=t[s];if(null===i)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(i))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class u{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new u).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new u).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):s.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,s.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,s,i,r,n,o,a,b,h,c,d){return u.startColumn(t),u.addName(t,e),u.addType(t,s),u.addTitle(t,i),u.addDescription(t,r),u.addWidth(t,n),u.addPrecision(t,o),u.addScale(t,a),u.addNullable(t,b),u.addUnique(t,h),u.addPrimaryKey(t,c),u.addMetadata(t,d),u.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,s,i,r,n,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,s),f.addName(t,i),f.addDescription(t,r),f.addWkt(t,n),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(c||(c={}));class _{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new _).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new _).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,c.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class p{constructor(t,e,s,i,r,n,o,a){this.geometryType=t,this.columns=e,this.featuresCount=s,this.indexNodeSize=i,this.crs=r,this.title=n,this.description=o,this.metadata=a}static fromByteBuffer(t){const s=_.getRootAsHeader(t),r=s.featuresCount().toFloat64(),n=s.indexNodeSize(),o=[];for(let t=0;t<s.columnsLength();t++){const i=s.columns(t);if(!i)throw new Error("Column unexpectedly missing");if(!i.name())throw new Error("Column name unexpectedly missing");o.push(new e(i.name(),i.type(),i.title(),i.description(),i.width(),i.precision(),i.scale(),i.nullable(),i.unique(),i.primaryKey()))}const a=s.crs(),b=a?new i(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new p(s.geometryType(),o,r,n,b,s.title(),s.description(),s.metadata())}}class g{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new g).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new g).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):c.Unknown}parts(t,e){const s=this.bb.__offset(this.bb_pos,18);return s?(e||new g).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addInt32(e[s]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addFloat64(e[s]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let s=e.length-1;s>=0;s--)t.addInt64(e[s]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,c.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,s,i,r,n,o,a,b){return g.startGeometry(t),g.addEnds(t,e),g.addXy(t,s),g.addZ(t,i),g.addM(t,r),g.addT(t,n),g.addTm(t,o),g.addType(t,a),g.addParts(t,b),g.endGeometry(t)}}function y(t,e,s){if(0!==t.length)if(Array.isArray(t[0]))for(const i of t)y(i,e,s);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),s.push(t[2]))}function w(t,e){const s=[];for(let i=0;i<t.length;i+=2){const r=[t[i],t[i+1]];e&&r.push(e[i>>1]),s.push(r)}return s}function m(t){return t?c[t]:c.Unknown}function v(t){const e=t.coordinates,s=[],i=[];let r,n;const o=m(t.type);let a=0;switch(t.type){case"Point":y(e,s,i);break;case"MultiPoint":case"LineString":y(e,s,i);break;case"MultiLineString":case"Polygon":{const t=e;y(t,s,i),t.length>1&&(r=t.map(t=>a+=t.length));break}case"MultiPolygon":n=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(n=t.geometries.map(v))}return{xy:s,z:i.length>0?i:void 0,ends:r,type:o,parts:n}}function I(t,e){if(e===c.GeometryCollection){const s=[];for(let e=0;e<t.partsLength();e++){const i=t.parts(e),r=i.type();s.push(I(i,r))}return{type:c[e],geometries:s}}if(e===c.MultiPolygon){const s=[];for(let e=0;e<t.partsLength();e++)s.push(I(t.parts(e),c.Polygon));return{type:c[e],coordinates:s.map(t=>t.coordinates)}}const s=function(t,e){const s=t.xyArray(),i=t.zArray();switch(e){case c.Point:{const t=Array.from(s);return i&&t.push(i[0]),t}case c.MultiPoint:case c.LineString:return w(s,i);case c.MultiLineString:case c.Polygon:return function(t,e,s){if(!s||0===s.length)return[w(t,e)];let i=0;const r=Array.from(s).map(e=>t.slice(i,i=e<<1));let n;return e&&(i=0,n=Array.from(s).map(t=>e.slice(i,i=t))),r.map((t,e)=>w(t,n?n[e]:void 0))}(s,i,t.endsArray())}}(t,e);return{type:c[e],coordinates:s}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new g).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const s=this.bb.__offset(this.bb_pos,8);return s?(e||new u).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+s)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let s=e.length-1;s>=0;s--)t.addInt8(e[s]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let s=e.length-1;s>=0;s--)t.addOffset(e[s]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,s,i){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,s),F.addColumns(t,i),F.endFeature(t)}}const U=new TextEncoder,O=new TextDecoder;function S(t,e,i){const r=i.columns,n=new l;let o=0,a=1024,b=new Uint8Array(a),h=new DataView(b.buffer);const c=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(b),b=e,h=new DataView(b.buffer,o)};if(r)for(let t=0;t<r.length;t++){const i=r[t],n=e[i.name];if(null!==n)switch(h.setUint16(o,t,!0),o+=2,i.type){case s.Bool:c(1),h.setUint8(o,n),o+=1;break;case s.Short:c(2),h.setInt16(o,n,!0),o+=2;break;case s.UShort:c(2),h.setUint16(o,n,!0),o+=2;break;case s.Int:c(4),h.setInt32(o,n,!0),o+=4;break;case s.UInt:c(4),h.setUint32(o,n,!0),o+=4;break;case s.Long:c(8),h.setBigInt64(o,BigInt(n),!0),o+=8;break;case s.Double:c(8),h.setFloat64(o,n,!0),o+=8;break;case s.DateTime:case s.String:{const t=U.encode(n);c(4),h.setUint32(o,t.length,!0),o+=4,c(t.length),b.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+i.type)}}let d=null;o>0&&(d=F.createPropertiesVector(n,b.slice(0,o)));const u=function t(e,s){const{xy:i,z:r,ends:n,parts:o,type:a}=s;if(o){const s=o.map(s=>t(e,s)),i=g.createPartsVector(e,s);return g.startGeometry(e),g.addParts(e,i),g.endGeometry(e)}const b=g.createXyVector(e,i);let h,c;return r&&(h=g.createZVector(e,r)),n&&(c=g.createEndsVector(e,n)),g.startGeometry(e),c&&g.addEnds(e,c),g.addXy(e,b),h&&g.addZ(e,h),g.addType(e,a),g.endGeometry(e)}(n,t);F.startFeature(n),F.addGeometry(n,u),d&&F.addProperties(n,d);const f=F.endFeature(n);return n.finishSizePrefixed(f),n.asUint8Array()}function C(t,e){const i=e.columns,r={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return i&&i.length>0&&(r.properties=function(t,e){const i={};if(!e||0===e.length)return i;const r=t.propertiesArray();if(!r)return i;const n=new DataView(r.buffer,r.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=n.getUint16(a,!0);a+=2;const o=e[t],b=o.name;switch(o.type){case s.Bool:i[b]=!!n.getUint8(a),a+=1;break;case s.Byte:i[b]=n.getInt8(a),a+=1;break;case s.UByte:i[b]=n.getUint8(a),a+=1;break;case s.Short:i[b]=n.getInt16(a,!0),a+=2;break;case s.UShort:i[b]=n.getUint16(a,!0),a+=2;break;case s.Int:i[b]=n.getInt32(a,!0),a+=4;break;case s.UInt:i[b]=n.getUint32(a,!0),a+=4;break;case s.Long:i[b]=Number(n.getBigInt64(a,!0)),a+=8;break;case s.ULong:i[b]=Number(n.getBigUint64(a,!0)),a+=8;break;case s.Double:i[b]=n.getFloat64(a,!0),a+=8;break;case s.DateTime:case s.String:{const t=n.getUint32(a,!0);a+=4,i[b]=O.decode(r.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return i}(t,i)),r}var A,V=new Uint8Array(0);function P(t,e){if(!t.length)return e;if(!e.length)return t;var s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function x(t){this._source=t,this._array=V,this._index=0}x.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(s){return t._array=V,t._index=0,s.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:P(e,s.value)}}))},x.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,s=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var i=new Uint8Array(t);return i.set(this._array.subarray(this._index)),function r(){return e._source.read().then((function(n){return n.done?(e._array=V,e._index=0,s>0?i.subarray(0,s):null):s+n.value.length>=t?(e._array=n.value,e._index=t-s,i.set(n.value.subarray(0,t-s),s),i):(i.set(n.value,s),s+=n.value.length,r())}))}()},x.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(A||(A={}));class B{static debug(...t){this.log(A.Debug,...t)}static info(...t){this.log(A.Info,...t)}static warn(...t){this.log(A.Warn,...t)}static error(...t){this.log(A.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case A.Debug:console.debug(...e);break;case A.Info:console.info(...e);break;case A.Warn:console.warn(...e);break;case A.Error:console.error(...e)}}}function L(t,e){e=Math.min(Math.max(+e,2),65535);let s=t,i=s;do{s=Math.ceil(s/e),i+=s}while(1!==s);return 40*i}function T(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}B.logLevel=A.Info;const N=new Uint8Array([102,103,98,3,102,103,98,0]);class E{constructor(t,e,s,i){this.headerClient=t,this.header=e,this.headerLength=s,this.indexLength=i}static async open(t){const e=new k(t),s=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),i=2024+s;B.debug(`fetching header. minReqLength: ${i} (assumedHeaderLength: 2024, assumedIndexLength: ${s})`);{const t=new Uint8Array(await e.getRange(0,8,i,"header"));if(!t.every((t,e)=>N[e]===t))throw B.error(`bytes: ${t} != ${N}`),new Error("Not a FlatGeobuf file");B.debug("magic bytes look good")}let r;{const t=await e.getRange(8,4,i,"header");if(r=new DataView(t).getUint32(0,!0),r>10485760||r<8)throw new Error("Invalid header size");B.debug("headerLength: "+r)}const n=await e.getRange(12,r,i,"header"),o=new d(new Uint8Array(n)),a=p.fromByteBuffer(o),b=L(a.featuresCount,a.indexNodeSize);return B.debug("completed: opening http reader"),new E(e,a,r,b)}async*selectBbox(t){const e=this.lengthBeforeTree(),s=this.headerClient;B.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,s,i){class r{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:n,minY:o,maxX:a,maxY:b}=s,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let s=t,i=s;const r=[s];do{s=Math.ceil(s/e),i+=s,r.push(s)}while(1!==s);const n=[];s=i;for(const t of r)n.push(s-t),s-=t;n.reverse(),r.reverse();const o=[];for(let t=0;t<r.length;t++)o.push([n[t],n[t]+r[t]]);return o.reverse(),o}(t,e),c=h[0][0],d=[(()=>{const t=h.length-1;return new r([0,1],t)})()];for(B.debug(`starting stream search with queue: ${d}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=d.length;){const t=d.shift();B.debug(`popped node: ${t}, queueLength: ${d.length}`);let s=t.startNode();const l=s>=c,[,u]=h[t.level()],f=Math.min(t.endNode()+e,u),_=f-s,p=await i(40*s,40*_),g=new Float64Array(p),y=new Uint32Array(p);for(let e=s;e<f;e++){const i=5*(e-s);if(a<g[i+0])continue;if(b<g[i+1])continue;if(n>g[i+2])continue;if(o>g[i+3])continue;const h=y[8+(i<<1)],u=T(y[9+(i<<1)],h);if(l){B.debug("yielding feature"),yield[u,e-c];continue}const f=6553.6,_=d[d.length-1];if(void 0!==_&&_.level()==t.level()-1&&u<_.endNode()+f){B.debug(`Merging "nodeRange" request into existing range: ${_}, newOffset: ${_.endNode()} -> ${u}`),_.extendEndNodeToNewOffset(u);continue}let p=(()=>{let e=t.level()-1;return new r([u,u+1],e)})();void 0!==_&&_.level()==p.level()?B.debug(`Same level, but too far away. Pushing new request at offset: ${u} rather than merging with distant ${_}`):B.debug(`Pushing new level for ${p} onto queue with nearestNodeRange: ${_} since there's not already a range for this level.`),d.push(p)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,i){return s.getRange(e+t,i,0,"index")}))}lengthBeforeTree(){return N.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,s=t+this.lengthBeforeFeatures();let i;{const t=await this.featureClient().getRange(s,4,e,"feature length");i=new DataView(t).getUint32(0,!0)}B.debug(`featureOffset: ${s}, featureLength: ${i}`);const r=await this.featureClient().getRange(s+4,i,e,"feature data"),n=new Uint8Array(r),o=new Uint8Array(i+4);o.set(n,4);const a=new d(o);return a.setPosition(4),F.getRootAsFeature(a)}}class k{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new j(t):t}clone(){const t=new k(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,s,i){B.debug(`need Range: ${t}-${t+e-1}`);const r=t-this.head,n=r+e;if(r>=0&&n<this.buffer.byteLength)return B.debug(`slicing existing Range: ${r}-${n-1}`),this.buffer.slice(r,n);const o=Math.max(e,s);return this.buffer=await this.httpClient.getRange(t,o,i),this.head=t,this.buffer.slice(0,e)}}class j{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,s){this.requestsEverMade+=1,this.bytesEverRequested+=e;const i=`bytes=${t}-${t+e-1}`;return B.debug(`request: #${this.requestsEverMade}, purpose: ${s}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${i}`),(await fetch(this.url,{headers:{Range:i}})).arrayBuffer()}}async function M(t,e,s){let i=new Uint8Array(await t(4,"feature length"));if(0===i.byteLength)return;let r=new d(i);const n=r.readUint32(0);i=new Uint8Array(await t(n,"feature data"));const o=new Uint8Array(n+4);return o.set(i,4),r=new d(o),r.setPosition(4),s(F.getRootAsFeature(r),e)}function R(t){const e=new l;let s=null;t.columns&&(s=_.createColumnsVector(e,t.columns.map(t=>function(t,e){const s=t.createString(e.name);return u.startColumn(t),u.addName(t,s),u.addType(t,e.type),u.endColumn(t)}(e,t))));const i=e.createString("L1");_.startHeader(e),_.addFeaturesCount(e,new b(t.featuresCount,0)),_.addGeometryType(e,t.geometryType),_.addIndexNodeSize(e,0),s&&_.addColumns(e,s),_.addName(e,i);const r=_.endHeader(e);return e.finishSizePrefixed(r),e.asUint8Array()}t.deserialize=function(t,e,s){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,s){if(!t.subarray(0,7).every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");const i=new d(t),r=i.readUint32(N.length);i.setPosition(N.length+4);const n=p.fromByteBuffer(i);s&&s(n);let o=N.length+4+r;const{indexNodeSize:a,featuresCount:b}=n;a>0&&(o+=L(b,a));const h=[];for(;o<i.capacity();){const t=i.readUint32(o);i.setPosition(o+4);const s=F.getRootAsFeature(i);h.push(e(s,n)),o+=4+t}return h}(t,C,e)}}(t,s):t instanceof ReadableStream?function(t,e){return async function*(t,e,s){const i="function"==typeof(r=t).slice?r:new x("function"==typeof r.read?r:r.getReader());var r;const n=async t=>await i.slice(t);let o=new Uint8Array(await n(8));if(!o.every((t,e)=>N[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await n(4));let a=new d(o);const b=a.readUint32(0);o=new Uint8Array(await n(b)),a=new d(o);const h=p.fromByteBuffer(a);s&&s(h);const{indexNodeSize:c,featuresCount:l}=h;if(c>0){const t=L(l,c);await n(t)}let u;for(;u=await M(n,h,e);)yield u}(t,C,e)}(t,s):function(t,e,s){return async function*(t,e,s,i){const r=await E.open(t);B.debug("opened reader"),i&&i(r.header);for await(const t of r.selectBbox(e)){const e=await r.readFeature(t[0]);yield s(e,r.header)}}(t,e,C,s)}(t,e,s)},t.serialize=function(t){return function(t){const i=function(t){const i=t.features[0],r=i.properties;let n=null;return r&&(n=Object.keys(r).map(t=>new e(t,function(t){if("boolean"==typeof t)return s.Bool;if("number"==typeof t)return t%1==0?s.Int:s.Double;if("string"==typeof t)return s.String;if(null===t)return s.String;throw new Error(`Unknown type (value '${t}')`)}(r[t]),null,null,-1,-1,-1,!0,!1,!1))),new p(m(i.geometry.type),n,t.features.length,0,null,null,null,null)}(t),r=R(i),n=t.features.map(t=>S(v(t.geometry),t.properties,i)),o=n.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(N.length+r.length+o);a.set(r,N.length);let b=N.length+r.length;for(const t of n)a.set(t,b),b+=t.length;return a.set(N),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e,s){(function(e){const i=s(3),r="undefined"==typeof window?e:window;r.loaders=r.loaders||{},t.exports=Object.assign(r.loaders,i)}).call(this,s(2))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";s.r(e),s.d(e,"FlatGeobufLoader",(function(){return n}));var i=s(0);function r(t,e){if(0===t.byteLength)return[];const s=new Uint8Array(t),{features:r}=Object(i.deserialize)(s);return r}const n={...{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.8",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}},parse:async(t,e)=>r(t),parseSync:r,parseInBatchesFromStream:function(t,e){return Object(i.deserializeStream)(t)},binary:!0}}])})); | ||
//# sourceMappingURL=dist.min.js.map |
@@ -28,3 +28,3 @@ "use strict"; | ||
var VERSION = typeof "3.0.0-beta.7" !== 'undefined' ? "3.0.0-beta.7" : 'latest'; | ||
var VERSION = typeof "3.0.0-beta.8" !== 'undefined' ? "3.0.0-beta.8" : 'latest'; | ||
var FlatGeobufWorkerLoader = { | ||
@@ -31,0 +31,0 @@ id: 'flatgeobuf', |
import parseFlatGeobuf, { parseFlatGeobufInBatches } from './lib/parse-flatgeobuf'; | ||
const VERSION = typeof "3.0.0-beta.7" !== 'undefined' ? "3.0.0-beta.7" : 'latest'; | ||
const VERSION = typeof "3.0.0-beta.8" !== 'undefined' ? "3.0.0-beta.8" : 'latest'; | ||
export const FlatGeobufWorkerLoader = { | ||
@@ -4,0 +4,0 @@ id: 'flatgeobuf', |
@@ -1,2 +0,2 @@ | ||
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){t.exports=r(7)},function(t,e){function r(t,e,r,n,s,i,o){try{var a=t[i](o),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,s)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(s,i){var o=t.apply(e,n);function a(t){r(o,s,i,a,c,"next",t)}function c(t){r(o,s,i,a,c,"throw",t)}a(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){!function(t){"use strict";class e{constructor(t,e,r,n,s,i,o,a,c,h){this.name=t,this.type=e,this.title=r,this.description=n,this.width=s,this.precision=i,this.scale=o,this.nullable=a,this.unique=c,this.primary_key=h}}var r;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(r||(r={}));class n{constructor(t,e,r,n,s,i){this.org=t,this.code=e,this.name=r,this.description=n,this.wkt=s,this.code_string=i}}const s=new Int32Array(2),i=new Float32Array(s.buffer),o=new Float64Array(s.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class c{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?c.ZERO:new c(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,u;c.ZERO=new c(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class b{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new b(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new c(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new c(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return s[0]=this.readInt32(t),i[0]}readFloat64(t){return s[a?0:1]=this.readInt32(t),s[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){i[0]=e,this.writeInt32(t,s[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,s[a?0:1]),this.writeInt32(t+4,s[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const r=t-this.readInt32(t);return e<this.readInt16(r)?this.readInt16(r+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const r=this.readInt32(t);let n="",s=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+r);for(;s<r;){let e;const r=this.readUint8(t+s++);if(r<192)e=r;else{const n=this.readUint8(t+s++);if(r<224)e=(31&r)<<6|63&n;else{const i=this.readUint8(t+s++);e=r<240?(15&r)<<12|(63&n)<<6|63&i:(7&r)<<18|(63&n)<<12|(63&i)<<6|63&this.readUint8(t+s++)}}e<65536?n+=String.fromCharCode(e):(e-=65536,n+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return n}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return c.create(t,e)}createScalarList(t,e){const r=[];for(let n=0;n<e;++n)null!==t(n)&&r.push(t(n));return r}createObjList(t,e){const r=[];for(let n=0;n<e;++n){const e=t(n);null!==e&&r.push(e.unpack())}return r}}class l{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=b.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const r=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<r+t+e;){const t=this.bb.capacity();this.bb=l.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,r){!this.force_defaults&&e.equals(r)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,r){e!=r&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=e<<1,n=b.allocate(r);return n.setPosition(r-e),n.bytes().set(t.bytes(),r-e),n}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const r=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const n=2*(r+2);this.addInt16(n);let s=0;const i=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(n==this.bb.readInt16(t)){for(let e=2;e<n;e+=2)if(this.bb.readInt16(i+e)!=this.bb.readInt16(t+e))continue t;s=this.vtables[e];break}}return s?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,s-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,r){const n=r?4:0;if(e){const t=e;if(this.prep(this.minalign,8+n),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const r=this.bb.capacity()-t,n=r-this.bb.readInt32(r);if(0==this.bb.readInt16(n+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,r){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(r,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let r=0;for(;r<t.length;){let n;const s=t.charCodeAt(r++);n=s<55296||s>=56320?s:(s<<10)+t.charCodeAt(r++)+-56613888,n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(63&n|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,r=this.space,n=this.bb.bytes();t<e.length;t++)n[r++]=e[t];return this.endVector()}createLong(t,e){return c.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let r=0;r<t.length;++r){const n=t[r];if(null===n)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(n))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class d{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new d).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new d).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):r.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,r.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,r,n,s,i,o,a,c,h,u,b){return d.startColumn(t),d.addName(t,e),d.addType(t,r),d.addTitle(t,n),d.addDescription(t,s),d.addWidth(t,i),d.addPrecision(t,o),d.addScale(t,a),d.addNullable(t,c),d.addUnique(t,h),d.addPrimaryKey(t,u),d.addMetadata(t,b),d.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,r,n,s,i,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,r),f.addName(t,n),f.addDescription(t,s),f.addWkt(t,i),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(u||(u={}));class p{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new p).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new p).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):u.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const r=this.bb.__offset(this.bb_pos,18);return r?(e||new d).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,u.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class _{constructor(t,e,r,n,s,i,o,a){this.geometryType=t,this.columns=e,this.featuresCount=r,this.indexNodeSize=n,this.crs=s,this.title=i,this.description=o,this.metadata=a}static fromByteBuffer(t){const r=p.getRootAsHeader(t),s=r.featuresCount().toFloat64(),i=r.indexNodeSize(),o=[];for(let t=0;t<r.columnsLength();t++){const n=r.columns(t);if(!n)throw new Error("Column unexpectedly missing");if(!n.name())throw new Error("Column name unexpectedly missing");o.push(new e(n.name(),n.type(),n.title(),n.description(),n.width(),n.precision(),n.scale(),n.nullable(),n.unique(),n.primaryKey()))}const a=r.crs(),c=a?new n(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new _(r.geometryType(),o,s,i,c,r.title(),r.description(),r.metadata())}}class y{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new y).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new y).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):u.Unknown}parts(t,e){const r=this.bb.__offset(this.bb_pos,18);return r?(e||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,u.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,r,n,s,i,o,a,c){return y.startGeometry(t),y.addEnds(t,e),y.addXy(t,r),y.addZ(t,n),y.addM(t,s),y.addT(t,i),y.addTm(t,o),y.addType(t,a),y.addParts(t,c),y.endGeometry(t)}}function g(t,e,r){if(0!==t.length)if(Array.isArray(t[0]))for(const n of t)g(n,e,r);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),r.push(t[2]))}function w(t,e){const r=[];for(let n=0;n<t.length;n+=2){const s=[t[n],t[n+1]];e&&s.push(e[n>>1]),r.push(s)}return r}function m(t){return t?u[t]:u.Unknown}function v(t){const e=t.coordinates,r=[],n=[];let s,i;const o=m(t.type);let a=0;switch(t.type){case"Point":g(e,r,n);break;case"MultiPoint":case"LineString":g(e,r,n);break;case"MultiLineString":case"Polygon":{const t=e;g(t,r,n),t.length>1&&(s=t.map(t=>a+=t.length));break}case"MultiPolygon":i=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(i=t.geometries.map(v))}return{xy:r,z:n.length>0?n:void 0,ends:s,type:o,parts:i}}function I(t,e){if(e===u.GeometryCollection){const r=[];for(let e=0;e<t.partsLength();e++){const n=t.parts(e),s=n.type();r.push(I(n,s))}return{type:u[e],geometries:r}}if(e===u.MultiPolygon){const r=[];for(let e=0;e<t.partsLength();e++)r.push(I(t.parts(e),u.Polygon));return{type:u[e],coordinates:r.map(t=>t.coordinates)}}const r=function(t,e){const r=t.xyArray(),n=t.zArray();switch(e){case u.Point:{const t=Array.from(r);return n&&t.push(n[0]),t}case u.MultiPoint:case u.LineString:return w(r,n);case u.MultiLineString:case u.Polygon:return function(t,e,r){if(!r||0===r.length)return[w(t,e)];let n=0;const s=Array.from(r).map(e=>t.slice(n,n=e<<1));let i;return e&&(n=0,i=Array.from(r).map(t=>e.slice(n,n=t))),s.map((t,e)=>w(t,i?i[e]:void 0))}(r,n,t.endsArray())}}(t,e);return{type:u[e],coordinates:r}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new y).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const r=this.bb.__offset(this.bb_pos,8);return r?(e||new d).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)t.addInt8(e[r]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,r,n){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,r),F.addColumns(t,n),F.endFeature(t)}}const O=new TextEncoder,x=new TextDecoder;function S(t,e,n){const s=n.columns,i=new l;let o=0,a=1024,c=new Uint8Array(a),h=new DataView(c.buffer);const u=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(c),c=e,h=new DataView(c.buffer,o)};if(s)for(let t=0;t<s.length;t++){const n=s[t],i=e[n.name];if(null!==i)switch(h.setUint16(o,t,!0),o+=2,n.type){case r.Bool:u(1),h.setUint8(o,i),o+=1;break;case r.Short:u(2),h.setInt16(o,i,!0),o+=2;break;case r.UShort:u(2),h.setUint16(o,i,!0),o+=2;break;case r.Int:u(4),h.setInt32(o,i,!0),o+=4;break;case r.UInt:u(4),h.setUint32(o,i,!0),o+=4;break;case r.Long:u(8),h.setBigInt64(o,BigInt(i),!0),o+=8;break;case r.Double:u(8),h.setFloat64(o,i,!0),o+=8;break;case r.DateTime:case r.String:{const t=O.encode(i);u(4),h.setUint32(o,t.length,!0),o+=4,u(t.length),c.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+n.type)}}let b=null;o>0&&(b=F.createPropertiesVector(i,c.slice(0,o)));const d=function t(e,r){const{xy:n,z:s,ends:i,parts:o,type:a}=r;if(o){const r=o.map(r=>t(e,r)),n=y.createPartsVector(e,r);return y.startGeometry(e),y.addParts(e,n),y.endGeometry(e)}const c=y.createXyVector(e,n);let h,u;return s&&(h=y.createZVector(e,s)),i&&(u=y.createEndsVector(e,i)),y.startGeometry(e),u&&y.addEnds(e,u),y.addXy(e,c),h&&y.addZ(e,h),y.addType(e,a),y.endGeometry(e)}(i,t);F.startFeature(i),F.addGeometry(i,d),b&&F.addProperties(i,b);const f=F.endFeature(i);return i.finishSizePrefixed(f),i.asUint8Array()}function U(t,e){const n=e.columns,s={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return n&&n.length>0&&(s.properties=function(t,e){const n={};if(!e||0===e.length)return n;const s=t.propertiesArray();if(!s)return n;const i=new DataView(s.buffer,s.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=i.getUint16(a,!0);a+=2;const o=e[t],c=o.name;switch(o.type){case r.Bool:n[c]=!!i.getUint8(a),a+=1;break;case r.Byte:n[c]=i.getInt8(a),a+=1;break;case r.UByte:n[c]=i.getUint8(a),a+=1;break;case r.Short:n[c]=i.getInt16(a,!0),a+=2;break;case r.UShort:n[c]=i.getUint16(a,!0),a+=2;break;case r.Int:n[c]=i.getInt32(a,!0),a+=4;break;case r.UInt:n[c]=i.getUint32(a,!0),a+=4;break;case r.Long:n[c]=Number(i.getBigInt64(a,!0)),a+=8;break;case r.ULong:n[c]=Number(i.getBigUint64(a,!0)),a+=8;break;case r.Double:n[c]=i.getFloat64(a,!0),a+=8;break;case r.DateTime:case r.String:{const t=i.getUint32(a,!0);a+=4,n[c]=x.decode(s.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return n}(t,n)),s}var P,L=new Uint8Array(0);function C(t,e){if(!t.length)return e;if(!e.length)return t;var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function E(t){this._source=t,this._array=L,this._index=0}E.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(r){return t._array=L,t._index=0,r.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:C(e,r.value)}}))},E.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,r=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var n=new Uint8Array(t);return n.set(this._array.subarray(this._index)),function s(){return e._source.read().then((function(i){return i.done?(e._array=L,e._index=0,r>0?n.subarray(0,r):null):r+i.value.length>=t?(e._array=i.value,e._index=t-r,n.set(i.value.subarray(0,t-r),r),n):(n.set(i.value,r),r+=i.value.length,s())}))}()},E.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(P||(P={}));class A{static debug(...t){this.log(P.Debug,...t)}static info(...t){this.log(P.Info,...t)}static warn(...t){this.log(P.Warn,...t)}static error(...t){this.log(P.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case P.Debug:console.debug(...e);break;case P.Info:console.info(...e);break;case P.Warn:console.warn(...e);break;case P.Error:console.error(...e)}}}function k(t,e){e=Math.min(Math.max(+e,2),65535);let r=t,n=r;do{r=Math.ceil(r/e),n+=r}while(1!==r);return 40*n}function j(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}A.logLevel=P.Info;const V=new Uint8Array([102,103,98,3,102,103,98,0]);class B{constructor(t,e,r,n){this.headerClient=t,this.header=e,this.headerLength=r,this.indexLength=n}static async open(t){const e=new T(t),r=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),n=2024+r;A.debug(`fetching header. minReqLength: ${n} (assumedHeaderLength: 2024, assumedIndexLength: ${r})`);{const t=new Uint8Array(await e.getRange(0,8,n,"header"));if(!t.every((t,e)=>V[e]===t))throw A.error(`bytes: ${t} != ${V}`),new Error("Not a FlatGeobuf file");A.debug("magic bytes look good")}let s;{const t=await e.getRange(8,4,n,"header");if(s=new DataView(t).getUint32(0,!0),s>10485760||s<8)throw new Error("Invalid header size");A.debug("headerLength: "+s)}const i=await e.getRange(12,s,n,"header"),o=new b(new Uint8Array(i)),a=_.fromByteBuffer(o),c=k(a.featuresCount,a.indexNodeSize);return A.debug("completed: opening http reader"),new B(e,a,s,c)}async*selectBbox(t){const e=this.lengthBeforeTree(),r=this.headerClient;A.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,r,n){class s{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:i,minY:o,maxX:a,maxY:c}=r,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let r=t,n=r;const s=[r];do{r=Math.ceil(r/e),n+=r,s.push(r)}while(1!==r);const i=[];r=n;for(const t of s)i.push(r-t),r-=t;i.reverse(),s.reverse();const o=[];for(let t=0;t<s.length;t++)o.push([i[t],i[t]+s[t]]);return o.reverse(),o}(t,e),u=h[0][0],b=[(()=>{const t=h.length-1;return new s([0,1],t)})()];for(A.debug(`starting stream search with queue: ${b}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=b.length;){const t=b.shift();A.debug(`popped node: ${t}, queueLength: ${b.length}`);let r=t.startNode();const l=r>=u,[,d]=h[t.level()],f=Math.min(t.endNode()+e,d),p=f-r,_=await n(40*r,40*p),y=new Float64Array(_),g=new Uint32Array(_);for(let e=r;e<f;e++){const n=5*(e-r);if(a<y[n+0])continue;if(c<y[n+1])continue;if(i>y[n+2])continue;if(o>y[n+3])continue;const h=g[8+(n<<1)],d=j(g[9+(n<<1)],h);if(l){A.debug("yielding feature"),yield[d,e-u];continue}const f=6553.6,p=b[b.length-1];if(void 0!==p&&p.level()==t.level()-1&&d<p.endNode()+f){A.debug(`Merging "nodeRange" request into existing range: ${p}, newOffset: ${p.endNode()} -> ${d}`),p.extendEndNodeToNewOffset(d);continue}let _=(()=>{let e=t.level()-1;return new s([d,d+1],e)})();void 0!==p&&p.level()==_.level()?A.debug(`Same level, but too far away. Pushing new request at offset: ${d} rather than merging with distant ${p}`):A.debug(`Pushing new level for ${_} onto queue with nearestNodeRange: ${p} since there's not already a range for this level.`),b.push(_)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,n){return r.getRange(e+t,n,0,"index")}))}lengthBeforeTree(){return V.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,r=t+this.lengthBeforeFeatures();let n;{const t=await this.featureClient().getRange(r,4,e,"feature length");n=new DataView(t).getUint32(0,!0)}A.debug(`featureOffset: ${r}, featureLength: ${n}`);const s=await this.featureClient().getRange(r+4,n,e,"feature data"),i=new Uint8Array(s),o=new Uint8Array(n+4);o.set(i,4);const a=new b(o);return a.setPosition(4),F.getRootAsFeature(a)}}class T{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new N(t):t}clone(){const t=new T(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,r,n){A.debug(`need Range: ${t}-${t+e-1}`);const s=t-this.head,i=s+e;if(s>=0&&i<this.buffer.byteLength)return A.debug(`slicing existing Range: ${s}-${i-1}`),this.buffer.slice(s,i);const o=Math.max(e,r);return this.buffer=await this.httpClient.getRange(t,o,n),this.head=t,this.buffer.slice(0,e)}}class N{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,r){this.requestsEverMade+=1,this.bytesEverRequested+=e;const n=`bytes=${t}-${t+e-1}`;return A.debug(`request: #${this.requestsEverMade}, purpose: ${r}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${n}`),(await fetch(this.url,{headers:{Range:n}})).arrayBuffer()}}async function M(t,e,r){let n=new Uint8Array(await t(4,"feature length"));if(0===n.byteLength)return;let s=new b(n);const i=s.readUint32(0);n=new Uint8Array(await t(i,"feature data"));const o=new Uint8Array(i+4);return o.set(n,4),s=new b(o),s.setPosition(4),r(F.getRootAsFeature(s),e)}function R(t){const e=new l;let r=null;t.columns&&(r=p.createColumnsVector(e,t.columns.map(t=>function(t,e){const r=t.createString(e.name);return d.startColumn(t),d.addName(t,r),d.addType(t,e.type),d.endColumn(t)}(e,t))));const n=e.createString("L1");p.startHeader(e),p.addFeaturesCount(e,new c(t.featuresCount,0)),p.addGeometryType(e,t.geometryType),p.addIndexNodeSize(e,0),r&&p.addColumns(e,r),p.addName(e,n);const s=p.endHeader(e);return e.finishSizePrefixed(s),e.asUint8Array()}t.deserialize=function(t,e,r){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,r){if(!t.subarray(0,7).every((t,e)=>V[e]===t))throw new Error("Not a FlatGeobuf file");const n=new b(t),s=n.readUint32(V.length);n.setPosition(V.length+4);const i=_.fromByteBuffer(n);r&&r(i);let o=V.length+4+s;const{indexNodeSize:a,featuresCount:c}=i;a>0&&(o+=k(c,a));const h=[];for(;o<n.capacity();){const t=n.readUint32(o);n.setPosition(o+4);const r=F.getRootAsFeature(n);h.push(e(r,i)),o+=4+t}return h}(t,U,e)}}(t,r):t instanceof ReadableStream?function(t,e){return async function*(t,e,r){const n="function"==typeof(s=t).slice?s:new E("function"==typeof s.read?s:s.getReader());var s;const i=async t=>await n.slice(t);let o=new Uint8Array(await i(8));if(!o.every((t,e)=>V[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await i(4));let a=new b(o);const c=a.readUint32(0);o=new Uint8Array(await i(c)),a=new b(o);const h=_.fromByteBuffer(a);r&&r(h);const{indexNodeSize:u,featuresCount:l}=h;if(u>0){const t=k(l,u);await i(t)}let d;for(;d=await M(i,h,e);)yield d}(t,U,e)}(t,r):function(t,e,r){return async function*(t,e,r,n){const s=await B.open(t);A.debug("opened reader"),n&&n(s.header);for await(const t of s.selectBbox(e)){const e=await s.readFeature(t[0]);yield r(e,s.header)}}(t,e,U,r)}(t,e,r)},t.serialize=function(t){return function(t){const n=function(t){const n=t.features[0],s=n.properties;let i=null;return s&&(i=Object.keys(s).map(t=>new e(t,function(t){if("boolean"==typeof t)return r.Bool;if("number"==typeof t)return t%1==0?r.Int:r.Double;if("string"==typeof t)return r.String;if(null===t)return r.String;throw new Error(`Unknown type (value '${t}')`)}(s[t]),null,null,-1,-1,-1,!0,!1,!1))),new _(m(n.geometry.type),i,t.features.length,0,null,null,null,null)}(t),s=R(n),i=t.features.map(t=>S(v(t.geometry),t.properties,n)),o=i.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(V.length+s.length+o);a.set(s,V.length);let c=V.length+s.length;for(const t of i)a.set(t,c),c+=t.length;return a.set(V),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=r=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},s=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var s=e&&e.prototype instanceof b?e:b,i=Object.create(s.prototype),o=new F(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return x()}for(r.method=s,r.arg=i;;){var o=r.delegate;if(o){var a=m(o,r);if(a){if(a===u)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,o),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var u={};function b(){}function l(){}function d(){}var f={};f[s]=function(){return this};var p=Object.getPrototypeOf,_=p&&p(p(O([])));_&&_!==e&&r.call(_,s)&&(f=_);var y=d.prototype=b.prototype=Object.create(f);function g(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(s,i){function o(){return new e((function(n,o){!function n(s,i,o,a){var c=h(t[s],t,i);if("throw"!==c.type){var u=c.arg,b=u.value;return b&&"object"==typeof b&&r.call(b,"__await")?e.resolve(b.__await).then((function(t){n("next",t,o,a)}),(function(t){n("throw",t,o,a)})):e.resolve(b).then((function(t){u.value=t,o(u)}),(function(t){return n("throw",t,o,a)}))}a(c.arg)}(s,i,n,o)}))}return n=n?n.then(o,o):o()}}function m(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,m(t,e),"throw"===e.method))return u;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,u;var s=n.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,u):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,u)}function v(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(v,this),this.reset(!0)}function O(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:x}}function x(){return{value:void 0,done:!0}}return l.prototype=y.constructor=d,d.constructor=l,l.displayName=a(d,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a(t,o,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,s,i){void 0===i&&(i=Promise);var o=new w(c(e,r,n,s),i);return t.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},g(y),a(y,o,"Generator"),y[s]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return o.type="throw",o.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var s=this.tryEntries.length-1;s>=0;--s){var i=this.tryEntries[s],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&r.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var i=s;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),u},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),u}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var s=n.arg;I(r)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(1),s=r.n(n),i=r(2),o=r.n(i),a=r(0),c=r.n(a),h=r(3);function u(t,e){if(0===t.byteLength)return[];var r=new Uint8Array(t);return Object(h.deserialize)(r).features}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var d,f=l(l({},{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.7",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}}),{},{parse:(d=s()(c.a.mark((function t(e,r){return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(e));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return d.apply(this,arguments)}),parseSync:u,parseInBatchesFromStream:function(t,e){return Object(h.deserializeStream)(t)},binary:!0}),p=r(4),_=r.n(p),y=r(5),g=r.n(y),w=r(6),m=r.n(w);function v(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}var I=new Map,F=function(){function t(){_()(this,t)}return g()(t,null,[{key:"onmessage",set:function(t){self.onmessage=function(e){if(O(e)){var r=e.data,n=r.type,s=r.payload;t(n,s)}}}},{key:"addEventListener",value:function(t){var e=I.get(t);e||(e=function(e){if(O(e)){var r=e.data,n=r.type,s=r.payload;t(n,s)}}),self.addEventListener("message",e)}},{key:"removeEventListener",value:function(t){var e=I.get(t);I.delete(t),self.removeEventListener("message",e)}},{key:"postMessage",value:function(t,e){if(self){var r={source:"loaders.gl",type:t,payload:e},n=function t(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,s=n||new Set;if(e){if(v(e))s.add(e);else if(v(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(r&&"object"===m()(e))for(var i in e)t(e[i],r,s)}else;return void 0===n?Array.from(s):[]}(e);self.postMessage(r,n)}}}]),t}();function O(t){var e=t.type,r=t.data;return"message"===e&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function x(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function S(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?x(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var U,P=0;function L(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var s=P++;F.addEventListener((function t(e,i){if(i.id===s)switch(e){case"done":F.removeEventListener(t),r(i.result);break;case"error":F.removeEventListener(t),n(i.error)}}));var i={id:s,input:t,options:e};F.postMessage("process",i)}))}function C(t){return E.apply(this,arguments)}function E(){return(E=s()(c.a.mark((function t(e){var r,n,s,i,o,a,h;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.loader,n=e.arrayBuffer,s=e.options,i=e.context,!r.parseSync&&!r.parse){t.next=6;break}o=n,a=r.parseSync||r.parse,t.next=13;break;case 6:if(!r.parseTextSync){t.next=12;break}h=new TextDecoder,o=h.decode(n),a=r.parseTextSync,t.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return s=S(S({},s),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),t.next=16,a(o,S({},s),i,r);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}U=f,"undefined"!=typeof self&&(F.onmessage=function(){var t=s()(c.a.mark((function t(e,r){var n,s,i,o,a;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="process"===t.t0?3:16;break;case 3:return t.prev=3,n=r.input,s=r.options,i=void 0===s?{}:s,t.next=7,C({loader:U,arrayBuffer:n,options:i,context:{parse:L}});case 7:o=t.sent,F.postMessage("done",{result:o}),t.next=15;break;case 11:t.prev=11,t.t1=t.catch(3),a=t.t1 instanceof Error?t.t1.message:"",F.postMessage("error",{error:a});case 15:return t.abrupt("break",16);case 16:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}())}]); | ||
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)r.d(n,s,function(e){return t[e]}.bind(null,s));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=8)}([function(t,e,r){t.exports=r(7)},function(t,e){function r(t,e,r,n,s,i,o){try{var a=t[i](o),c=a.value}catch(t){return void r(t)}a.done?e(c):Promise.resolve(c).then(n,s)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(s,i){var o=t.apply(e,n);function a(t){r(o,s,i,a,c,"next",t)}function c(t){r(o,s,i,a,c,"throw",t)}a(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){!function(t){"use strict";class e{constructor(t,e,r,n,s,i,o,a,c,h){this.name=t,this.type=e,this.title=r,this.description=n,this.width=s,this.precision=i,this.scale=o,this.nullable=a,this.unique=c,this.primary_key=h}}var r;!function(t){t[t.Byte=0]="Byte",t[t.UByte=1]="UByte",t[t.Bool=2]="Bool",t[t.Short=3]="Short",t[t.UShort=4]="UShort",t[t.Int=5]="Int",t[t.UInt=6]="UInt",t[t.Long=7]="Long",t[t.ULong=8]="ULong",t[t.Float=9]="Float",t[t.Double=10]="Double",t[t.String=11]="String",t[t.Json=12]="Json",t[t.DateTime=13]="DateTime",t[t.Binary=14]="Binary"}(r||(r={}));class n{constructor(t,e,r,n,s,i){this.org=t,this.code=e,this.name=r,this.description=n,this.wkt=s,this.code_string=i}}const s=new Int32Array(2),i=new Float32Array(s.buffer),o=new Float64Array(s.buffer),a=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];class c{constructor(t,e){this.low=0|t,this.high=0|e}static create(t,e){return 0==t&&0==e?c.ZERO:new c(t,e)}toFloat64(){return(this.low>>>0)+4294967296*this.high}equals(t){return this.low==t.low&&this.high==t.high}}var h,u;c.ZERO=new c(0,0),function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(h||(h={}));class b{constructor(t){this.bytes_=t,this.position_=0}static allocate(t){return new b(new Uint8Array(t))}clear(){this.position_=0}bytes(){return this.bytes_}position(){return this.position_}setPosition(t){this.position_=t}capacity(){return this.bytes_.length}readInt8(t){return this.readUint8(t)<<24>>24}readUint8(t){return this.bytes_[t]}readInt16(t){return this.readUint16(t)<<16>>16}readUint16(t){return this.bytes_[t]|this.bytes_[t+1]<<8}readInt32(t){return this.bytes_[t]|this.bytes_[t+1]<<8|this.bytes_[t+2]<<16|this.bytes_[t+3]<<24}readUint32(t){return this.readInt32(t)>>>0}readInt64(t){return new c(this.readInt32(t),this.readInt32(t+4))}readUint64(t){return new c(this.readUint32(t),this.readUint32(t+4))}readFloat32(t){return s[0]=this.readInt32(t),i[0]}readFloat64(t){return s[a?0:1]=this.readInt32(t),s[a?1:0]=this.readInt32(t+4),o[0]}writeInt8(t,e){this.bytes_[t]=e}writeUint8(t,e){this.bytes_[t]=e}writeInt16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeUint16(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8}writeInt32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeUint32(t,e){this.bytes_[t]=e,this.bytes_[t+1]=e>>8,this.bytes_[t+2]=e>>16,this.bytes_[t+3]=e>>24}writeInt64(t,e){this.writeInt32(t,e.low),this.writeInt32(t+4,e.high)}writeUint64(t,e){this.writeUint32(t,e.low),this.writeUint32(t+4,e.high)}writeFloat32(t,e){i[0]=e,this.writeInt32(t,s[0])}writeFloat64(t,e){o[0]=e,this.writeInt32(t,s[a?0:1]),this.writeInt32(t+4,s[a?1:0])}getBufferIdentifier(){if(this.bytes_.length<this.position_+4+4)throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.readInt8(this.position_+4+e));return t}__offset(t,e){const r=t-this.readInt32(t);return e<this.readInt16(r)?this.readInt16(r+e):0}__union(t,e){return t.bb_pos=e+this.readInt32(e),t.bb=this,t}__string(t,e){t+=this.readInt32(t);const r=this.readInt32(t);let n="",s=0;if(t+=4,e===h.UTF8_BYTES)return this.bytes_.subarray(t,t+r);for(;s<r;){let e;const r=this.readUint8(t+s++);if(r<192)e=r;else{const n=this.readUint8(t+s++);if(r<224)e=(31&r)<<6|63&n;else{const i=this.readUint8(t+s++);e=r<240?(15&r)<<12|(63&n)<<6|63&i:(7&r)<<18|(63&n)<<12|(63&i)<<6|63&this.readUint8(t+s++)}}e<65536?n+=String.fromCharCode(e):(e-=65536,n+=String.fromCharCode(55296+(e>>10),56320+(1023&e)))}return n}__union_with_string(t,e){return"string"==typeof t?this.__string(e):this.__union(t,e)}__indirect(t){return t+this.readInt32(t)}__vector(t){return t+this.readInt32(t)+4}__vector_len(t){return this.readInt32(t+this.readInt32(t))}__has_identifier(t){if(4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=0;e<4;e++)if(t.charCodeAt(e)!=this.readInt8(this.position()+4+e))return!1;return!0}createLong(t,e){return c.create(t,e)}createScalarList(t,e){const r=[];for(let n=0;n<e;++n)null!==t(n)&&r.push(t(n));return r}createObjList(t,e){const r=[];for(let n=0;n<e;++n){const e=t(n);null!==e&&r.push(e.unpack())}return r}}class l{constructor(t){let e;this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null,e=t||1024,this.bb=b.allocate(e),this.space=e}clear(){this.bb.clear(),this.space=this.bb.capacity(),this.minalign=1,this.vtable=null,this.vtable_in_use=0,this.isNested=!1,this.object_start=0,this.vtables=[],this.vector_num_elems=0,this.force_defaults=!1,this.string_maps=null}forceDefaults(t){this.force_defaults=t}dataBuffer(){return this.bb}asUint8Array(){return this.bb.bytes().subarray(this.bb.position(),this.bb.position()+this.offset())}prep(t,e){t>this.minalign&&(this.minalign=t);const r=1+~(this.bb.capacity()-this.space+e)&t-1;for(;this.space<r+t+e;){const t=this.bb.capacity();this.bb=l.growByteBuffer(this.bb),this.space+=this.bb.capacity()-t}this.pad(r)}pad(t){for(let e=0;e<t;e++)this.bb.writeInt8(--this.space,0)}writeInt8(t){this.bb.writeInt8(this.space-=1,t)}writeInt16(t){this.bb.writeInt16(this.space-=2,t)}writeInt32(t){this.bb.writeInt32(this.space-=4,t)}writeInt64(t){this.bb.writeInt64(this.space-=8,t)}writeFloat32(t){this.bb.writeFloat32(this.space-=4,t)}writeFloat64(t){this.bb.writeFloat64(this.space-=8,t)}addInt8(t){this.prep(1,0),this.writeInt8(t)}addInt16(t){this.prep(2,0),this.writeInt16(t)}addInt32(t){this.prep(4,0),this.writeInt32(t)}addInt64(t){this.prep(8,0),this.writeInt64(t)}addFloat32(t){this.prep(4,0),this.writeFloat32(t)}addFloat64(t){this.prep(8,0),this.writeFloat64(t)}addFieldInt8(t,e,r){(this.force_defaults||e!=r)&&(this.addInt8(e),this.slot(t))}addFieldInt16(t,e,r){(this.force_defaults||e!=r)&&(this.addInt16(e),this.slot(t))}addFieldInt32(t,e,r){(this.force_defaults||e!=r)&&(this.addInt32(e),this.slot(t))}addFieldInt64(t,e,r){!this.force_defaults&&e.equals(r)||(this.addInt64(e),this.slot(t))}addFieldFloat32(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat32(e),this.slot(t))}addFieldFloat64(t,e,r){(this.force_defaults||e!=r)&&(this.addFloat64(e),this.slot(t))}addFieldOffset(t,e,r){(this.force_defaults||e!=r)&&(this.addOffset(e),this.slot(t))}addFieldStruct(t,e,r){e!=r&&(this.nested(e),this.slot(t))}nested(t){if(t!=this.offset())throw new Error("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new Error("FlatBuffers: object serialization must not be nested.")}slot(t){null!==this.vtable&&(this.vtable[t]=this.offset())}offset(){return this.bb.capacity()-this.space}static growByteBuffer(t){const e=t.capacity();if(3221225472&e)throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");const r=e<<1,n=b.allocate(r);return n.setPosition(r-e),n.bytes().set(t.bytes(),r-e),n}addOffset(t){this.prep(4,0),this.writeInt32(this.offset()-t+4)}startObject(t){this.notNested(),null==this.vtable&&(this.vtable=[]),this.vtable_in_use=t;for(let e=0;e<t;e++)this.vtable[e]=0;this.isNested=!0,this.object_start=this.offset()}endObject(){if(null==this.vtable||!this.isNested)throw new Error("FlatBuffers: endObject called without startObject");this.addInt32(0);const t=this.offset();let e=this.vtable_in_use-1;for(;e>=0&&0==this.vtable[e];e--);const r=e+1;for(;e>=0;e--)this.addInt16(0!=this.vtable[e]?t-this.vtable[e]:0);this.addInt16(t-this.object_start);const n=2*(r+2);this.addInt16(n);let s=0;const i=this.space;t:for(e=0;e<this.vtables.length;e++){const t=this.bb.capacity()-this.vtables[e];if(n==this.bb.readInt16(t)){for(let e=2;e<n;e+=2)if(this.bb.readInt16(i+e)!=this.bb.readInt16(t+e))continue t;s=this.vtables[e];break}}return s?(this.space=this.bb.capacity()-t,this.bb.writeInt32(this.space,s-t)):(this.vtables.push(this.offset()),this.bb.writeInt32(this.bb.capacity()-t,this.offset()-t)),this.isNested=!1,t}finish(t,e,r){const n=r?4:0;if(e){const t=e;if(this.prep(this.minalign,8+n),4!=t.length)throw new Error("FlatBuffers: file identifier must be length 4");for(let e=3;e>=0;e--)this.writeInt8(t.charCodeAt(e))}this.prep(this.minalign,4+n),this.addOffset(t),n&&this.addInt32(this.bb.capacity()-this.space),this.bb.setPosition(this.space)}finishSizePrefixed(t,e){this.finish(t,e,!0)}requiredField(t,e){const r=this.bb.capacity()-t,n=r-this.bb.readInt32(r);if(0==this.bb.readInt16(n+e))throw new Error("FlatBuffers: field "+e+" must be set")}startVector(t,e,r){this.notNested(),this.vector_num_elems=e,this.prep(4,t*e),this.prep(r,t*e)}endVector(){return this.writeInt32(this.vector_num_elems),this.offset()}createSharedString(t){if(!t)return 0;if(this.string_maps||(this.string_maps=new Map),this.string_maps.has(t))return this.string_maps.get(t);const e=this.createString(t);return this.string_maps.set(t,e),e}createString(t){if(!t)return 0;let e;if(t instanceof Uint8Array)e=t;else{e=[];let r=0;for(;r<t.length;){let n;const s=t.charCodeAt(r++);n=s<55296||s>=56320?s:(s<<10)+t.charCodeAt(r++)+-56613888,n<128?e.push(n):(n<2048?e.push(n>>6&31|192):(n<65536?e.push(n>>12&15|224):e.push(n>>18&7|240,n>>12&63|128),e.push(n>>6&63|128)),e.push(63&n|128))}}this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length);for(let t=0,r=this.space,n=this.bb.bytes();t<e.length;t++)n[r++]=e[t];return this.endVector()}createLong(t,e){return c.create(t,e)}createObjectOffset(t){return null===t?0:"string"==typeof t?this.createString(t):t.pack(this)}createObjectOffsetList(t){const e=[];for(let r=0;r<t.length;++r){const n=t[r];if(null===n)throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");e.push(this.createObjectOffset(n))}return e}createStructOffsetList(t,e){return e(this,t.length),this.createObjectOffsetList(t),this.endVector()}}class d{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsColumn(t,e){return(e||new d).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsColumn(t,e){return t.setPosition(t.position()+4),(e||new d).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):r.Byte}title(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){const t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){const t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){const t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){const e=this.bb.__offset(this.bb_pos,24);return e?this.bb.__string(this.bb_pos+e,t):null}static startColumn(t){t.startObject(11)}static addName(t,e){t.addFieldOffset(0,e,0)}static addType(t,e){t.addFieldInt8(1,e,r.Byte)}static addTitle(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWidth(t,e){t.addFieldInt32(4,e,-1)}static addPrecision(t,e){t.addFieldInt32(5,e,-1)}static addScale(t,e){t.addFieldInt32(6,e,-1)}static addNullable(t,e){t.addFieldInt8(7,+e,1)}static addUnique(t,e){t.addFieldInt8(8,+e,0)}static addPrimaryKey(t,e){t.addFieldInt8(9,+e,0)}static addMetadata(t,e){t.addFieldOffset(10,e,0)}static endColumn(t){const e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,r,n,s,i,o,a,c,h,u,b){return d.startColumn(t),d.addName(t,e),d.addType(t,r),d.addTitle(t,n),d.addDescription(t,s),d.addWidth(t,i),d.addPrecision(t,o),d.addScale(t,a),d.addNullable(t,c),d.addUnique(t,h),d.addPrimaryKey(t,u),d.addMetadata(t,b),d.endColumn(t)}}class f{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new f).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new f).__init(t.readInt32(t.position())+t.position(),t)}org(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.__string(this.bb_pos+e,t):null}static startCrs(t){t.startObject(6)}static addOrg(t,e){t.addFieldOffset(0,e,0)}static addCode(t,e){t.addFieldInt32(1,e,0)}static addName(t,e){t.addFieldOffset(2,e,0)}static addDescription(t,e){t.addFieldOffset(3,e,0)}static addWkt(t,e){t.addFieldOffset(4,e,0)}static addCodeString(t,e){t.addFieldOffset(5,e,0)}static endCrs(t){return t.endObject()}static createCrs(t,e,r,n,s,i,o){return f.startCrs(t),f.addOrg(t,e),f.addCode(t,r),f.addName(t,n),f.addDescription(t,s),f.addWkt(t,i),f.addCodeString(t,o),f.endCrs(t)}}!function(t){t[t.Unknown=0]="Unknown",t[t.Point=1]="Point",t[t.LineString=2]="LineString",t[t.Polygon=3]="Polygon",t[t.MultiPoint=4]="MultiPoint",t[t.MultiLineString=5]="MultiLineString",t[t.MultiPolygon=6]="MultiPolygon",t[t.GeometryCollection=7]="GeometryCollection",t[t.CircularString=8]="CircularString",t[t.CompoundCurve=9]="CompoundCurve",t[t.CurvePolygon=10]="CurvePolygon",t[t.MultiCurve=11]="MultiCurve",t[t.MultiSurface=12]="MultiSurface",t[t.Curve=13]="Curve",t[t.Surface=14]="Surface",t[t.PolyhedralSurface=15]="PolyhedralSurface",t[t.TIN=16]="TIN",t[t.Triangle=17]="Triangle"}(u||(u={}));class p{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new p).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new p).__init(t.readInt32(t.position())+t.position(),t)}name(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}geometryType(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):u.Unknown}hasZ(){const t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){const t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){const t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){const t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){const r=this.bb.__offset(this.bb_pos,18);return r?(e||new d).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){const t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):this.bb.createLong(0,0)}indexNodeSize(){const t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){const e=this.bb.__offset(this.bb_pos,24);return e?(t||new f).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){const e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){const e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){const e=this.bb.__offset(this.bb_pos,30);return e?this.bb.__string(this.bb_pos+e,t):null}static startHeader(t){t.startObject(14)}static addName(t,e){t.addFieldOffset(0,e,0)}static addEnvelope(t,e){t.addFieldOffset(1,e,0)}static createEnvelopeVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startEnvelopeVector(t,e){t.startVector(8,e,8)}static addGeometryType(t,e){t.addFieldInt8(2,e,u.Unknown)}static addHasZ(t,e){t.addFieldInt8(3,+e,0)}static addHasM(t,e){t.addFieldInt8(4,+e,0)}static addHasT(t,e){t.addFieldInt8(5,+e,0)}static addHasTm(t,e){t.addFieldInt8(6,+e,0)}static addColumns(t,e){t.addFieldOffset(7,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static addFeaturesCount(t,e){t.addFieldInt64(8,e,t.createLong(0,0))}static addIndexNodeSize(t,e){t.addFieldInt16(9,e,16)}static addCrs(t,e){t.addFieldOffset(10,e,0)}static addTitle(t,e){t.addFieldOffset(11,e,0)}static addDescription(t,e){t.addFieldOffset(12,e,0)}static addMetadata(t,e){t.addFieldOffset(13,e,0)}static endHeader(t){return t.endObject()}static finishHeaderBuffer(t,e){t.finish(e)}static finishSizePrefixedHeaderBuffer(t,e){t.finish(e,void 0,!0)}}class _{constructor(t,e,r,n,s,i,o,a){this.geometryType=t,this.columns=e,this.featuresCount=r,this.indexNodeSize=n,this.crs=s,this.title=i,this.description=o,this.metadata=a}static fromByteBuffer(t){const r=p.getRootAsHeader(t),s=r.featuresCount().toFloat64(),i=r.indexNodeSize(),o=[];for(let t=0;t<r.columnsLength();t++){const n=r.columns(t);if(!n)throw new Error("Column unexpectedly missing");if(!n.name())throw new Error("Column name unexpectedly missing");o.push(new e(n.name(),n.type(),n.title(),n.description(),n.width(),n.precision(),n.scale(),n.nullable(),n.unique(),n.primaryKey()))}const a=r.crs(),c=a?new n(a.org(),a.code(),a.name(),a.description(),a.wkt(),a.codeString()):null;return new _(r.geometryType(),o,s,i,c,r.title(),r.description(),r.metadata())}}class y{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new y).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new y).__init(t.readInt32(t.position())+t.position(),t)}ends(t){const e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){const t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){const t=this.bb.__offset(this.bb_pos,4);return t?new Uint32Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}xy(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}z(t){const e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){const t=this.bb.__offset(this.bb_pos,8);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}m(t){const e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){const t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){const t=this.bb.__offset(this.bb_pos,10);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}t(t){const e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){const t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){const t=this.bb.__offset(this.bb_pos,12);return t?new Float64Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}tm(t){const e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):this.bb.createLong(0,0)}tmLength(){const t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){const t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):u.Unknown}parts(t,e){const r=this.bb.__offset(this.bb_pos,18);return r?(e||new y).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}partsLength(){const t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}static startGeometry(t){t.startObject(8)}static addEnds(t,e){t.addFieldOffset(0,e,0)}static createEndsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addInt32(e[r]);return t.endVector()}static startEndsVector(t,e){t.startVector(4,e,4)}static addXy(t,e){t.addFieldOffset(1,e,0)}static createXyVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startXyVector(t,e){t.startVector(8,e,8)}static addZ(t,e){t.addFieldOffset(2,e,0)}static createZVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startZVector(t,e){t.startVector(8,e,8)}static addM(t,e){t.addFieldOffset(3,e,0)}static createMVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startMVector(t,e){t.startVector(8,e,8)}static addT(t,e){t.addFieldOffset(4,e,0)}static createTVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addFloat64(e[r]);return t.endVector()}static startTVector(t,e){t.startVector(8,e,8)}static addTm(t,e){t.addFieldOffset(5,e,0)}static createTmVector(t,e){t.startVector(8,e.length,8);for(let r=e.length-1;r>=0;r--)t.addInt64(e[r]);return t.endVector()}static startTmVector(t,e){t.startVector(8,e,8)}static addType(t,e){t.addFieldInt8(6,e,u.Unknown)}static addParts(t,e){t.addFieldOffset(7,e,0)}static createPartsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startPartsVector(t,e){t.startVector(4,e,4)}static endGeometry(t){return t.endObject()}static createGeometry(t,e,r,n,s,i,o,a,c){return y.startGeometry(t),y.addEnds(t,e),y.addXy(t,r),y.addZ(t,n),y.addM(t,s),y.addT(t,i),y.addTm(t,o),y.addType(t,a),y.addParts(t,c),y.endGeometry(t)}}function g(t,e,r){if(0!==t.length)if(Array.isArray(t[0]))for(const n of t)g(n,e,r);else 2===t.length?e.push(...t):(e.push(t[0],t[1]),r.push(t[2]))}function w(t,e){const r=[];for(let n=0;n<t.length;n+=2){const s=[t[n],t[n+1]];e&&s.push(e[n>>1]),r.push(s)}return r}function m(t){return t?u[t]:u.Unknown}function v(t){const e=t.coordinates,r=[],n=[];let s,i;const o=m(t.type);let a=0;switch(t.type){case"Point":g(e,r,n);break;case"MultiPoint":case"LineString":g(e,r,n);break;case"MultiLineString":case"Polygon":{const t=e;g(t,r,n),t.length>1&&(s=t.map(t=>a+=t.length));break}case"MultiPolygon":i=e.map(t=>({type:"Polygon",coordinates:t})).map(v);break;case"GeometryCollection":t.geometries&&(i=t.geometries.map(v))}return{xy:r,z:n.length>0?n:void 0,ends:s,type:o,parts:i}}function I(t,e){if(e===u.GeometryCollection){const r=[];for(let e=0;e<t.partsLength();e++){const n=t.parts(e),s=n.type();r.push(I(n,s))}return{type:u[e],geometries:r}}if(e===u.MultiPolygon){const r=[];for(let e=0;e<t.partsLength();e++)r.push(I(t.parts(e),u.Polygon));return{type:u[e],coordinates:r.map(t=>t.coordinates)}}const r=function(t,e){const r=t.xyArray(),n=t.zArray();switch(e){case u.Point:{const t=Array.from(r);return n&&t.push(n[0]),t}case u.MultiPoint:case u.LineString:return w(r,n);case u.MultiLineString:case u.Polygon:return function(t,e,r){if(!r||0===r.length)return[w(t,e)];let n=0;const s=Array.from(r).map(e=>t.slice(n,n=e<<1));let i;return e&&(n=0,i=Array.from(r).map(t=>e.slice(n,n=t))),s.map((t,e)=>w(t,i?i[e]:void 0))}(r,n,t.endsArray())}}(t,e);return{type:u[e],coordinates:r}}class F{constructor(){this.bb=null,this.bb_pos=0}__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new F).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new F).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){const e=this.bb.__offset(this.bb_pos,4);return e?(t||new y).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){const e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){const t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){const t=this.bb.__offset(this.bb_pos,6);return t?new Uint8Array(this.bb.bytes().buffer,this.bb.bytes().byteOffset+this.bb.__vector(this.bb_pos+t),this.bb.__vector_len(this.bb_pos+t)):null}columns(t,e){const r=this.bb.__offset(this.bb_pos,8);return r?(e||new d).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){const t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}static startFeature(t){t.startObject(3)}static addGeometry(t,e){t.addFieldOffset(0,e,0)}static addProperties(t,e){t.addFieldOffset(1,e,0)}static createPropertiesVector(t,e){t.startVector(1,e.length,1);for(let r=e.length-1;r>=0;r--)t.addInt8(e[r]);return t.endVector()}static startPropertiesVector(t,e){t.startVector(1,e,1)}static addColumns(t,e){t.addFieldOffset(2,e,0)}static createColumnsVector(t,e){t.startVector(4,e.length,4);for(let r=e.length-1;r>=0;r--)t.addOffset(e[r]);return t.endVector()}static startColumnsVector(t,e){t.startVector(4,e,4)}static endFeature(t){return t.endObject()}static finishFeatureBuffer(t,e){t.finish(e)}static finishSizePrefixedFeatureBuffer(t,e){t.finish(e,void 0,!0)}static createFeature(t,e,r,n){return F.startFeature(t),F.addGeometry(t,e),F.addProperties(t,r),F.addColumns(t,n),F.endFeature(t)}}const O=new TextEncoder,x=new TextDecoder;function S(t,e,n){const s=n.columns,i=new l;let o=0,a=1024,c=new Uint8Array(a),h=new DataView(c.buffer);const u=function(t){if(o+t<a)return;a*=2;const e=new Uint8Array(a);e.set(c),c=e,h=new DataView(c.buffer,o)};if(s)for(let t=0;t<s.length;t++){const n=s[t],i=e[n.name];if(null!==i)switch(h.setUint16(o,t,!0),o+=2,n.type){case r.Bool:u(1),h.setUint8(o,i),o+=1;break;case r.Short:u(2),h.setInt16(o,i,!0),o+=2;break;case r.UShort:u(2),h.setUint16(o,i,!0),o+=2;break;case r.Int:u(4),h.setInt32(o,i,!0),o+=4;break;case r.UInt:u(4),h.setUint32(o,i,!0),o+=4;break;case r.Long:u(8),h.setBigInt64(o,BigInt(i),!0),o+=8;break;case r.Double:u(8),h.setFloat64(o,i,!0),o+=8;break;case r.DateTime:case r.String:{const t=O.encode(i);u(4),h.setUint32(o,t.length,!0),o+=4,u(t.length),c.set(t,o),o+=t.length;break}default:throw new Error("Unknown type "+n.type)}}let b=null;o>0&&(b=F.createPropertiesVector(i,c.slice(0,o)));const d=function t(e,r){const{xy:n,z:s,ends:i,parts:o,type:a}=r;if(o){const r=o.map(r=>t(e,r)),n=y.createPartsVector(e,r);return y.startGeometry(e),y.addParts(e,n),y.endGeometry(e)}const c=y.createXyVector(e,n);let h,u;return s&&(h=y.createZVector(e,s)),i&&(u=y.createEndsVector(e,i)),y.startGeometry(e),u&&y.addEnds(e,u),y.addXy(e,c),h&&y.addZ(e,h),y.addType(e,a),y.endGeometry(e)}(i,t);F.startFeature(i),F.addGeometry(i,d),b&&F.addProperties(i,b);const f=F.endFeature(i);return i.finishSizePrefixed(f),i.asUint8Array()}function U(t,e){const n=e.columns,s={type:"Feature",geometry:I(t.geometry(),e.geometryType)};return n&&n.length>0&&(s.properties=function(t,e){const n={};if(!e||0===e.length)return n;const s=t.propertiesArray();if(!s)return n;const i=new DataView(s.buffer,s.byteOffset),o=t.propertiesLength();let a=0;for(;a<o;){const t=i.getUint16(a,!0);a+=2;const o=e[t],c=o.name;switch(o.type){case r.Bool:n[c]=!!i.getUint8(a),a+=1;break;case r.Byte:n[c]=i.getInt8(a),a+=1;break;case r.UByte:n[c]=i.getUint8(a),a+=1;break;case r.Short:n[c]=i.getInt16(a,!0),a+=2;break;case r.UShort:n[c]=i.getUint16(a,!0),a+=2;break;case r.Int:n[c]=i.getInt32(a,!0),a+=4;break;case r.UInt:n[c]=i.getUint32(a,!0),a+=4;break;case r.Long:n[c]=Number(i.getBigInt64(a,!0)),a+=8;break;case r.ULong:n[c]=Number(i.getBigUint64(a,!0)),a+=8;break;case r.Double:n[c]=i.getFloat64(a,!0),a+=8;break;case r.DateTime:case r.String:{const t=i.getUint32(a,!0);a+=4,n[c]=x.decode(s.subarray(a,a+t)),a+=t;break}default:throw new Error("Unknown type "+o.type)}}return n}(t,n)),s}var P,L=new Uint8Array(0);function C(t,e){if(!t.length)return e;if(!e.length)return t;var r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),r}function E(t){this._source=t,this._array=L,this._index=0}E.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then((function(r){return t._array=L,t._index=0,r.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:C(e,r.value)}}))},E.prototype.slice=function(t){if((t|=0)<0)throw new Error("invalid length");var e=this,r=this._array.length-this._index;if(this._index+t<=this._array.length)return Promise.resolve(this._array.subarray(this._index,this._index+=t));var n=new Uint8Array(t);return n.set(this._array.subarray(this._index)),function s(){return e._source.read().then((function(i){return i.done?(e._array=L,e._index=0,r>0?n.subarray(0,r):null):r+i.value.length>=t?(e._array=i.value,e._index=t-r,n.set(i.value.subarray(0,t-r),r),n):(n.set(i.value,r),r+=i.value.length,s())}))}()},E.prototype.cancel=function(){return this._source.cancel()},function(t){t[t.Debug=0]="Debug",t[t.Info=1]="Info",t[t.Warn=2]="Warn",t[t.Error=3]="Error"}(P||(P={}));class A{static debug(...t){this.log(P.Debug,...t)}static info(...t){this.log(P.Info,...t)}static warn(...t){this.log(P.Warn,...t)}static error(...t){this.log(P.Error,...t)}static log(t,...e){if(!(this.logLevel>t))switch(t){case P.Debug:console.debug(...e);break;case P.Info:console.info(...e);break;case P.Warn:console.warn(...e);break;case P.Error:console.error(...e)}}}function k(t,e){e=Math.min(Math.max(+e,2),65535);let r=t,n=r;do{r=Math.ceil(r/e),n+=r}while(1!==r);return 40*n}function j(t,e){if(0!=(4293918720&t))throw Error("integer is too large to be safely represented");return e+t*2**32}A.logLevel=P.Info;const V=new Uint8Array([102,103,98,3,102,103,98,0]);class B{constructor(t,e,r,n){this.headerClient=t,this.header=e,this.headerLength=r,this.indexLength=n}static async open(t){const e=new T(t),r=(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})(),n=2024+r;A.debug(`fetching header. minReqLength: ${n} (assumedHeaderLength: 2024, assumedIndexLength: ${r})`);{const t=new Uint8Array(await e.getRange(0,8,n,"header"));if(!t.every((t,e)=>V[e]===t))throw A.error(`bytes: ${t} != ${V}`),new Error("Not a FlatGeobuf file");A.debug("magic bytes look good")}let s;{const t=await e.getRange(8,4,n,"header");if(s=new DataView(t).getUint32(0,!0),s>10485760||s<8)throw new Error("Invalid header size");A.debug("headerLength: "+s)}const i=await e.getRange(12,s,n,"header"),o=new b(new Uint8Array(i)),a=_.fromByteBuffer(o),c=k(a.featuresCount,a.indexNodeSize);return A.debug("completed: opening http reader"),new B(e,a,s,c)}async*selectBbox(t){const e=this.lengthBeforeTree(),r=this.headerClient;A.debug("starting: selectBbox, traversing index. lengthBeforeTree: "+e),yield*async function*(t,e,r,n){class s{constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNode(){return this.nodes[0]}endNode(){return this.nodes[1]}extendEndNodeToNewOffset(t){console.assert(t>this.nodes[1]),this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}const{minX:i,minY:o,maxX:a,maxY:c}=r,h=function(t,e){if(e<2)throw new Error("Node size must be at least 2");if(0===t)throw new Error("Number of items must be greater than 0");let r=t,n=r;const s=[r];do{r=Math.ceil(r/e),n+=r,s.push(r)}while(1!==r);const i=[];r=n;for(const t of s)i.push(r-t),r-=t;i.reverse(),s.reverse();const o=[];for(let t=0;t<s.length;t++)o.push([i[t],i[t]+s[t]]);return o.reverse(),o}(t,e),u=h[0][0],b=[(()=>{const t=h.length-1;return new s([0,1],t)})()];for(A.debug(`starting stream search with queue: ${b}, numItems: ${t}, nodeSize: ${e}, levelBounds: ${h}`);0!=b.length;){const t=b.shift();A.debug(`popped node: ${t}, queueLength: ${b.length}`);let r=t.startNode();const l=r>=u,[,d]=h[t.level()],f=Math.min(t.endNode()+e,d),p=f-r,_=await n(40*r,40*p),y=new Float64Array(_),g=new Uint32Array(_);for(let e=r;e<f;e++){const n=5*(e-r);if(a<y[n+0])continue;if(c<y[n+1])continue;if(i>y[n+2])continue;if(o>y[n+3])continue;const h=g[8+(n<<1)],d=j(g[9+(n<<1)],h);if(l){A.debug("yielding feature"),yield[d,e-u];continue}const f=6553.6,p=b[b.length-1];if(void 0!==p&&p.level()==t.level()-1&&d<p.endNode()+f){A.debug(`Merging "nodeRange" request into existing range: ${p}, newOffset: ${p.endNode()} -> ${d}`),p.extendEndNodeToNewOffset(d);continue}let _=(()=>{let e=t.level()-1;return new s([d,d+1],e)})();void 0!==p&&p.level()==_.level()?A.debug(`Same level, but too far away. Pushing new request at offset: ${d} rather than merging with distant ${p}`):A.debug(`Pushing new level for ${_} onto queue with nearestNodeRange: ${p} since there's not already a range for this level.`),b.push(_)}}}(this.header.featuresCount,this.header.indexNodeSize,t,(async function(t,n){return r.getRange(e+t,n,0,"index")}))}lengthBeforeTree(){return V.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}featureClient(){return void 0===this._featureClient&&(this._featureClient=this.headerClient.clone()),this._featureClient}async readFeature(t){const e=131072,r=t+this.lengthBeforeFeatures();let n;{const t=await this.featureClient().getRange(r,4,e,"feature length");n=new DataView(t).getUint32(0,!0)}A.debug(`featureOffset: ${r}, featureLength: ${n}`);const s=await this.featureClient().getRange(r+4,n,e,"feature data"),i=new Uint8Array(s),o=new Uint8Array(n+4);o.set(i,4);const a=new b(o);return a.setPosition(4),F.getRootAsFeature(a)}}class T{constructor(t){this.buffer=new ArrayBuffer(0),this.head=0,this.httpClient="string"==typeof t?new N(t):t}clone(){const t=new T(this.httpClient);return t.buffer=this.buffer.slice(0),t.head=this.head,t}async getRange(t,e,r,n){A.debug(`need Range: ${t}-${t+e-1}`);const s=t-this.head,i=s+e;if(s>=0&&i<this.buffer.byteLength)return A.debug(`slicing existing Range: ${s}-${i-1}`),this.buffer.slice(s,i);const o=Math.max(e,r);return this.buffer=await this.httpClient.getRange(t,o,n),this.head=t,this.buffer.slice(0,e)}}class N{constructor(t){this.requestsEverMade=0,this.bytesEverRequested=0,this.url=t}async getRange(t,e,r){this.requestsEverMade+=1,this.bytesEverRequested+=e;const n=`bytes=${t}-${t+e-1}`;return A.debug(`request: #${this.requestsEverMade}, purpose: ${r}), bytes: (this_request: ${e}, ever: ${this.bytesEverRequested}), Range: ${n}`),(await fetch(this.url,{headers:{Range:n}})).arrayBuffer()}}async function M(t,e,r){let n=new Uint8Array(await t(4,"feature length"));if(0===n.byteLength)return;let s=new b(n);const i=s.readUint32(0);n=new Uint8Array(await t(i,"feature data"));const o=new Uint8Array(i+4);return o.set(n,4),s=new b(o),s.setPosition(4),r(F.getRootAsFeature(s),e)}function R(t){const e=new l;let r=null;t.columns&&(r=p.createColumnsVector(e,t.columns.map(t=>function(t,e){const r=t.createString(e.name);return d.startColumn(t),d.addName(t,r),d.addType(t,e.type),d.endColumn(t)}(e,t))));const n=e.createString("L1");p.startHeader(e),p.addFeaturesCount(e,new c(t.featuresCount,0)),p.addGeometryType(e,t.geometryType),p.addIndexNodeSize(e,0),r&&p.addColumns(e,r),p.addName(e,n);const s=p.endHeader(e);return e.finishSizePrefixed(s),e.asUint8Array()}t.deserialize=function(t,e,r){return t instanceof Uint8Array?function(t,e){return{type:"FeatureCollection",features:function(t,e,r){if(!t.subarray(0,7).every((t,e)=>V[e]===t))throw new Error("Not a FlatGeobuf file");const n=new b(t),s=n.readUint32(V.length);n.setPosition(V.length+4);const i=_.fromByteBuffer(n);r&&r(i);let o=V.length+4+s;const{indexNodeSize:a,featuresCount:c}=i;a>0&&(o+=k(c,a));const h=[];for(;o<n.capacity();){const t=n.readUint32(o);n.setPosition(o+4);const r=F.getRootAsFeature(n);h.push(e(r,i)),o+=4+t}return h}(t,U,e)}}(t,r):t instanceof ReadableStream?function(t,e){return async function*(t,e,r){const n="function"==typeof(s=t).slice?s:new E("function"==typeof s.read?s:s.getReader());var s;const i=async t=>await n.slice(t);let o=new Uint8Array(await i(8));if(!o.every((t,e)=>V[e]===t))throw new Error("Not a FlatGeobuf file");o=new Uint8Array(await i(4));let a=new b(o);const c=a.readUint32(0);o=new Uint8Array(await i(c)),a=new b(o);const h=_.fromByteBuffer(a);r&&r(h);const{indexNodeSize:u,featuresCount:l}=h;if(u>0){const t=k(l,u);await i(t)}let d;for(;d=await M(i,h,e);)yield d}(t,U,e)}(t,r):function(t,e,r){return async function*(t,e,r,n){const s=await B.open(t);A.debug("opened reader"),n&&n(s.header);for await(const t of s.selectBbox(e)){const e=await s.readFeature(t[0]);yield r(e,s.header)}}(t,e,U,r)}(t,e,r)},t.serialize=function(t){return function(t){const n=function(t){const n=t.features[0],s=n.properties;let i=null;return s&&(i=Object.keys(s).map(t=>new e(t,function(t){if("boolean"==typeof t)return r.Bool;if("number"==typeof t)return t%1==0?r.Int:r.Double;if("string"==typeof t)return r.String;if(null===t)return r.String;throw new Error(`Unknown type (value '${t}')`)}(s[t]),null,null,-1,-1,-1,!0,!1,!1))),new _(m(n.geometry.type),i,t.features.length,0,null,null,null,null)}(t),s=R(n),i=t.features.map(t=>S(v(t.geometry),t.properties,n)),o=i.map(t=>t.length).reduce((t,e)=>t+e),a=new Uint8Array(V.length+s.length+o);a.set(s,V.length);let c=V.length+s.length;for(const t of i)a.set(t,c),c+=t.length;return a.set(V),a}(t)},Object.defineProperty(t,"__esModule",{value:!0})}(e)},function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=r=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),r(e)}t.exports=r,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,r){var n=function(t){"use strict";var e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},s=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",o=n.toStringTag||"@@toStringTag";function a(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,r){return t[e]=r}}function c(t,e,r,n){var s=e&&e.prototype instanceof b?e:b,i=Object.create(s.prototype),o=new F(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(s,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===s)throw i;return x()}for(r.method=s,r.arg=i;;){var o=r.delegate;if(o){var a=m(o,r);if(a){if(a===u)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===u)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,o),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var u={};function b(){}function l(){}function d(){}var f={};f[s]=function(){return this};var p=Object.getPrototypeOf,_=p&&p(p(O([])));_&&_!==e&&r.call(_,s)&&(f=_);var y=d.prototype=b.prototype=Object.create(f);function g(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var n;this._invoke=function(s,i){function o(){return new e((function(n,o){!function n(s,i,o,a){var c=h(t[s],t,i);if("throw"!==c.type){var u=c.arg,b=u.value;return b&&"object"==typeof b&&r.call(b,"__await")?e.resolve(b.__await).then((function(t){n("next",t,o,a)}),(function(t){n("throw",t,o,a)})):e.resolve(b).then((function(t){u.value=t,o(u)}),(function(t){return n("throw",t,o,a)}))}a(c.arg)}(s,i,n,o)}))}return n=n?n.then(o,o):o()}}function m(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,m(t,e),"throw"===e.method))return u;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return u}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,u;var s=n.arg;return s?s.done?(e[t.resultName]=s.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,u):s:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,u)}function v(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function F(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(v,this),this.reset(!0)}function O(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return i.next=i}}return{next:x}}function x(){return{value:void 0,done:!0}}return l.prototype=y.constructor=d,d.constructor=l,l.displayName=a(d,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===l||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,d):(t.__proto__=d,a(t,o,"GeneratorFunction")),t.prototype=Object.create(y),t},t.awrap=function(t){return{__await:t}},g(w.prototype),w.prototype[i]=function(){return this},t.AsyncIterator=w,t.async=function(e,r,n,s,i){void 0===i&&(i=Promise);var o=new w(c(e,r,n,s),i);return t.isGeneratorFunction(r)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},g(y),a(y,o,"Generator"),y[s]=function(){return this},y.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=O,F.prototype={constructor:F,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(I),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return o.type="throw",o.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var s=this.tryEntries.length-1;s>=0;--s){var i=this.tryEntries[s],o=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(a){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var s=this.tryEntries[n];if(s.tryLoc<=this.prev&&r.call(s,"finallyLoc")&&this.prev<s.finallyLoc){var i=s;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var o=i?i.completion:{};return o.type=t,o.arg=e,i?(this.method="next",this.next=i.finallyLoc,u):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),u},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),u}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var s=n.arg;I(r)}return s}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),u}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e,r){"use strict";r.r(e);var n=r(1),s=r.n(n),i=r(2),o=r.n(i),a=r(0),c=r.n(a),h=r(3);function u(t,e){if(0===t.byteLength)return[];var r=new Uint8Array(t);return Object(h.deserialize)(r).features}function b(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function l(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?b(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var d,f=l(l({},{id:"flatgeobuf",name:"FlatGeobuf",module:"flatgeobuf",version:"3.0.0-beta.8",worker:!0,extensions:["fgb"],category:"geometry",options:{flatgeobuf:{}}}),{},{parse:(d=s()(c.a.mark((function t(e,r){return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",u(e));case 1:case"end":return t.stop()}}),t)}))),function(t,e){return d.apply(this,arguments)}),parseSync:u,parseInBatchesFromStream:function(t,e){return Object(h.deserializeStream)(t)},binary:!0}),p=r(4),_=r.n(p),y=r(5),g=r.n(y),w=r(6),m=r.n(w);function v(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}var I=new Map,F=function(){function t(){_()(this,t)}return g()(t,null,[{key:"onmessage",set:function(t){self.onmessage=function(e){if(O(e)){var r=e.data,n=r.type,s=r.payload;t(n,s)}}}},{key:"addEventListener",value:function(t){var e=I.get(t);e||(e=function(e){if(O(e)){var r=e.data,n=r.type,s=r.payload;t(n,s)}}),self.addEventListener("message",e)}},{key:"removeEventListener",value:function(t){var e=I.get(t);I.delete(t),self.removeEventListener("message",e)}},{key:"postMessage",value:function(t,e){if(self){var r={source:"loaders.gl",type:t,payload:e},n=function t(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,s=n||new Set;if(e){if(v(e))s.add(e);else if(v(e.buffer))s.add(e.buffer);else if(ArrayBuffer.isView(e));else if(r&&"object"===m()(e))for(var i in e)t(e[i],r,s)}else;return void 0===n?Array.from(s):[]}(e);self.postMessage(r,n)}}}]),t}();function O(t){var e=t.type,r=t.data;return"message"===e&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function x(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function S(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?x(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var U,P=0;function L(t,e){return new Promise((function(r,n){var s=P++;F.addEventListener((function t(e,i){if(i.id===s)switch(e){case"done":F.removeEventListener(t),r(i.result);break;case"error":F.removeEventListener(t),n(i.error)}}));var i={id:s,input:t,options:e};F.postMessage("process",i)}))}function C(t){return E.apply(this,arguments)}function E(){return(E=s()(c.a.mark((function t(e){var r,n,s,i,o,a,h;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.loader,n=e.arrayBuffer,s=e.options,i=e.context,!r.parseSync&&!r.parse){t.next=6;break}o=n,a=r.parseSync||r.parse,t.next=13;break;case 6:if(!r.parseTextSync){t.next=12;break}h=new TextDecoder,o=h.decode(n),a=r.parseTextSync,t.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return s=S(S({},s),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),t.next=16,a(o,S({},s),i,r);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}U=f,"undefined"!=typeof self&&(F.onmessage=function(){var t=s()(c.a.mark((function t(e,r){var n,s,i,o,a;return c.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.t0=e,t.next="process"===t.t0?3:16;break;case 3:return t.prev=3,n=r.input,s=r.options,i=void 0===s?{}:s,t.next=7,C({loader:U,arrayBuffer:n,options:i,context:{parse:L}});case 7:o=t.sent,F.postMessage("done",{result:o}),t.next=15;break;case 11:t.prev=11,t.t1=t.catch(3),a=t.t1 instanceof Error?t.t1.message:"",F.postMessage("error",{error:a});case 15:return t.abrupt("break",16);case 16:case"end":return t.stop()}}),t,null,[[3,11]])})));return function(e,r){return t.apply(this,arguments)}}())}]); | ||
//# sourceMappingURL=flatgeobuf-worker.js.map |
{ | ||
"name": "@loaders.gl/flatgeobuf", | ||
"description": "Loader for FlatGeobuf", | ||
"version": "3.0.0-beta.7", | ||
"version": "3.0.0-beta.8", | ||
"license": "MIT", | ||
@@ -35,3 +35,3 @@ "publishConfig": { | ||
"dependencies": { | ||
"@loaders.gl/loader-utils": "3.0.0-beta.7", | ||
"@loaders.gl/loader-utils": "3.0.0-beta.8", | ||
"flatgeobuf": "^3.1.0" | ||
@@ -42,3 +42,3 @@ }, | ||
}, | ||
"gitHead": "7760178558818f1b32f3c56d888c2378e2f6daca" | ||
"gitHead": "b5b361c4a7fbf21dabaa4522d07e5917f1f4213a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
503264
+ Added@loaders.gl/loader-utils@3.0.0-beta.8(transitive)
+ Added@loaders.gl/worker-utils@3.0.0-beta.8(transitive)
- Removed@loaders.gl/loader-utils@3.0.0-beta.7(transitive)
- Removed@loaders.gl/worker-utils@3.0.0-beta.7(transitive)