UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 1.55 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{zScale as e}from"../../../geometry/support/zscale.js";import{OptimizedFeature as t}from"../../../layers/graphics/OptimizedFeature.js";import r from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";import{createFeatureId as i}from"../../../layers/graphics/data/createFeatureId.js";class o{constructor(e){this._options=e,this.featureSet=new r,this.parseOnly=null,this._idInfo=null,this._coords=null}queryGeometryType(){return this.featureSet.queryGeometryType}queryGeometry(){return this.featureSet.queryGeometry}idField(e){"string"==typeof e?this._idInfo??={type:"object-id",fieldName:e}:this._idInfo={type:"unique-id-simple",fieldName:e.name}}finish(){if(this._idInfo)for(const e of this.featureSet.features)e.objectId=i(e,this._idInfo);const{hasZ:t,hasM:r,spatialReference:s}=this.featureSet,{sourceSpatialReference:o}=this._options,a=t?e(o,s):1;if(1!==a){const e=2+Number(t)+Number(r);for(let t=2;t<this._coords.length;t+=e)this._coords[t]*=a}}feature(){this.featureSet.features.push(new t(null,{},null,0))}centroid(e){const{hasZ:t,hasM:r}=this.featureSet;this.featureSet.features.at(-1).centroid=new s([],e,t,r)}geometry(e,t,r){this._coords=[];const{hasZ:i,hasM:o}=this.featureSet,a=new s(r,this._coords,i,o);return 1===e?(this.featureSet.queryGeometry=a,this.featureSet.queryGeometryType=t):this.featureSet.features.at(-1).geometry=a,0}coord(e){this._coords?.push(e)}}export{o as OptimizedFeatureSetParserContext};