@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.51 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{Point as e}from"../../../../geometry/support/TileClipper.js";var t;!function(e){e[e.moveTo=1]="moveTo",e[e.lineTo=2]="lineTo",e[e.close=7]="close"}(t||(t={}));class s{constructor(e,t,s=0){this.values={},this._geometry=void 0,this._pbfGeometry=null,this.featureIndex=s;const o=t.keys,r=t.values,a=e.asUnsafe();for(;a.next();)switch(a.tag()){case 1:this.id=a.getUInt64();break;case 2:{const e=a.getMessage().asUnsafe(),t=this.values;for(;!e.empty();){const s=e.getUInt32(),a=e.getUInt32();t[o[s]]=r[a]}e.release();break}case 3:this.type=a.getUInt32();break;case 4:this._pbfGeometry=a.getMessage();break;default:a.skip()}}getGeometry(s){if(void 0!==this._geometry)return this._geometry;if(!this._pbfGeometry)return null;const o=this._pbfGeometry.asUnsafe();let r,a;this._pbfGeometry=null,s?s.reset(this.type):r=[];let n,i=t.moveTo,l=0,h=0,c=0;for(;!o.empty();){if(0===l){const e=o.getUInt32();i=7&e,l=e>>3}switch(l--,i){case t.moveTo:h+=o.getSInt32(),c+=o.getSInt32(),s?s.moveTo(h,c):r&&(a&&r.push(a),a=[],a.push(new e(h,c)));break;case t.lineTo:h+=o.getSInt32(),c+=o.getSInt32(),s?s.lineTo(h,c):a&&a.push(new e(h,c));break;case t.close:s?s.close():a&&!a[0].equals(h,c)&&a.push(a[0].clone());break;default:throw o.release(),new Error("Invalid path operation")}}return s?n=s.result():r&&(a&&r.push(a),n=r),o.release(),this._geometry=n,n}}export{s as default};