rlayers
Version:
React Components for OpenLayers
1 lines • 20.8 kB
JavaScript
(self.webpackChunkrlayers=self.webpackChunkrlayers||[]).push([[1060],{1060:(e,t,r)=>{"use strict";var n;r.r(t),r.d(t,{MBTilesFormat:()=>j,MBTilesRasterSource:()=>L,MBTilesVectorSource:()=>A,importMBTiles:()=>T}),globalThis.sqlite3Worker1Promiser=function e(t=e.defaultConfig){if(1===arguments.length&&"function"==typeof arguments[0]){const r=t;(t=Object.assign(Object.create(null),e.defaultConfig)).onready=r}else t=Object.assign(Object.create(null),e.defaultConfig,t);const r=Object.create(null),n=function(){},o=t.onerror||n,i=t.debug||n,s=t.generateMessageId?void 0:Object.create(null),a=t.generateMessageId||function(e){return e.type+"#"+(s[e.type]=(s[e.type]||0)+1)},l=(...e)=>{throw new Error(e.join(" "))};let u;return t.worker||(t.worker=e.defaultConfig.worker),"function"==typeof t.worker&&(t.worker=t.worker()),t.worker.onmessage=function(e){e=e.data,i("worker1.onmessage",e);let n=r[e.messageId];if(!n)return e&&"sqlite3-api"===e.type&&"worker1-ready"===e.result?void(t.onready&&t.onready()):(n=r[e.type],n&&n.onrow?void n.onrow(e):void(t.onunhandled?t.onunhandled(arguments[0]):o("sqlite3Worker1Promiser() unhandled worker message:",e)));switch(delete r[e.messageId],e.type){case"error":return void n.reject(e);case"open":u||(u=e.dbId);break;case"close":e.dbId===u&&(u=void 0)}try{n.resolve(e)}catch(e){n.reject(e)}},function(){let e;1===arguments.length?e=arguments[0]:2===arguments.length?(e=Object.create(null),e.type=arguments[0],e.args=arguments[1]):l("Invalid arugments for sqlite3Worker1Promiser()-created factory."),e.dbId||(e.dbId=u),e.messageId=a(e),e.departureTime=performance.now();const n=Object.create(null);let o;n.message=e,"exec"===e.type&&e.args&&("function"==typeof e.args.callback?(o=e.messageId+":row",n.onrow=e.args.callback,e.args.callback=o,r[o]=n):"string"==typeof e.args.callback&&l("exec callback may not be a string when using the Promise interface."));let s=new Promise((function(o,s){n.resolve=o,n.reject=s,r[e.messageId]=n,i("Posting",e.type,"message to Worker dbId="+(u||"default")+":",e),t.worker.postMessage(e)}));return o&&(s=s.finally((()=>delete r[o]))),s}},globalThis.sqlite3Worker1Promiser.defaultConfig={worker:function(){return new Worker(new URL(r.p+r.u(1901),r.b),{type:void 0})},onerror:(...e)=>console.error("worker1 promiser error",...e)};const o={timeout:2e4,maxPageSize:4096,cacheSize:1024,headers:{}};var i;!function(e){e[e.WORKMSG=16777215]="WORKMSG",e[e.HANDSHAKE=16777214]="HANDSHAKE"}(i=i||(i={}));const s="undefined"!=typeof SQLITE_DEBUG&&SQLITE_DEBUG||void 0!==(null===(n=void 0==={env:{RLAYERS_DEBUG:void 0}}?void 0:{RLAYERS_DEBUG:void 0})||void 0===n?void 0:n.SQLITE_DEBUG)&&{RLAYERS_DEBUG:void 0}.SQLITE_DEBUG||"",a=["threads","vfs","cache","http"],l={};for(const e of a)l[e]=s.includes(e)?console.debug.bind(console):()=>{};!function(){const e=new ArrayBuffer(2),t=new Uint8Array(e),r=new Uint16Array(e);if(t[0]=240,t[1]=13,61453==r[0])return l.threads("System is Big-Endian"),!1;if(3568==r[0])return l.threads("System is Little-Endian"),!0;throw new Error(`Failed determining endianness: ${r}`)}();var u=function(e,t,r,n){return new(r||(r=Promise))((function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,a)}l((n=n.apply(e,t||[])).next())}))};function c(e){let t;return l.threads("Creating new SQLite thread",e),new Promise(((n,o)=>{const i=sqlite3Worker1Promiser({onready:()=>{n(i)},worker:()=>{try{t=new Worker(new URL(r.p+r.u(7985),r.b)),t.onerror=e=>console.error("Worker bootstrap failed",e);const n=null==e?void 0:e.http;return"shared"===(null==n?void 0:n.type)?n.createNewChannel().then((e=>{t.postMessage({httpChannel:e,httpOptions:n.options},[e.port])})):"sync"===(null==n?void 0:n.type)?t.postMessage({httpChannel:!0,httpOptions:n.options}):t.postMessage({}),t}catch(e){console.error("Failed to create SQLite worker",e),o(e)}}})})).then((e=>(e.close=()=>{t.terminate()},e)))}const d='SharedArrayBuffer is not available. If your browser supports it, the webserver must send "Cross-Origin-Opener-Policy: same-origin "and "Cross-Origin-Embedder-Policy: require-corp" headers. Alternatively, if you do not intend to use concurrent connections, pass `sync` to `createHttpBackend` to explicitly create a synchronous HTTP backend and suppress this warning message.';function h(e){var t;return u(this,void 0,void 0,(function*(){const n=function(e){if(l.threads("Creating new HTTP VFS backend thread"),"undefined"==typeof SharedArrayBuffer||"sync"===(null==e?void 0:e.backendType)){if("shared"===(null==e?void 0:e.backendType))throw new Error(d);return"sync"!==(null==e?void 0:e.backendType)&&console.warn(d+" Falling back to the legacy HTTP backend."),{type:"sync",worker:null,options:e,createNewChannel:()=>{throw new Error("Sync backend does not support channels")},close:()=>Promise.resolve(),terminate:()=>{}}}let t=1;const n=new Worker(new URL(r.p+r.u(5806),r.b));n.postMessage({msg:"init",options:e});const i={};return n.onmessage=({data:e})=>{if(l.threads("Received control message reply",e),"ack"===e.msg)return i[e.id]?(l.threads("New HTTP VFS channel created",i),i[e.id].resolve({port:i[e.id].channel.port2,shm:e.shm}),clearTimeout(i[e.id].timeout),delete i[e.id].resolve,void delete i[e.id].timeout):void console.error("Invalid response received from backend",e)},{type:"shared",worker:n,options:e,createNewChannel:function(){l.threads("Creating a new HTTP VFS channel");const r=new MessageChannel,s=t++;return n.postMessage({msg:"handshake",port:r.port1,id:s},[r.port1]),new Promise(((t,n)=>{var a;const l=setTimeout((()=>{delete i[s],n("Timeout while waiting on backend")}),null!==(a=null==e?void 0:e.timeout)&&void 0!==a?a:o.timeout);i[s]={id:s,channel:r,resolve:t,timeout:l}}))},terminate:function(){n.terminate()},close:function(){return l.threads("Closing the HTTP VFS channel"),n.postMessage({msg:"close"}),new Promise(((t,r)=>{var i;const s=setTimeout((()=>{r("Timeout while waiting on backend")}),null!==(i=null==e?void 0:e.timeout)&&void 0!==i?i:o.timeout);n.onmessage=({data:e})=>{l.threads("Received close response",e),"ack"===e.msg&&void 0===e.id&&(t(),clearTimeout(s))}}))}}}(null==e?void 0:e.httpOptions),i=[],s=[];for(let r=0;r<(null!==(t=e.workers)&&void 0!==t?t:1);r++)s.push(c({http:n}).then((e=>i.push({worker:e,busy:null}))).then((()=>{})));return yield Promise.all(s),{backendType:n.type,open:e=>Promise.all(i.map((t=>t.worker("open",{filename:"file:"+encodeURI(e),vfs:"http"})))).then((()=>{})),close:()=>Promise.all(i.map((e=>e.worker.close()))).then((()=>n.close())),exec:function(e,t,r){return u(this,void 0,void 0,(function*(){let n;do{n=i.find((e=>!e.busy)),n||(yield Promise.race(i.map((e=>e.busy))).catch((()=>{})))}while(!n);const o=[];return n.busy=n.worker("exec",{sql:e,bind:t,rowMode:null==r?void 0:r.rowMode,callback:e=>{e.row&&o.push(e)}}).then((()=>{})).finally((()=>{if(!n)throw new Error("Lost worker pool");n.busy=null})),yield n.busy,o}))}}}))}var p,f=r(6391),y=r(915),m=r(6758),v=r(5923),g=r(8112),w=r(4537),b=r(3075),x=r(8217),_=r(5286),P=r(4778),k=r(8512),E=r(1078);const S="undefined"!=typeof OL_MBTILES_DEBUG&&OL_MBTILES_DEBUG||void 0!==(null===(p={RLAYERS_DEBUG:void 0})||void 0===p?void 0:p.OL_MBTILES_DEBUG)&&{RLAYERS_DEBUG:void 0}.OL_MBTILES_DEBUG?console.debug.bind(console):()=>{},M={jpg:{type:"raster",mime:"image/jpeg"},png:{type:"raster",mime:"image/png"},webp:{type:"raster",mime:"image/webp"},pbf:{type:"vector"},mvt:{type:"vector"}};function C(e){var t,r,n;return{workers:null!==(t=null==e?void 0:e.sqlWorkers)&&void 0!==t?t:4,httpOptions:{backendType:null==e?void 0:e.backendType,maxPageSize:null!==(r=null==e?void 0:e.maxSqlPageSize)&&void 0!==r?r:4096,cacheSize:null!==(n=null==e?void 0:e.sqlCacheSize)&&void 0!==n?n:4096}}}function T(e){const t=h(C(e));return t.then((t=>t.open(e.url).then((()=>t)))).then((e=>e.exec("SELECT name,value FROM metadata"))).then((e=>{if(e&&e.length){const t=e.reduce(((e,t)=>(e[t.row[0]]=t.row[1],e)),{});return S("Loaded metadata",t),t}throw new Error("Could not load metadata")})).then((r=>{var n,o,i,s,a,l,u,c,d;const h=Object.assign({},e),p=null===(o=null===(n=r.format)||void 0===n?void 0:n.toLowerCase)||void 0===o?void 0:o.call(n);M[p]||console.warn("Unknown tile format",p),h.projection=null!==(i=e.projection)&&void 0!==i?i:"EPSG:3857",h.attributions=null!==(s=r.attribution)&&void 0!==s?s:r.description,h.maxZoom=null!==(a=e.maxZoom)&&void 0!==a?a:+r.maxzoom,h.minZoom=null!==(l=e.minZoom)&&void 0!==l?l:+r.minzoom;const v=null===(c=null===(u=(0,f.Jt)(h.projection))||void 0===u?void 0:u.getExtent)||void 0===c?void 0:c.call(u),g=r.bounds,w=g?(0,f.DI)(g.split(",").map((e=>+e)),"EPSG:4326",h.projection):v;if("raster"===M[p].type){if(void 0===h.maxZoom||void 0===h.minZoom||void 0===v)throw new Error("Cannot determine tilegrid, need minZoom, maxZoom");const e=[(0,y.RG)(v)/256];for(let t=1;t<=h.maxZoom;t++)e.push(e[e.length-1]/2);const t=null!==(d=M[p].mime)&&void 0!==d?d:p;h.mime=t,h.tileGrid=new m.A({origin:[v[0],v[2]],extent:w,minZoom:h.minZoom,resolutions:e})}else h.extent=v;return h.pool=t,h.url=e.url,h})).catch((e=>t.then((e=>e.close())).then((()=>Promise.reject(e)))))}class j extends x.Ay{constructor(e){var t,r,n;super(),e=e||{},this.dataProjection=new _.A({code:"",units:"tile-pixels"}),this.featureClass_=e.featureClass?e.featureClass:P.Ay,this.geometryName_=null!==(t=e.geometryName)&&void 0!==t?t:"Geometry",this.layers_=null!==(r=e.layers)&&void 0!==r?r:null,this.idProperty_=e.idProperty,this.extent=null!==(n=e.extent)&&void 0!==n?n:4096,this.supportedMediaTypes=["application/vnd-mbtiles"]}readFeature(e,t){const r=e.properties;let n;this.idProperty_?(n=r[this.idProperty_],delete r[this.idProperty_]):n=e.id;const o=e.loadGeometry(),i=[],s=[],a=j.MBTypes[o.length>1?"multi":"mono"][e.type];if("Unknown"===a)return null;for(let e=0;e<o.length;e++)if(0!=o[e].length){for(let t=0;t<o[e].length;t++)i.push(o[e][t].x,o[e][t].y);s.push(i.length)}const l=new this.featureClass_(a,i,s,2,r,n);return(null==t?void 0:t.dataProjection)&&"transform"in l&&l.transform(null==t?void 0:t.dataProjection),l}readFeatures(e,t){const r=this.layers_,n=[],o=new w.VectorTile(new g.A(b.Ay.ungzip(e)));t=this.adaptOptions(t);const i=(0,f.Jt)(null==t?void 0:t.dataProjection),s=null==t?void 0:t.extent;if(!i||!t||!s)throw new Error("Cannot determine the projection/extent");i.setWorldExtent(s),i.setExtent([0,0,this.extent,this.extent]),t.dataProjection=i;for(const e of Object.keys(o.layers)){if(r&&!r.includes(e))continue;const i=o.layers[e];for(let r=0;r<i.length;r++){const o=i.feature(r),s=this.readFeature(o,t);s.getProperties().layer=e,n.push(s)}}return n}readProjection(){return this.dataProjection}}j.MBTypes={mono:["Unknown","Point","LineString","Polygon"],multi:["Unknown","MultiPoint","MultiLineString","Polygon"]};class A extends v.A{constructor(e){var t;if(void 0===e.url&&void 0===e.pool)throw new Error("Must specify url");super(Object.assign(Object.assign({},e),{url:void 0,format:new j({layers:e.layers}),tileUrlFunction:t=>`${e.url}#${t[0]}:${t[1]}:${t[2]}`})),this.setTileLoadFunction(this.tileLoader.bind(this)),this.pool=null!==(t=e.pool)&&void 0!==t?t:h(C(e)).then((t=>t.open(e.url).then((()=>t))))}tileLoader(e,t){const r=e;S("loading tile",[r.tileCoord[0],r.tileCoord[1],r.tileCoord[2]]),r.setLoader(((e,t,n)=>{this.pool.then((e=>e.exec("SELECT tile_data FROM tiles WHERE zoom_level = $zoom AND tile_column = $col AND tile_row = $row",{$zoom:r.tileCoord[0],$col:r.tileCoord[1],$row:(1<<r.tileCoord[0])-1-r.tileCoord[2]}))).then((t=>{if(t&&t[0]&&t[0].row[0]){const o=r.getFormat().readFeatures(t[0].row[0],{extent:e,featureProjection:n});return r.setFeatures(o),void r.onLoad(o,n)}throw new Error(`No data for ${r.tileCoord}`)})).catch((e=>{S(e),r.onError()}))}))}disposeInternal(){return this.pool.then((e=>e.close()))}}class L extends k.A{constructor(e){var t;if(void 0===e.url&&void 0===e.pool)throw new Error("Must specify url");super(Object.assign(Object.assign({},e),{url:void 0,tileUrlFunction:t=>`${e.url}#${t[0]}:${t[1]}:${t[2]}`})),this.setTileLoadFunction(this.tileLoader.bind(this)),this.pool=null!==(t=e.pool)&&void 0!==t?t:h(C(e)).then((t=>t.open(e.url).then((()=>t)))),this.mime=e.mime}tileLoader(e,t){S("loading tile",[e.tileCoord[0],e.tileCoord[1],e.tileCoord[2]]);const r=e.getImage();this.pool.then((t=>t.exec("SELECT tile_data FROM tiles WHERE zoom_level = $zoom AND tile_column = $col AND tile_row = $row",{$zoom:e.tileCoord[0],$col:e.tileCoord[1],$row:(1<<e.tileCoord[0])-1-e.tileCoord[2]}))).then((t=>{if(!(t&&t[0]&&t[0].row[0]instanceof Uint8Array))throw new Error(`No data for ${e.tileCoord}`);{const e=new Blob([t[0].row[0]],{type:this.mime}),n=URL.createObjectURL(e);r.src=n}})).catch((t=>{S(t),e.setState(E.A.ERROR)}))}disposeInternal(){return this.pool.then((e=>e.close()))}}},4537:(e,t,r)=>{e.exports.VectorTile=r(7054),r(8729),r(6241)},4748:e=>{"use strict";function t(e,t){this.x=e,this.y=t}e.exports=t,t.prototype={clone:function(){return new t(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,r=e.y-this.y;return t*t+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[0]*this.x+e[1]*this.y,r=e[2]*this.x+e[3]*this.y;return this.x=t,this.y=r,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),r=Math.sin(e),n=t*this.x-r*this.y,o=r*this.x+t*this.y;return this.x=n,this.y=o,this},_rotateAround:function(e,t){var r=Math.cos(e),n=Math.sin(e),o=t.x+r*(this.x-t.x)-n*(this.y-t.y),i=t.y+n*(this.x-t.x)+r*(this.y-t.y);return this.x=o,this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},t.convert=function(e){return e instanceof t?e:Array.isArray(e)?new t(e[0],e[1]):e}},6241:(e,t,r)=>{"use strict";var n=r(8729);function o(e,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=e,this._keys=[],this._values=[],this._features=[],e.readFields(i,this,t),this.length=this._features.length}function i(e,t,r){15===e?t.version=r.readVarint():1===e?t.name=r.readString():5===e?t.extent=r.readVarint():2===e?t._features.push(r.pos):3===e?t._keys.push(r.readString()):4===e&&t._values.push(function(e){for(var t=null,r=e.readVarint()+e.pos;e.pos<r;){var n=e.readVarint()>>3;t=1===n?e.readString():2===n?e.readFloat():3===n?e.readDouble():4===n?e.readVarint64():5===n?e.readVarint():6===n?e.readSVarint():7===n?e.readBoolean():null}return t}(r))}e.exports=o,o.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new n(this._pbf,t,this.extent,this._keys,this._values)}},7054:(e,t,r)=>{"use strict";var n=r(6241);function o(e,t,r){if(3===e){var o=new n(r,r.readVarint()+r.pos);o.length&&(t[o.name]=o)}}e.exports=function(e,t){this.layers=e.readFields(o,{},t)}},8217:(e,t,r)=>{"use strict";r.d(t,{Ay:()=>y,Bs:()=>g,hX:()=>m,te:()=>w});var n=r(6717),o=r(3402),i=r(4294),s=r(1217),a=r(1064),l=r(503),u=r(6702),c=r(2871),d=r(4338),h=r(6391),p=r(4778),f=r(4087);const y=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=n.A,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let r=t.dataProjection?(0,h.Jt)(t.dataProjection):this.readProjection(e);t.extent&&r&&"tile-pixels"===r.getUnits()&&(r=(0,h.Jt)(r),r.setWorldExtent(t.extent)),t={dataProjection:r,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return(0,f.b0)()}readFeature(e,t){return(0,f.b0)()}readFeatures(e,t){return(0,f.b0)()}readGeometry(e,t){return(0,f.b0)()}readProjection(e){return(0,f.b0)()}writeFeature(e,t){return(0,f.b0)()}writeFeatures(e,t){return(0,f.b0)()}writeGeometry(e,t){return(0,f.b0)()}};function m(e,t,r){const n=r?(0,h.Jt)(r.featureProjection):null,o=r?(0,h.Jt)(r.dataProjection):null;let i=e;if(n&&o&&!(0,h.tI)(n,o)){t&&(i=e.clone());const r=t?n:o,s=t?o:n;"tile-pixels"===r.getUnits()?i.transform(r,s):i.applyTransform((0,h.RG)(r,s))}if(t&&r&&void 0!==r.decimals){const t=Math.pow(10,r.decimals),n=function(e){for(let r=0,n=e.length;r<n;++r)e[r]=Math.round(e[r]*t)/t;return e};i===e&&(i=e.clone()),i.applyTransform(n)}return i}const v={Point:i.A,LineString:s.A,Polygon:a.Ay,MultiPoint:l.A,MultiLineString:u.A,MultiPolygon:c.A};function g(e,t){const r=e.geometry;if(!r)return[];if(Array.isArray(r))return r.map((t=>g({...e,geometry:t}))).flat();const n="MultiPolygon"===r.type?"Polygon":r.type;if("GeometryCollection"===n||"Circle"===n)throw new Error("Unsupported geometry type: "+n);const i=r.layout.length;return m(new p.Ay(n,"Polygon"===n?function(e,t,r){return Array.isArray(t[0])?((0,o.mb)(e,0,t,r)||(e=e.slice(),(0,o.NK)(e,0,t,r)),e):((0,o.PA)(e,0,t,r)||(e=e.slice(),(0,o.ug)(e,0,t,r)),e)}(r.flatCoordinates,r.ends,i):r.flatCoordinates,r.ends?.flat(),i,e.properties||{},e.id).enableSimplifyTransformed(),!1,t)}function w(e,t){if(!e)return null;if(Array.isArray(e)){const r=e.map((e=>w(e,t)));return new d.A(r)}return m(new(0,v[e.type])(e.flatCoordinates,e.layout||"XY",e.ends),!1,t)}},8729:(e,t,r)=>{"use strict";var n=r(4748);function o(e,t,r,n,o){this.properties={},this.extent=r,this.type=0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=o,e.readFields(i,this,t)}function i(e,t,r){1==e?t.id=r.readVarint():2==e?function(e,t){for(var r=e.readVarint()+e.pos;e.pos<r;){var n=t._keys[e.readVarint()],o=t._values[e.readVarint()];t.properties[n]=o}}(r,t):3==e?t.type=r.readVarint():4==e&&(t._geometry=r.pos)}function s(e){for(var t,r,n=0,o=0,i=e.length,s=i-1;o<i;s=o++)t=e[o],n+=((r=e[s]).x-t.x)*(t.y+r.y);return n}e.exports=o,o.types=["Unknown","Point","LineString","Polygon"],o.prototype.loadGeometry=function(){var e=this._pbf;e.pos=this._geometry;for(var t,r=e.readVarint()+e.pos,o=1,i=0,s=0,a=0,l=[];e.pos<r;){if(i<=0){var u=e.readVarint();o=7&u,i=u>>3}if(i--,1===o||2===o)s+=e.readSVarint(),a+=e.readSVarint(),1===o&&(t&&l.push(t),t=[]),t.push(new n(s,a));else{if(7!==o)throw new Error("unknown command "+o);t&&t.push(t[0].clone())}}return t&&l.push(t),l},o.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,r=1,n=0,o=0,i=0,s=1/0,a=-1/0,l=1/0,u=-1/0;e.pos<t;){if(n<=0){var c=e.readVarint();r=7&c,n=c>>3}if(n--,1===r||2===r)(o+=e.readSVarint())<s&&(s=o),o>a&&(a=o),(i+=e.readSVarint())<l&&(l=i),i>u&&(u=i);else if(7!==r)throw new Error("unknown command "+r)}return[s,l,a,u]},o.prototype.toGeoJSON=function(e,t,r){var n,i,a=this.extent*Math.pow(2,r),l=this.extent*e,u=this.extent*t,c=this.loadGeometry(),d=o.types[this.type];function h(e){for(var t=0;t<e.length;t++){var r=e[t],n=180-360*(r.y+u)/a;e[t]=[360*(r.x+l)/a-180,360/Math.PI*Math.atan(Math.exp(n*Math.PI/180))-90]}}switch(this.type){case 1:var p=[];for(n=0;n<c.length;n++)p[n]=c[n][0];h(c=p);break;case 2:for(n=0;n<c.length;n++)h(c[n]);break;case 3:for(c=function(e){var t=e.length;if(t<=1)return[e];for(var r,n,o=[],i=0;i<t;i++){var a=s(e[i]);0!==a&&(void 0===n&&(n=a<0),n===a<0?(r&&o.push(r),r=[e[i]]):r.push(e[i]))}return r&&o.push(r),o}(c),n=0;n<c.length;n++)for(i=0;i<c[n].length;i++)h(c[n][i])}1===c.length?c=c[0]:d="Multi"+d;var f={type:"Feature",geometry:{type:d,coordinates:c},properties:this.properties};return"id"in this&&(f.id=this.id),f}}}]);