arcgis-pbf-parser
Advanced tools
Comparing version 0.0.3 to 0.0.4
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self)[""]=e[""]||{},e[""]["/dist/arcgis-pbf"]=e[""]["/dist/arcgis-pbf"]||{},e[""]["/dist/arcgis-pbf"].min=e[""]["/dist/arcgis-pbf"].min||{},e[""]["/dist/arcgis-pbf"].min.js=t())}(this,(function(){"use strict";const e={read:function(t,i){return t.readFields(e._readField,{version:"",queryResult:null},i)},_readField:function(t,i,r){1===t?i.version=r.readString():2===t&&(i.queryResult=e.QueryResult.read(r,r.readVarint()+r.pos))},write:function(t,i){t.version&&i.writeStringField(1,t.version),t.queryResult&&i.writeMessage(2,e.QueryResult.write,t.queryResult)},GeometryType:{esriGeometryTypePoint:{value:0,options:{}},esriGeometryTypeMultipoint:{value:1,options:{}},esriGeometryTypePolyline:{value:2,options:{}},esriGeometryTypePolygon:{value:3,options:{}},esriGeometryTypeMultipatch:{value:4,options:{}},esriGeometryTypeNone:{value:127,options:{}}},FieldType:{esriFieldTypeSmallInteger:{value:0,options:{}},esriFieldTypeInteger:{value:1,options:{}},esriFieldTypeSingle:{value:2,options:{}},esriFieldTypeDouble:{value:3,options:{}},esriFieldTypeString:{value:4,options:{}},esriFieldTypeDate:{value:5,options:{}},esriFieldTypeOID:{value:6,options:{}},esriFieldTypeGeometry:{value:7,options:{}},esriFieldTypeBlob:{value:8,options:{}},esriFieldTypeRaster:{value:9,options:{}},esriFieldTypeGUID:{value:10,options:{}},esriFieldTypeGlobalID:{value:11,options:{}},esriFieldTypeXML:{value:12,options:{}}},SQLType:{sqlTypeBigInt:{value:0,options:{}},sqlTypeBinary:{value:1,options:{}},sqlTypeBit:{value:2,options:{}},sqlTypeChar:{value:3,options:{}},sqlTypeDate:{value:4,options:{}},sqlTypeDecimal:{value:5,options:{}},sqlTypeDouble:{value:6,options:{}},sqlTypeFloat:{value:7,options:{}},sqlTypeGeometry:{value:8,options:{}},sqlTypeGUID:{value:9,options:{}},sqlTypeInteger:{value:10,options:{}},sqlTypeLongNVarchar:{value:11,options:{}},sqlTypeLongVarbinary:{value:12,options:{}},sqlTypeLongVarchar:{value:13,options:{}},sqlTypeNChar:{value:14,options:{}},sqlTypeNVarchar:{value:15,options:{}},sqlTypeOther:{value:16,options:{}},sqlTypeReal:{value:17,options:{}},sqlTypeSmallInt:{value:18,options:{}},sqlTypeSqlXml:{value:19,options:{}},sqlTypeTime:{value:20,options:{}},sqlTypeTimestamp:{value:21,options:{}},sqlTypeTimestamp2:{value:22,options:{}},sqlTypeTinyInt:{value:23,options:{}},sqlTypeVarbinary:{value:24,options:{}},sqlTypeVarchar:{value:25,options:{}}},QuantizeOriginPostion:{upperLeft:{value:0,options:{}},lowerLeft:{value:1,options:{}}},SpatialReference:{}};e.SpatialReference.read=function(t,i){return t.readFields(e.SpatialReference._readField,{wkid:0,lastestWkid:0,vcsWkid:0,latestVcsWkid:0,wkt:""},i)},e.SpatialReference._readField=function(e,t,i){1===e?t.wkid=i.readVarint():2===e?t.lastestWkid=i.readVarint():3===e?t.vcsWkid=i.readVarint():4===e?t.latestVcsWkid=i.readVarint():5===e&&(t.wkt=i.readString())},e.SpatialReference.write=function(e,t){e.wkid&&t.writeVarintField(1,e.wkid),e.lastestWkid&&t.writeVarintField(2,e.lastestWkid),e.vcsWkid&&t.writeVarintField(3,e.vcsWkid),e.latestVcsWkid&&t.writeVarintField(4,e.latestVcsWkid),e.wkt&&t.writeStringField(5,e.wkt)},e.Field={},e.Field.read=function(t,i){return t.readFields(e.Field._readField,{name:"",fieldType:0,alias:"",sqlType:0,domain:"",defaultValue:""},i)},e.Field._readField=function(e,t,i){1===e?t.name=i.readString():2===e?t.fieldType=i.readVarint():3===e?t.alias=i.readString():4===e?t.sqlType=i.readVarint():5===e?t.domain=i.readString():6===e&&(t.defaultValue=i.readString())},e.Field.write=function(e,t){e.name&&t.writeStringField(1,e.name),e.fieldType&&t.writeVarintField(2,e.fieldType),e.alias&&t.writeStringField(3,e.alias),e.sqlType&&t.writeVarintField(4,e.sqlType),e.domain&&t.writeStringField(5,e.domain),e.defaultValue&&t.writeStringField(6,e.defaultValue)},e.Value={},e.Value.read=function(t,i){return t.readFields(e.Value._readField,{string_value:"",value_type:null,float_value:0,double_value:0,sint_value:0,uint_value:0,int64_value:0,uint64_value:0,sint64_value:0,bool_value:!1},i)},e.Value._readField=function(e,t,i){1===e?(t.string_value=i.readString(),t.value_type="string_value"):2===e?(t.float_value=i.readFloat(),t.value_type="float_value"):3===e?(t.double_value=i.readDouble(),t.value_type="double_value"):4===e?(t.sint_value=i.readSVarint(),t.value_type="sint_value"):5===e?(t.uint_value=i.readVarint(),t.value_type="uint_value"):6===e?(t.int64_value=i.readVarint(!0),t.value_type="int64_value"):7===e?(t.uint64_value=i.readVarint(),t.value_type="uint64_value"):8===e?(t.sint64_value=i.readSVarint(),t.value_type="sint64_value"):9===e&&(t.bool_value=i.readBoolean(),t.value_type="bool_value")},e.Value.write=function(e,t){e.string_value&&t.writeStringField(1,e.string_value),e.float_value&&t.writeFloatField(2,e.float_value),e.double_value&&t.writeDoubleField(3,e.double_value),e.sint_value&&t.writeSVarintField(4,e.sint_value),e.uint_value&&t.writeVarintField(5,e.uint_value),e.int64_value&&t.writeVarintField(6,e.int64_value),e.uint64_value&&t.writeVarintField(7,e.uint64_value),e.sint64_value&&t.writeSVarintField(8,e.sint64_value),e.bool_value&&t.writeBooleanField(9,e.bool_value)},e.Geometry={},e.Geometry.read=function(t,i){return t.readFields(e.Geometry._readField,{lengths:[],coords:[]},i)},e.Geometry._readField=function(e,t,i){2===e?i.readPackedVarint(t.lengths):3===e&&i.readPackedSVarint(t.coords)},e.Geometry.write=function(e,t){e.lengths&&t.writePackedVarint(2,e.lengths),e.coords&&t.writePackedSVarint(3,e.coords)},e.esriShapeBuffer={},e.esriShapeBuffer.read=function(t,i){return t.readFields(e.esriShapeBuffer._readField,{bytes:null},i)},e.esriShapeBuffer._readField=function(e,t,i){1===e&&(t.bytes=i.readBytes())},e.esriShapeBuffer.write=function(e,t){e.bytes&&t.writeBytesField(1,e.bytes)},e.Feature={},e.Feature.read=function(t,i){return t.readFields(e.Feature._readField,{attributes:[],geometry:null,compressed_geometry:null,shapeBuffer:null,centroid:null},i)},e.Feature._readField=function(t,i,r){1===t?i.attributes.push(e.Value.read(r,r.readVarint()+r.pos)):2===t?(i.geometry=e.Geometry.read(r,r.readVarint()+r.pos),i.compressed_geometry="geometry"):3===t?(i.shapeBuffer=e.esriShapeBuffer.read(r,r.readVarint()+r.pos),i.compressed_geometry="shapeBuffer"):4===t&&(i.centroid=e.Geometry.read(r,r.readVarint()+r.pos))},e.Feature.write=function(t,i){if(t.attributes)for(let r=0;r<t.attributes.length;r++)i.writeMessage(1,e.Value.write,t.attributes[r]);t.geometry&&i.writeMessage(2,e.Geometry.write,t.geometry),t.shapeBuffer&&i.writeMessage(3,e.esriShapeBuffer.write,t.shapeBuffer),t.centroid&&i.writeMessage(4,e.Geometry.write,t.centroid)},e.UniqueIdField={},e.UniqueIdField.read=function(t,i){return t.readFields(e.UniqueIdField._readField,{name:"",isSystemMaintained:!1},i)},e.UniqueIdField._readField=function(e,t,i){1===e?t.name=i.readString():2===e&&(t.isSystemMaintained=i.readBoolean())},e.UniqueIdField.write=function(e,t){e.name&&t.writeStringField(1,e.name),e.isSystemMaintained&&t.writeBooleanField(2,e.isSystemMaintained)},e.GeometryProperties={},e.GeometryProperties.read=function(t,i){return t.readFields(e.GeometryProperties._readField,{shapeAreaFieldName:"",shapeLengthFieldName:"",units:""},i)},e.GeometryProperties._readField=function(e,t,i){1===e?t.shapeAreaFieldName=i.readString():2===e?t.shapeLengthFieldName=i.readString():3===e&&(t.units=i.readString())},e.GeometryProperties.write=function(e,t){e.shapeAreaFieldName&&t.writeStringField(1,e.shapeAreaFieldName),e.shapeLengthFieldName&&t.writeStringField(2,e.shapeLengthFieldName),e.units&&t.writeStringField(3,e.units)},e.ServerGens={},e.ServerGens.read=function(t,i){return t.readFields(e.ServerGens._readField,{minServerGen:0,serverGen:0},i)},e.ServerGens._readField=function(e,t,i){1===e?t.minServerGen=i.readVarint():2===e&&(t.serverGen=i.readVarint())},e.ServerGens.write=function(e,t){e.minServerGen&&t.writeVarintField(1,e.minServerGen),e.serverGen&&t.writeVarintField(2,e.serverGen)},e.Scale={},e.Scale.read=function(t,i){return t.readFields(e.Scale._readField,{xScale:0,yScale:0,mScale:0,zScale:0},i)},e.Scale._readField=function(e,t,i){1===e?t.xScale=i.readDouble():2===e?t.yScale=i.readDouble():3===e?t.mScale=i.readDouble():4===e&&(t.zScale=i.readDouble())},e.Scale.write=function(e,t){e.xScale&&t.writeDoubleField(1,e.xScale),e.yScale&&t.writeDoubleField(2,e.yScale),e.mScale&&t.writeDoubleField(3,e.mScale),e.zScale&&t.writeDoubleField(4,e.zScale)},e.Translate={},e.Translate.read=function(t,i){return t.readFields(e.Translate._readField,{xTranslate:0,yTranslate:0,mTranslate:0,zTranslate:0},i)},e.Translate._readField=function(e,t,i){1===e?t.xTranslate=i.readDouble():2===e?t.yTranslate=i.readDouble():3===e?t.mTranslate=i.readDouble():4===e&&(t.zTranslate=i.readDouble())},e.Translate.write=function(e,t){e.xTranslate&&t.writeDoubleField(1,e.xTranslate),e.yTranslate&&t.writeDoubleField(2,e.yTranslate),e.mTranslate&&t.writeDoubleField(3,e.mTranslate),e.zTranslate&&t.writeDoubleField(4,e.zTranslate)},e.Transform={},e.Transform.read=function(t,i){return t.readFields(e.Transform._readField,{quantizeOriginPostion:0,scale:null,translate:null},i)},e.Transform._readField=function(t,i,r){1===t?i.quantizeOriginPostion=r.readVarint():2===t?i.scale=e.Scale.read(r,r.readVarint()+r.pos):3===t&&(i.translate=e.Translate.read(r,r.readVarint()+r.pos))},e.Transform.write=function(t,i){t.quantizeOriginPostion&&i.writeVarintField(1,t.quantizeOriginPostion),t.scale&&i.writeMessage(2,e.Scale.write,t.scale),t.translate&&i.writeMessage(3,e.Translate.write,t.translate)},e.FeatureResult={},e.FeatureResult.read=function(t,i){return t.readFields(e.FeatureResult._readField,{objectIdFieldName:"",uniqueIdField:null,globalIdFieldName:"",geohashFieldName:"",geometryProperties:null,serverGens:null,geometryType:0,spatialReference:null,exceededTransferLimit:!1,hasZ:!1,hasM:!1,transform:null,fields:[],values:[],features:[]},i)},e.FeatureResult._readField=function(t,i,r){1===t?i.objectIdFieldName=r.readString():2===t?i.uniqueIdField=e.UniqueIdField.read(r,r.readVarint()+r.pos):3===t?i.globalIdFieldName=r.readString():4===t?i.geohashFieldName=r.readString():5===t?i.geometryProperties=e.GeometryProperties.read(r,r.readVarint()+r.pos):6===t?i.serverGens=e.ServerGens.read(r,r.readVarint()+r.pos):7===t?i.geometryType=r.readVarint():8===t?i.spatialReference=e.SpatialReference.read(r,r.readVarint()+r.pos):9===t?i.exceededTransferLimit=r.readBoolean():10===t?i.hasZ=r.readBoolean():11===t?i.hasM=r.readBoolean():12===t?i.transform=e.Transform.read(r,r.readVarint()+r.pos):13===t?i.fields.push(e.Field.read(r,r.readVarint()+r.pos)):14===t?i.values.push(e.Value.read(r,r.readVarint()+r.pos)):15===t&&i.features.push(e.Feature.read(r,r.readVarint()+r.pos))},e.FeatureResult.write=function(t,i){if(t.objectIdFieldName&&i.writeStringField(1,t.objectIdFieldName),t.uniqueIdField&&i.writeMessage(2,e.UniqueIdField.write,t.uniqueIdField),t.globalIdFieldName&&i.writeStringField(3,t.globalIdFieldName),t.geohashFieldName&&i.writeStringField(4,t.geohashFieldName),t.geometryProperties&&i.writeMessage(5,e.GeometryProperties.write,t.geometryProperties),t.serverGens&&i.writeMessage(6,e.ServerGens.write,t.serverGens),t.geometryType&&i.writeVarintField(7,t.geometryType),t.spatialReference&&i.writeMessage(8,e.SpatialReference.write,t.spatialReference),t.exceededTransferLimit&&i.writeBooleanField(9,t.exceededTransferLimit),t.hasZ&&i.writeBooleanField(10,t.hasZ),t.hasM&&i.writeBooleanField(11,t.hasM),t.transform&&i.writeMessage(12,e.Transform.write,t.transform),t.fields)for(var r=0;r<t.fields.length;r++)i.writeMessage(13,e.Field.write,t.fields[r]);if(t.values)for(r=0;r<t.values.length;r++)i.writeMessage(14,e.Value.write,t.values[r]);if(t.features)for(r=0;r<t.features.length;r++)i.writeMessage(15,e.Feature.write,t.features[r])},e.CountResult={},e.CountResult.read=function(t,i){return t.readFields(e.CountResult._readField,{count:0},i)},e.CountResult._readField=function(e,t,i){1===e&&(t.count=i.readVarint())},e.CountResult.write=function(e,t){e.count&&t.writeVarintField(1,e.count)},e.ObjectIdsResult={},e.ObjectIdsResult.read=function(t,i){return t.readFields(e.ObjectIdsResult._readField,{objectIdFieldName:"",serverGens:null,objectIds:[]},i)},e.ObjectIdsResult._readField=function(t,i,r){1===t?i.objectIdFieldName=r.readString():2===t?i.serverGens=e.ServerGens.read(r,r.readVarint()+r.pos):3===t&&r.readPackedVarint(i.objectIds)},e.ObjectIdsResult.write=function(t,i){t.objectIdFieldName&&i.writeStringField(1,t.objectIdFieldName),t.serverGens&&i.writeMessage(2,e.ServerGens.write,t.serverGens),t.objectIds&&i.writePackedVarint(3,t.objectIds)},e.QueryResult={},e.QueryResult.read=function(t,i){return t.readFields(e.QueryResult._readField,{featureResult:null,Results:null,countResult:null,idsResult:null},i)},e.QueryResult._readField=function(t,i,r){1===t?(i.featureResult=e.FeatureResult.read(r,r.readVarint()+r.pos),i.Results="featureResult"):2===t?(i.countResult=e.CountResult.read(r,r.readVarint()+r.pos),i.Results="countResult"):3===t&&(i.idsResult=e.ObjectIdsResult.read(r,r.readVarint()+r.pos),i.Results="idsResult")},e.QueryResult.write=function(t,i){t.featureResult&&i.writeMessage(1,e.FeatureResult.write,t.featureResult),t.countResult&&i.writeMessage(2,e.CountResult.write,t.countResult),t.idsResult&&i.writeMessage(3,e.ObjectIdsResult.write,t.idsResult)};var t={ | ||
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ | ||
read:function(e,t,i,r,a){var n,s,o=8*a-r-1,l=(1<<o)-1,u=l>>1,d=-7,f=i?a-1:0,h=i?-1:1,p=e[t+f];for(f+=h,n=p&(1<<-d)-1,p>>=-d,d+=o;d>0;n=256*n+e[t+f],f+=h,d-=8);for(s=n&(1<<-d)-1,n>>=-d,d+=r;d>0;s=256*s+e[t+f],f+=h,d-=8);if(0===n)n=1-u;else{if(n===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),n-=u}return(p?-1:1)*s*Math.pow(2,n-r)},write:function(e,t,i,r,a,n){var s,o,l,u=8*n-a-1,d=(1<<u)-1,f=d>>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,c=r?1:-1,F=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(s++,l/=2),s+f>=d?(o=0,s=d):s+f>=1?(o=(t*l-1)*Math.pow(2,a),s+=f):(o=t*Math.pow(2,f-1)*Math.pow(2,a),s=0));a>=8;e[i+p]=255&o,p+=c,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[i+p]=255&s,p+=c,s/=256,u-=8);e[i+p-c]|=128*F}},i=a,r=t;function a(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}a.Varint=0,a.Fixed64=1,a.Bytes=2,a.Fixed32=5;var n=4294967296,s=1/n,o="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function l(e){return e.type===a.Bytes?e.readVarint()+e.pos:e.pos+1}function u(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function d(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var a=i.pos-1;a>=e;a--)i.buf[a+r]=i.buf[a]}function f(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function h(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function p(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function c(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function F(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function y(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function w(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function g(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function v(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function m(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function b(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function S(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function V(e,t){return{type:"Point",coordinates:q(e.geometry.coords,t)}}function T(e,t){let i=null;const r=e.geometry.lengths.length;if(1===r)i={type:"LineString",coordinates:R(e.geometry.coords,t,0,2*e.geometry.lengths[0])};else if(r>1){i={type:"MultiLineString",coordinates:[]};let a=0;for(let n=0;n<r;n++){const r=a+2*e.geometry.lengths[n],s=R(e.geometry.coords,t,a,r);i.coordinates.push(s),a=r}}return i}function _(e,t){const i=e.geometry.lengths.length,r={type:"Polygon",coordinates:[]};if(1===i)r.coordinates.push(R(e.geometry.coords,t,0,2*e.geometry.lengths[0]));else{r.type="MultiPolygon";let a=0;for(let n=0;n<i;n++){const i=a+2*e.geometry.lengths[n],s=R(e.geometry.coords,t,a,i);x(s)?r.coordinates.push([s]):r.coordinates.length>0&&r.coordinates[r.coordinates.length-1].push(s),a=i}}return r}function x(e){let t=0,i=0;const r=e.length;let a,n=e[i];for(;i<r-1;i++)a=e[i+1],t+=(a[0]-n[0])*(a[1]+n[1]),n=a;return t>=0}function R(e,t,i,r){const a=[];if(0===e.length)return a;const n=e[i],s=e[i+1];a.push(q([n,s],t));let o=n,l=s;for(let n=i+2;n<r;n+=2){const i=k(o,e[n]),r=k(l,e[n+1]),s=q([i,r],t);a.push(s),o=i,l=r}return a}function M(e,t){const i={};for(let r=0;r<e.length;r++){const a=e[r];void 0!==t[r][t[r].value_type]?i[a.name]=t[r][t[r].value_type]:i[a.name]=null}return i}function B(e,t,i){for(let r=0;r<e.length;r++){if(e[r].name===i)return t[r][t[r].value_type]}return null}function G(e){switch(e.fieldType){case 1:return"sintValue";case 2:return"floatValue";case 3:return"doubleValue";case 4:return"stringValue";case 5:return"sint64Value";case 6:return"uintValue";default:return null}}function q(e,t){let i=e[0],r=e[1],a=e[2]?e[2]:void 0;t.scale&&(i*=t.scale.xScale,r*=-t.scale.yScale,void 0!==a&&(a*=t.scale.zScale)),t.translate&&(i+=t.translate.xTranslate,r+=t.translate.yTranslate,void 0!==a&&(a+=t.translate.zTranslate));const n=[i,r];return void 0!==a&&n.push(a),n}function k(e,t){return e+t}return a.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),a=r>>3,n=this.pos;this.type=7&r,e(a,t,this),this.pos===n&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=m(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=S(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=m(this.buf,this.pos)+m(this.buf,this.pos+4)*n;return this.pos+=8,e},readSFixed64:function(){var e=m(this.buf,this.pos)+S(this.buf,this.pos+4)*n;return this.pos+=8,e},readFloat:function(){var e=r.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=r.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,a,n=i.buf;if(a=n[i.pos++],r=(112&a)>>4,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<3,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<10,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<17,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<24,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(1&a)<<31,a<128)return u(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&o?function(e,t,i){return o.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){var r="",a=t;for(;a<i;){var n,s,o,l=e[a],u=null,d=l>239?4:l>223?3:l>191?2:1;if(a+d>i)break;1===d?l<128&&(u=l):2===d?128==(192&(n=e[a+1]))&&(u=(31&l)<<6|63&n)<=127&&(u=null):3===d?(n=e[a+1],s=e[a+2],128==(192&n)&&128==(192&s)&&((u=(15&l)<<12|(63&n)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(n=e[a+1],s=e[a+2],o=e[a+3],128==(192&n)&&128==(192&s)&&128==(192&o)&&((u=(15&l)<<18|(63&n)<<12|(63&s)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),a+=d}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==a.Bytes)return e.push(this.readVarint(t));var i=l(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==a.Bytes)return e.push(this.readSVarint());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==a.Bytes)return e.push(this.readBoolean());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==a.Bytes)return e.push(this.readFloat());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==a.Bytes)return e.push(this.readDouble());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==a.Bytes)return e.push(this.readFixed32());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==a.Bytes)return e.push(this.readSFixed32());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==a.Bytes)return e.push(this.readFixed64());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==a.Bytes)return e.push(this.readSFixed64());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===a.Varint)for(;this.buf[this.pos++]>127;);else if(t===a.Bytes)this.pos=this.readVarint()+this.pos;else if(t===a.Fixed32)this.pos+=4;else{if(t!==a.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),b(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),b(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),b(this.buf,-1&e,this.pos),b(this.buf,Math.floor(e*s),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),b(this.buf,-1&e,this.pos),b(this.buf,Math.floor(e*s),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos]=127&e}(i,0,t),function(e,t){var i=(7&e)<<4;if(t.buf[t.pos++]|=i|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,a,n=0;n<t.length;n++){if((r=t.charCodeAt(n))>55295&&r<57344){if(!a){r>56319||n+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):a=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,a=r;continue}r=a-55296<<10|r-56320|65536,a=null}else a&&(e[i++]=239,e[i++]=191,e[i++]=189,a=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&d(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),r.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),r.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&d(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,a.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,F,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,y,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,w,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,g,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,v,t)},writeBytesField:function(e,t){this.writeTag(e,a.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,a.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,a.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,a.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,a.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,a.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,a.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,a.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,a.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,a.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},function(t){let r;try{r=e.read(new i(t))}catch(e){throw new Error("Could not parse arcgis-pbf buffer")}const a=r.queryResult.featureResult,n=a.transform,s=a.geometryType,o=a.objectIdFieldName,l=a.fields;for(let e=0;e<l.length;e++){const t=l[e];t.keyName=G(t)}const u={type:"FeatureCollection",features:[]},d=function(e){switch(e){case 3:return _;case 2:return T;case 0:return V;default:return _}}(s),f=a.features.length;for(let e=0;e<f;e++){const t=a.features[e];u.features.push({type:"Feature",id:B(l,t.attributes,o),properties:M(l,t.attributes),geometry:d(t,n)})}return{featureCollection:u,exceededTransferLimit:a.exceededTransferLimit}}})); | ||
read:function(e,t,i,r,a){var n,s,o=8*a-r-1,l=(1<<o)-1,u=l>>1,d=-7,f=i?a-1:0,h=i?-1:1,p=e[t+f];for(f+=h,n=p&(1<<-d)-1,p>>=-d,d+=o;d>0;n=256*n+e[t+f],f+=h,d-=8);for(s=n&(1<<-d)-1,n>>=-d,d+=r;d>0;s=256*s+e[t+f],f+=h,d-=8);if(0===n)n=1-u;else{if(n===l)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,r),n-=u}return(p?-1:1)*s*Math.pow(2,n-r)},write:function(e,t,i,r,a,n){var s,o,l,u=8*n-a-1,d=(1<<u)-1,f=d>>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,p=r?0:n-1,c=r?1:-1,F=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),(t+=s+f>=1?h/l:h*Math.pow(2,1-f))*l>=2&&(s++,l/=2),s+f>=d?(o=0,s=d):s+f>=1?(o=(t*l-1)*Math.pow(2,a),s+=f):(o=t*Math.pow(2,f-1)*Math.pow(2,a),s=0));a>=8;e[i+p]=255&o,p+=c,o/=256,a-=8);for(s=s<<a|o,u+=a;u>0;e[i+p]=255&s,p+=c,s/=256,u-=8);e[i+p-c]|=128*F}},i=a,r=t;function a(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}a.Varint=0,a.Fixed64=1,a.Bytes=2,a.Fixed32=5;var n=4294967296,s=1/n,o="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function l(e){return e.type===a.Bytes?e.readVarint()+e.pos:e.pos+1}function u(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function d(e,t,i){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(var a=i.pos-1;a>=e;a--)i.buf[a+r]=i.buf[a]}function f(e,t){for(var i=0;i<e.length;i++)t.writeVarint(e[i])}function h(e,t){for(var i=0;i<e.length;i++)t.writeSVarint(e[i])}function p(e,t){for(var i=0;i<e.length;i++)t.writeFloat(e[i])}function c(e,t){for(var i=0;i<e.length;i++)t.writeDouble(e[i])}function F(e,t){for(var i=0;i<e.length;i++)t.writeBoolean(e[i])}function y(e,t){for(var i=0;i<e.length;i++)t.writeFixed32(e[i])}function w(e,t){for(var i=0;i<e.length;i++)t.writeSFixed32(e[i])}function g(e,t){for(var i=0;i<e.length;i++)t.writeFixed64(e[i])}function v(e,t){for(var i=0;i<e.length;i++)t.writeSFixed64(e[i])}function m(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+16777216*e[t+3]}function b(e,t,i){e[i]=t,e[i+1]=t>>>8,e[i+2]=t>>>16,e[i+3]=t>>>24}function S(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function V(e,t){return{type:"Point",coordinates:q(e.geometry.coords,t)}}function T(e,t){let i=null;const r=e.geometry.lengths.length;if(1===r)i={type:"LineString",coordinates:R(e.geometry.coords,t,0,2*e.geometry.lengths[0])};else if(r>1){i={type:"MultiLineString",coordinates:[]};let a=0;for(let n=0;n<r;n++){const r=a+2*e.geometry.lengths[n],s=R(e.geometry.coords,t,a,r);i.coordinates.push(s),a=r}}return i}function _(e,t){const i=e.geometry.lengths.length,r={type:"Polygon",coordinates:[]};if(1===i)r.coordinates.push(R(e.geometry.coords,t,0,2*e.geometry.lengths[0]));else{r.type="MultiPolygon";let a=0;for(let n=0;n<i;n++){const i=a+2*e.geometry.lengths[n],s=R(e.geometry.coords,t,a,i);x(s)?r.coordinates.push([s]):r.coordinates.length>0&&r.coordinates[r.coordinates.length-1].push(s),a=i}}return r}function x(e){let t=0,i=0;const r=e.length;let a,n=e[i];for(;i<r-1;i++)a=e[i+1],t+=(a[0]-n[0])*(a[1]+n[1]),n=a;return t>=0}function R(e,t,i,r){const a=[];if(0===e.length)return a;const n=e[i],s=e[i+1];a.push(q([n,s],t));let o=n,l=s;for(let n=i+2;n<r;n+=2){const i=k(o,e[n]),r=k(l,e[n+1]),s=q([i,r],t);a.push(s),o=i,l=r}return a}function M(e,t){const i={};for(let r=0;r<e.length;r++){const a=e[r];void 0!==t[r][t[r].value_type]?i[a.name]=t[r][t[r].value_type]:i[a.name]=null}return i}function B(e,t,i){for(let r=0;r<e.length;r++){if(e[r].name===i)return t[r][t[r].value_type]}return null}function G(e){switch(e.fieldType){case 1:return"sintValue";case 2:return"floatValue";case 3:return"doubleValue";case 4:return"stringValue";case 5:return"sint64Value";case 6:return"uintValue";default:return null}}function q(e,t){let i=e[0],r=e[1],a=e[2]?e[2]:void 0;t.scale&&(i*=t.scale.xScale,r*=-t.scale.yScale,void 0!==a&&(a*=t.scale.zScale)),t.translate&&(i+=t.translate.xTranslate,r+=t.translate.yTranslate,void 0!==a&&(a+=t.translate.zTranslate));const n=[i,r];return void 0!==a&&n.push(a),n}function k(e,t){return e+t}return a.prototype={destroy:function(){this.buf=null},readFields:function(e,t,i){for(i=i||this.length;this.pos<i;){var r=this.readVarint(),a=r>>3,n=this.pos;this.type=7&r,e(a,t,this),this.pos===n&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=m(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=S(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=m(this.buf,this.pos)+m(this.buf,this.pos+4)*n;return this.pos+=8,e},readSFixed64:function(){var e=m(this.buf,this.pos)+S(this.buf,this.pos+4)*n;return this.pos+=8,e},readFloat:function(){var e=r.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=r.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,i,r=this.buf;return t=127&(i=r[this.pos++]),i<128?t:(t|=(127&(i=r[this.pos++]))<<7,i<128?t:(t|=(127&(i=r[this.pos++]))<<14,i<128?t:(t|=(127&(i=r[this.pos++]))<<21,i<128?t:function(e,t,i){var r,a,n=i.buf;if(a=n[i.pos++],r=(112&a)>>4,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<3,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<10,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<17,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(127&a)<<24,a<128)return u(e,r,t);if(a=n[i.pos++],r|=(1&a)<<31,a<128)return u(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(i=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&o?function(e,t,i){return o.decode(e.subarray(t,i))}(this.buf,t,e):function(e,t,i){var r="",a=t;for(;a<i;){var n,s,o,l=e[a],u=null,d=l>239?4:l>223?3:l>191?2:1;if(a+d>i)break;1===d?l<128&&(u=l):2===d?128==(192&(n=e[a+1]))&&(u=(31&l)<<6|63&n)<=127&&(u=null):3===d?(n=e[a+1],s=e[a+2],128==(192&n)&&128==(192&s)&&((u=(15&l)<<12|(63&n)<<6|63&s)<=2047||u>=55296&&u<=57343)&&(u=null)):4===d&&(n=e[a+1],s=e[a+2],o=e[a+3],128==(192&n)&&128==(192&s)&&128==(192&o)&&((u=(15&l)<<18|(63&n)<<12|(63&s)<<6|63&o)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,d=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),a+=d}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==a.Bytes)return e.push(this.readVarint(t));var i=l(this);for(e=e||[];this.pos<i;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==a.Bytes)return e.push(this.readSVarint());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==a.Bytes)return e.push(this.readBoolean());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==a.Bytes)return e.push(this.readFloat());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==a.Bytes)return e.push(this.readDouble());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==a.Bytes)return e.push(this.readFixed32());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==a.Bytes)return e.push(this.readSFixed32());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==a.Bytes)return e.push(this.readFixed64());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==a.Bytes)return e.push(this.readSFixed64());var t=l(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=7&e;if(t===a.Varint)for(;this.buf[this.pos++]>127;);else if(t===a.Bytes)this.pos=this.readVarint()+this.pos;else if(t===a.Fixed32)this.pos+=4;else{if(t!==a.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var i=new Uint8Array(t);i.set(this.buf),this.buf=i,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),b(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),b(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),b(this.buf,-1&e,this.pos),b(this.buf,Math.floor(e*s),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),b(this.buf,-1&e,this.pos),b(this.buf,Math.floor(e*s),this.pos+4),this.pos+=8},writeVarint:function(e){(e=+e||0)>268435455||e<0?function(e,t){var i,r;e>=0?(i=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(i=~(-e%4294967296))?i=i+1|0:(i=0,r=r+1|0));if(e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos]=127&e}(i,0,t),function(e,t){var i=(7&e)<<4;if(t.buf[t.pos++]|=i|((e>>>=3)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;if(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),!e)return;t.buf[t.pos++]=127&e}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,i){for(var r,a,n=0;n<t.length;n++){if((r=t.charCodeAt(n))>55295&&r<57344){if(!a){r>56319||n+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):a=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,a=r;continue}r=a-55296<<10|r-56320|65536,a=null}else a&&(e[i++]=239,e[i++]=191,e[i++]=189,a=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);var i=this.pos-t;i>=128&&d(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeFloat:function(e){this.realloc(4),r.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),r.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var i=0;i<t;i++)this.buf[this.pos++]=e[i]},writeRawMessage:function(e,t){this.pos++;var i=this.pos;e(t,this);var r=this.pos-i;r>=128&&d(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,i){this.writeTag(e,a.Bytes),this.writeRawMessage(t,i)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,f,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,h,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,F,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,p,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,c,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,y,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,w,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,g,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,v,t)},writeBytesField:function(e,t){this.writeTag(e,a.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,a.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,a.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,a.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,a.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,a.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,a.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,a.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,a.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,a.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}},function(t){let r;try{r=e.read(new i(t))}catch(e){throw new Error("Could not parse arcgis-pbf buffer")}const a=r.queryResult.featureResult,n=a.transform,s=a.geometryType,o=a.objectIdFieldName,l=a.fields;for(let e=0;e<l.length;e++){const t=l[e];t.keyName=G(t)}const u={type:"FeatureCollection",features:[]},d=function(e){switch(e){case 3:return _;case 2:return T;case 0:return V;default:return _}}(s),f=a.features.length;for(let e=0;e<f;e++){const t=a.features[e];u.features.push({type:"Feature",id:B(l,t.attributes,o),properties:M(l,t.attributes),geometry:t.geometry&&d(t,n)})}return{featureCollection:u,exceededTransferLimit:a.exceededTransferLimit}}})); |
{ | ||
"name": "arcgis-pbf-parser", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A library for parsing the arcgis pbf format into geojson", | ||
@@ -20,3 +20,3 @@ "main": "dist/arcgis-pbf.cjs", | ||
"build": "rollup -c", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "node test/test.js" | ||
}, | ||
@@ -30,2 +30,5 @@ "repository": { | ||
"license": "Apache-2.0", | ||
"eslintConfig": { | ||
"extends": "mourner" | ||
}, | ||
"dependencies": { | ||
@@ -40,5 +43,9 @@ "pbf": "^3.2.1" | ||
"esm": "^3.2.25", | ||
"glob": "^10.0.0", | ||
"load-json-file": "^7.0.1", | ||
"rollup": "^2.48.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
"rollup-plugin-terser": "^7.0.2", | ||
"tape": "^5.6.3", | ||
"write-json-file": "^5.0.0" | ||
} | ||
} |
# arcgis-pbf-parser | ||
A library for converting an [arcgis-pbf](https://github.com/Esri/arcgis-pbf) into a geojson `FeatureCollection`. | ||
By itself it doesn't do much but you can find a more complex example of it's usage is in my mapbox-gl-arcgis-featureserver library. | ||
By itself it doesn't do much but you can find a more complex example of it's usage is in my [mapbox-gl-arcgis-featureserver](https://github.com/rowanwins/mapbox-gl-arcgis-featureserver) library. | ||
[![Test Status](https://github.com/rowanwins/arcgis-pbf-parser/workflows/Tests/badge.svg?branch=master)](https://github.com/rowanwins/arcgis-pbf-parser/actions) | ||
[![minzipped size](https://badgen.net/bundlephobia/minzip/arcgis-pbf-parser)](https://esm.run/arcgis-pbf-parser) | ||
## Basic Usage | ||
@@ -19,3 +22,3 @@ ```` | ||
The decode method returns an object containing the featureCollection, and a boolean specifying if there were too many features and so you need to paginate for more features with the same request. | ||
The decode method returns an object containing the `featureCollection` object, and a boolean specifying if there were too many features and so you need to paginate for more features with the same request. | ||
```` | ||
@@ -30,4 +33,2 @@ { | ||
*Note* | ||
I've not bundled the `pbf` dependency in my package, so you may need to `npm install pbf --save` in your project, although many of the common mapping libraries already include it so 🤞 you shouldn't need to. | ||
@@ -38,2 +39,3 @@ ## Status | ||
### Done | ||
@@ -47,6 +49,7 @@ - Polgon | ||
- Attributes | ||
- Features with null geometries | ||
### To Do | ||
- MultiPoint (a sample service would be helpful) | ||
- Write proper tests | ||
- Improve tests | ||
@@ -53,0 +56,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
99245
1
58
0
11