UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.73 kB
import{getMetersPerVerticalUnitForSR as e}from"../../../core/unitUtils.js";import{equals as t}from"../../../geometry/support/spatialReferenceUtils.js";import{hasGeometry as r,OptimizedFeature as o}from"../../../layers/graphics/OptimizedFeature.js";import i from"../../../layers/graphics/OptimizedFeatureSet.js";import s from"../../../layers/graphics/OptimizedGeometry.js";const n=["esriGeometryPoint","esriGeometryMultipoint","esriGeometryPolyline","esriGeometryPolygon"];class a{constructor(e){this._options=e,this.geometryTypes=n,this._coordinatePtr=0,this._vertexDimension=0}createFeatureResult(){return new i}prepareFeatures(e){this._vertexDimension=2,e.hasZ&&this._vertexDimension++,e.hasM&&this._vertexDimension++}finishFeatureResult(o){if(!o||!o.features||!o.hasZ||!this._options.sourceSpatialReference||!o.spatialReference||t(o.spatialReference,this._options.sourceSpatialReference)||o.spatialReference.vcsWkid)return;const i=e(this._options.sourceSpatialReference)/e(o.spatialReference);if(1!==i)for(const e of o.features){if(!r(e))continue;const t=e.geometry.coords;for(let e=2;e<t.length;e+=3)t[e]*=i}}addFeature(e,t){e.features.push(t)}createFeature(){return new o}createSpatialReference(){return{wkid:0}}createGeometry(){return new s}addField(e,t){e.fields.push(t)}allocateCoordinates(e){e.coords.length=e.lengths.reduce(((e,t)=>e+t),0)*this._vertexDimension,this._coordinatePtr=0}addCoordinate(e,t){e.coords[this._coordinatePtr++]=t}addCoordinatePoint(e,t){e.coords.push(t)}addLength(e,t){e.lengths.push(t)}addQueryGeometry(e,t){e.queryGeometry=t.queryGeometry,e.queryGeometryType=t.queryGeometryType}createPointGeometry(){return new s}}export{n as OPTIMIZED_GEOMETRY_TYPES,a as OptimizedFeatureSetParserContext};