/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{QuantizedGeometryBuffer as r}from"../../../../../chunks/bundle.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let s;const i=new TextDecoder;class d extends n{constructor(t,r,n,s,i=new Uint32Array(n.size())){super(t),this._fields=r,this._inner=n,this._fileIndex=s,this._displayIds=i,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type}destroy(){super.destroy(),this._inner.free()}get fields(){return this._fields}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}getInTransform(){return null}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return this._fileIndex<<24|this._inner.rowId(this._index)}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new d(this.metadata,this._fields,this._inner,this._fileIndex,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[n,i]=e.translate,[d,o]=e.scale;s||(s=r.new());return this._inner.transformGeometry(s,n,i,d,o,this._index)?new t(s.readLengthsUnsafe(),s.readCoordsUnsafe(),this.hasZ,this.hasM):null}_readGeometry(e){const r=this._inner.readCoordsUnsafe(this._index),n=this._inner.readLengthsUnsafe(this._index);return r&&n?new t(n,r,this.hasZ,this.hasM):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;if(null==r.column)return this.getObjectId();const n=this._inner.readAttribute(this._index,r.column);if(null==n)return n;if("esriFieldTypeString"===r.type){const e=this._inner.readAttribute(this._index,r.column);return i.decode(e)}const s=this.fields.isDateField(r.name);return t?null==n?n:s?new Date(n):n:n}_readAttributes(){const e={};for(const t of this._fields.fields)if(null!=t.column&&null!=t.column){const r=this._readAttribute(t.name,!1);void 0!==r&&(e[t.name]=r)}return e.__OBJECTID=this.getObjectId(),e}}export{d as FeatureSetReaderParquet};
