UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 2.29 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import{estimateNumberArrayMemory as e}from"../../../../../core/memoryEstimations.js";import{getFeatureIdInfoFieldNames as t}from"../../../../../layers/graphics/data/FeatureIdInfo.js";import s from"../../../../../layers/support/FieldsIndex.js";import{parseField as r,parseTransform as o}from"../../../../../rest/query/operations/pbfFeatureServiceParser.js";const n=268435455;class i{constructor(){this.hasFeatures=!1,this.exceededTransferLimit=!1,this.fieldCount=0,this.featureCount=0,this.idFieldIndices=[],this.vertexCount=0,this.offsets={attributes:new Array,geometry:new Array},this.centroid=new Array}get usedMemory(){let t=0;return t+=e(this.idFieldIndices),t+=e(this.offsets.attributes),t+=e(this.offsets.geometry),t+=e(this.centroid),this.displayIds&&(t+=e(this.displayIds)),this.groupIds&&(t+=e(this.groupIds)),t}}function a(e,a,c){const d=9,f=12,u=13,p=15,g=e.asUnsafe(),h=g.pos(),l=new i;let m=0,y=0;const I=1,k=2,b=4,x=3;let w=null;const L=[];for(;g.next();)switch(g.tag()){case f:w=g.processMessage(o);break;case d:l.exceededTransferLimit=g.getBool();break;case u:{const e=g.processMessage(r);e.index=m++,L.push(e);break}case p:{const e=g.getLength(),t=g.pos()+e,s=l.offsets.geometry,r=l.centroid;for(s.push(0),r.push(n),r.push(n);g.pos()<t&&g.next();)switch(g.tag()){case I:{l.offsets.attributes.push(g.pos());const e=g.getLength();g.skipLen(e);break}case k:if(a){const e=g.getLength(),t=g.pos()+e;for(;g.pos()<t&&g.next();)switch(g.tag()){case x:{g.getUInt32();const e=g.getSInt64(),t=g.getSInt64();l.centroid[2*y]=e,l.centroid[2*y+1]=t;break}default:g.skip()}}else{l.offsets.geometry[y]=g.pos();const e=g.getLength();l.vertexCount+=e,g.skipLen(e)}break;case b:{const e=g.getLength(),t=g.pos()+e;for(;g.pos()<t&&g.next();)switch(g.tag()){case x:{g.getUInt32();const e=g.getSInt64(),t=g.getSInt64();l.centroid[2*y]=e,l.centroid[2*y+1]=t;break}default:g.skip()}break}default:g.skip()}y++,l.hasFeatures=!0;break}default:g.skip()}l.fields=new s(L),l.featureCount=y,l.fieldCount=m;const C=t(c);return l.idFieldIndices=Array.from(C,e=>l.fields.get(e)?.index),l.transform=w,l.displayIds=new Uint32Array(l.featureCount),l.groupIds=new Uint16Array(l.featureCount),g.move(h),l}export{i as FeatureSetHeader,a as parseHeader};