UNPKG

flatgeobuf

Version:

A performant binary encoding for geographic data

15 lines (13 loc) 56.7 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("ol/loadingstrategy.js"),require("ol/Feature.js"),require("ol/proj"),require("ol/format/Feature"),require("ol/render/Feature.js"),require("ol/geom/LineString.js"),require("ol/geom/MultiLineString.js"),require("ol/geom/MultiPoint.js"),require("ol/geom/MultiPolygon.js"),require("ol/geom/Point.js"),require("ol/geom/Polygon.js")):"function"==typeof define&&define.amd?define(["exports","ol/loadingstrategy.js","ol/Feature.js","ol/proj","ol/format/Feature","ol/render/Feature.js","ol/geom/LineString.js","ol/geom/MultiLineString.js","ol/geom/MultiPoint.js","ol/geom/MultiPolygon.js","ol/geom/Point.js","ol/geom/Polygon.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).flatgeobuf={},t.ol.loadingstrategy,t.ol.Feature,t.proj,t.Feature$1,t.r$4,t.ol.geom.LineString,t.ol.geom.MultiLineString,t.ol.geom.MultiPoint,t.ol.geom.MultiPolygon,t.ol.geom.Point,t.ol.geom.Polygon)}(this,function(t,e,r,n,i,s,o,a,l,h,u,b){"use strict";const c=new Int32Array(2),d=new Float32Array(c.buffer),f=new Float64Array(c.buffer),p=1===new Uint16Array(new Uint8Array([1,0]).buffer)[0];var _;!function(t){t[t.UTF8_BYTES=1]="UTF8_BYTES",t[t.UTF16_STRING=2]="UTF16_STRING"}(_||(_={}));class y{constructor(t){this.bytes_=t,this.position_=0,this.text_decoder_=new TextDecoder}static allocate(t){return new y(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 BigInt.asIntN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readUint64(t){return BigInt.asUintN(64,BigInt(this.readUint32(t))+(BigInt(this.readUint32(t+4))<<BigInt(32)))}readFloat32(t){return c[0]=this.readInt32(t),d[0]}readFloat64(t){return c[p?0:1]=this.readInt32(t),c[p?1:0]=this.readInt32(t+4),f[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,Number(BigInt.asIntN(32,e))),this.writeInt32(t+4,Number(BigInt.asIntN(32,e>>BigInt(32))))}writeUint64(t,e){this.writeUint32(t,Number(BigInt.asUintN(32,e))),this.writeUint32(t+4,Number(BigInt.asUintN(32,e>>BigInt(32))))}writeFloat32(t,e){d[0]=e,this.writeInt32(t,c[0])}writeFloat64(t,e){f[0]=e,this.writeInt32(t,c[p?0:1]),this.writeInt32(t+4,c[p?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);t+=4;const n=this.bytes_.subarray(t,t+r);return e===_.UTF8_BYTES?n:this.text_decoder_.decode(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}createScalarList(t,e){const r=[];for(let n=0;n<e;++n){const e=t(n);null!==e&&r.push(e)}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 g{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,this.text_encoder=new TextEncoder,e=t||1024,this.bb=y.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=g.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!==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 TypeError("FlatBuffers: struct must be serialized inline.")}notNested(){if(this.isNested)throw new TypeError("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=y.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 i=0;const s=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(s+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,r){const n=r?4:0;if(e){const t=e;if(this.prep(this.minalign,8+n),4!=t.length)throw new TypeError("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(!(e<this.bb.readInt16(n)&&0!=this.bb.readInt16(n+e)))throw new TypeError("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(null==t)return 0;let e;return e=t instanceof Uint8Array?t:this.text_encoder.encode(t),this.addInt8(0),this.startVector(1,e.length,1),this.bb.setPosition(this.space-=e.length),this.bb.bytes().set(e,this.space),this.endVector()}createByteVector(t){return null==t?0:(this.startVector(1,t.length,1),this.bb.setPosition(this.space-=t.length),this.bb.bytes().set(t,this.space),this.endVector())}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 TypeError("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.slice().reverse()),this.endVector()}}var m=new Uint8Array(0);function w(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 v(t){this._source=t,this._array=m,this._index=0}v.prototype.read=function(){var t=this,e=t._array.subarray(t._index);return t._source.read().then(function(r){return t._array=m,t._index=0,r.done?e.length>0?{done:!1,value:e}:{done:!0,value:void 0}:{done:!1,value:w(e,r.value)}})},v.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 i(){return e._source.read().then(function(s){return s.done?(e._array=m,e._index=0,r>0?n.subarray(0,r):null):r+s.value.length>=t?(e._array=s.value,e._index=t-r,n.set(s.value.subarray(0,t-r),r),n):(n.set(s.value,r),r+=s.value.length,i())})}()},v.prototype.cancel=function(){return this._source.cancel()};const F=new Uint8Array([102,103,98,3,102,103,98,0]);var I,x,P=((I={})[I.Byte=0]="Byte",I[I.UByte=1]="UByte",I[I.Bool=2]="Bool",I[I.Short=3]="Short",I[I.UShort=4]="UShort",I[I.Int=5]="Int",I[I.UInt=6]="UInt",I[I.Long=7]="Long",I[I.ULong=8]="ULong",I[I.Float=9]="Float",I[I.Double=10]="Double",I[I.String=11]="String",I[I.Json=12]="Json",I[I.DateTime=13]="DateTime",I[I.Binary=14]="Binary",I);class U{bb=null;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){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}type(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readUint8(this.bb_pos+t):P.Byte}title(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}width(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.readInt32(this.bb_pos+t):-1}precision(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.readInt32(this.bb_pos+t):-1}scale(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readInt32(this.bb_pos+t):-1}nullable(){let t=this.bb.__offset(this.bb_pos,18);return!t||!!this.bb.readInt8(this.bb_pos+t)}unique(){let t=this.bb.__offset(this.bb_pos,20);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}primaryKey(){let t=this.bb.__offset(this.bb_pos,22);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}metadata(t){let 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,P.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){let e=t.endObject();return t.requiredField(e,4),e}static createColumn(t,e,r,n,i,s,o,a,l,h,u,b){return U.startColumn(t),U.addName(t,e),U.addType(t,r),U.addTitle(t,n),U.addDescription(t,i),U.addWidth(t,s),U.addPrecision(t,o),U.addScale(t,a),U.addNullable(t,l),U.addUnique(t,h),U.addPrimaryKey(t,u),U.addMetadata(t,b),U.endColumn(t)}}var S=((x={})[x.Unknown=0]="Unknown",x[x.Point=1]="Point",x[x.LineString=2]="LineString",x[x.Polygon=3]="Polygon",x[x.MultiPoint=4]="MultiPoint",x[x.MultiLineString=5]="MultiLineString",x[x.MultiPolygon=6]="MultiPolygon",x[x.GeometryCollection=7]="GeometryCollection",x[x.CircularString=8]="CircularString",x[x.CompoundCurve=9]="CompoundCurve",x[x.CurvePolygon=10]="CurvePolygon",x[x.MultiCurve=11]="MultiCurve",x[x.MultiSurface=12]="MultiSurface",x[x.Curve=13]="Curve",x[x.Surface=14]="Surface",x[x.PolyhedralSurface=15]="PolyhedralSurface",x[x.TIN=16]="TIN",x[x.Triangle=17]="Triangle",x);class C{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsGeometry(t,e){return(e||new C).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsGeometry(t,e){return t.setPosition(t.position()+4),(e||new C).__init(t.readInt32(t.position())+t.position(),t)}ends(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.readUint32(this.bb.__vector(this.bb_pos+e)+4*t):0}endsLength(){let t=this.bb.__offset(this.bb_pos,4);return t?this.bb.__vector_len(this.bb_pos+t):0}endsArray(){let 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){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}xyLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}xyArray(){let 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){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}zLength(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.__vector_len(this.bb_pos+t):0}zArray(){let 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){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}mLength(){let t=this.bb.__offset(this.bb_pos,10);return t?this.bb.__vector_len(this.bb_pos+t):0}mArray(){let 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){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}tLength(){let t=this.bb.__offset(this.bb_pos,12);return t?this.bb.__vector_len(this.bb_pos+t):0}tArray(){let 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){let e=this.bb.__offset(this.bb_pos,14);return e?this.bb.readUint64(this.bb.__vector(this.bb_pos+e)+8*t):BigInt(0)}tmLength(){let t=this.bb.__offset(this.bb_pos,14);return t?this.bb.__vector_len(this.bb_pos+t):0}type(){let t=this.bb.__offset(this.bb_pos,16);return t?this.bb.readUint8(this.bb_pos+t):S.Unknown}parts(t,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new C).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}partsLength(){let 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,S.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,i,s,o,a,l){return C.startGeometry(t),C.addEnds(t,e),C.addXy(t,r),C.addZ(t,n),C.addM(t,i),C.addT(t,s),C.addTm(t,o),C.addType(t,a),C.addParts(t,l),C.endGeometry(t)}}class O{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsFeature(t,e){return(e||new O).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsFeature(t,e){return t.setPosition(t.position()+4),(e||new O).__init(t.readInt32(t.position())+t.position(),t)}geometry(t){let e=this.bb.__offset(this.bb_pos,4);return e?(t||new C).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}properties(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readUint8(this.bb.__vector(this.bb_pos+e)+t):0}propertiesLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}propertiesArray(){let 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){let r=this.bb.__offset(this.bb_pos,8);return r?(e||new U).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){let 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 O.startFeature(t),O.addGeometry(t,e),O.addProperties(t,r),O.addColumns(t,n),O.endFeature(t)}}class B{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsCrs(t,e){return(e||new B).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsCrs(t,e){return t.setPosition(t.position()+4),(e||new B).__init(t.readInt32(t.position())+t.position(),t)}org(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}code(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.readInt32(this.bb_pos+t):0}name(t){let e=this.bb.__offset(this.bb_pos,8);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,10);return e?this.bb.__string(this.bb_pos+e,t):null}wkt(t){let e=this.bb.__offset(this.bb_pos,12);return e?this.bb.__string(this.bb_pos+e,t):null}codeString(t){let 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,i,s,o){return B.startCrs(t),B.addOrg(t,e),B.addCode(t,r),B.addName(t,n),B.addDescription(t,i),B.addWkt(t,s),B.addCodeString(t,o),B.endCrs(t)}}class T{bb=null;bb_pos=0;__init(t,e){return this.bb_pos=t,this.bb=e,this}static getRootAsHeader(t,e){return(e||new T).__init(t.readInt32(t.position())+t.position(),t)}static getSizePrefixedRootAsHeader(t,e){return t.setPosition(t.position()+4),(e||new T).__init(t.readInt32(t.position())+t.position(),t)}name(t){let e=this.bb.__offset(this.bb_pos,4);return e?this.bb.__string(this.bb_pos+e,t):null}envelope(t){let e=this.bb.__offset(this.bb_pos,6);return e?this.bb.readFloat64(this.bb.__vector(this.bb_pos+e)+8*t):0}envelopeLength(){let t=this.bb.__offset(this.bb_pos,6);return t?this.bb.__vector_len(this.bb_pos+t):0}envelopeArray(){let 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(){let t=this.bb.__offset(this.bb_pos,8);return t?this.bb.readUint8(this.bb_pos+t):S.Unknown}hasZ(){let t=this.bb.__offset(this.bb_pos,10);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasM(){let t=this.bb.__offset(this.bb_pos,12);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasT(){let t=this.bb.__offset(this.bb_pos,14);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}hasTm(){let t=this.bb.__offset(this.bb_pos,16);return!!t&&!!this.bb.readInt8(this.bb_pos+t)}columns(t,e){let r=this.bb.__offset(this.bb_pos,18);return r?(e||new U).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos+r)+4*t),this.bb):null}columnsLength(){let t=this.bb.__offset(this.bb_pos,18);return t?this.bb.__vector_len(this.bb_pos+t):0}featuresCount(){let t=this.bb.__offset(this.bb_pos,20);return t?this.bb.readUint64(this.bb_pos+t):BigInt("0")}indexNodeSize(){let t=this.bb.__offset(this.bb_pos,22);return t?this.bb.readUint16(this.bb_pos+t):16}crs(t){let e=this.bb.__offset(this.bb_pos,24);return e?(t||new B).__init(this.bb.__indirect(this.bb_pos+e),this.bb):null}title(t){let e=this.bb.__offset(this.bb_pos,26);return e?this.bb.__string(this.bb_pos+e,t):null}description(t){let e=this.bb.__offset(this.bb_pos,28);return e?this.bb.__string(this.bb_pos+e,t):null}metadata(t){let 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,S.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,BigInt("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)}}function V(t){let e=T.getRootAsHeader(t),r=e.featuresCount(),n=e.indexNodeSize(),i=[];for(let t=0;t<e.columnsLength();t++){let r=e.columns(t);if(!r)throw Error("Column unexpectedly missing");if(!r.name())throw Error("Column name unexpectedly missing");i.push({name:r.name(),type:r.type(),title:r.title(),description:r.description(),width:r.width(),precision:r.precision(),scale:r.scale(),nullable:r.nullable(),unique:r.unique(),primary_key:r.primaryKey()})}let s=e.crs(),o=s?{org:s.org(),code:s.code(),name:s.name(),description:s.description(),wkt:s.wkt(),code_string:s.codeString()}:null;return{geometryType:e.geometryType(),columns:i,envelope:null,featuresCount:Number(r),indexNodeSize:n,crs:o,title:e.title(),description:e.description(),metadata:e.metadata()}}class A{static global=new A;_extraRequestThreshold=262144;extraRequestThreshold(){return this._extraRequestThreshold}setExtraRequestThreshold(t){if(t<0)throw Error("extraRequestThreshold cannot be negative");this._extraRequestThreshold=t}}function E(t,e){e=Math.min(Math.max(+e,2),65535);let r=t,n=r;do{n+=r=Math.ceil(r/e)}while(1!==r);return 40*n}async function*N(t,e,r,n){class i{_level;nodes;constructor(t,e){this._level=e,this.nodes=t}level(){return this._level}startNodeIdx(){return this.nodes[0]}endNodeIdx(){return this.nodes[1]}extendEndNodeIdx(t){this.nodes[1]=t}toString(){return`[NodeRange level: ${this._level}, nodes: ${this.nodes[0]}-${this.nodes[1]}]`}}let{minX:s,minY:o,maxX:a,maxY:l}=r,h=function(t,e){if(e<2)throw Error("Node size must be at least 2");if(0===t)throw Error("Number of items must be greater than 0");let r=t,n=r,i=[r];do{n+=r=Math.ceil(r/e),i.push(r)}while(1!==r);let s=[];for(let t of(r=n,i))s.push(r-t),r-=t;let o=[];for(let t=0;t<i.length;t++)o.push([s[t],s[t]+i[t]]);return o}(t,e),u=h[0][0],b=[new i([0,1],h.length-1)];for(;0!==b.length;){let r=b.shift(),c=r.startNodeIdx(),d=c>=u,f=(()=>{let[,t]=h[r.level()],n=Math.min(r.endNodeIdx()+e,t);return d&&n<t?n+1:n})(),p=f-c,_=new DataView(await n(40*c,40*p));for(let e=c;e<f;e++){let n=e-c,h=40*n;if(a<_.getFloat64(h+0,!0)||l<_.getFloat64(h+8,!0)||s>_.getFloat64(h+16,!0)||o>_.getFloat64(h+24,!0))continue;let f=_.getBigUint64(h+32,!0);if(d){let r=(()=>{if(e<t-1){let t=40*(n+1);return _.getBigUint64(t+32,!0)-f}return null})(),i=e-u;yield[Number(f),i,Number(r)];continue}let p=A.global.extraRequestThreshold()/40,y=b[b.length-1];if(void 0!==y&&y.level()===r.level()-1&&f<y.endNodeIdx()+p){y.extendEndNodeIdx(Number(f));continue}let g=(()=>{let t=r.level()-1;return new i([Number(f),Number(f)+1],t)})();void 0!==y&&(y.level(),g.level()),b.push(g)}}}class j{bytes;header;headerLength;indexLength;constructor(t,e,r,n){this.bytes=t,this.header=e,this.headerLength=r,this.indexLength=n}static open(t){if(!t.subarray(0,3).every((t,e)=>F[e]===t))throw Error("Not a FlatGeobuf file");let e=new DataView(t.buffer).getUint32(8,!0);if(e>10485760||e<8)throw Error("Invalid header size");let r=t.subarray(12,12+e),n=V(new y(r)),i=E(n.featuresCount,n.indexNodeSize);return new j(t,n,e,i)}async*selectBbox(t){let e=this.lengthBeforeTree(),r=async(t,r)=>{let n=e+t;return this.bytes.slice(n,n+r).buffer};for await(let e of N(this.header.featuresCount,this.header.indexNodeSize,t,r)){let[t,r]=e,n=this.readFeature(t);yield{id:r,feature:n}}}lengthBeforeTree(){return F.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}readFeature(t){let e=t+this.lengthBeforeFeatures(),r=new DataView(this.bytes.buffer).getUint32(e,!0),n=this.bytes.subarray(e+4,e+4+r),i=new Uint8Array(r+4);i.set(n,4);let s=new y(i);return s.setPosition(4),O.getRootAsFeature(s)}} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var k=function(t,e){return k=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])},k(t,e)};function M(t,e,r,n){return new(r||(r=Promise))(function(e,i){function s(t){try{a(n.next(t))}catch(t){i(t)}}function o(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(t){t(n)})).then(s,o)}a((n=n.apply(t,[])).next())})}function L(t,e){var r,n,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&s[0]?n.return:s[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,s[1])).done)return i;switch(n=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],n=0}finally{r=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function q(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function R(t){return this instanceof R?(this.v=t,this):new R(t)}function z(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,i=r.apply(t,e||[]),s=[];return n={},o("next"),o("throw"),o("return"),n[Symbol.asyncIterator]=function(){return this},n;function o(t){i[t]&&(n[t]=function(e){return new Promise(function(r,n){s.push([t,e,r,n])>1||a(t,e)})})}function a(t,e){try{!function(t){t.value instanceof R?Promise.resolve(t.value.v).then(l,h):u(s[0][2],t)}(i[t](e))}catch(t){u(s[0][3],t)}}function l(t){a("next",t)}function h(t){a("throw",t)}function u(t,e){t(e),s.shift(),s.length&&a(s[0][0],s[0][1])}}var G=function(t){function e(e){var r=t.call(this,e)||this;return Object.defineProperty(r,"name",{value:"RepeaterOverflowError",enumerable:!1}),"function"==typeof Object.setPrototypeOf?Object.setPrototypeOf(r,r.constructor.prototype):r.__proto__=r.constructor.prototype,"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(r,r.constructor),r}return function(t,e){function r(){this.constructor=t}k(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(e,t),e}(Error);function D(t){null!=t&&"function"==typeof t.then&&t.then(Y,Y)}!function(){function t(t){if(t<0)throw new RangeError("Capacity may not be less than 0");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return this._q.length>=this._c},enumerable:!1,configurable:!0}),t.prototype.add=function(t){if(this.full)throw new Error("Buffer full");this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function t(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(t){for(;this._q.length>=this._c;)this._q.shift();this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}(),function(){function t(t){if(t<1)throw new RangeError("Capacity may not be less than 1");this._c=t,this._q=[]}Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this._q.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"full",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.add=function(t){this._q.length<this._c&&this._q.push(t)},t.prototype.remove=function(){if(this.empty)throw new Error("Buffer empty");return this._q.shift()}}();var X=1024,Y=function(){};function H(t){var e=t.err,r=Promise.resolve(t.execution).then(function(t){if(null!=e)throw e;return t});return t.err=void 0,t.execution=r.then(function(){},function(){}),void 0===t.pending?r:t.pending.then(function(){return r})}function Z(t,e){var r=t.state>=3;return Promise.resolve(e).then(function(e){return!r&&t.state>=4?H(t).then(function(t){return{value:t,done:!0}}):{value:e,done:r}})}function $(t,e){var r,n;if(!(t.state>=2))if(t.state=2,t.onnext(),t.onstop(),null==t.err&&(t.err=e),0!==t.pushes.length||void 0!==t.buffer&&!t.buffer.empty)try{for(var i=q(t.pushes),s=i.next();!s.done;s=i.next()){s.value.resolve()}}catch(t){r={error:t}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}else W(t)}function W(t){var e,r;if(!(t.state>=3)){t.state<2&&$(t),t.state=3,t.buffer=void 0;try{for(var n=q(t.nexts),i=n.next();!i.done;i=n.next()){var s=i.value,o=void 0===t.pending?H(t):t.pending.then(function(){return H(t)});s.resolve(Z(t,o))}}catch(t){e={error:t}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}t.pushes=[],t.nexts=[]}}function J(t){t.state>=4||(t.state<3&&W(t),t.state=4)}function K(t,e){if(D(e),t.pushes.length>=X)throw new G("No more than 1024 pending calls to push are allowed on a single repeater.");if(t.state>=2)return Promise.resolve(void 0);var r,n=void 0===t.pending?Promise.resolve(e):t.pending.then(function(){return e});(n=n.catch(function(e){t.state<2&&(t.err=e),J(t)}),t.nexts.length)?(t.nexts.shift().resolve(Z(t,n)),r=t.nexts.length?Promise.resolve(t.nexts[0].value):void 0===t.buffer||t.buffer.full?new Promise(function(e){return t.onnext=e}):Promise.resolve(void 0)):void 0===t.buffer||t.buffer.full?r=new Promise(function(e){return t.pushes.push({resolve:e,value:n})}):(t.buffer.add(n),r=Promise.resolve(void 0));var i=!0,s={},o=r.catch(function(t){if(i)throw t});return s.then=function(t,e){return i=!1,Promise.prototype.then.call(r,t,e)},s.catch=function(t){return i=!1,Promise.prototype.catch.call(r,t)},s.finally=r.finally.bind(r),t.pending=n.then(function(){return o}).catch(function(e){t.err=e,J(t)}),s}function Q(t){if(!(t.state>=1)){t.state=1;var e=K.bind(null,t),r=function(t){var e=$.bind(null,t),r=new Promise(function(e){return t.onstop=e});return e.then=r.then.bind(r),e.catch=r.catch.bind(r),e.finally=r.finally.bind(r),e}(t);t.execution=new Promise(function(n){return n(t.executor(e,r))}),t.execution.catch(function(){return $(t)})}}var tt=new WeakMap,et=function(){function t(t,e){tt.set(this,{executor:t,buffer:e,err:void 0,state:0,pushes:[],nexts:[],pending:void 0,execution:void 0,onnext:Y,onstop:Y})}return t.prototype.next=function(t){D(t);var e=tt.get(this);if(void 0===e)throw new Error("WeakMap error");if(e.nexts.length>=X)throw new G("No more than 1024 pending calls to next are allowed on a single repeater.");if(e.state<=0&&Q(e),e.onnext(t),void 0!==e.buffer&&!e.buffer.empty){var r=Z(e,e.buffer.remove());if(e.pushes.length){var n=e.pushes.shift();e.buffer.add(n.value),e.onnext=n.resolve}return r}if(e.pushes.length){var i=e.pushes.shift();return e.onnext=i.resolve,Z(e,i.value)}return e.state>=2?(W(e),Z(e,H(e))):new Promise(function(r){return e.nexts.push({resolve:r,value:t})})},t.prototype.return=function(t){D(t);var e=tt.get(this);if(void 0===e)throw new Error("WeakMap error");return W(e),e.execution=Promise.resolve(e.execution).then(function(){return t}),Z(e,H(e))},t.prototype.throw=function(t){var e=tt.get(this);if(void 0===e)throw new Error("WeakMap error");return e.state<=0||e.state>=2||void 0!==e.buffer&&!e.buffer.empty?(W(e),null==e.err&&(e.err=t),Z(e,H(e))):this.next(Promise.reject(t))},t.prototype[Symbol.asyncIterator]=function(){return this},t.race=nt,t.merge=it,t.zip=st,t.latest=ot,t}();function rt(t,e){var r,n,i=[],s=function(t){null!=t&&"function"==typeof t[Symbol.asyncIterator]?i.push(t[Symbol.asyncIterator]()):null!=t&&"function"==typeof t[Symbol.iterator]?i.push(t[Symbol.iterator]()):i.push(function(){return z(this,arguments,function(){return L(this,function(r){switch(r.label){case 0:return e.yieldValues?[4,R(t)]:[3,3];case 1:return[4,r.sent()];case 2:r.sent(),r.label=3;case 3:return e.returnValues?[4,R(t)]:[3,5];case 4:return[2,r.sent()];case 5:return[2]}})})}())};try{for(var o=q(t),a=o.next();!a.done;a=o.next()){s(a.value)}}catch(t){r={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return i}function nt(t){var e=this,r=rt(t,{returnValues:!0});return new et(function(t,n){return M(e,0,void 0,function(){var e,i,s,o,a,l;return L(this,function(h){switch(h.label){case 0:if(!r.length)return n(),[2];i=!1,n.then(function(){e(),i=!0}),h.label=1;case 1:h.trys.push([1,,5,7]),o=void 0,a=0,l=function(){var i,l,h,u,b,c;return L(this,function(d){switch(d.label){case 0:i=a;try{for(b=void 0,l=q(r),h=l.next();!h.done;h=l.next())u=h.value,Promise.resolve(u.next()).then(function(t){t.done?(n(),void 0===s&&(s=t)):a===i&&(a++,e(t))},function(t){return n(t)})}catch(t){b={error:t}}finally{try{h&&!h.done&&(c=l.return)&&c.call(l)}finally{if(b)throw b.error}}return[4,new Promise(function(t){return e=t})];case 1:return void 0===(o=d.sent())?[3,3]:[4,t(o.value)];case 2:d.sent(),d.label=3;case 3:return[2]}})},h.label=2;case 2:return i?[3,4]:[5,l()];case 3:return h.sent(),[3,2];case 4:return[2,s&&s.value];case 5:return n(),[4,Promise.race(r.map(function(t){return t.return&&t.return()}))];case 6:return h.sent(),[7];case 7:return[2]}})})})}function it(t){var e=this,r=rt(t,{yieldValues:!0});return new et(function(t,n){return M(e,0,void 0,function(){var e,i,s,o=this;return L(this,function(a){switch(a.label){case 0:if(!r.length)return n(),[2];e=[],i=!1,n.then(function(){var t,r;i=!0;try{for(var n=q(e),s=n.next();!s.done;s=n.next()){(0,s.value)()}}catch(e){t={error:e}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}}),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,Promise.all(r.map(function(r,a){return M(o,0,void 0,function(){var o;return L(this,function(l){switch(l.label){case 0:l.trys.push([0,,6,9]),l.label=1;case 1:return i?[3,5]:(Promise.resolve(r.next()).then(function(t){return e[a](t)},function(t){return n(t)}),[4,new Promise(function(t){e[a]=t})]);case 2:return void 0===(o=l.sent())?[3,4]:o.done?(s=o,[2]):[4,t(o.value)];case 3:l.sent(),l.label=4;case 4:return[3,1];case 5:return[3,9];case 6:return r.return?[4,r.return()]:[3,8];case 7:l.sent(),l.label=8;case 8:return[7];case 9:return[2]}})})}))];case 2:return a.sent(),[2,s&&s.value];case 3:return n(),[7];case 4:return[2]}})})})}function st(t){var e=this,r=rt(t,{returnValues:!0});return new et(function(t,n){return M(e,0,void 0,function(){var e,i,s,o;return L(this,function(a){switch(a.label){case 0:if(!r.length)return n(),[2,[]];i=!1,n.then(function(){e(),i=!0}),a.label=1;case 1:a.trys.push([1,,6,8]),a.label=2;case 2:return i?[3,5]:(Promise.all(r.map(function(t){return t.next()})).then(function(t){return e(t)},function(t){return n(t)}),[4,new Promise(function(t){return e=t})]);case 3:return void 0===(s=a.sent())?[2]:(o=s.map(function(t){return t.value}),s.some(function(t){return t.done})?[2,o]:[4,t(o)]);case 4:return a.sent(),[3,2];case 5:return[3,8];case 6:return n(),[4,Promise.all(r.map(function(t){return t.return&&t.return()}))];case 7:return a.sent(),[7];case 8:return[2]}})})})}function ot(t){var e=this,r=rt(t,{yieldValues:!0,returnValues:!0});return new et(function(t,n){return M(e,0,void 0,function(){var e,i,s,o,a,l=this;return L(this,function(h){switch(h.label){case 0:if(!r.length)return n(),[2,[]];i=[],s=!1,n.then(function(){var t,r;e();try{for(var n=q(i),o=n.next();!o.done;o=n.next()){(0,o.value)()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}s=!0}),h.label=1;case 1:return h.trys.push([1,,5,7]),Promise.all(r.map(function(t){return t.next()})).then(function(t){return e(t)},function(t){return n(t)}),[4,new Promise(function(t){return e=t})];case 2:return void 0===(o=h.sent())?[2]:(a=o.map(function(t){return t.value}),o.every(function(t){return t.done})?[2,a]:[4,t(a.slice())]);case 3:return h.sent(),[4,Promise.all(r.map(function(e,r){return M(l,0,void 0,function(){var l;return L(this,function(h){switch(h.label){case 0:if(o[r].done)return[2,o[r].value];h.label=1;case 1:return s?[3,4]:(Promise.resolve(e.next()).then(function(t){return i[r](t)},function(t){return n(t)}),[4,new Promise(function(t){return i[r]=t})]);case 2:return void 0===(l=h.sent())?[2,o[r].value]:l.done?[2,l.value]:(a[r]=l.value,[4,t(a.slice())]);case 3:return h.sent(),[3,1];case 4:return[2]}})})}))];case 4:return[2,h.sent()];case 5:return n(),[4,Promise.all(r.map(function(t){return t.return&&t.return()}))];case 6:return h.sent(),[7];case 7:return[2]}})})})}class at{headerClient;header;headerLength;indexLength;nocache;headers;constructor(t,e,r,n,i,s={}){this.headerClient=t,this.header=e,this.headerLength=r,this.indexLength=n,this.nocache=i,this.headers=s}static async open(t,e,r={}){let n,i=new lt(t,e,r),s=2024+(()=>{let t,e=0;for(t=0;t<3;t++)e+=16**t*40;return e})();if(!new Uint8Array(await i.getRange(0,8,s,"header")).subarray(0,3).every((t,e)=>F[e]===t))throw Error("Not a FlatGeobuf file");if((n=new DataView(await i.getRange(8,4,s,"header")).getUint32(0,!0))>10485760||n<8)throw Error("Invalid header size");let o=await i.getRange(12,n,s,"header"),a=V(new y(new Uint8Array(o)));if(0===a.indexNodeSize)throw Error("No index found, cannot read features filtered by bbox");let l=E(a.featuresCount,a.indexNodeSize);return new at(i,a,n,l,e,r)}async*selectBbox(t){let e=this.lengthBeforeTree(),r=this.headerClient,n=async(t,n)=>r.getRange(e+t,n,0,"index"),i=[],s=[];for await(let e of N(this.header.featuresCount,this.header.indexNodeSize,t,n)){let[t,r]=e,[,,n]=e;if(n||(n=4),0===s.length){s.push([t,n,r]);continue}let o=s[s.length-1];t-(o[0]+o[1])>A.global.extraRequestThreshold()&&(i.push(s),s=[]),s.push([t,n,r])}this.headerClient.logUsage("header+index"),s.length>0&&i.push(s);let o=i.flatMap(t=>this.readFeatureBatch(t,this.nocache));yield*et.merge(o)}lengthBeforeTree(){return F.length+4+this.headerLength}lengthBeforeFeatures(){return this.lengthBeforeTree()+this.indexLength}buildFeatureClient(t){return new lt(this.headerClient.httpClient,t,this.headers)}async*readFeatureBatch(t,e){let[r]=t[0],[n,i]=t[t.length-1],s=this.buildFeatureClient(e),o=n+i-r;for(let[e,,r]of t){let t=await this.readFeature(s,e,o);yield{id:r,feature:t},o=0}s.logUsage("feature")}async readFeature(t,e,r){let n,i=e+this.lengthBeforeFeatures();n=new DataView(await t.getRange(i,4,r,"feature length")).getUint32(0,!0);let s=new Uint8Array(await t.getRange(i+4,n,r,"feature data")),o=new Uint8Array(n+4);o.set(s,4);let a=new y(o);return a.setPosition(4),O.getRootAsFeature(a)}}class lt{httpClient;bytesEverUsed=0;bytesEverFetched=0;buffer=new ArrayBuffer(0);head=0;constructor(t,e,r={}){if("string"==typeof t)this.httpClient=new ht(t,e,r);else{if(!(t instanceof ht))throw Error("Unknown source");this.httpClient=t}}async getRange(t,e,r,n){this.bytesEverUsed+=e;let i=t-this.head,s=i+e;if(i>=0&&s<=this.buffer.byteLength)return this.buffer.slice(i,s);let o=Math.max(e,r);return this.bytesEverFetched+=o,this.buffer=await this.httpClient.getRange(t,o,n),this.head=t,this.buffer.slice(0,e)}logUsage(t){t.split(" ")[0],(100*this.bytesEverUsed/this.bytesEverFetched).toFixed(2)}}class ht{url;nocache;headers;requestsEverMade=0;bytesEverRequested=0;constructor(t,e,r={}){this.url=t,this.nocache=e,this.headers=r}async getRange(t,e,r){this.requestsEverMade+=1,this.bytesEverRequested+=e;let n=`bytes=${t}-${t+e-1}`,i=new Headers(this.headers);i.set("Range",n),this.nocache&&i.set("Cache-Control","no-cache, no-store");let s=await fetch(this.url,{headers:i});return await s.arrayBuffer()}}function ut(t,e){let r,n,i,{xy:s,z:o,m:a,ends:l,parts:h,type:u}=e;if(h){let e=h.map(e=>ut(t,e)),r=C.createPartsVector(t,e);return C.startGeometry(t),C.addParts(t,r),C.addType(t,u),C.endGeometry(t)}let b=C.createXyVector(t,s);return o&&(r=C.createZVector(t,o)),a&&(n=C.createMVector(t,a)),l&&(i=C.createEndsVector(t,l)),C.startGeometry(t),i&&C.addEnds(t,i),C.addXy(t,b),r&&C.addZ(t,r),n&&C.addM(t,n),C.addType(t,u),C.endGeometry(t)}function bt(t){let e=t.length/3,r=Array(2*e),n=Array(e);for(let e=0,i=0;e<t.length;e+=3,i++)r[2*i]=t[e],r[2*i+1]=t[e+1],n[i]=t[e+2];return[r,n]}function ct(t,e){let r,n,i,s,o,a,l,h=e;h===S.Unknown&&(h=dt(t.getType())),h===S.MultiLineString||h===S.Polygon?(t.getFlatCoordinates&&(r=t.getFlatCoordinates()),l=t.getEnds()):h===S.MultiPolygon?a=t.getPolygons().map(t=>ct(t,S.Polygon)):t.getFlatCoordinates&&(r=t.getFlatCoordinates());let u=t.getLayout?.()??"XY";if(r&&("XY"===u?n=r:"XYZ"===u?[n,i]=bt(r):"XYM"===u?[n,s]=bt(r):"XYZM"===u&&([n,i,s]=function(t){let e=t.length/4,r=Array(2*e),n=Array(e),i=Array(e);for(let e=0,s=0;e<t.length;e+=4,s++)r[2*s]=t[e],r[2*s+1]=t[e+1],n[s]=t[e+2],i[s]=t[e+3];return[r,n,i]}(r))),l){let t=2;"XYZ"===u||"XYM"===u?t=3:"XYZM"===u&&(t=4),o=l.map(e=>e/t)}return{xy:n,z:i,m:s,ends:o,type:h,parts:a}}function dt(t){return t?S[t]:S.Unknown}let ft=new TextEncoder,pt=new TextDecoder;function _t(t,e,r){let n=r.columns,i=new g,s=0,o=1024,a=new Uint8Array(1024),l=new DataView(a.buffer),h=t=>{if(s+t<o)return;let e=new Uint8Array(o=Math.max(o+t,2*o));e.set(a),l=new DataView((a=e).buffer)};if(n)for(let t=0;t<n.length;t++){let r=n[t],i=e[r.name];if(null!==i)switch(h(2),l.setUint16(s,t,!0),s+=2,r.type){case P.Bool:h(1),l.setUint8(s,i),s+=1;break;case P.Short:h(2),l.setInt16(s,i,!0),s+=2;break;case P.UShort:h(2),l.setUint16(s,i,!0),s+=2;break;case P.Int:h(4),l.setInt32(s,i,!0),s+=4;break;case P.UInt:h(4),l.setUint32(s,i,!0),s+=4;break;case P.Long:h(8),l.setBigInt64(s,BigInt(i),!0),s+=8;break;case P.Float:h(4),l.setFloat32(s,i,!0),s+=4;break;case P.Double:h(8),l.setFloat64(s,i,!0),s+=8;break;case P.DateTime:case P.String:{let t=ft.encode(i);h(4),l.setUint32(s,t.length,!0),s+=4,h(t.length),a.set(t,s),s+=t.length;break}case P.Json:{let t=ft.encode(JSON.stringify(i));h(4),l.setUint32(s,t.length,!0),s+=4,h(t.length),a.set(t,s),s+=t.length;break}case P.Binary:h(4),l.setUint32(s,i.length,!0),s+=4,h(i.length),a.set(i,s),s+=i.length;break;default:throw Error(`Unknown type ${r.type}`)}}let u=0;s>0&&(u=O.createPropertiesVector(i,a.slice(0,s)));let b=ut(i,t);O.startFeature(i),O.addGeometry(i,b),u&&O.addProperties(i,u);let c=O.endFeature(i);return i.finishSizePrefixed(c),i.asUint8Array()}function yt(t,e){let r={};if(!e||0===e.length)return r;let n=t.propertiesArray();if(!n)return r;let i=new DataView(n.buffer,n.byteOffset),s=t.propertiesLength(),o=0;for(;o<s;){let t=i.getUint16(o,!0);o+=2;let s=e[t],a=s.name;switch(s.type){case P.Bool:r[a]=!!i.getUint8(o),o+=1;break;case P.Byte:r[a]=i.getInt8(o),o+=1;break;case P.UByte:r[a]=i.getUint8(o),o+=1;break;case P.Short:r[a]=i.getInt16(o,!0),o+=2;break;case P.UShort:r[a]=i.getUint16(o,!0),o+=2;break;case P.Int:r[a]=i.getInt32(o,!0),o+=4;break;case P.UInt:r[a]=i.getUint32(o,!0),o+=4;break;case P.Long:r[a]=Number(i.getBigInt64(o,!0)),o+=8;break;case P.ULong:r[a]=Number(i.getBigUint64(o,!0)),o+=8;break;case P.Float:r[a]=i.getFloat32(o,!0),o+=4;break;case P.Double:r[a]=i.getFloat64(o,!0),o+=8;break;case P.DateTime:case P.String:{let t=i.getUint32(o,!0);o+=4,r[a]=pt.decode(n.subarray(o,o+t)),o+=t;break}case P.Json:{let t=i.getUint32(o,!0);o+=4;let e=pt.decode(n.subarray(o,o+t));r[a]=JSON.parse(e),o+=t;break}case P.Binary:{let t=i.getUint32(o,!0);o+=4,r[a]=n.subarray(o,o+t),o+=t;break}default:throw Error(`Unk