@arcgis/core 5.2.0-next.64 → 5.2.0-next.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{bb95922cd4631d6f17fb.js → 04ac5ac6f592d8c34bbd.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{0977f4d77c36175c2895.js → 3ddd717ea12d9823eee2.js} +1 -1
  4. package/assets/esri/core/workers/chunks/5adf16c034a590b5e9f5.js +1 -0
  5. package/assets/esri/core/workers/chunks/{57824ecc10b25e3ad794.js → 903e1cd8b76eff19ebdf.js} +1 -1
  6. package/assets/esri/core/workers/chunks/93c0a620a147cbf4a0ba.js +1 -0
  7. package/assets/esri/core/workers/chunks/9be6827e5756031a56c1.js +1 -0
  8. package/assets/esri/core/workers/chunks/a52c88e2d837b525ff6c.js +1 -0
  9. package/assets/esri/core/workers/chunks/{771ead806efbe9c91fdc.js → a5fdb02b1714e93fa69e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/b4e5ee81b9eb171499a6.js +1 -0
  11. package/assets/esri/core/workers/chunks/bece22668622a9a6bfe2.js +1 -0
  12. package/assets/esri/core/workers/chunks/c02ae1d40c1fe95ae6c5.js +1 -0
  13. package/assets/esri/core/workers/chunks/d51c41c1944df0cbab3e.js +1 -0
  14. package/assets/esri/core/workers/chunks/d583bcea4d1a21da9147.js +1 -0
  15. package/assets/esri/core/workers/chunks/{ef27bf1d7941ae265ca4.js → d7267f429a051943187b.js} +1 -1
  16. package/assets/esri/core/workers/chunks/d9c78c2db04a06ee83ed.js +1 -0
  17. package/assets/esri/core/workers/chunks/{c1e45e24f5ef719a714c.js → dc7e4f7879debf557e46.js} +143 -95
  18. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  19. package/chunks/Component.glsl.js +60 -62
  20. package/chunks/DefaultMaterial.glsl.js +27 -28
  21. package/chunks/GaussianSplat.glsl.js +7 -7
  22. package/chunks/GaussianSplatShadow.glsl.js +9 -9
  23. package/chunks/GlobalIllumination.glsl.js +35 -15
  24. package/chunks/Path.glsl.js +7 -6
  25. package/chunks/RealisticTree.glsl.js +22 -24
  26. package/chunks/SSAO.glsl.js +1 -1
  27. package/chunks/Terrain.glsl.js +3 -2
  28. package/chunks/Water.glsl.js +20 -11
  29. package/chunks/_commonjsHelpers.js +1 -1
  30. package/chunks/bundle2.js +1 -1
  31. package/config.js +1 -1
  32. package/kernel.js +1 -1
  33. package/layers/graphics/sources/ParquetSource.js +1 -1
  34. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  35. package/layers/graphics/sources/parquet/ParquetFileInfo.js +1 -1
  36. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  37. package/layers/raster/datasets/EphemeralBlockCache.js +1 -1
  38. package/layers/raster/datasets/RawBlockCache.js +1 -1
  39. package/layers/support/KMLSublayer.js +1 -1
  40. package/layers/video/VideoController.js +1 -1
  41. package/libs/parquet/parquet.js +1 -1
  42. package/package.json +1 -1
  43. package/rest/support/Query.js +1 -1
  44. package/support/revision.js +1 -1
  45. package/symbols/LabelSymbol3D.js +1 -1
  46. package/symbols/LineSymbol3D.js +1 -1
  47. package/symbols/MeshSymbol3D.js +1 -1
  48. package/symbols/PointSymbol3D.js +1 -1
  49. package/symbols/PolygonSymbol3D.js +1 -1
  50. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  51. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  52. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  53. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  54. package/views/3d/state/controllers/RotateController.js +1 -1
  55. package/views/3d/state/utils/navigationUtils.js +1 -1
  56. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  57. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  58. package/views/3d/terrain/OverlayRenderer.js +1 -1
  59. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +24 -16
  60. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialExternalColor.glsl.js +25 -0
  61. package/views/3d/webgl-engine/lib/GaussianSplatRenderUtils.js +2 -0
  62. package/views/3d/webgl-engine/lib/GaussianSplatRenderer.js +1 -1
  63. package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +1 -1
  64. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  65. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  66. package/views/3d/webgl-engine/shaders/GaussianSplatPassParameters.js +2 -0
  67. package/views/3d/webgl-engine/shaders/GaussianSplatShadow.glsl.js +1 -1
  68. package/views/3d/webgl-engine/shaders/GaussianSplatShadowTechnique.js +1 -1
  69. package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
  70. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  71. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  72. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  73. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  74. package/widgets/LayerList/ListItem.js +1 -1
  75. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  76. package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
  77. package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
  78. package/widgets/OrientedImageryViewer/support/superimposeUtils.js +1 -1
  79. package/widgets/OrientedImageryViewer.js +1 -1
  80. package/widgets/TableList/ListItem.js +1 -1
  81. package/assets/esri/core/workers/chunks/43b39abd49c4a8ce891f.js +0 -1
  82. package/assets/esri/core/workers/chunks/5dbd8ca7e7b8eb9a0bf7.js +0 -1
  83. package/assets/esri/core/workers/chunks/6123894e2ae9233cdf89.js +0 -1
  84. package/assets/esri/core/workers/chunks/6b536d03b4bef408035b.js +0 -1
  85. package/assets/esri/core/workers/chunks/6c98a64d92c9bca78203.js +0 -1
  86. package/assets/esri/core/workers/chunks/78b80da3bbc1b608fe83.js +0 -1
  87. package/assets/esri/core/workers/chunks/7d85048c6cd6ad84faf9.js +0 -1
  88. package/assets/esri/core/workers/chunks/9008090a5d8431ddfa22.js +0 -1
  89. package/assets/esri/core/workers/chunks/a2d8bc0efddd2e13b1ad.js +0 -1
  90. package/assets/esri/core/workers/chunks/c97451f75c23be979476.js +0 -1
package/config.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.2.0-next.64";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
2
+ import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,apiKeys:{scopes:[]},applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",respectPrefersReducedMotion:!0,routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],internalInterceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:62e3,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="5.2.0-next.65";s.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
package/kernel.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.2.0-next.64",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
2
+ import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";export{buildDate,commitHash as revision}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const e="5.2";let s,r=e;function i(o){s=o}function t(e){const r=s?.findCredential(e);return r?.token?o(e,"token",r.token):e}r="5.2.0-next.65",has("host-webworker")||globalThis.$arcgis||Object.defineProperty(globalThis,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),has("host-webworker");export{t as addTokenParameter,r as fullVersion,s as id,i as setId,e as version};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{EventedMixin as r}from"../../../core/Evented.js";import{Loadable as s}from"../../../core/Loadable.js";import o from"../../../core/Logger.js";import{throwIfAborted as a}from"../../../core/promiseUtils.js";import{watch as i}from"../../../core/reactiveUtils.js";import{open as n}from"../../../core/workers.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import y from"../../../geometry/Extent.js";import{createFileProviderSchema as l,toParquetJSONGeometryType as p}from"../../support/parquetUtils.js";import m from"../../../rest/support/FeatureSet.js";let h=class extends(r(s)){constructor(t){super(t),this.type="parquet"}load(t){const e=null!=t?t.signal:null;return this.addResolvingPromise(this._initialize(e)),this.addHandles([i(()=>this.layer.data,async t=>{if(t)try{await this._proxy.updateFileProvider(await l(t))}catch{}}),i(()=>this.layer.customParameters,t=>this._setCustomParameters(t))]),Promise.resolve(this)}async reload(t){const e=await this._createLoadParameters(t);return this._proxy.reload(e)}destroy(){this._connection?.destroy()}async openPorts(){return await this.load(),this._connection.openPorts()}async queryFeaturesJSON(t,e={}){return await this.load(e),this._proxy.queryFeatures(t.toJSON(),{signal:e?.signal})}async queryFeatures(t,e={}){const r=await this.queryFeaturesJSON(t,{signal:e?.signal});return m.fromJSON(r)}async queryObjectIds(t,e){return await this._proxy.queryObjectIds(t.toJSON(),{signal:e?.signal})}async queryFeatureCount(t,e){return this._proxy.queryFeatureCount(t.toJSON(),{signal:e?.signal})}async queryExtent(t,e){if(null==this.layer.geometryEncoding)return o.getLogger(this).warn("Tried to queryExtent, but source does not have a geometry. Returning null extent."),{count:0,extent:null};const r=await this._proxy.queryExtent(t.toJSON(),{signal:e?.signal});return{count:r.count,extent:y.fromJSON(r.extent)}}async _initialize(t){const e={onSourceChange:()=>this.emit("source-changed")};this._connection=await n("ParquetSourceWorker",{strategy:"dedicated",signal:t,registryTarget:this,client:e}),a(t),this._proxy=this._connection.createInvokeProxy();const r=await this._createLoadParameters(t),{layerDefinition:s,capabilities:o}=await this._proxy.load(r);a(t),this.sourceJSON=s,this.capabilities=o}async _createLoadParameters(t){if(!this.layer.data)throw new e("parquet:missing-data","A data source must be specified",this.layer);const r=await l(this.layer.data,{signal:t});return a(t),{provider:r,fields:this.layer.fields?.map(t=>t.toJSON()),geometryType:this.layer.geometryType?p(this.layer.geometryType):null,spatialReference:this.layer.spatialReference?.toJSON(),geometryEncoding:this.layer.geometryEncoding?.toJSON(),displayOptimization:this.layer.displayOptimization,customParameters:this.layer.customParameters}}_setCustomParameters(t){this._proxy.setCustomParameters(t).catch(()=>{o.getLogger(this).warn("Failed to update customParameters")})}_queryStream(t,e){return this._proxy.queryStream(t,e)}_getStreamNextFeatures(t,e){return this._proxy.getStreamNextFeatures(t,e)}};t([c()],h.prototype,"type",void 0),t([c({constructOnly:!0})],h.prototype,"layer",void 0),t([c()],h.prototype,"sourceJSON",void 0),t([c()],h.prototype,"capabilities",void 0),h=t([u("esri.layers.graphics.sources.ParquetSource")],h);export{h as ParquetSource};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{EventedMixin as r}from"../../../core/Evented.js";import{Loadable as s}from"../../../core/Loadable.js";import a from"../../../core/Logger.js";import{throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as i}from"../../../core/reactiveUtils.js";import{open as n}from"../../../core/workers.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import y from"../../../geometry/Extent.js";import{createFileProviderSchema as l,toParquetJSONGeometryType as p}from"../../support/parquetUtils.js";import m from"../../../rest/support/FeatureSet.js";let h=class extends(r(s)){constructor(t){super(t),this.type="parquet"}load(t){const e=null!=t?t.signal:null;return this.addResolvingPromise(this._initialize(e)),this.addHandles([i(()=>this.layer.data,async t=>{if(t)try{await this._proxy.updateFileProvider(await l(t))}catch{}}),i(()=>this.layer.customParameters,t=>this._setCustomParameters(t))]),Promise.resolve(this)}async reload(t){const e=await this._createLoadParameters(t);return this._proxy.reload(e)}destroy(){this._connection?.destroy()}async openPorts(){return await this.load(),this._connection.openPorts()}async getDiagnosticsSnapshot(){return await this.load(),this._proxy.getDiagnosticsSnapshot()}async getColumnIndex(t){return await this.load(),this._proxy.getColumnIndex(t)}async getOffsetIndex(t){return await this.load(),this._proxy.getOffsetIndex(t)}async queryFeaturesJSON(t,e={}){return await this.load(e),this._proxy.queryFeatures(t.toJSON(),{signal:e?.signal})}async queryFeatures(t,e={}){const r=await this.queryFeaturesJSON(t,{signal:e?.signal});return m.fromJSON(r)}async queryObjectIds(t,e){return await this._proxy.queryObjectIds(t.toJSON(),{signal:e?.signal})}async queryFeatureCount(t,e){return this._proxy.queryFeatureCount(t.toJSON(),{signal:e?.signal})}async queryExtent(t,e){if(null==this.layer.geometryEncoding)return a.getLogger(this).warn("Tried to queryExtent, but source does not have a geometry. Returning null extent."),{count:0,extent:null};const r=await this._proxy.queryExtent(t.toJSON(),{signal:e?.signal});return{count:r.count,extent:y.fromJSON(r.extent)}}async _initialize(t){const e={onSourceChange:()=>this.emit("source-changed"),onRangeRead:t=>this.emit("range-read",t)};this._connection=await n("ParquetSourceWorker",{strategy:"dedicated",signal:t,registryTarget:this,client:e}),o(t),this._proxy=this._connection.createInvokeProxy();const r=await this._createLoadParameters(t),{layerDefinition:s,capabilities:a}=await this._proxy.load(r);o(t),this.sourceJSON=s,this.capabilities=a}async _createLoadParameters(t){if(!this.layer.data)throw new e("parquet:missing-data","A data source must be specified",this.layer);const r=await l(this.layer.data,{signal:t});return o(t),{provider:r,fields:this.layer.fields?.map(t=>t.toJSON()),geometryType:this.layer.geometryType?p(this.layer.geometryType):null,spatialReference:this.layer.spatialReference?.toJSON(),geometryEncoding:this.layer.geometryEncoding?.toJSON(),displayOptimization:this.layer.displayOptimization,customParameters:this.layer.customParameters}}_setCustomParameters(t){this._proxy.setCustomParameters(t).catch(()=>{a.getLogger(this).warn("Failed to update customParameters")})}_queryStream(t,e){return this._proxy.queryStream(t,e)}_getStreamNextFeatures(t,e){return this._proxy.getStreamNextFeatures(t,e)}};t([c()],h.prototype,"type",void 0),t([c({constructOnly:!0})],h.prototype,"layer",void 0),t([c()],h.prototype,"sourceJSON",void 0),t([c()],h.prototype,"capabilities",void 0),h=t([u("esri.layers.graphics.sources.ParquetSource")],h);export{h as ParquetSource};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as t,__disposeResources as e}from"tslib";import a from"../../../../request.js";import s from"../../../../core/Error.js";import{EventEmitter as r}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{QueueProcessor as n}from"../../../../core/QueueProcessor.js";import{isBlobProtocol as i}from"../../../../core/urlUtils.js";import{ParquetFileInfo as o}from"./ParquetFileInfo.js";import{parseFileStatisticsMap as c}from"./ParquetFileStatistics.js";import{createParquetFile as h,readMetadata as u}from"../../../../libs/parquet/parquet.js";const f="parquet.v1",l="_spatial.json",g=new n({concurrency:12,process:async t=>{const{data:e}=await a(t.url,t.options);return e}});class p{constructor(t,e=()=>{}){this._geometryInfo=t,this._getCustomParameters=e,this.events=new r}async destroy(){await this.clear()}async clear(){if(this._infos){const t=await this._infos;for(const e of t.values())e.destroy();t.clear(),this._infos=null}}async getMetadata(){const a={stack:[],error:void 0,hasError:!1};try{const e=(await this._getParquetFileNames()).at(0);if(!e)return null;const s=t(a,await h(e,{provider:this}),!1);return u(s)}catch(s){a.error=s,a.hasError=!0}finally{e(a)}}getGeometryInfo(){return this._geometryInfo}async getFiles(){const t=await this._getInfoMap();return Array.from(t.values())}async updateGeometryInfo(t){if(this._geometryInfo)throw new Error("GeometryInfo already set");await this.clear(),this._geometryInfo=t}async fetchLength(t){const{byteLength:e,cacheTag:a}=await this._fetchLengthAndTag(t);if(!has("parquetlayer-cache-enabled"))return e;try{await this._createOrResetCache(t,a)}catch(s){}return e}async fetchRange(t,e,a,s){if(!has("parquetlayer-cache-enabled"))return this._fetchRange(t,e,a,s);const r=new URL(this._getCacheFileName(t));r.searchParams.append("range",`${e}-${a}`);try{const n=await this._openCache(t),i=await n.match(r);if(i)return await i.arrayBuffer();const o=await this._fetchRange(t,e,a,s);return await n.put(r,new Response(o,{headers:{"Content-Type":"application/octet-stream","Content-Length":o.byteLength.toString()}})),o}catch(n){return this._fetchRange(t,e,a,s)}}_getCacheFileName(t){return t}async _requestStatistics(t){const{data:e}=await a(t,{responseType:"json",query:this._getCustomParameters()});return e}async _fetchRange(t,e,a,r){const n={url:t,options:{responseType:"array-buffer",query:this._getCustomParameters()??{},cacheMode:"no-store",useQueue:!0,headers:{range:`bytes=${e}-${a}`}}},i=await g.push(n),o=a-e+1;if(i.byteLength!==o)throw new s("InvalidRangeRequest",`request returned ${i.byteLength} bytes for range ${e}-${a}, expected ${o}.`);return i}async _fetchLengthAndTag(t){if(i(t)){const{data:e}=await a(t,{responseType:"blob"});return{byteLength:e.size,cacheTag:null}}const e=await this._requestHead(t),s=e.headers.get("Content-Length");if(null==s)throw new Error("Unable to parse content length");const r=e.headers.get("etag")??e.headers.get("Last-Modified");return{byteLength:parseInt(s,10),cacheTag:r}}async _getInfoMap(){return this._infos||(this._infos=this._fetchParquetFiles()),this._infos}async _updateParquetFileInfos(t){const e=await this._getInfoMap(),a=new Set(t);for(const s of a)if(!e.get(s)){const t=e.size,a=await o.create(this.getGeometryInfo(),this,s,t,null);e.set(s,a)}for(const s of e.keys())if(!a.has(s))throw new Error("Deletion not supported")}async _getFileStatistics(t){this._statistics||(this._statistics=this._fetchStatistics());const e=await this._statistics,a=m(t);return e.get(a)}async _fetchParquetFiles(){const t=(await this._getParquetFileNames()).map(async(t,e)=>{const a=e,s=await this._getFileStatistics(t);return o.create(this.getGeometryInfo(),this,t,a,s)}),e=await Promise.all(t),a=new Map;for(const s of e)a.set(s.url,s);return a}async _fetchStatistics(){const t=await this._getStatisticsFileName();if(null==t)return new Map;const e=await this._resolveFileUrl(t),a=await this._requestStatistics(e);return c(a)}async _requestHead(t){const{data:e}=await a(t,{responseType:"native",method:"head",query:this._getCustomParameters()});return e}async _openCache(t){return caches.open(this._getCacheName(t))}_getCacheName(t){return`${f}:${this._getCacheFileName(t)}`}async _createOrResetCache(t,e){const a=this._getCacheName(t),s=new URL(this._getCacheFileName(t));if(s.searchParams.append("metadata","true"),null==e)return void await caches.delete(a);let r=await caches.open(a);const n=await r.match(s),i=await(n?.json());i?.tag!==e&&(await caches.delete(a),r=await caches.open(a));const o=JSON.stringify({tag:e});await r.put(s,new Response(o,{headers:{"Content-Type":"application/json","Content-Length":o.length.toString()}}))}}function y(t){const e=t.split(/[?#]/)[0];return e===l||e.endsWith(l)}function m(t){return t.split(/[?#]/)[0].split("/").at(-1)??t}export{p as FileProvider,y as isStatisticsFileName,l as spatialFileName};
2
+ import{__addDisposableResource as t,__disposeResources as e}from"tslib";import a from"../../../../request.js";import s from"../../../../core/Error.js";import{EventEmitter as r}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{QueueProcessor as n}from"../../../../core/QueueProcessor.js";import{isBlobProtocol as i}from"../../../../core/urlUtils.js";import{ParquetFileInfo as o}from"./ParquetFileInfo.js";import{parseFileStatisticsMap as c}from"./ParquetFileStatistics.js";import{createParquetFile as h,readMetadata as u}from"../../../../libs/parquet/parquet.js";const f="parquet.v1",g="_spatial.json",l=new n({concurrency:12,process:async t=>{const{data:e}=await a(t.url,t.options);return e}});let p=1;class y{constructor(t,e=()=>{}){this._geometryInfo=t,this._getCustomParameters=e,this.events=new r}async destroy(){await this.clear()}async clear(){if(this._infos){const t=await this._infos;for(const e of t.values())e.destroy();t.clear(),this._infos=null}}async getMetadata(){const a={stack:[],error:void 0,hasError:!1};try{const e=(await this._getParquetFileNames()).at(0);if(!e)return null;const s=t(a,await h(e,{provider:this}),!1);return u(s)}catch(s){a.error=s,a.hasError=!0}finally{e(a)}}getGeometryInfo(){return this._geometryInfo}async getFiles(){const t=await this._getInfoMap();return Array.from(t.values())}async updateGeometryInfo(t){if(this._geometryInfo)throw new Error("GeometryInfo already set");await this.clear(),this._geometryInfo=t}async fetchLength(t){const{byteLength:e,cacheTag:a}=await this._fetchLengthAndTag(t);if(!has("parquetlayer-cache-enabled"))return e;try{await this._createOrResetCache(t,a)}catch(s){}return e}async fetchRange(t,e,a,s){const r={fileId:t,requestId:p++,range:{start:e,end:a+1}};this.events.emit("rangeRead",{...r,phase:"start"});try{const n=await this._fetchRangeWithCache(t,e,a,s);return this.events.emit("rangeRead",{...r,phase:"complete"}),n}catch(n){throw this.events.emit("rangeRead",{...r,phase:"error"}),n}}_getCacheFileName(t){return t}async _requestStatistics(t){const{data:e}=await a(t,{responseType:"json",query:this._getCustomParameters()});return e}async _fetchRange(t,e,a,r){const n={url:t,options:{responseType:"array-buffer",query:this._getCustomParameters()??{},cacheMode:"no-store",useQueue:!0,headers:{range:`bytes=${e}-${a}`}}},i=await l.push(n),o=a-e+1;if(i.byteLength!==o)throw new s("InvalidRangeRequest",`request returned ${i.byteLength} bytes for range ${e}-${a}, expected ${o}.`);return i}async _fetchLengthAndTag(t){if(i(t)){const{data:e}=await a(t,{responseType:"blob"});return{byteLength:e.size,cacheTag:null}}const e=await this._requestHead(t),s=e.headers.get("Content-Length");if(null==s)throw new Error("Unable to parse content length");const r=e.headers.get("etag")??e.headers.get("Last-Modified");return{byteLength:parseInt(s,10),cacheTag:r}}async _getInfoMap(){return this._infos||(this._infos=this._fetchParquetFiles()),this._infos}async _updateParquetFileInfos(t){const e=await this._getInfoMap(),a=new Set(t);for(const s of a)if(!e.get(s)){const t=e.size,a=await o.create(this.getGeometryInfo(),this,s,t,null);e.set(s,a)}for(const s of e.keys())if(!a.has(s))throw new Error("Deletion not supported")}async _getFileStatistics(t){this._statistics||(this._statistics=this._fetchStatistics());const e=await this._statistics,a=_(t);return e.get(a)}async _fetchParquetFiles(){const t=(await this._getParquetFileNames()).map(async(t,e)=>{const a=e,s=await this._getFileStatistics(t);return o.create(this.getGeometryInfo(),this,t,a,s)}),e=await Promise.all(t),a=new Map;for(const s of e)a.set(s.url,s);return a}async _fetchStatistics(){const t=await this._getStatisticsFileName();if(null==t)return new Map;const e=await this._resolveFileUrl(t),a=await this._requestStatistics(e);return c(a)}async _requestHead(t){const{data:e}=await a(t,{responseType:"native",method:"head",query:this._getCustomParameters()});return e}async _openCache(t){return caches.open(this._getCacheName(t))}async _fetchRangeWithCache(t,e,a,s){if(!has("parquetlayer-cache-enabled"))return this._fetchRange(t,e,a,s);const r=new URL(this._getCacheFileName(t));r.searchParams.append("range",`${e}-${a}`);try{const n=await this._openCache(t),i=await n.match(r);if(i)return await i.arrayBuffer();const o=await this._fetchRange(t,e,a,s);return await n.put(r,new Response(o,{headers:{"Content-Type":"application/octet-stream","Content-Length":o.byteLength.toString()}})),o}catch(n){return this._fetchRange(t,e,a,s)}}_getCacheName(t){return`${f}:${this._getCacheFileName(t)}`}async _createOrResetCache(t,e){const a=this._getCacheName(t),s=new URL(this._getCacheFileName(t));if(s.searchParams.append("metadata","true"),null==e)return void await caches.delete(a);let r=await caches.open(a);const n=await r.match(s),i=await(n?.json());i?.tag!==e&&(await caches.delete(a),r=await caches.open(a));const o=JSON.stringify({tag:e});await r.put(s,new Response(o,{headers:{"Content-Type":"application/json","Content-Length":o.length.toString()}}))}}function m(t){const e=t.split(/[?#]/)[0];return e===g||e.endsWith(g)}function _(t){return t.split(/[?#]/)[0].split("/").at(-1)??t}export{y as FileProvider,m as isStatisticsFileName,g as spatialFileName};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{FileStatistics as t}from"./ParquetFileStatistics.js";import{createParquetFile as e}from"../../../../libs/parquet/parquet.js";class i{static async create(r,s,o,l,f){if(!f){const f=await e(o,{geometryInfo:r,provider:s}),n=t.fromFile(f);return new i(r,s,o,l,n,Promise.resolve(f))}return new i(r,s,o,l,f,null)}constructor(t,e,i,r,s,o){this._geometryInfo=t,this._provider=e,this.url=i,this.id=r,this.statistics=s,this._file=o}destroy(){null!=this._file&&this._file.then(t=>t.free())}get file(){return null==this._file&&(this._file=e(this.url,{geometryInfo:this._geometryInfo,provider:this._provider})),this._file}}export{i as ParquetFileInfo};
2
+ import{FileStatistics as t}from"./ParquetFileStatistics.js";import{createParquetFile as e}from"../../../../libs/parquet/parquet.js";class i{static async create(s,r,n,o,l){if(!l){const l=await e(n,{geometryInfo:s,provider:r}),a=t.fromFile(l);return new i(s,r,n,o,a,Promise.resolve(l))}return new i(s,r,n,o,l,null)}constructor(t,e,i,s,r,n){this._geometryInfo=t,this._provider=e,this.url=i,this.id=s,this.statistics=r,this._file=n}destroy(){null!=this._file&&this._file.then(t=>t.free())}get file(){return null==this._file&&(this._file=e(this.url,{geometryInfo:this._geometryInfo,provider:this._provider})),this._file}async getDiagnosticsSnapshot(){return{...(await this.file).diagnosticsSnapshot(),fileId:this.id,fileName:this.url}}async getColumnIndex(t,e){return(await this.file).columnIndex(t,e)}async getOffsetIndex(t,e){return(await this.file).offsetIndex(t,e)}}export{i as ParquetFileInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as s}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as n,throwIfAborted as u}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import c from"../../../../geometry/SpatialReference.js";import{set as p,create as d,expandWithAABB as f,expandWithRect as h,negativeInfinity as m}from"../../../../geometry/support/aaBoundingBox.js";import{copy as y,negativeInfinity as g,create as _,expandWithRect as w}from"../../../../geometry/support/aaBoundingRect.js";import{getScaleForResolution as x}from"../../../../geometry/support/scaleUtils.js";import{isWebMercator as F,isWGS84 as S}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as I}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as v}from"../../data/attributeSupport.js";import{getQueryResultExtent as q,getQueryBoundingRects as R,QueryEngine as b}from"../../data/QueryEngine.js";import{queryCapabilities as C}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as O}from"../../data/queryUtils.js";import{createFileProvider as P}from"../parquet/createFileProvider.js";import{readFieldStatistic as M}from"../parquet/ParquetFileStatistics.js";import{createDrawingInfo as T}from"./clientSideDefaults.js";import{getParquetFileId as j,getParquetRowId as Q,getParquetObjectId as A}from"./parquetIdUtils.js";import B from"../../../support/Field.js";import G from"../../../support/FieldsIndex.js";import{isNumericField as N}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as D}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as z,fromParquetJSONGeometryType as V,toParquetJSONGeometryType as k}from"../../../support/parquetUtils.js";import{loadParquetModule as W}from"../../../../libs/parquet/loadParquetModule.js";import{FeatureStoreQueryAdapter as U}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as Z}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as J}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as L}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as H}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const X=new U,Y=4,$="__OBJECTID",K=new TextDecoder,ee=8e3,te=2e7,se=8,re=2,ie=20;class ae{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){u(e),await this._fill(e);const t=await ne(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<se;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=se?se:re;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],s=new ue(t.id,this._createFileStream(t,e));return this._streams.push(s),s}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const s=(this._streamIndex+t)%e,r=this._streams[s];if(r.canRead)return this._streamIndex=(s+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ne(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class ue{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,s=await t.next(e);return null==s?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:s}}finally{this._readCount--}}}class oe{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new o({concurrency:Y,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){const t=e.spatialReference?c.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._provider=P(e.provider,null,()=>this._customParameters),this._handles.add(this._provider.events.on("sourceChanged",async()=>{await this.reload(e),await this._source.onSourceChange()}));const s=await this._provider.getMetadata(),i=await z(s,{fields:e.fields?.map(e=>B.fromJSON(e)),geometryEncoding:e.geometryEncoding?D(e.geometryEncoding):null,geometryType:e.geometryType?V(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!s?.hasZ,this._hasM=!!s?.hasM,!i.fields)throw new r("parquet:unsupported","Fields must be defined");let n;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r("parquet:unsupported","SpatialReference must be defined");if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:i.spatialReference}),i.spatialReference=c.WGS84),n={geometry:i.geometryEncoding?{geometryType:k(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(n),this._capabilities=Re(await this._getFileStatistics(),this._hasZ,this._hasM);const u=await this._provider.getFiles();if(!u.length)return{layerDefinition:{},capabilities:Re(null,this._hasZ,this._hasM)};const o=await u[0].file;i.file=o;const{fields:l}=i;if(null==l)throw new r("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",l);l.push(new B({name:$,type:"oid",alias:$}));for(const r of l){const e=o.getColumnId(r.name);null!=e&&(this._indexMap[r.name]=e)}const p=new G(l.map(e=>e.toJSON()));this._fieldsIndex=p;const d=k(i.geometryType??"point");return this._metadata=L.createFeature({fieldsIndex:p.toJSON(),geometryType:d,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:"object-id",fieldName:$},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:$},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=s?.extent?s.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:T(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy("")}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._provider=P(e,this._provider.getGeometryInfo(),()=>this._customParameters)}async queryFeatures(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),be(s)||(s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,ee):ee,s.resultOffset=s.resultOffset??0),s.outStatistics)return this._queryStatistics(s,t);s.returnDistinctValues&&(s.returnGeometry=void 0);return(await this._enqueueQuery(s,t)).createQueryResponse()}async queryFeatureCount(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return this._getFeatureCount();s.outFields=void 0,s.returnGeometry=void 0;return(await this._enqueueQuery(s,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const s=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,8e3):8e3,s.resultOffset=s.resultOffset??0,s.returnGeometry=void 0,s.outFields=void 0;return(await this._enqueueQuery(s,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new r("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const r=await O(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!de(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const a=p(d(),m),n=d(),u=await this._enqueueQuery(r,t);let o=0;for(const s of u.items)s.getBounds(n)&&(f(a,n),o+=1);return{count:o,extent:q(a,i,r.outSR?s(r.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this._getCandidateFiles(e),r=new ae(s,async(t,s)=>{const r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,ee,s)}),i=this._streamIdCounter++,a=n(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=this._streams.get(e);if(!s)return{result:null};const r=await s.stream.next(t.signal);if(null==r)return s.handle.remove(),this._streams.delete(e),{result:null};const i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){const{result:s}=await this.getStreamNext(e,t);if(null==s)return null;const r=(await W()).ParquetChunk.deserialize(new Uint8Array(s.buffer)),i=new H(this._metadata,this._indexMap,r,s.fileId),a=[];for(;i.next();){const e=I(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,s,r,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const a=await this._getFileInfoById(e),n=await a.file;return(await n.createChunkPatch(t,s,r,i.signal)).serialize().buffer}async _getCandidateFiles(e){const t=await this._provider.getFiles(),s=await this._getSpatialFilePruning(e);if(null==s)return t;const r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,s));return"xz"===s.type?ve(r,s):r}async _queryStatistics(e,t){const s=await O({...e},null,this._queryEngineParams.spatialReference);if(s.returnGeometry=void 0,me(s,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(s);if(e)return e}return(await this._enqueueQuery(s,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),s={},r=[];for(const i of e.outStatistics??[]){const e=_e(i,t);if(!e.available)return null;s[i.outStatisticFieldName]=e.value,r.push(ge(i,this._fieldsIndex))}return{fields:r,features:[{attributes:s}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,s=t?.index;if(null==s)return null;const r=e.outSpatialReference.wkid;if(null==s.wkid||null==r)return null;const i=s.wkid,a=await W();switch(s.type){case"xz":return{type:"xz",fieldName:s.code,intersects:(t,n)=>a.queryIntersectsXZStatistics(s.fullExtent,e.extent,r,i,ie,t,n)};case"z":return{type:"xy",xFieldName:s.xColumn,yFieldName:s.yColumn,intersects:(t,s,n,u)=>a.queryIntersectsXYStatistics(e.extent,r,i,t,s,n,u)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const s=Ie(e,t);return"null-only"!==s?.type&&("bounds"!==s?.type||t.intersects(s.minValue,s.maxValue))}case"xy":{const s=e.statistics.statistics.get(t.xFieldName),r=e.statistics.statistics.get(t.yFieldName);return"null-only"!==s?.type&&"null-only"!==r?.type&&("bounds"!==s?.type||"bounds"!==r?.type||t.intersects(s.minValue,s.maxValue,r.minValue,r.maxValue))}}}async _tryDeriveParquetFullExtent(s){if(!s.spatialReference)return null;if(null==this._fullExtent&&"location"===s.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:a,yField:n}=s.geometryEncoding,u=p(d(),m);let o=!1;for(const s of i){const i=await s.file;for(const s of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,s.columnDescriptorForAttribute(a),!1),r=e(i,s.columnDescriptorForAttribute(n),!1),l=M(t),c=M(r);if("bounds"===l?.type&&"bounds"===c?.type){const e=[l.minValue,c.minValue,l.maxValue,c.maxValue];h(u,e),o=!0}s.free()}catch(r){i.error=r,i.hasError=!0}finally{t(i)}}}return o?{xmin:u[0],ymin:u[1],xmax:u[3],ymax:u[4],spatialReference:s.spatialReference?.toJSON()}:null}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const s of t)if(s.id===e)return s;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,s,r,i){const a=(await W()).Query.new();null!=s&&a.setPreFilterStart(s),null!=r&&a.setPreFilterCount(r),null!=i&&a.setPostFilterCount(i);const n=await this._getRequiredFields(e);a.setOutFields(n),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);const u=this._tryGetGeneralizedGeometryScale(e);null!=u&&a.setScale(u);const o=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=o.wkid;if(e.geometry&&(F(o)||S(o))){const t=y(_(),g);for(const s of R(e.geometry))w(t,s);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){const{id:s,file:r}=t;await this._setWhereClause(a,await r,s,e.where)}return a}async _createParquetDisplayQuery(e,t,s){const r=(await W()).Query.new();return"tile"===s.type?(r.setExtent(s.extent),r.setQuantizationTransform(s.transform),r.setScale(s.scale)):"arcade"===s.type&&null!=s.extent&&r.setExtent(s.extent),r.setOutFields(s.outFields.filter(e=>null!=this._indexMap[e])),r.setOutSpatialReference(s.outSpatialReference.wkid),r.setReturnGeometry(s.returnGeometry),r.setReturnZ(s.returnZ),r.setReturnM(s.returnM),s.where&&await this._setWhereClause(r,e,t,s.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,s,i){const a=this._indexMap,n=this._fieldsIndex,u={getAttribute(e,r){const i=a[r];if(null==i){const t=n.get(r);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return A(s,t)}return null}const u=t.readAttribute(e.rowGroup,e.row,i);if(null==u)return null;const o=n.get(r);return"esriFieldTypeString"===o.type||"esriFieldTypeDateOnly"===o.type||"esriFieldTypeTimeOnly"===o.type||"esriFieldTypeTimestampOffset"===o.type?K.decode(u):u}},o=await l(i,this._fieldsIndex);if(!o.isStandardized)throw new r("sql-parse-error","expression is not standardized");const c=(e,t,s)=>o.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:s},u,null),p=o.fieldNames.map(e=>n.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_streamFeatures(e,t,s,r,i){const a=await this._provider.getFiles();let n=0;for(const u of a){const a=n,o=n+u.statistics.rowCount;if(n+=u.statistics.rowCount,null!=t&&t>=o)continue;const l=null!=t?Math.max(t-a,0):null;let c=s;if(null!=s){const e=t??0,r=e+s,i=Math.max(e,a),n=Math.min(r,o);c=Math.max(n-i,0)}if(0===c)continue;const p=await this._createParquetQuery(e,u,l,c,r),d=await u.file,f=await d.executeQuery(p,ee),h=async()=>{const e=await f.next(i);if(!e)return null;const t=new H(this._metadata,this._indexMap,e,u.id);return Se([new Z(t,null,0,!1)],this._queryEngineParams)};let m=await h();for(;null!=m;)yield m,m=await h()}}async _queryFeaturesWithQueryEnginePagination(e,t){const s=[],r=this._streamFeatures(e,null,null,null,t);let i=await r.next();for(;!i.done;){const a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of a)s.push(e);i=await r.next()}return s}async _queryFeaturesWithUpfrontPagination(e,t){let s,r,i,a=e.resultOffset??0,n=e.resultRecordCount??ee;fe(e)?he(e)||(i=a+n):(a&&(s=a,a=0),r=e.resultRecordCount);const u=[],o=this._streamFeatures(e,s,r,i,t);let l=await o.next();for(;!l.done&&n>0;){const s=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of s)if(a>0)a--;else if(u.push(e),--n<=0)return u;l=await o.next()}return u}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const s=new Map;for(const t of e.objectIds){const e=j(t),r=Q(t);let i=s.get(e);i||(i=[],s.set(e,i)),i.push(r)}const r=[];for(const[i,a]of s.entries()){const s=await this._executeFileIdQuery(e,i,a,t);for(const e of s)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:X,featureIdInfo:this._queryEngineParams.featureIdInfo})}if("1=1"===e.where&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>te){if(!(this._displayOptimization&&e.geometry))throw new r("parquet:cannot-execute-query","Unable to execute query, dataset is too large.")}const s=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=s?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return s||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:X,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,s,r){const i=await this._getRequiredFields(e),a=(await W()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(s));const n=await this._getFile(t),u=await n.executeQuery(a,ee,r);let o=await u.next(r),l=0;const c=[];for(;null!=o;){const e=new H(this._metadata,this._indexMap,o,t),s=new Z(e,null,l++,!1);c.push(s),o=await u.next(r)}return Se(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const s of v(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(s);else if(e.outFields)for(const s of e.outFields)t.add(s);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryScale(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!F(t)&&!S(t))return null;const s=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return s?x(s,t):null}}function le(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":case"resultOffset":case"resultRecordCount":return!0;default:return!1}}function ce(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":return!0;default:return!1}}function pe(e){switch(e){case"fullText":case"having":case"timeExtent":return!0;case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"resultOffset":case"geometry":case"resultRecordCount":return!1}return!1}function de(e){for(const t in e){const s=t;if(le(s)&&null!==e[s])return!0}return!1}function fe(e){for(const t in e){const s=t;if(ce(s)&&null!==e[s])return!0}return!1}function he(e){for(const t in e){const s=t;if(pe(s)&&null!==e[s])return!0}return!1}function me(e,t){return!!e.outStatistics?.length&&!de(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ye(e,t))}function ye(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const s=t.get(e.onStatisticField);return null!=s&&N(s)}default:return!1}}function ge(e,t){const s="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,r="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==s?.type?"esriFieldTypeDouble":s.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function _e(e,t){switch(e.statisticType){case"count":return we(e,t);case"min":return xe(e,t,Math.min);case"max":return xe(e,t,Math.max);default:return{available:!1,value:null}}}function we(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let s=0;for(const r of t){const t=r.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};s+=r.statistics.rowCount-t.nullCount}return{available:!0,value:s}}function xe(e,t,s){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let r=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const a of t){const t=a.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};switch(t.type){case"null-only":continue;case"unknown":return{available:!1,value:null};case"bounds":{const e=Fe(t[i]);if(null==e)return{available:!1,value:null};r=null==r?e:s(r,e);break}}}return{available:!0,value:r}}function Fe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Se(e,t){const s=new J;for(const r of e)s.insert(r);return new b({...t,featureStore:s})}function Ie(e,t){return e.statistics.statistics.get(t.fieldName)??null}function ve(e,t){return e.slice().sort((e,s)=>{const r=qe(e,t),i=qe(s,t);return r===i?0:r<i?-1:1})}function qe(e,t){const s=Ie(e,t);return"bounds"!==s?.type?Number.POSITIVE_INFINITY:s.maxValue-s.minValue}function Re(e,t,s){const r=e?.featureCount;let i=!1;return null!=r&&r<has("parquetlayer-full-query-feature-count")&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:s,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...C,maxRecordCount:ee,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function be(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{oe as default};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as s}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as n,throwIfAborted as o}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import{getMetersPerUnitForSR as c}from"../../../../core/units.js";import p from"../../../../geometry/SpatialReference.js";import{set as d,create as f,expandWithAABB as h,expandWithRect as m,negativeInfinity as y}from"../../../../geometry/support/aaBoundingBox.js";import{copy as g,negativeInfinity as _,create as w,expandWithRect as x}from"../../../../geometry/support/aaBoundingRect.js";import{isWebMercator as F,isWGS84 as S}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as I}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as v}from"../../data/attributeSupport.js";import{getQueryResultExtent as R,getQueryBoundingRects as q,QueryEngine as b}from"../../data/QueryEngine.js";import{queryCapabilities as C}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as P}from"../../data/queryUtils.js";import{createFileProvider as O}from"../parquet/createFileProvider.js";import{readFieldStatistic as M}from"../parquet/ParquetFileStatistics.js";import{createDrawingInfo as T}from"./clientSideDefaults.js";import{getParquetFileId as j,getParquetRowId as Q,getParquetObjectId as A}from"./parquetIdUtils.js";import B from"../../../support/Field.js";import G from"../../../support/FieldsIndex.js";import{isNumericField as N}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as D}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as z,fromParquetJSONGeometryType as V,toParquetJSONGeometryType as k}from"../../../support/parquetUtils.js";import{loadParquetModule as W}from"../../../../libs/parquet/loadParquetModule.js";import{normalizeColumnPath as U}from"../../../../libs/parquet/parquet.js";import{FeatureStoreQueryAdapter as Z}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as J}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as L}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as H}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as X}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const Y=new Z,$=4,K="__OBJECTID",ee=new TextDecoder,te=8e3,se=2e7,re=8,ie=2;class ae{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){o(e),await this._fill(e);const t=await ne(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<re;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=re?re:ie;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],s=new oe(t.id,this._createFileStream(t,e));return this._streams.push(s),s}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const s=(this._streamIndex+t)%e,r=this._streams[s];if(r.canRead)return this._streamIndex=(s+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ne(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class oe{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,s=await t.next(e);return null==s?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:s}}finally{this._readCount--}}}class ue{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new u({concurrency:$,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){const t=e.spatialReference?p.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._loadParameters=e,await this._updateProvider(O(e.provider,null,()=>this._customParameters));const s=await this._provider.getMetadata(),i=await z(s,{fields:e.fields?.map(e=>B.fromJSON(e)),geometryEncoding:e.geometryEncoding?D(e.geometryEncoding):null,geometryType:e.geometryType?V(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!s?.hasZ,this._hasM=!!s?.hasM,!i.fields)throw new r("parquet:unsupported","Fields must be defined");let n;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r("parquet:unsupported","SpatialReference must be defined");if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:i.spatialReference}),i.spatialReference=p.WGS84),n={geometry:i.geometryEncoding?{geometryType:k(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(n),this._capabilities=qe(await this._getFileStatistics(),this._hasZ,this._hasM);const o=await this._provider.getFiles();if(!o.length)return{layerDefinition:{},capabilities:qe(null,this._hasZ,this._hasM)};const u=await o[0].file;i.file=u;const{fields:l}=i;if(null==l)throw new r("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",l);l.push(new B({name:K,type:"oid",alias:K}));for(const r of l){const e=u.getColumnId(r.name);null!=e&&(this._indexMap[r.name]=e)}const c=new G(l.map(e=>e.toJSON()));this._fieldsIndex=c;const d=k(i.geometryType??"point");return this._metadata=H.createFeature({fieldsIndex:c.toJSON(),geometryType:d,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:"object-id",fieldName:K},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:K},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=s?.extent?s.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:T(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy("")}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._loadParameters={...this._loadParameters,provider:e};const t=O(e,this._provider.getGeometryInfo(),()=>this._customParameters);await this._updateProvider(t)}async getDiagnosticsSnapshot(){const e=await this._provider.getFiles();return{files:await Promise.all(e.map(e=>e.getDiagnosticsSnapshot()))}}async getColumnIndex(e){return(await this._getFileInfoById(e.fileId)).getColumnIndex(e.rowGroupIndex,e.columnIndex)}async getOffsetIndex(e){return(await this._getFileInfoById(e.fileId)).getOffsetIndex(e.rowGroupIndex,e.columnIndex)}async queryFeatures(e,t){const s=await P(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),be(s)||(s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,te):te,s.resultOffset=s.resultOffset??0),s.outStatistics)return this._queryStatistics(s,t);s.returnDistinctValues&&(s.returnGeometry=void 0);return(await this._enqueueQuery(s,t)).createQueryResponse()}async queryFeatureCount(e,t){const s=await P(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return this._getFeatureCount();s.outFields=void 0,s.returnGeometry=void 0;return(await this._enqueueQuery(s,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const s=await P(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),!de(s))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);s.resultRecordCount=s.resultRecordCount?Math.min(s.resultRecordCount,8e3):8e3,s.resultOffset=s.resultOffset??0,s.returnGeometry=void 0,s.outFields=void 0;return(await this._enqueueQuery(s,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new r("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const r=await P(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!de(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=s(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;const a=d(f(),y),n=f(),o=await this._enqueueQuery(r,t);let u=0;for(const s of o.items)s.getBounds(n)&&(h(a,n),u+=1);return{count:u,extent:R(a,i,r.outSR?s(r.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=await this._getCandidateFiles(e),r=new ae(s,async(t,s)=>{const r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,te,s)}),i=this._streamIdCounter++,a=n(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const s=this._streams.get(e);if(!s)return{result:null};const r=await s.stream.next(t.signal);if(null==r)return s.handle.remove(),this._streams.delete(e),{result:null};const i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){const{result:s}=await this.getStreamNext(e,t);if(null==s)return null;const r=(await W()).ParquetChunk.deserialize(new Uint8Array(s.buffer)),i=new X(this._metadata,this._indexMap,r,s.fileId),a=[];for(;i.next();){const e=I(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,s,r,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const a=await this._getFileInfoById(e),n=await a.file;return(await n.createChunkPatch(t,s,r,i.signal)).serialize().buffer}async _updateProvider(e){const t=this._provider;this._handles.removeAll(),this._provider=e,this._handles.add([e.events.on("rangeRead",e=>{this._source.onRangeRead(e)}),e.events.on("sourceChanged",async()=>{await this.reload(this._loadParameters),await this._source.onSourceChange()})]),await(t?.destroy())}async _getCandidateFiles(e){const t=await this._provider.getFiles(),s=await this._getSpatialFilePruning(e);if(null==s)return t;const r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,s));return"xz"===s.type?ve(r,s):r}async _queryStatistics(e,t){const s=await P({...e},null,this._queryEngineParams.spatialReference);if(s.returnGeometry=void 0,me(s,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(s);if(e)return e}return(await this._enqueueQuery(s,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),s={},r=[];for(const i of e.outStatistics??[]){const e=_e(i,t);if(!e.available)return null;s[i.outStatisticFieldName]=e.value,r.push(ge(i,this._fieldsIndex))}return{fields:r,features:[{attributes:s}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,s=t?.index;if(null==s)return null;const r=e.outSpatialReference.wkid;if(null==s.wkid||null==r)return null;const i=s.wkid,a=await W();switch(s.type){case"xz":return{type:"xz",fieldName:U(s.code),intersects:(t,n)=>a.queryIntersectsXZStatistics(s.fullExtent,e.extent,r,i,s.maxLevel,t,n)};case"z":return{type:"xy",xFieldName:U(s.xColumn),yFieldName:U(s.yColumn),intersects:(t,s,n,o)=>a.queryIntersectsXYStatistics(e.extent,r,i,t,s,n,o)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const s=Ie(e,t);return"null-only"!==s?.type&&("bounds"!==s?.type||t.intersects(s.minValue,s.maxValue))}case"xy":{const s=e.statistics.statistics.get(t.xFieldName),r=e.statistics.statistics.get(t.yFieldName);return"null-only"!==s?.type&&"null-only"!==r?.type&&("bounds"!==s?.type||"bounds"!==r?.type||t.intersects(s.minValue,s.maxValue,r.minValue,r.maxValue))}}}async _tryDeriveParquetFullExtent(s){if(!s.spatialReference)return null;if(null==this._fullExtent&&"location"===s.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:a,yField:n}=s.geometryEncoding,o=d(f(),y);let u=!1;for(const s of i){const i=await s.file;for(const s of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,s.columnDescriptorForAttribute(a),!1),r=e(i,s.columnDescriptorForAttribute(n),!1),l=M(t),c=M(r);if("bounds"===l?.type&&"bounds"===c?.type){const e=[l.minValue,c.minValue,l.maxValue,c.maxValue];m(o,e),u=!0}s.free()}catch(r){i.error=r,i.hasError=!0}finally{t(i)}}}return u?{xmin:o[0],ymin:o[1],xmax:o[3],ymax:o[4],spatialReference:s.spatialReference?.toJSON()}:null}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const s of t)if(s.id===e)return s;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,s,r,i){const a=(await W()).Query.new();null!=s&&a.setPreFilterStart(s),null!=r&&a.setPreFilterCount(r),null!=i&&a.setPostFilterCount(i);const n=await this._getRequiredFields(e);a.setOutFields(n),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);const o=this._tryGetGeneralizedGeometryResolution(e);null!=o&&a.setSourceResolution(o);const u=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=u.wkid;if(e.geometry&&(F(u)||S(u))){const t=g(w(),_);for(const s of q(e.geometry))x(t,s);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){const{id:s,file:r}=t;await this._setWhereClause(a,await r,s,e.where)}return a}async _createParquetDisplayQuery(e,t,s){const r=(await W()).Query.new();if("tile"===s.type){r.setExtent(s.extent),r.setQuantizationTransform(s.transform);const e=this._sourceResolution(s.resolution,s.outSpatialReference);null!=e&&r.setSourceResolution(e)}else"arcade"===s.type&&null!=s.extent&&r.setExtent(s.extent);return r.setOutFields(s.outFields.filter(e=>null!=this._indexMap[e])),r.setOutSpatialReference(s.outSpatialReference.wkid),r.setReturnGeometry(s.returnGeometry),r.setReturnZ(s.returnZ),r.setReturnM(s.returnM),s.where&&await this._setWhereClause(r,e,t,s.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,s,i){const a=this._indexMap,n=this._fieldsIndex,o={getAttribute(e,r){const i=a[r];if(null==i){const t=n.get(r);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return A(s,t)}return null}const o=t.readAttribute(e.rowGroup,e.row,i);if(null==o)return null;const u=n.get(r);return"esriFieldTypeString"===u.type||"esriFieldTypeDateOnly"===u.type||"esriFieldTypeTimeOnly"===u.type||"esriFieldTypeTimestampOffset"===u.type?ee.decode(o):o}},u=await l(i,this._fieldsIndex);if(!u.isStandardized)throw new r("sql-parse-error","expression is not standardized");const c=(e,t,s)=>u.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:s},o,null),p=u.fieldNames.map(e=>n.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_streamFeatures(e,t,s,r,i){const a=await this._provider.getFiles();let n=0;for(const o of a){const a=n,u=n+o.statistics.rowCount;if(n+=o.statistics.rowCount,null!=t&&t>=u)continue;const l=null!=t?Math.max(t-a,0):null;let c=s;if(null!=s){const e=t??0,r=e+s,i=Math.max(e,a),n=Math.min(r,u);c=Math.max(n-i,0)}if(0===c)continue;const p=await this._createParquetQuery(e,o,l,c,r),d=await o.file,f=await d.executeQuery(p,te),h=async()=>{const e=await f.next(i);if(!e)return null;const t=new X(this._metadata,this._indexMap,e,o.id);return Se([new J(t,null,0,!1)],this._queryEngineParams)};let m=await h();for(;null!=m;)yield m,m=await h()}}async _queryFeaturesWithQueryEnginePagination(e,t){const s=[],r=this._streamFeatures(e,null,null,null,t);let i=await r.next();for(;!i.done;){const a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of a)s.push(e);i=await r.next()}return s}async _queryFeaturesWithUpfrontPagination(e,t){let s,r,i,a=e.resultOffset??0,n=e.resultRecordCount??te;fe(e)?he(e)||(i=a+n):(a&&(s=a,a=0),r=e.resultRecordCount);const o=[],u=this._streamFeatures(e,s,r,i,t);let l=await u.next();for(;!l.done&&n>0;){const s=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of s)if(a>0)a--;else if(o.push(e),--n<=0)return o;l=await u.next()}return o}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const s=new Map;for(const t of e.objectIds){const e=j(t),r=Q(t);let i=s.get(e);i||(i=[],s.set(e,i)),i.push(r)}const r=[];for(const[i,a]of s.entries()){const s=await this._executeFileIdQuery(e,i,a,t);for(const e of s)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:Y,featureIdInfo:this._queryEngineParams.featureIdInfo})}if("1=1"===e.where&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>se){if(!(this._displayOptimization&&e.geometry))throw new r("parquet:cannot-execute-query","Unable to execute query, dataset is too large.")}const s=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=s?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return s||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:Y,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,s,r){const i=await this._getRequiredFields(e),a=(await W()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(s));const n=await this._getFile(t),o=await n.executeQuery(a,te,r);let u=await o.next(r),l=0;const c=[];for(;null!=u;){const e=new X(this._metadata,this._indexMap,u,t),s=new J(e,null,l++,!1);c.push(s),u=await o.next(r)}return Se(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const s of v(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(s);else if(e.outFields)for(const s of e.outFields)t.add(s);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryResolution(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!F(t)&&!S(t))return null;const s=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return s?this._sourceResolution(s,t):null}_sourceResolution(e,t){const s=this._queryEngineParams.spatialReference,r=e*(c(t)/c(s));return!Number.isFinite(r)||r<=0?null:r}}function le(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":case"resultOffset":case"resultRecordCount":return!0;default:return!1}}function ce(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":return!0;default:return!1}}function pe(e){switch(e){case"fullText":case"having":case"timeExtent":return!0;case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"resultOffset":case"geometry":case"resultRecordCount":return!1}return!1}function de(e){for(const t in e){const s=t;if(le(s)&&null!==e[s])return!0}return!1}function fe(e){for(const t in e){const s=t;if(ce(s)&&null!==e[s])return!0}return!1}function he(e){for(const t in e){const s=t;if(pe(s)&&null!==e[s])return!0}return!1}function me(e,t){return!!e.outStatistics?.length&&!de(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ye(e,t))}function ye(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const s=t.get(e.onStatisticField);return null!=s&&N(s)}default:return!1}}function ge(e,t){const s="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,r="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==s?.type?"esriFieldTypeDouble":s.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function _e(e,t){switch(e.statisticType){case"count":return we(e,t);case"min":return xe(e,t,Math.min);case"max":return xe(e,t,Math.max);default:return{available:!1,value:null}}}function we(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let s=0;for(const r of t){const t=r.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};s+=r.statistics.rowCount-t.nullCount}return{available:!0,value:s}}function xe(e,t,s){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let r=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const a of t){const t=a.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};switch(t.type){case"null-only":continue;case"unknown":return{available:!1,value:null};case"bounds":{const e=Fe(t[i]);if(null==e)return{available:!1,value:null};r=null==r?e:s(r,e);break}}}return{available:!0,value:r}}function Fe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Se(e,t){const s=new L;for(const r of e)s.insert(r);return new b({...t,featureStore:s})}function Ie(e,t){return e.statistics.statistics.get(t.fieldName)??null}function ve(e,t){return e.slice().sort((e,s)=>{const r=Re(e,t),i=Re(s,t);return r===i?0:r<i?-1:1})}function Re(e,t){const s=Ie(e,t);return"bounds"!==s?.type?Number.POSITIVE_INFINITY:s.maxValue-s.minValue}function qe(e,t,s){const r=e?.featureCount;let i=!1;return null!=r&&r<has("parquetlayer-full-query-feature-count")&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:s,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...C,maxRecordCount:te,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function be(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{ue as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- class t{constructor(t=15e3,e=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=t,this._interval=Math.min(t,e)}decreaseRefCount(t,e){const s=t+"/"+e,r=this._cachedBlocks;if(r.has(s)){const t=r.get(s);return t.refCount--,t.refCount<=0&&(r.delete(s),t.controller&&t.controller.abort()),t.refCount}return 0}getBlock(t,e){const s=t+"/"+e,r=this._cachedBlocks;if(r.has(s)){const t=r.get(s);return t.ts=Date.now(),t.refCount++,r.delete(s),r.set(s,t),t.block}return null}putBlock(t,e,s,r){const i=this._cachedBlocks,c=t+"/"+e;if(i.has(c)){const t=i.get(c);t.ts=Date.now(),t.refCount++}else i.set(c,{block:s,ts:Date.now(),refCount:1,controller:r});this._trim(),this._updateTimer()}deleteBlock(t,e){const s=this._cachedBlocks,r=t+"/"+e;s.has(r)&&s.delete(r)}updateMaxSize(t){this._size=t,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const t=this._cachedBlocks;this._timer=setInterval(()=>{const e=Array.from(t),s=Date.now();for(let r=0;r<e.length&&e[r][1].ts<=s-this._duration;r++)t.delete(e[r][0]);0===t.size&&this._clearTimer()},this._interval)}_trim(){const t=this._cachedBlocks;if(-1===this._size||this._size>=t.size)return;const e=Array.from(t);for(let s=0;s<e.length-this._size;s++)t.delete(e[s][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}}export{t as default};
2
+ class t{constructor(t=15e3,e=5e3,s=-1){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=t,this._interval=Math.min(t,e),this._size=s}decreaseRefCount(t,e){const s=t+"/"+e,r=this._cachedBlocks;if(r.has(s)){const t=r.get(s);return t.refCount--,t.refCount<=0&&(r.delete(s),t.controller&&t.controller.abort()),t.refCount}return 0}getBlock(t,e){const s=t+"/"+e,r=this._cachedBlocks;if(r.has(s)){const t=r.get(s);return t.ts=Date.now(),t.refCount++,r.delete(s),r.set(s,t),t.block}return null}putBlock(t,e,s,r){const i=this._cachedBlocks,c=t+"/"+e;if(i.has(c)){const t=i.get(c);t.ts=Date.now(),t.refCount++}else i.set(c,{block:s,ts:Date.now(),refCount:1,controller:r});this._trim(),this._updateTimer()}deleteBlock(t,e){const s=this._cachedBlocks,r=t+"/"+e;s.has(r)&&s.delete(r)}updateMaxSize(t){this._size=t,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const t=this._cachedBlocks;this._timer=setInterval(()=>{const e=Array.from(t),s=Date.now();for(let r=0;r<e.length&&e[r][1].ts<=s-this._duration;r++)t.delete(e[r][0]);0===t.size&&this._clearTimer()},this._interval)}_trim(){const t=this._cachedBlocks;if(-1===this._size||this._size>=t.size)return;const e=Array.from(t).sort((t,e)=>t[1].refCount-e[1].refCount||t[1].ts-e[1].ts);for(let s=0;s<e.length-this._size;s++)t.delete(e[s][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}}export{t as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../geometry/Point.js";import n from"./EphemeralBlockCache.js";import{projectExtent as t,projectResolution as o,snapPyramid as l}from"../functions/rasterProjectionHelper.js";const r=new Map,c=new n;function i(e,n,t){const o=[];return null!=n&&o.push(`sliceId=${n}`),null!=t&&o.push(`bandIds=${t.join(",")}`),o.length?`${e}?${o.join("&")}`:e}function u(e,n){const t={extent:null,rasterInfo:n,cache:new Map},o=r.get(e);return o?(o.push(t),o.length-1):(r.set(e,[t]),0)}function a(e,n){const t=r.get(e);t&&(t[n]=null,t.some(e=>null!=e)||s(e))}function f(e,n){const t=r.get(e);if(t){const e=n.map(e=>t[e]).filter(e=>null!=e);for(const n of e)if(n){Array.from(n.cache.values()).forEach(e=>{e.isResolved||e.isRejected||!e.controller||e.controller.abort()}),n.cache.clear()}}}function s(e){r.delete(e)}function m(e,n,t){const o=r.get(e);if(!o)return null==n?c.decreaseRefCount(e,t):0;if(null==n||null==o[n])return c.decreaseRefCount(e,t);const l=o[n]?.cache,i=l?.get(t);if(l&&i){if(i.refCount--,0===i.refCount){l.delete(t);for(let e=0;e<o.length;e++)o[e]?.cache.delete(t);i.controller&&i.controller.abort()}return i.refCount}return 0}function h(e,n,t){const o=r.get(e);if(!o)return null==n?c.getBlock(e,t):null;if(null==n||null==o[n]){for(let e=0;e<o.length;e++){const n=o[e]?.cache.get(t);if(n)return n.refCount++,n.block}return c.getBlock(e,t)}const l=o[n]?.cache.get(t);if(l)return l.refCount++,l.block;for(let r=0;r<o.length;r++){if(r===n||!o[r])continue;const e=o[r]?.cache,l=e?.get(t);if(e&&l)return l.refCount++,e.set(t,l),l.block}return null}function x(e,n,t,o,l=null){const i=r.get(e);if(!i)return void(null==n&&c.putBlock(e,t,o,l));if(null==n||null==i[n])return void c.putBlock(e,t,o,l);const u={refCount:1,block:o,isResolved:!1,isRejected:!1,controller:l};o.then(()=>u.isResolved=!0).catch(()=>u.isRejected=!0),i[n]?.cache.set(t,u)}function d(e,n,t){const o=r.get(e);o?null!=n&&null!=o[n]?o[n]?.cache.delete(t):c.deleteBlock(e,t):null==n&&c.deleteBlock(e,t)}function g(e,n){const t=r.get(e);return t?t[n]??null:null}function p(n,r,c,i,u,a,f=null){const s=g(n,r);if(!s)return;const m=s.extent,{cache:h,rasterInfo:x}=s;if(m?.xmin===c.xmin&&m.xmax===c.xmax&&m.ymin===c.ymin&&m.ymax===c.ymax)return;i=i??0;const d=c.clone().normalize(),{spatialReference:p,transform:y}=x,R=new Set;for(let g=0;g<d.length;g++){const n=d[g];if(n.xmax-n.xmin<=i||n.ymax-n.ymin<=i)continue;let r=t(n,p,f);if(null==r)continue;if(null!=y&&(r=y.inverseTransform(r),null==r))continue;const c=new e({x:i,y:i,spatialReference:n.spatialReference});if(null==u&&!(u=o(c,p,n,f)))return;const{pyramidLevel:s,pyramidResolution:m,excessiveReading:h}=l(u,x,a||"closest");if(h)return;const{storageInfo:k}=x,{origin:M}=k,{x:C,y:b}=m,j=Math.max(0,Math.floor((r.xmin-M.x)/C)),v=Math.max(0,Math.floor((M.y-r.ymax)/b)),B=Math.ceil(r.width/C-.1),w=Math.ceil(r.height/b-.1),$=s>0?k.pyramidBlockWidth:k.blockWidth,I=s>0?k.pyramidBlockHeight:k.blockHeight,E=k.blockBoundary[s];if(!E)continue;const H=1,P=Math.max(E.minCol,Math.floor(j/$)-H),W=Math.max(E.minRow,Math.floor(v/I)-H),z=Math.min(E.maxCol,Math.floor((j+B-1)/$)+H),A=Math.min(E.maxRow,Math.floor((v+w-1)/I)+H);for(let e=W;e<=A;e++)for(let n=P;n<=z;n++)R.add(`${s}/${e}/${n}`)}h.forEach((e,n)=>{if(!R.has(n)){const e=h.get(n);(null==e||e.isResolved||e.isRejected)&&h.delete(n)}}),s.extent={xmin:c.xmin,ymin:c.ymin,xmax:c.xmax,ymax:c.ymax}}export{f as clearRegisteredIds,m as decreaseRefCount,d as deleteBlock,s as deleteRaster,h as getBlock,i as getRasterId,x as putBlock,u as register,a as unregister,p as update};
2
+ import e from"../../../geometry/Point.js";import n from"./EphemeralBlockCache.js";import{projectExtent as t,projectResolution as o,snapPyramid as l}from"../functions/rasterProjectionHelper.js";const r=new Map,c=new n(15e3,5e3,100);function i(e,n,t){const o=[];return null!=n&&o.push(`sliceId=${n}`),null!=t&&o.push(`bandIds=${t.join(",")}`),o.length?`${e}?${o.join("&")}`:e}function u(e,n){const t={extent:null,rasterInfo:n,cache:new Map},o=r.get(e);return o?(o.push(t),o.length-1):(r.set(e,[t]),0)}function a(e,n){const t=r.get(e);t&&(t[n]=null,t.some(e=>null!=e)||s(e))}function f(e,n){const t=r.get(e);if(t){const e=n.map(e=>t[e]).filter(e=>null!=e);for(const n of e)if(n){Array.from(n.cache.values()).forEach(e=>{e.isResolved||e.isRejected||!e.controller||e.controller.abort()}),n.cache.clear()}}}function s(e){r.delete(e)}function m(e,n,t){const o=r.get(e);if(!o)return null==n?c.decreaseRefCount(e,t):0;if(null==n||null==o[n])return c.decreaseRefCount(e,t);const l=o[n]?.cache,i=l?.get(t);if(l&&i){if(i.refCount--,0===i.refCount){l.delete(t);for(let e=0;e<o.length;e++)o[e]?.cache.delete(t);i.controller&&i.controller.abort()}return i.refCount}return 0}function h(e,n,t){const o=r.get(e);if(!o)return null==n?c.getBlock(e,t):null;if(null==n||null==o[n]){for(let e=0;e<o.length;e++){const n=o[e]?.cache.get(t);if(n)return n.refCount++,n.block}return c.getBlock(e,t)}const l=o[n]?.cache.get(t);if(l)return l.refCount++,l.block;for(let r=0;r<o.length;r++){if(r===n||!o[r])continue;const e=o[r]?.cache,l=e?.get(t);if(e&&l)return l.refCount++,e.set(t,l),l.block}return null}function x(e,n,t,o,l=null){const i=r.get(e);if(!i)return void(null==n&&c.putBlock(e,t,o,l));if(null==n||null==i[n])return void c.putBlock(e,t,o,l);const u={refCount:1,block:o,isResolved:!1,isRejected:!1,controller:l};o.then(()=>u.isResolved=!0).catch(()=>u.isRejected=!0),i[n]?.cache.set(t,u)}function d(e,n,t){const o=r.get(e);o?null!=n&&null!=o[n]?o[n]?.cache.delete(t):c.deleteBlock(e,t):null==n&&c.deleteBlock(e,t)}function g(e,n){const t=r.get(e);return t?t[n]??null:null}function p(n,r,c,i,u,a,f=null){const s=g(n,r);if(!s)return;const m=s.extent,{cache:h,rasterInfo:x}=s;if(m?.xmin===c.xmin&&m.xmax===c.xmax&&m.ymin===c.ymin&&m.ymax===c.ymax)return;i=i??0;const d=c.clone().normalize(),{spatialReference:p,transform:y}=x,R=new Set;for(let g=0;g<d.length;g++){const n=d[g];if(n.xmax-n.xmin<=i||n.ymax-n.ymin<=i)continue;let r=t(n,p,f);if(null==r)continue;if(null!=y&&(r=y.inverseTransform(r),null==r))continue;const c=new e({x:i,y:i,spatialReference:n.spatialReference});if(null==u&&!(u=o(c,p,n,f)))return;const{pyramidLevel:s,pyramidResolution:m,excessiveReading:h}=l(u,x,a||"closest");if(h)return;const{storageInfo:k}=x,{origin:M}=k,{x:C,y:b}=m,j=Math.max(0,Math.floor((r.xmin-M.x)/C)),v=Math.max(0,Math.floor((M.y-r.ymax)/b)),B=Math.ceil(r.width/C-.1),w=Math.ceil(r.height/b-.1),$=s>0?k.pyramidBlockWidth:k.blockWidth,I=s>0?k.pyramidBlockHeight:k.blockHeight,E=k.blockBoundary[s];if(!E)continue;const H=1,P=Math.max(E.minCol,Math.floor(j/$)-H),W=Math.max(E.minRow,Math.floor(v/I)-H),z=Math.min(E.maxCol,Math.floor((j+B-1)/$)+H),A=Math.min(E.maxRow,Math.floor((v+w-1)/I)+H);for(let e=W;e<=A;e++)for(let n=P;n<=z;n++)R.add(`${s}/${e}/${n}`)}h.forEach((e,n)=>{if(!R.has(n)){const e=h.get(n);(null==e||e.isResolved||e.isRejected)&&h.delete(n)}}),s.extent={xmin:c.xmin,ymin:c.ymin,xmax:c.xmax,ymax:c.ymax}}export{f as clearRegisteredIds,m as decreaseRefCount,d as deleteBlock,s as deleteRaster,h as getBlock,i as getRasterId,x as putBlock,u as register,a as unregister,p as update};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{EventedMixin as r}from"../../core/Evented.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import{Loadable as s}from"../../core/Loadable.js";import{on as o,sync as l,watch as a,whenOnce as n}from"../../core/reactiveUtils.js";import{stripHTML as p}from"../../core/string.js";import{property as u,subclass as h}from"../../core/accessorSupport/decorators.js";import{ensureType as y}from"../../core/accessorSupport/ensureType.js";import c from"../../geometry/Extent.js";import f from"../../graphic/KMLGraphicOrigin.js";import{computeExtent as d,sublayersFromJSON as m,fetchService as v,parseKML as b}from"./kmlUtils.js";import{reader as g}from"../../core/accessorSupport/decorators/reader.js";var j;let S=j=class extends(r(i(s))){constructor(...e){super(...e),this.description=null,this.fullExtent=null,this.id=null,this.networkLink=null,this.parent=null,this.sublayers=null,this.title=null,this.sourceJSON=null,this.layer=null,this.addHandles([o(()=>this.sublayers,"after-add",({item:e})=>{e.parent=this,e.layer=this.layer},l),o(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=e.parent=null},l),a(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=this,r.layer=this.layer},l),a(()=>this.layer,e=>{if(this.sublayers)for(const t of this.sublayers)t.layer=e},l)])}initialize(){n(()=>this.networkLink).then(()=>n(()=>!0===this.visible)).then(()=>this.load())}async load(e){if(!this.networkLink)return this;if(this.networkLink.viewFormat)return this;const r=null!=e?e.signal:null,i=this._fetchService(this._get("networkLink")?.href??"",r).then(e=>{const r=d(e.sublayers);this.fullExtent=c.fromJSON(r),this.sourceJSON=e;const i=y(t.ofType(j),m(j,e));this.sublayers?this.sublayers.addMany(i):this.sublayers=i,this.layer?.emit("sublayer-update"),this.layer&&this.layer.notifyChange("visibleSublayers")});return this.addResolvingPromise(i),this}get visible(){return this._get("visible")}set visible(e){this._get("visible")!==e&&(this._set("visible",e),this.layer&&this.layer.notifyChange("visibleSublayers"))}readVisible(e,t){return!!t.visibility}get origin(){return this.layer?new f(this.layer,this):null}_fetchService(e,t){return v(e,this.layer.outSpatialReference,this.layer.refreshInterval,t).then(e=>b(e.data))}};e([u()],S.prototype,"description",void 0),e([u({type:c})],S.prototype,"fullExtent",void 0),e([u()],S.prototype,"id",void 0),e([u({readOnly:!0,value:null})],S.prototype,"networkLink",void 0),e([u({json:{write:{allowNull:!0}}})],S.prototype,"parent",void 0),e([u({type:t.ofType(S),json:{write:{allowNull:!0}}})],S.prototype,"sublayers",void 0),e([u({value:null,json:{read:{source:"name",reader:e=>p(e)}}})],S.prototype,"title",void 0),e([u({value:!0})],S.prototype,"visible",null),e([g("visible",["visibility"])],S.prototype,"readVisible",null),e([u()],S.prototype,"sourceJSON",void 0),e([u()],S.prototype,"layer",void 0),e([u()],S.prototype,"origin",null),S=j=e([h("esri.layers.support.KMLSublayer")],S);export{S as default};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Collection.js";import{EventedMixin as r}from"../../core/Evented.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import{Loadable as s}from"../../core/Loadable.js";import{on as o,sync as l,watch as a,whenOnce as n}from"../../core/reactiveUtils.js";import{stripHTML as p}from"../../core/string.js";import{property as u,subclass as h}from"../../core/accessorSupport/decorators.js";import{ensureType as y}from"../../core/accessorSupport/ensureType.js";import c from"../../geometry/Extent.js";import f from"../../graphic/KMLGraphicOrigin.js";import{computeExtent as d,sublayersFromJSON as m,fetchService as v,parseKML as b}from"./kmlUtils.js";import{reader as g}from"../../core/accessorSupport/decorators/reader.js";var j;let S=j=class extends(r(i(s))){constructor(...e){super(...e),this.description=null,this.fullExtent=null,this.id=null,this.networkLink=null,this.parent=null,this.sublayers=null,this.title=null,this.sourceJSON=null,this.layer=null,this.addHandles([o(()=>this.sublayers,"after-add",({item:e})=>{e.parent=this,e.layer=this.layer},l),o(()=>this.sublayers,"after-remove",({item:e})=>{e.layer=e.parent=null},l),a(()=>this.sublayers,(e,t)=>{if(t)for(const r of t)r.layer=r.parent=null;if(e)for(const r of e)r.parent=this,r.layer=this.layer},l),a(()=>this.layer,e=>{if(this.sublayers)for(const t of this.sublayers)t.layer=e},l)])}initialize(){n(()=>this.networkLink).then(()=>n(()=>!0===this.visible)).then(()=>this.load())}async load(e){if(!this.networkLink)return this;if(this.networkLink.viewFormat)return this;const r=null!=e?e.signal:null,i=this._fetchService(this._get("networkLink")?.href??"",r).then(e=>{const r=d(e.sublayers);this.fullExtent=c.fromJSON(r),this.sourceJSON=e;const i=y(t.ofType(j),m(j,e));this.sublayers?this.sublayers.addMany(i):this.sublayers=i,this.layer?.emit("sublayer-update"),this.layer&&this.layer.notifyChange("visibleSublayers")});return this.addResolvingPromise(i),this}get visible(){return this._get("visible")}set visible(e){this._get("visible")!==e&&(this._set("visible",e),this.layer&&this.layer.notifyChange("visibleSublayers"))}readVisible(e,t){return!!t.visibility}get origin(){return this.layer?new f(this.layer,this):null}_fetchService(e,t){return v(e,this.layer.outSpatialReference,this.layer.refreshInterval,t).then(e=>b(e.data))}};e([u()],S.prototype,"description",void 0),e([u({type:c})],S.prototype,"fullExtent",void 0),e([u()],S.prototype,"id",void 0),e([u({readOnly:!0,value:null})],S.prototype,"networkLink",void 0),e([u({json:{write:{allowNull:!0}}})],S.prototype,"parent",void 0),e([u({type:t.ofType(j),json:{write:{allowNull:!0}}})],S.prototype,"sublayers",void 0),e([u({value:null,json:{read:{source:"name",reader:e=>p(e)}}})],S.prototype,"title",void 0),e([u({value:!0})],S.prototype,"visible",null),e([g("visible",["visibility"])],S.prototype,"readVisible",null),e([u()],S.prototype,"sourceJSON",void 0),e([u()],S.prototype,"layer",void 0),e([u()],S.prototype,"origin",null),S=j=e([h("esri.layers.support.KMLSublayer")],S);export{S as default};