@arcgis/core 5.2.0-next.155 → 5.2.0-next.156
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d994bcf0a65d1c07160f.js → 0320cbd825f9a4222042.js} +1 -1
- package/assets/esri/core/workers/chunks/0590857215c547e63b51.js +1 -0
- package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
- package/assets/esri/core/workers/chunks/0cb50bc2b2125c5fedf2.js +1 -0
- package/assets/esri/core/workers/chunks/1201b8c5852830836eac.js +1 -0
- package/assets/esri/core/workers/chunks/129e04d24ced77c9bb6d.js +1 -0
- package/assets/esri/core/workers/chunks/15e1117a706a98b17ad5.js +1 -0
- package/assets/esri/core/workers/chunks/164e74d586297946a717.js +1 -0
- package/assets/esri/core/workers/chunks/168a523bdc3653081f8a.js +1 -0
- package/assets/esri/core/workers/chunks/{6f4e6022a52de0c54aab.js → 172cfeb5f415e4662432.js} +1 -1
- package/assets/esri/core/workers/chunks/1aa4f5394a596e544aeb.js +1 -0
- package/assets/esri/core/workers/chunks/22b01fe31bbf0bdc48db.js +1 -0
- package/assets/esri/core/workers/chunks/27c2da2e779def2ee08b.js +1 -0
- package/assets/esri/core/workers/chunks/{481589c3eddad6e026ad.js → 369780276b2755361f7d.js} +1 -1
- package/assets/esri/core/workers/chunks/{2a226b69d38c72a47a08.js → 3914d96147642a9d4b01.js} +1 -1
- package/assets/esri/core/workers/chunks/{731018c0deffc41ffc97.js → 3e3e076fa5e8d5d5f33f.js} +1 -1
- package/assets/esri/core/workers/chunks/{96b6ea199ad949fef17c.js → 43cf862577bf37344ff4.js} +1 -1
- package/assets/esri/core/workers/chunks/4932773663469919d10a.js +1 -0
- package/assets/esri/core/workers/chunks/4996869b9cbd8c8ddcfa.js +1 -0
- package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +1 -0
- package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +1 -0
- package/assets/esri/core/workers/chunks/{eb815148ae65388dd733.js → 544070198d2ca556103a.js} +1 -1
- package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
- package/assets/esri/core/workers/chunks/{aeaaff7a4b1a99540f52.js → 5cb26bbaa08114aec5ce.js} +1 -1
- package/assets/esri/core/workers/chunks/6f73e41e14817acfaead.js +1 -0
- package/assets/esri/core/workers/chunks/{320e5942a098dd104366.js → 74137ffec5265628c33b.js} +1 -1
- package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +1 -0
- package/assets/esri/core/workers/chunks/{688f2dbf784e66082308.js → 74c866e0b66e61751861.js} +1 -1
- package/assets/esri/core/workers/chunks/7711ae5612f685078fc8.js +1 -0
- package/assets/esri/core/workers/chunks/{5116b569a8dbda4910c8.js → 784a2fba3e18286958d1.js} +1 -1
- package/assets/esri/core/workers/chunks/{f6e62d2d279a328cbed7.js → 7bcedf479b07a4b4a234.js} +1 -1
- package/assets/esri/core/workers/chunks/842893e75696428d536f.js +1 -0
- package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
- package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +1 -0
- package/assets/esri/core/workers/chunks/{68be3fb88ca61f82fb90.js → 95dbbddac6581b9d671f.js} +1 -1
- package/assets/esri/core/workers/chunks/{900181f68449d8f82eeb.js → aa1ac7954e4f0fefe15b.js} +1 -1
- package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +1 -0
- package/assets/esri/core/workers/chunks/ace2e0a9d9013edd8624.js +1 -0
- package/assets/esri/core/workers/chunks/b1d5d236d5268fcbc74b.js +1 -0
- package/assets/esri/core/workers/chunks/{49ff0985fb307ac193ab.js → b573df59391ca41ee5a7.js} +1 -1
- package/assets/esri/core/workers/chunks/bac8c32665e982896ecc.js +1 -0
- package/assets/esri/core/workers/chunks/{f3da30d7300b92bd8bb0.js → befa32b9e7b3fbdd431e.js} +1 -1
- package/assets/esri/core/workers/chunks/{6c469b43089767176ced.js → c5ed67fdf261cbb1624b.js} +1 -1
- package/assets/esri/core/workers/chunks/d9b1aed88b205689cec6.js +1 -0
- package/assets/esri/core/workers/chunks/{c598b22f78ccc57f9d6d.js → dfd2dc5cdc97ffba8926.js} +1 -1
- package/assets/esri/core/workers/chunks/e1b7806ab3e1967b15f0.js +1 -0
- package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +1 -0
- package/assets/esri/core/workers/chunks/eb2652ec48faa78de3c5.js +1 -0
- package/assets/esri/core/workers/chunks/{c62738f84c914671b143.js → f4a7aa3cdbc0c429c359.js} +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -0
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/config.d.ts +2 -0
- package/config.js +1 -1
- package/core/ObjectPool.js +1 -1
- package/core/PooledArray.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/geometry/support/buffer/BufferPool.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +2 -2
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/CatalogLayer.d.ts +2 -2
- package/layers/CatalogLayer.js +1 -1
- package/layers/DimensionFeatureLayer.d.ts +2 -2
- package/layers/DimensionFeatureLayer.js +1 -1
- package/layers/FeatureLayer.d.ts +2 -2
- package/layers/FeatureLayer.js +1 -1
- package/layers/SubtypeGroupLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +9 -9
- package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
- package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
- package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
- package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/sources/parquet/FileProvider.js +1 -1
- package/layers/mixins/{FeatureLayerReload.d.ts → ReloadableLayer.d.ts} +5 -3
- package/layers/mixins/ReloadableLayer.js +2 -0
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/raster/datasets/BaseRaster.js +1 -1
- package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
- package/layers/raster/datasets/ImageAuxRaster.js +1 -1
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/raster/datasets/MRFRaster.js +1 -1
- package/layers/raster/datasets/TIFFRaster.js +1 -1
- package/layers/raster/datasets/WCSRaster.js +1 -1
- package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
- package/layers/raster/formats/RasterCodec.js +1 -1
- package/layers/raster/formats/TiffDecoder.js +1 -1
- package/layers/raster/formats/Zlib.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/package.json +2 -2
- package/popup/FeatureModel.js +1 -1
- package/popup/FeaturesModel.js +1 -1
- package/request/process.js +1 -1
- package/request/types.d.ts +7 -0
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueBackground.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/vectorTiles/VTLTechniqueFill.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
- package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
- package/widgets/HistogramRangeSlider.d.ts +2 -2
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +2 -2
- package/widgets/PanoramicViewer/PanoramicVideoViewerViewModel.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/types.d.ts +2 -0
- package/assets/esri/core/workers/chunks/03261b9451e293a0fac8.js +0 -1
- package/assets/esri/core/workers/chunks/0ad0484ffcbe4ad21bd3.js +0 -1
- package/assets/esri/core/workers/chunks/19743dedaa40446259ec.js +0 -1
- package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
- package/assets/esri/core/workers/chunks/1f339247b68b061ab0a4.js +0 -1
- package/assets/esri/core/workers/chunks/251921cd10ecfbc89451.js +0 -1
- package/assets/esri/core/workers/chunks/3252b1fae363bb0129a0.js +0 -1
- package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
- package/assets/esri/core/workers/chunks/50036a323c2e7f155311.js +0 -1
- package/assets/esri/core/workers/chunks/55dcbf296d8d0092e473.js +0 -1
- package/assets/esri/core/workers/chunks/59b216b60464611742d4.js +0 -1
- package/assets/esri/core/workers/chunks/5bfea0c55aca826de536.js +0 -1
- package/assets/esri/core/workers/chunks/60d3056a31d982c9cad0.js +0 -1
- package/assets/esri/core/workers/chunks/6558488ea96620439f34.js +0 -1
- package/assets/esri/core/workers/chunks/6aebf7cfd294e88bf926.js +0 -1
- package/assets/esri/core/workers/chunks/6b43bb78f9839ed43135.js +0 -1
- package/assets/esri/core/workers/chunks/6c83398cf586ecea0eb1.js +0 -1
- package/assets/esri/core/workers/chunks/7267b17de212207142c9.js +0 -1
- package/assets/esri/core/workers/chunks/88c74f3316f1fc253207.js +0 -1
- package/assets/esri/core/workers/chunks/912080c90b5cc2e817cf.js +0 -1
- package/assets/esri/core/workers/chunks/a97d85774f9a417202df.js +0 -1
- package/assets/esri/core/workers/chunks/aff32980d91dab07dfb7.js +0 -1
- package/assets/esri/core/workers/chunks/b1b4066e8d1c0c9656e5.js +0 -1
- package/assets/esri/core/workers/chunks/b6ba66a05030d3815dfd.js +0 -1
- package/assets/esri/core/workers/chunks/bbec9d2e3b75a5c59681.js +0 -1
- package/assets/esri/core/workers/chunks/bf69024804ac51c8f733.js +0 -1
- package/assets/esri/core/workers/chunks/c1254cd131a62750ff6f.js +0 -1
- package/assets/esri/core/workers/chunks/d938987344bce83cc660.js +0 -1
- package/assets/esri/core/workers/chunks/db1ab9b9c8bf5c7635d3.js +0 -1
- package/assets/esri/core/workers/chunks/fd9663952d5a94f3a83f.js +0 -1
- package/layers/mixins/FeatureLayerReload.js +0 -2
- /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
|
@@ -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/Error.js";import{Loadable as n}from"../../core/Loadable.js";import{open as r}from"../../core/workers.js";import{subclass as i}from"../../core/accessorSupport/decorators.js";import a from"./GeospatialPDFFrame.js";import{parse as o}from"./geospatialPDFParserUtils.js";let s=class extends n{constructor(){super(...arguments),this._connection=null,this._workerHandler=null}load(e){let t=r(`GeospatialPDFLayerWorker`,{...e,strategy:`dedicated`,registryTarget:this}).then(e=>{this._connection=e,this._workerHandler=this._connection.createInvokeProxy()});return this.addResolvingPromise(t),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null,this._workerHandler=null,super.destroy()}async loadPDF(e,n={}){await this.load(n);let{geospatialMetadata:r}=await this._workerHandler.loadPDF(e,n),i=o(r,0),s=i.lgiDictFrame??i.vpFrame;if(!s)throw new t(`geospatial-pdf-layer:load`,`pdf does not contain supported LGIDict or VP/Measure.`);let c=new a(s);return{frame:c,sourceSpatialReference:c.spatialReference.toJSON(),
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{Loadable as n}from"../../core/Loadable.js";import{open as r}from"../../core/workers.js";import{subclass as i}from"../../core/accessorSupport/decorators.js";import a from"./GeospatialPDFFrame.js";import{parse as o}from"./geospatialPDFParserUtils.js";let s=class extends n{constructor(){super(...arguments),this._connection=null,this._workerHandler=null}load(e){let t=r(`GeospatialPDFLayerWorker`,{...e,strategy:`dedicated`,registryTarget:this}).then(e=>{this._connection=e,this._workerHandler=this._connection.createInvokeProxy()});return this.addResolvingPromise(t),Promise.resolve(this)}destroy(){this._connection?.close(),this._connection=null,this._workerHandler=null,super.destroy()}async loadPDF(e,n={}){await this.load(n);let{geospatialMetadata:r}=await this._workerHandler.loadPDF(e,n),i=o(r,0),s=i.lgiDictFrame??i.vpFrame;if(!s)throw new t(`geospatial-pdf-layer:load`,`pdf does not contain supported LGIDict or VP/Measure.`);let c=new a(s);return{frame:c,sourceSpatialReference:c.spatialReference.toJSON(),neatlineExtent:c.toExtent()}}async render(e,t,n,r,i,a){let o={sourceExtentAsJSON:e.toJSON(),width:t,height:n,ctm:r,currentRing:i};return this._workerHandler.renderPDF(o,a)}};s=e([i(`esri.layers.geospatialPDF.GeospatialPDFWorkerClient`)],s);export{s as GeospatialPDFWorkerClient};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/mat2df64.js";import{fromValues as n}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{expandMediaBox as r,createGeoreferencer as i,validateTransform as a,affineTransformationFromGeoreference as o}from"./sharedUtils.js";class s{constructor(e){let t=this.
|
|
2
|
+
import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/mat2df64.js";import{fromValues as n}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import{expandMediaBox as r,createGeoreferencer as i,validateTransform as a,affineTransformationFromGeoreference as o}from"./sharedUtils.js";class s{constructor(e){let t=this._inputValidation(e);this._registration=t.registration,this._projection=t.projection,this._neatline=t.neatline,this.spatialReference=this._projection,this.pairedNeatline=f(this._neatline),this.outerExtentMediaBox=r(t.mediaBox),this.geoControlPoints=u(`geo`,this._registration),this.ctm=t.ctm??c(this.outerExtentMediaBox,this.pairedNeatline,this._registration,this.spatialReference),this._outputValidation()}_inputValidation(n){let{ctm:r,registration:i,projection:a,display:o,neatline:s,mediaBox:c}=n;if(r&&r.length!==6)throw new e(`geospatial-pdf-layer:invalid-frame`,`LGIDict has invalid CTM.`);if(!r&&(!i||i.length<3))throw new e(`geospatial-pdf-layer:invalid-frame`,`LGIDict missing CTM and minimum registration points`);if(!c||c.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`LGIDict missing or invalid MediaBox.`);if(!s||s.length<4||s.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`LGIDict missing or invalid amount of neatline points`);return{ctm:r?t(r[0],r[1],r[2],r[3],r[4],r[5]):void 0,registration:i??[],projection:a,display:o,neatline:s,mediaBox:c}}_outputValidation(){if(this.ctm.length!==6)throw new e(`geospatial-pdf-layer:invalid-frame`,`LGIDict missing or invalid CTM`);if(this.pairedNeatline.length<4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 4 neatline points.`);if(this.outerExtentMediaBox.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Failed to generate outerextent from mediaBox.`);if(!this.ctm&&this.geoControlPoints.length<2)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 2 geoControlPoints if defaulting.`)}}function c(e,t,r,s){let c=[],l=[];for(let e of r)e.length<4||(c.push(n(e[0],e[1])),l.push(n(e[2],e[3])));let u=d(e,t,r),f=i(c,l,s,u),p=a(f);return o(p)}function l(t){let n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e<t.length;e++){let o=t[e];n=Math.min(n,o[0]),r=Math.min(r,o[1]),i=Math.max(i,o[0]),a=Math.max(a,o[1])}if(!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(i)||!Number.isFinite(a))throw new e(`geospatial-pdf-layer: invalid-frame`,`Failed to compute extent from registration.`);return{xmin:n,ymin:r,xmax:i,ymax:a}}function u(e,t){let[n,r]=e===`page`?[0,1]:[2,3];return t.filter(e=>e.length>r).map(e=>[e[n],e[r]])}function d(t,n,r){if(t.length===4)return l(t);if(n.length>=6)return l(n);let i=u(`page`,r);if(i.length>=2)return l(i);throw new e(`geospatial-pdf-layer: invalid-frame`,`Cannot build source rectangle from Neatline or Registration points.`)}function f(e){let t=[];for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];Number.isFinite(r)&&Number.isFinite(i)&&t.push([r,i])}return t.length===2&&(t.splice(1,0,[t[1][0],t[0][1]]),t.push([t[0][0],t[2][1]])),t}export{s as LGIDictMapFrame,l as extentFromArray,f as pairNeatline};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import n from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";import{projectExecute as i}from"../../geometry/operators/projectOperator.js";import{expandMediaBox as a,validateTransform as o,affineTransformationFromGeoreference as s,createGeoreferencer as c}from"./sharedUtils.js";class l{constructor(e){let{bbox:t,bounds:n,gpts:r,lpts:i,gcs:c,mediaBox:l}=this.
|
|
2
|
+
import e from"../../core/Error.js";import{fromValues as t}from"../../core/libs/gl-matrix-2/factories/vec2f64.js";import n from"../../geometry/Point.js";import r from"../../geometry/SpatialReference.js";import{projectExecute as i}from"../../geometry/operators/projectOperator.js";import{expandMediaBox as a,validateTransform as o,affineTransformationFromGeoreference as s,createGeoreferencer as c}from"./sharedUtils.js";class l{constructor(e){let{bbox:t,bounds:n,gpts:r,lpts:i,gcs:c,mediaBox:l}=this._inputValidation(e);this._bbox=t,this._bounds=n,this._gpts=r,this._lpts=i,this._gcs=c,this.spatialReference=_(this._gcs),this.outerExtentMediaBox=a(l),this.geoControlPoints=f(this._gpts,this.spatialReference).map(e=>[e[0],e[1]]);let p=u(this._bbox,this._bounds)??d(this._lpts,this._bbox);this.pairedNeatline=p.map(e=>[e[0],e[1]]),this.neatLine=this.pairedNeatline.flat(),this._georeference=m(this._bbox,this._lpts,this._gpts,this.spatialReference);let h=o(this._georeference);this.ctm=s(h),this._outputValidation()}_inputValidation(t){let{bbox:n,bounds:r,gpts:i,lpts:a,gcs:o,mediaBox:s}=t;if(!n||n.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid BBox`);if(!s||s.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Viewport missing or invalid MediaBox`);if(!i||i.length<6||i.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid GPTS`);if(!a||a.length<6||a.length%2!=0)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing or invalid LPTS`);if(a.length!==i.length)throw new e(`geospatial-pdf-layer: invalid-frame`,`MeasureFrame LPTS and GPTS must be same length`);if(!o?.WKT&&!o?.EPSG)throw new e(`geospatial-pdf-layer:invalid-frame`,`MeasureFrame missing a WKT or EPSG code`);return{bbox:n,bounds:r,gpts:i,lpts:a,gcs:o,mediaBox:s}}_outputValidation(){if(this.outerExtentMediaBox.length!==4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Failed to generate outer extent from mediaBox`);if(this.geoControlPoints.length<2)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 2 geoControlPoints`);if(this.pairedNeatline.length<4)throw new e(`geospatial-pdf-layer:invalid-frame`,`Map Frame should have at least 4 neatline points`);if(!this.ctm||this.ctm.length!==6)throw new e(`geospatial-pdf-layer:invalid-frame`,`Missing or invalid Map Frame CTM`)}}function u(e,t){return h(t)?.map(t=>p(e,t.u,t.v))??null}function d(e,t){let n=[];for(let r=0;r<e.length;r+=2){let i=e[r],a=e[r+1];n.push(p(t,i,a))}return n}function f(e,r){let a=[];for(let o=0;o<e.length;o+=2){let s=e[o],c=e[o+1],l=new n({x:c,y:s}),u=i(l,r);a.push(t(u.x,u.y))}return a}function p(e,n,r){let[i,a,o,s]=e;return t(i+n*(o-i),a+r*(s-a))}function m(e,t,n,r){let i=d(t,e),a=f(n,r),o=g(e);return c(i,a,r,o)}function h(e){if(!e||e.length<8||e.length%2!=0)return null;let t=[];for(let n=0;n<e.length;n+=2)t.push({u:e[n],v:e[n+1]});return t}function g(e){let[t,n,r,i]=e;return{xmin:Math.min(t,r),ymin:Math.min(n,i),xmax:Math.max(t,r),ymax:Math.max(n,i)}}function _(t){if(t?.WKT)return new r({wkt:t.WKT});if(t?.EPSG)return new r({wkid:t.EPSG});throw new e(`geospatial-pdf-layer: invalid-frame`,`MeasureFrame missing WKT or EPSG.`)}export{l as ViewportMeasureFrame};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../core/Error.js";import"../../core/has.js";import{LGIDictMapFrame as t}from"./LGIDictMapFrame.js";import{projectionToSpatialReference as
|
|
2
|
+
import e from"../../core/Error.js";import"../../core/has.js";import{LGIDictMapFrame as t,pairNeatline as n,extentFromArray as r}from"./LGIDictMapFrame.js";import{projectionToSpatialReference as i}from"./projectionToWKTUtils.js";import{ViewportMeasureFrame as a}from"./ViewportMeasureFrame.js";function o(n,r=0){let o={mediaBox:y(n.MediaBox),rotate:C(n.Rotate),hasLGIDict:n.LGIDict!=null,hasVP:n.VP!=null};if(o.hasVP){let t=c(n.VP,r);if(!t)throw new e(`geospatial-pdf-layer:invalid frame`,`Failed to parse VP frame at index ${r}`);return{result:o,vpFrame:new a({bbox:t.BBox,bounds:t.Measure?.Bounds,gpts:t.Measure?.GPTS,lpts:t.Measure?.LPTS,gcs:t.Measure?.GCS,mediaBox:y(n.MediaBox)})}}if(o.hasLGIDict){let a=s(n.LGIDict,r);if(!a)throw new e(`geospatial-pdf-layer:invalid frame`,`Failed to parse LGI Dict frame at index ${r}`);if(!a.Projection)throw new e(`geospatial-pdf-layer:parse`,`LGIDict map frame missing Projection.`);let c=i(a.Projection),l;try{l=a.Display?i(a.Display):void 0}catch{l=c}return{result:o,lgiDictFrame:new t({ctm:a.CTM,registration:a.Registration,projection:c,display:l,neatline:a.Neatline,mediaBox:y(n.MediaBox)})}}return{result:o}}function s(e,t){let n=l(e);try{let e=n[0],t=E(e);for(let r of n){let n=E(r);n>t&&(t=n,e=r)}return e}catch{return n[t]}}function c(e,t){return u(e)[t]}function l(e){return e==null?[]:Array.isArray(e)?e.map(e=>d(e)):[d(e)]}function u(e){return e==null?[]:Array.isArray(e)?e.map(e=>f(e)):[f(e)]}function d(e){let t=T(e,`LGIDict map frame must be an object.`);return{CTM:y(t.CTM),Registration:b(t.Registration),Neatline:y(t.Neatline),Projection:h(t.Projection),Display:h(t.Display)}}function f(e){let t=T(e,`Viewport frame must be an object.`),n=p(t.Measure);return{BBox:y(t.BBox),Measure_Raw:t.Measure,Measure:n,Raw:t}}function p(e){if(w(e))return{Bounds:y(e.Bounds),GPTS:y(e.GPTS),LPTS:y(e.LPTS),GCS:m(e.GCS)}}function m(e){if(w(e))return{WKT:x(e.WKT),EPSG:C(e.EPSG)}}function h(e){if(w(e))return{Type:S(e.Type),Units:S(e.Units),Datum:g(e.Datum),Projection_Type:S(e.ProjectionType),Central_Meridian:C(e.CentralMeridian),False_Easting:C(e.FalseEasting),False_Northing:C(e.FalseNorthing),Height:C(e.Height),Hemisphere:S(e.Hemisphere),Latitude_One:C(e.LatitudeOne),Latitude_Two:C(e.LatitudeTwo),Latitude_Of_True_Scale:C(e.LatitudeOfTrueScale),Longitude_One:C(e.LongitudeOne),Longitude_Two:C(e.LongitudeTwo),Longitude_Down_From_Pole:C(e.LongitudeDownFromPole),Orientation:S(e.Orientation),Origin_Height:C(e.OriginHeight),Origin_Latitude:C(e.OriginLatitude),Origin_Longitude:C(e.OriginLongitude),Scale_Factor:C(e.ScaleFactor),Standard_Parallel:C(e.StandardParallel),Standard_Parallel_One:C(e.StandardParallelOne),Standard_Parallel_Two:C(e.StandardParallelTwo),Zone:C(e.Zone),Description:S(e.Description),raw:e}}function g(e){return e==null?null:typeof e==`string`?{kind:`name`,name:S(e),ellipsoid:null,to_WGS84:null,raw:e}:w(e)?{kind:`definition`,name:S(e.Description),ellipsoid:_(e.Ellipsoid),to_WGS84:v(e.ToWGS84),raw:e}:{kind:`unknown`,name:S(e),ellipsoid:null,to_WGS84:null,raw:e}}function _(e){if(w(e))return{semi_Major_Axis:C(e.SemiMajorAxis),inverse_Flattening:C(e.InvFlattening),semi_Minor_Axis:C(e.SemiMinorAxis),description:S(e.Description)}}function v(e){if(w(e))return{dx:C(e.dx)??0,dy:C(e.dy)??0,dz:C(e.dz)??0,rx:C(e.rx)??0,ry:C(e.ry)??0,rz:C(e.rz)??0,sf:C(e.sf)??0}}function y(e){if(!Array.isArray(e))return;let t=[];for(let n of e){let e=C(n);if(e===void 0)return;t.push(e)}return t}function b(e){if(Array.isArray(e))return e.filter(e=>Array.isArray(e)).map(e=>e.map(e=>C(e)).filter(e=>e!==void 0))}function x(e){if(e!=null)return typeof e==`string`?e:String(e)}function S(e){let t=x(e);if(t!==void 0)return t.trim()}function C(e){if(e==null)return;if(typeof e==`number`)return Number.isFinite(e)?e:void 0;if(typeof e!=`string`)return;let t=e.trim();if(t===``)return;let n=Number(t);return Number.isFinite(n)?n:void 0}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(t,n){if(!w(t))throw new e(`geospatial-pdf-layer:parse`,n);return t}function E(e){let t=e.Neatline;if(!t)return 0;let i=n(t),a=r(i);return(a.xmax-a.xmin)*(a.ymax-a.ymin)}export{o as parse};
|
|
@@ -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/Accessor.js";import{result as n}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{destroyMaybe as s,removeMaybe as c,abortMaybe as l}from"../../../core/maybe.js";import{EsriPromiseMixin as u}from"../../../core/Promise.js";import{createAbortError as d,isAbortError as f}from"../../../core/promiseUtils.js";import{initial as p,watch as m,syncAndInitial as h,sync as g}from"../../../core/reactiveUtils.js";import{sqlAnd as _}from"../../../core/sql.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as b}from"../../../core/support/UpdatingHandles.js";import{projectAsync as x}from"../../../geometry/projectionUtils.js";import{isHostedAgolService as S}from"../../support/arcgisLayerUrl.js";import{checkServiceCurrentUserSupport as C}from"../../support/featureLayerUtils.js";import{getEffectiveLayerCapabilities as w}from"../../support/layerUtils.js";import T from"../../../rest/support/StatisticDefinition.js";import{FeatureTileDescriptor as E,virtualSnapshotTileId as D,virtualDisplayFilterHighlightTileId as O}from"../../../views/3d/layers/support/FeatureTileDescriptor.js";import{FeatureTileFetcher3D as k}from"../../../views/3d/layers/support/FeatureTileFetcher3D.js";import{FeatureTileFetcher3DDebugger as A}from"../../../views/3d/layers/support/FeatureTileFetcher3DDebugger.js";import{debugFlags as j}from"../../../views/3d/support/debugFlags.js";let M=class extends u(t){get dataUpdating(){return this._tileFetcher?.dataUpdating??!1}set extent(e){if(e!=null&&!e.spatialReference.equals(this.layerView.view.spatialReference)){o.getLogger(this).error(`#extent=`,`extent needs to be in the same spatial reference as the view`);return}let t=this._get(`extent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`extent`,n)}get updating(){return!!(this._tileFetcher?.updating||this._fetchDataInfoPromise!=null||this.mode===`tiles`&&this.layerView.view.featureTiles?.updating||this._updatingHandles?.updating)}get updatingTotal(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.updatingTotal:0}get updatingRemaining(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.updatingRemaining:0}get expectedFeatureDiff(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.expectedFeatureDiff:0}get usedMemory(){return this._tileFetcher?.usedMemory??0}get usedMemoryPerFeature(){return this._tileFetcher?.usedMemoryPerFeature??0}get maximumNumberOfFeaturesExceeded(){return!!(this._tileFetcher!=null&&this._tileFetcher.maximumNumberOfFeaturesExceeded)}get snappingComplexityExceeded(){return this._tileFetcher?.snappingComplexityExceeded??!0}get maximumNumberOfFeatures(){return this.displayFeatureLimit?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){e!==this.maximumNumberOfFeatures&&this._overrideIfSome(`maximumNumberOfFeatures`,e)}get hasMaximumNumberOfFeaturesOverride(){return this._isOverridden(`maximumNumberOfFeatures`)}get hasAllFeatures(){return this.serviceDataCount===I.noServiceDataCount&&this.mode===`snapshot`&&this.hasAllFeaturesInView||this.serviceDataCount===this.graphics.length}get hasAllFeaturesInView(){let e=this.context.effectiveDisplayFilter?.where||null,t=e!=null&&e!==`1=1`;return this.mode===`tiles`&&t?!1:this._tileFetcher?.showsAllFeatures??!1}get hasFullGeometries(){return this._tileFetcher?.hasFullGeometries??!1}get mode(){let e=this.layerView.layer;if(e.type===`feature`&&e.infoFor3D!=null)return`snapshot`;if(e.type===`catalog-footprint`||this._forceTilesMode)return`tiles`;let t=this.layerView.view;if(t.qualitySettings?.graphics3D?.snapshotAvailable===!1||this.serviceDataCount===I.noServiceDataCount||this._snapshotLimitExceeded||this.maximumNumberOfFeaturesExceeded||t.quality<1)return`tiles`;let n=(t&&t.featureTiles)?.tilingScheme;if(e&&e.minScale&&this.serviceDataExtent&&n){let t=this._approximateExtentSizeAtScale(e.minScale,n);if((this.serviceDataExtent.width/t+this.serviceDataExtent.height/t)/2>I.maxSnapshotMinScaleFactor)return`tiles`}return!this.maximumNumberOfFeatures||this.serviceDataCount<=this.maximumNumberOfFeatures?`snapshot`:`tiles`}get maxTotalSnapshotVertices(){let e=this._get(`maxTotalSnapshotVertices`)||0,t=this.mode===`snapshot`&&this._tileFetcher?.totalVertices||0;return Math.max(e,t)}_approximateExtentSizeAtScale(e,t){let n=this.layerView.view,r=Math.ceil((n.width/t.pixelSize+n.height/t.pixelSize)/2),i=t.levels[0];return r*((i.tileSize[0]/(i.scale/e)+i.tileSize[1]/(i.scale/e))/2)}get tileDescriptors(){if(this.mode===`snapshot`){let e=new E(0,0,0,null,D);return new r([e])}let e=this.layerView.view.featureTiles;if(!e)return new r;let t=e.tiles;if(this.layerView.displayFilterEnabled&&this.layerView.effectiveDisplayFilterClause!=null&&this.layerView.effectiveDisplayFilterClause!==`1=1`&&this.layerView.highlightIds?.length>0){let e=new E(0,0,0,this.layerView.view.featureTiles?.tilingScheme,O);return new r([...t,e])}return t}get test(){}constructor(e){super(e),this.type=`feature-tile-3d`,this._updatingHandles=new b,this.serviceDataExtent=null,this.serviceDataCount=I.noServiceDataCount,this._snapshotLimitExceeded=!1,this.displayFeatureLimit=null,this._forceTilesMode=!1,this._suspended=!1,this._tileFetcher=null,this._fetchDataInfoPromise=null,this._fetchDataInfoAbortController=null,this._lifeCycleAbortController=new AbortController}initialize(){this._updatingHandles.add(()=>this.displayFeatureLimit,e=>this._updatingHandles.addPromise(this._updateSnapshotLimit(e,null,this._lifeCycleAbortController.signal))),this._updatingHandles.add(()=>this.mode,()=>this._modeChanged(),p),this._updatingHandles.add(()=>this.mode,(e,t)=>{e===`tiles`&&t===`snapshot`&&(this._forceTilesMode=!0)},p),this.addResolvingPromise(Promise.resolve().then(()=>this._verifyCapabilities()).then(()=>this._updatingHandles.addPromise(this._fetchServiceDataInfo())).then(()=>this._initializeTileFetcher()))}_verifyCapabilities(){let e=this.layerView.layer;if(e.type!==`ogc-feature`&&!w(e)?.operations.supportsQuery)throw new i(`graphicscontroller:query-capability-required`,`Service requires query capabilities to be used as a feature layer`,{layer:e})}destroy(){this._cancelFetchServiceDataInfo(),this._tileFetcher=s(this._tileFetcher),this._tilesHandle=c(this._tilesHandle),this._lifeCycleAbortController=l(this._lifeCycleAbortController),this._updatingHandles.destroy(),this._set(`_updatingHandles`,null)}suspend(){this._suspended||(this._suspended=!0,this._tileFetcher!=null&&this._tileFetcher.suspend())}resume(){this._suspended&&(this._suspended=!1,this._tileFetcher!=null&&this._tileFetcher.resume())}restart(){let e=()=>{this._tileFetcher!=null&&this._tileFetcher.restart()};this._updatingHandles.consumePromise(this._fetchServiceDataInfo().then(e,e))}refetch(){this._refetch({resetForceTilesMode:!1})}getMissingAttributesForFeature(e){return this._tileFetcher?.getMissingAttributesForFeature(e)}_refetch(e){let t=()=>{this._tileFetcher!=null&&(e.resetForceTilesMode&&(this._forceTilesMode=!1),this._tileFetcher.refetch())};this._updatingHandles.consumePromise(this._fetchServiceDataInfo().then(t,t))}_initializeTileFetcher(){let e=this.layerView.view;if(!e)return;let{layerView:t,tileDescriptors:n}=this,r=t.layer,i=new k({context:this.context,filterExtent:this.extent,tileDescriptors:n,features:this.graphics});this._tileFetcher=i,this._suspended?i.suspend():i.resume(),e&&this.addHandles(m(()=>e.quality,e=>i.memoryFactor=e,h));let a=this.context.geometryType===`polygon`?`polygonLodFactor`:this.context.geometryType===`polyline`?`polylineLodFactor`:null;a&&this.addHandles(m(()=>this.layerView.view?.qualitySettings?.graphics3D?.[a],e=>i.lodFactor=e||1,p)),r.type!==`ogc-feature`&&this._updatingHandles.add(()=>r.createQueryVersion,()=>this._dataFilterChanged()),this._updatingHandles.add(()=>this.layerView.effectiveDisplayFilter,()=>this._effectiveDisplayFilterChanged()),this._updatingHandles.add(()=>this.layerView.highlightIds,()=>this._displayFilterHighlightIdsChanged()),this._updatingHandles.add(()=>t.availableFields,(e,t)=>this._availableFieldsChanged(t,e)),this._updatingHandles.add(()=>t.requiredFields,(e,t)=>this._requiredFieldsChanged(t,e)),`customParameters`in r&&this._updatingHandles.add(()=>r.customParameters,()=>this.restart()),this.addHandles([r.on(`apply-edits`,e=>this._applyEdits(e)),m(()=>this.extent,e=>i.filterExtent=e,g),m(()=>this.tileDescriptors,e=>i.tileDescriptors=e,g),m(()=>this.maximumNumberOfFeatures,e=>{i.maximumNumberOfFeatures=e,i.useTileCount=this.serviceDataCount>e},h),m(()=>this.serviceDataCount,e=>{i.useTileCount=e>this.maximumNumberOfFeatures},h),m(()=>({featureTiles:e.featureTiles,show:j.FEATURE_TILE_FETCH_SHOW_TILES}),({show:t,featureTiles:n})=>{t&&i&&n?i.debugger??=new A(i,n.tilingScheme.toTileInfo(),e):i.debugger=s(i.debugger)},p)]),this._supportsExceedsLimitQuery||this._updatingHandles.add(()=>this.maxTotalSnapshotVertices,()=>this._updatingHandles.addPromise(this._updateSnapshotLimit(this.displayFeatureLimit,null,this._lifeCycleAbortController.signal)))}_modeChanged(){switch(this.mode){case`tiles`:this._tilesHandle||=this.layerView.view.enableFeatureTiles();break;default:o.getLogger(this).warn(`Unhandled feature layer mode `+this.mode);case`snapshot`:this._tilesHandle!=null&&(this._tilesHandle.remove(),this._tilesHandle=null)}}_dataFilterChanged(){this._set(`maxTotalSnapshotVertices`,0),this.notifyChange(`maxTotalSnapshotVertices`),this._refetch({resetForceTilesMode:!0})}_effectiveDisplayFilterChanged(){this.mode!==`snapshot`&&this._refetch({resetForceTilesMode:!1})}_displayFilterHighlightIdsChanged(){this.mode!==`snapshot`&&this._tileFetcher!=null&&this._tileFetcher.refetchDisplayFilterHighlightTile()}_applyEdits(e){let t=this.layerView.layer;this._tileFetcher!=null&&this._tileFetcher.applyEdits(e).then(e=>{if(e){if(!this._lifeCycleAbortController)throw d();e.exceededTransferLimit&&`refresh`in t?t.refresh():(e.deletedFeatures.length||e.updatedFeatures.length||e.addedFeatures.length)&&this._updatingHandles.consumePromise(this._updateServiceDataExtent(this._lifeCycleAbortController.signal))}}).catch(e=>{if(!f(e))throw e})}_availableFieldsChanged(e,t){this._tileFetcher!=null&&F(this._tileFetcher.availableFields,t)&&this._refetch({resetForceTilesMode:!1})}_requiredFieldsChanged(e,t){this._tileFetcher!=null&&F(this._tileFetcher.availableFields,t)&&this.restart()}_createVertexLimitExceededQuery(e){let t=this.layerView.layer,n=t.createQuery();return n.returnGeometry=!1,n.outStatistics=[new T({statisticType:`exceedslimit`,maxVertexCount:e,outStatisticFieldName:`exceedslimit`,maxPointCount:1e8,maxRecordCount:1e8})],t.capabilities?.query.supportsCacheHint&&(n.cacheHint=!0),n}_createDataInfoQuery(){let e=this.layerView.layer,t=this.layerView,n=e.createQuery();return n.returnGeometry=!1,n.outSpatialReference=this.layerView.view.spatialReference,e.capabilities?.query.supportsCacheHint&&(n.cacheHint=!0),t.effectiveDisplayFilter&&(n.where=_(n.where,t.effectiveDisplayFilter.where)),n}_fullExtentIsAccurate(){let e=this.layerView.layer;if(`definitionExpression`in e&&e.definitionExpression)return!1;switch(e.type){case`feature`:case`catalog-footprint`:case`oriented-imagery`:return S(e.url);case`csv`:case`geojson`:case`ogc-feature`:case`wfs`:return!0;default:return}}async _updateServiceDataExtent(e){try{await this._tryUpdateServiceDataExtent(e)}catch(e){f(e)||this._set(`serviceDataExtent`,a(this.layerView.fullExtentInLocalViewSpatialReference)??null)}}async _tryUpdateServiceDataExtent(e){let t=this.layerView,n=t.layer,r=n.capabilities?.query.supportsExtent??!1,i=a(t.fullExtentInLocalViewSpatialReference),o=n.fullExtent,s=this._fullExtentIsAccurate(),c=this.serviceDataCount;if(r&&c<=I.maxFeatureCountForExtent&&(!i||!s)&&`queryExtent`in n){let t=this._createDataInfoQuery(),r=await n.queryExtent(t,{timeout:I.queryExtentTimeout,signal:e});this._set(`serviceDataExtent`,r.extent)}else if(i)this._set(`serviceDataExtent`,i);else if(o!=null){let e=o.spatialReference?await x(o,t.view.spatialReference):null;this._set(`serviceDataExtent`,e??null)}else this._set(`serviceDataExtent`,null)}async _updateServiceDataCount(e){let t=this.layerView.layer;if(!(`queryFeatureCount`in t)||!has(`featurelayer-snapshot-enabled`)){this._set(`serviceDataCount`,I.noServiceDataCount);return}let r=await n(t.queryFeatureCount(this._createDataInfoQuery(),{timeout:I.queryStatisticsTimeout,signal:e}));if(r.ok===!0)this._set(`serviceDataCount`,r.value);else{if(f(r.error))throw r.error;this._set(`serviceDataCount`,I.noServiceDataCount)}}get _supportsExceedsLimitQuery(){let e=this.layerView.layer;return e.capabilities!=null&&e.capabilities.operations&&e.capabilities.operations.supportsExceedsLimitStatistics}get _minimumNumberOfVerticesForGeometry(){switch(this.layerView.layer.geometryType){case`point`:return 1;case`multipoint`:return 1;case`polygon`:return 4;case`polyline`:return 2;case`multipatch`:case`mesh`:return 3;case null:case void 0:return 0;default:return 0}}async _updateSnapshotLimit(e,t,r){if(e?.averageSymbolComplexity==null){this._snapshotLimitExceeded=!1;return}let{maximumTotalNumberOfVertices:i,averageSymbolComplexity:a}=e,{verticesPerFeature:o,verticesPerCoordinate:s}=a,c=o<=0,l=this._minimumNumberOfVerticesForGeometry>1;if(!c&&!l){this._snapshotLimitExceeded=!1;return}o!==0&&t!=null&&await t;let u=Math.min(i,N),d=this.serviceDataCount,p=d!==I.noServiceDataCount,m=Math.ceil(p?(u-d*o)/(s||1):u/(s||1));if(l&&(m=Math.min(m,P)),p&&this._minimumNumberOfVerticesForGeometry*d>m){this._snapshotLimitExceeded=!0;return}if(!this._supportsExceedsLimitQuery||!has(`featurelayer-snapshot-enabled`)){this._snapshotLimitExceeded=this.maxTotalSnapshotVertices>m;return}let h=await n(this.layerView.layer.queryFeatures(this._createVertexLimitExceededQuery(m),{timeout:I.queryStatisticsTimeout,signal:r}));if(h.ok===!1){if(f(h.error))throw h.error;this._snapshotLimitExceeded=!1;return}let g=h.value.features[0];this._snapshotLimitExceeded=g?.attributes?!!g.attributes.exceedslimit:!1}async _fetchServiceDataInfo(){this._cancelFetchServiceDataInfo(),await C(this.layerView.layer);let e=new AbortController,t=e.signal,n=this._updateServiceDataCount(t),r=Promise.allSettled([n,this._updateSnapshotLimit(this.displayFeatureLimit,n,t)]),i=r.then(()=>this._updateServiceDataExtent(t)).catch(e=>{f(e)||o.getLogger(this).error(`#fetchServiceDataInfo()`,e)}).then(()=>{i===this._fetchDataInfoPromise&&(this._fetchDataInfoPromise=null,this._fetchDataInfoAbortController=null),e=null});return e&&(this._fetchDataInfoPromise=i),this._fetchDataInfoAbortController=e,r.then(()=>{},()=>{})}_cancelFetchServiceDataInfo(){let e=this._fetchDataInfoAbortController;e&&(this._fetchDataInfoAbortController=null,this._fetchDataInfoPromise=null,e.abort())}get performanceInfo(){return{storedFeatures:this._tileFetcher?.storedFeatures??0,totalFeatures:this._tileFetcher?.totalFeatures??0,totalVertices:this._tileFetcher?.totalVertices??0,missingTiles:this._tileFetcher?.missingTiles??0}}};e([v({readOnly:!0})],M.prototype,`type`,void 0),e([v({constructOnly:!0})],M.prototype,`graphics`,void 0),e([v({constructOnly:!0})],M.prototype,`layerView`,void 0),e([v({constructOnly:!0})],M.prototype,`context`,void 0),e([v({readOnly:!0})],M.prototype,`dataUpdating`,null),e([v()],M.prototype,`extent`,null),e([v()],M.prototype,`updating`,null),e([v({readOnly:!0})],M.prototype,`_updatingHandles`,void 0),e([v()],M.prototype,`updatingTotal`,null),e([v()],M.prototype,`updatingRemaining`,null),e([v()],M.prototype,`expectedFeatureDiff`,null),e([v()],M.prototype,`usedMemory`,null),e([v()],M.prototype,`usedMemoryPerFeature`,null),e([v()],M.prototype,`maximumNumberOfFeaturesExceeded`,null),e([v()],M.prototype,`snappingComplexityExceeded`,null),e([v({readOnly:!0})],M.prototype,`serviceDataExtent`,void 0),e([v({readOnly:!0})],M.prototype,`serviceDataCount`,void 0),e([v()],M.prototype,`_snapshotLimitExceeded`,void 0),e([v()],M.prototype,`displayFeatureLimit`,void 0),e([v({type:Number})],M.prototype,`maximumNumberOfFeatures`,null),e([v({readOnly:!0})],M.prototype,`hasAllFeatures`,null),e([v({readOnly:!0})],M.prototype,`hasAllFeaturesInView`,null),e([v({readOnly:!0})],M.prototype,`hasFullGeometries`,null),e([v()],M.prototype,`_forceTilesMode`,void 0),e([v({readOnly:!0})],M.prototype,`mode`,null),e([v({readOnly:!0})],M.prototype,`maxTotalSnapshotVertices`,null),e([v({readOnly:!0})],M.prototype,`tileDescriptors`,null),e([v()],M.prototype,`_tileFetcher`,void 0),e([v()],M.prototype,`_fetchDataInfoPromise`,void 0),M=e([y(`esri.layers.graphics.controllers.FeatureTileController3D`)],M);const N=1e6,P=5e6;function F(e,t){if(!t)return!1;for(let n of t)if(!e.has(n))return!0;return!1}class I{static{this.noServiceDataCount=1/0}static{this.maxSnapshotMinScaleFactor=5}static reset(){I.maxFeatureCountForExtent=1e4,I.queryStatisticsTimeout=12e3,I.queryExtentTimeout=1e4}}I.reset();export{M as FeatureTileController3D,I as FeatureTileController3DConstants};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{result as n}from"../../../core/asyncUtils.js";import r from"../../../core/Collection.js";import i from"../../../core/Error.js";import has from"../../../core/has.js";import{clone as a}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{destroyMaybe as s,removeMaybe as c,abortMaybe as l}from"../../../core/maybe.js";import{EsriPromiseMixin as u}from"../../../core/Promise.js";import{createAbortError as d,isAbortError as f}from"../../../core/promiseUtils.js";import{initial as p,watch as m,syncAndInitial as h,sync as g}from"../../../core/reactiveUtils.js";import{sqlAnd as _}from"../../../core/sql.js";import{property as v,subclass as y}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as b}from"../../../core/support/UpdatingHandles.js";import{projectAsync as x}from"../../../geometry/projectionUtils.js";import{isHostedAgolService as S}from"../../support/arcgisLayerUrl.js";import{checkServiceCurrentUserSupport as C}from"../../support/featureLayerUtils.js";import{getEffectiveLayerCapabilities as w}from"../../support/layerUtils.js";import T from"../../../rest/support/StatisticDefinition.js";import{FeatureTileDescriptor as E,virtualSnapshotTileId as D,virtualDisplayFilterHighlightTileId as O}from"../../../views/3d/layers/support/FeatureTileDescriptor.js";import{FeatureTileFetcher3D as k}from"../../../views/3d/layers/support/FeatureTileFetcher3D.js";import{FeatureTileFetcher3DDebugger as A}from"../../../views/3d/layers/support/FeatureTileFetcher3DDebugger.js";import{debugFlags as j}from"../../../views/3d/support/debugFlags.js";let M=class extends u(t){get dataUpdating(){return this._tileFetcher?.dataUpdating??!1}set extent(e){if(e!=null&&!e.spatialReference.equals(this.layerView.view.spatialReference)){o.getLogger(this).error(`#extent=`,`extent needs to be in the same spatial reference as the view`);return}let t=this._get(`extent`);if(t===e||t!=null&&e&&t.equals(e))return;let n=e==null?null:e.clone();this._set(`extent`,n)}get updating(){return!!(this._tileFetcher?.updating||this._fetchDataInfoPromise!=null||this.mode===`tiles`&&this.layerView.view.featureTiles?.updating||this._updatingHandles?.updating)}get updatingTotal(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.updatingTotal:0}get updatingRemaining(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.updatingRemaining:0}get expectedFeatureDiff(){return this.updating&&this._tileFetcher!=null?this._tileFetcher.expectedFeatureDiff:0}get usedMemory(){return this._tileFetcher?.usedMemory??0}get usedMemoryPerFeature(){return this._tileFetcher?.usedMemoryPerFeature??0}get maximumNumberOfFeaturesExceeded(){return!!(this._tileFetcher!=null&&this._tileFetcher.maximumNumberOfFeaturesExceeded)}get snappingComplexityExceeded(){return this._tileFetcher?.snappingComplexityExceeded??!0}get maximumNumberOfFeatures(){return this.displayFeatureLimit?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){e!==this.maximumNumberOfFeatures&&this._overrideIfSome(`maximumNumberOfFeatures`,e)}get hasMaximumNumberOfFeaturesOverride(){return this._isOverridden(`maximumNumberOfFeatures`)}get hasAllFeatures(){return this.serviceDataCount===I.noServiceDataCount&&this.mode===`snapshot`&&this.hasAllFeaturesInView||this.serviceDataCount===this.graphics.length}get hasAllFeaturesInView(){let e=this.context.effectiveDisplayFilter?.where||null,t=e!=null&&e!==`1=1`;return this.mode===`tiles`&&t?!1:this._tileFetcher?.showsAllFeatures??!1}get hasFullGeometries(){return this._tileFetcher?.hasFullGeometries??!1}get mode(){let e=this.layerView.layer;if(e.type===`feature`&&e.infoFor3D!=null)return`snapshot`;if(e.type===`catalog-footprint`||this._forceTilesMode)return`tiles`;let t=this.layerView.view;if(t.qualitySettings?.graphics3D?.snapshotAvailable===!1||this.serviceDataCount===I.noServiceDataCount||this._snapshotLimitExceeded||this.maximumNumberOfFeaturesExceeded||t.quality<1)return`tiles`;let n=(t&&t.featureTiles)?.tilingScheme;if(e&&e.minScale&&this.serviceDataExtent&&n){let t=this._approximateExtentSizeAtScale(e.minScale,n);if((this.serviceDataExtent.width/t+this.serviceDataExtent.height/t)/2>I.maxSnapshotMinScaleFactor)return`tiles`}return!this.maximumNumberOfFeatures||this.serviceDataCount<=this.maximumNumberOfFeatures?`snapshot`:`tiles`}get maxTotalSnapshotVertices(){let e=this._get(`maxTotalSnapshotVertices`)||0,t=this.mode===`snapshot`&&this._tileFetcher?.totalVertices||0;return Math.max(e,t)}_approximateExtentSizeAtScale(e,t){let n=this.layerView.view,r=Math.ceil((n.width/t.pixelSize+n.height/t.pixelSize)/2),i=t.levels[0];return r*((i.tileSize[0]/(i.scale/e)+i.tileSize[1]/(i.scale/e))/2)}get tileDescriptors(){if(this.mode===`snapshot`){let e=new E(0,0,0,null,D);return new r([e])}let e=this.layerView.view.featureTiles;if(!e)return new r;let t=e.tiles;if(this.layerView.displayFilterEnabled&&this.layerView.effectiveDisplayFilterClause!=null&&this.layerView.effectiveDisplayFilterClause!==`1=1`&&this.layerView.highlightIds?.length>0){let e=new E(0,0,0,this.layerView.view.featureTiles?.tilingScheme,O);return new r([...t,e])}return t}get test(){}constructor(e){super(e),this.type=`feature-tile-3d`,this._updatingHandles=new b,this.serviceDataExtent=null,this.serviceDataCount=I.noServiceDataCount,this._snapshotLimitExceeded=!1,this.displayFeatureLimit=null,this._forceTilesMode=!1,this._suspended=!1,this._tileFetcher=null,this._fetchDataInfoPromise=null,this._fetchDataInfoAbortController=null,this._lifeCycleAbortController=new AbortController}initialize(){this._updatingHandles.add(()=>this.displayFeatureLimit,e=>this._updatingHandles.addPromise(this._updateSnapshotLimit(e,null,this._lifeCycleAbortController.signal))),this._updatingHandles.add(()=>this.mode,()=>this._modeChanged(),p),this._updatingHandles.add(()=>this.mode,(e,t)=>{e===`tiles`&&t===`snapshot`&&(this._forceTilesMode=!0)},p),this.addResolvingPromise(Promise.resolve().then(()=>this._verifyCapabilities()).then(()=>this._updatingHandles.addPromise(this._fetchServiceDataInfo())).then(()=>this._initializeTileFetcher()))}_verifyCapabilities(){let e=this.layerView.layer;if(e.type!==`ogc-feature`&&!w(e)?.operations.supportsQuery)throw new i(`graphicscontroller:query-capability-required`,`Service requires query capabilities to be used as a feature layer`,{layer:e})}destroy(){this._cancelFetchServiceDataInfo(),this._tileFetcher=s(this._tileFetcher),this._tilesHandle=c(this._tilesHandle),this._lifeCycleAbortController=l(this._lifeCycleAbortController),this._updatingHandles.destroy(),this._set(`_updatingHandles`,null)}suspend(){this._suspended||(this._suspended=!0,this._tileFetcher!=null&&this._tileFetcher.suspend())}resume(){this._suspended&&(this._suspended=!1,this._tileFetcher!=null&&this._tileFetcher.resume())}restart(){let e=()=>{this._tileFetcher!=null&&this._tileFetcher.restart()};this._updatingHandles.consumePromise(this._fetchServiceDataInfo().then(e,e))}refetch(){this._refetch({resetForceTilesMode:!1})}getMissingAttributesForFeature(e){return this._tileFetcher?.getMissingAttributesForFeature(e)}_refetch(e){let t=()=>{this._tileFetcher!=null&&(e.resetForceTilesMode&&(this._forceTilesMode=!1),this._tileFetcher.refetch())};this._updatingHandles.consumePromise(this._fetchServiceDataInfo().then(t,t))}_initializeTileFetcher(){let e=this.layerView.view;if(!e)return;let{layerView:t,tileDescriptors:n}=this,r=t.layer,i=new k({context:this.context,filterExtent:this.extent,tileDescriptors:n,features:this.graphics});this._tileFetcher=i,this._suspended?i.suspend():i.resume(),e&&this.addHandles(m(()=>e.quality,e=>i.memoryFactor=e,h));let a=this.context.geometryType===`polygon`?`polygonLodFactor`:this.context.geometryType===`polyline`?`polylineLodFactor`:null;a&&this.addHandles(m(()=>this.layerView.view?.qualitySettings?.graphics3D?.[a],e=>i.lodFactor=e||1,p)),r.type!==`ogc-feature`&&this._updatingHandles.add(()=>r.createQueryVersion,()=>this._dataFilterChanged()),this._updatingHandles.add(()=>this.layerView.effectiveDisplayFilter,()=>this._effectiveDisplayFilterChanged()),this._updatingHandles.add(()=>this.layerView.highlightIds,()=>this._displayFilterHighlightIdsChanged()),this._updatingHandles.add(()=>t.availableFields,(e,t)=>this._availableFieldsChanged(t,e)),this._updatingHandles.add(()=>t.requiredFields,(e,t)=>this._requiredFieldsChanged(t,e)),`customParameters`in r&&this._updatingHandles.add(()=>r.customParameters,()=>this.restart()),this.addHandles([r.on(`apply-edits`,e=>this._applyEdits(e)),m(()=>this.extent,e=>i.filterExtent=e,g),m(()=>this.tileDescriptors,e=>i.tileDescriptors=e,g),m(()=>this.maximumNumberOfFeatures,e=>{i.maximumNumberOfFeatures=e,i.useTileCount=this.serviceDataCount>e},h),m(()=>this.serviceDataCount,e=>{i.useTileCount=e>this.maximumNumberOfFeatures},h),m(()=>({featureTiles:e.featureTiles,show:j.FEATURE_TILE_FETCH_SHOW_TILES}),({show:t,featureTiles:n})=>{t&&i&&n?i.debugger??=new A(i,n.tilingScheme.toTileInfo(),e):i.debugger=s(i.debugger)},p)]),this._supportsExceedsLimitQuery||this._updatingHandles.add(()=>this.maxTotalSnapshotVertices,()=>this._updatingHandles.addPromise(this._updateSnapshotLimit(this.displayFeatureLimit,null,this._lifeCycleAbortController.signal)))}_modeChanged(){switch(this.mode){case`tiles`:this._tilesHandle||=this.layerView.view.enableFeatureTiles();break;default:o.getLogger(this).warn(`Unhandled feature layer mode `+this.mode);case`snapshot`:this._tilesHandle!=null&&(this._tilesHandle.remove(),this._tilesHandle=null)}}_dataFilterChanged(){this._set(`maxTotalSnapshotVertices`,0),this.notifyChange(`maxTotalSnapshotVertices`),this._refetch({resetForceTilesMode:!0})}_effectiveDisplayFilterChanged(){this.mode!==`snapshot`&&this._refetch({resetForceTilesMode:!1})}_displayFilterHighlightIdsChanged(){this.mode!==`snapshot`&&this._tileFetcher!=null&&this._tileFetcher.refetchDisplayFilterHighlightTile()}_applyEdits(e){let t=this.layerView.layer;this._tileFetcher!=null&&this._tileFetcher.applyEdits(e).then(e=>{if(e){if(!this._lifeCycleAbortController)throw d();e.exceededTransferLimit&&`refresh`in t?t.refresh():(e.deletedFeatures.length||e.updatedFeatures.length||e.addedFeatures.length)&&this._updatingHandles.consumePromise(this._updateServiceDataExtent(this._lifeCycleAbortController.signal))}}).catch(e=>{if(!f(e))throw e})}_availableFieldsChanged(e,t){this._tileFetcher!=null&&F(this._tileFetcher.availableFields,t)&&this._refetch({resetForceTilesMode:!1})}_requiredFieldsChanged(e,t){this._tileFetcher!=null&&F(this._tileFetcher.availableFields,t)&&this.restart()}_createVertexLimitExceededQuery(e){let t=this.layerView.layer,n=t.createQuery();return n.returnGeometry=!1,n.outStatistics=[new T({statisticType:`exceedslimit`,maxVertexCount:e,outStatisticFieldName:`exceedslimit`,maxPointCount:1e8,maxRecordCount:1e8})],t.capabilities?.query.supportsCacheHint&&(n.cacheHint=!0),n}_createDataInfoQuery(){let e=this.layerView.layer,t=this.layerView,n=e.createQuery();return n.returnGeometry=!1,n.outSpatialReference=this.layerView.view.spatialReference,e.capabilities?.query.supportsCacheHint&&(n.cacheHint=!0),t.effectiveDisplayFilter&&(n.where=_(n.where,t.effectiveDisplayFilter.where)),n}_fullExtentIsAccurate(){let e=this.layerView.layer;if(`definitionExpression`in e&&e.definitionExpression)return!1;switch(e.type){case`feature`:case`catalog-footprint`:case`oriented-imagery`:return S(e.url);case`csv`:case`geojson`:case`ogc-feature`:case`wfs`:return!0;default:return}}async _updateServiceDataExtent(e){try{await this._tryUpdateServiceDataExtent(e)}catch(e){f(e)||this._set(`serviceDataExtent`,a(this.layerView.fullExtentInLocalViewSpatialReference)??null)}}async _tryUpdateServiceDataExtent(e){let t=this.layerView,n=t.layer,r=n.capabilities?.query.supportsExtent??!1,i=a(t.fullExtentInLocalViewSpatialReference),o=n.fullExtent,s=this._fullExtentIsAccurate(),c=this.serviceDataCount;if(r&&c<=I.maxFeatureCountForExtent&&(!i||!s)&&`queryExtent`in n){let t=this._createDataInfoQuery(),r=await n.queryExtent(t,{timeout:I.queryExtentTimeout,signal:e});this._set(`serviceDataExtent`,r.extent)}else if(i)this._set(`serviceDataExtent`,i);else if(o!=null){let e=o.spatialReference?await x(o,t.view.spatialReference):null;this._set(`serviceDataExtent`,e??null)}else this._set(`serviceDataExtent`,null)}async _updateServiceDataCount(e){let t=this.layerView.layer;if(!(`queryFeatureCount`in t)||!has(`featurelayer-snapshot-enabled`)){this._set(`serviceDataCount`,I.noServiceDataCount);return}let r=await n(t.queryFeatureCount(this._createDataInfoQuery(),{timeout:I.queryStatisticsTimeout,signal:e}));if(r.ok===!0)this._set(`serviceDataCount`,r.value);else{if(f(r.error))throw r.error;this._set(`serviceDataCount`,I.noServiceDataCount)}}get _supportsExceedsLimitQuery(){let e=this.layerView.layer;return e.capabilities!=null&&e.capabilities.operations&&e.capabilities.operations.supportsExceedsLimitStatistics}get _minimumNumberOfVerticesForGeometry(){switch(this.layerView.layer.geometryType){case`point`:return 1;case`multipoint`:return 1;case`polygon`:return 4;case`polyline`:return 2;case`multipatch`:case`mesh`:return 3;case null:case void 0:return 0;default:return 0}}async _updateSnapshotLimit(e,t,r){if(e?.averageSymbolComplexity==null){this._snapshotLimitExceeded=!1;return}let{maximumTotalNumberOfVertices:i,averageSymbolComplexity:a}=e,{verticesPerFeature:o,verticesPerCoordinate:s}=a,c=o<=0,l=this._minimumNumberOfVerticesForGeometry>1;if(!c&&!l){this._snapshotLimitExceeded=!1;return}o!==0&&t!=null&&await t;let u=Math.min(i,N),d=this.serviceDataCount,p=d!==I.noServiceDataCount,m=Math.ceil(p?(u-d*o)/(s||1):u/(s||1));if(l&&(m=Math.min(m,P)),p&&this._minimumNumberOfVerticesForGeometry*d>m){this._snapshotLimitExceeded=!0;return}if(!this._supportsExceedsLimitQuery||!has(`featurelayer-snapshot-enabled`)){this._snapshotLimitExceeded=this.maxTotalSnapshotVertices>m;return}let h=await n(this.layerView.layer.queryFeatures(this._createVertexLimitExceededQuery(m),{timeout:I.queryStatisticsTimeout,signal:r}));if(h.ok===!1){if(f(h.error))throw h.error;this._snapshotLimitExceeded=!1;return}let g=h.value.features[0];this._snapshotLimitExceeded=g?.attributes?!!g.attributes.exceedslimit:!1}async _fetchServiceDataInfo(){this._cancelFetchServiceDataInfo(),await C(this.layerView.layer);let e=new AbortController,t=e.signal,n=this._updateServiceDataCount(t),r=Promise.allSettled([n,this._updateSnapshotLimit(this.displayFeatureLimit,n,t)]),i=r.then(()=>this._updateServiceDataExtent(t)).catch(e=>{f(e)||o.getLogger(this).error(`#fetchServiceDataInfo()`,e)}).then(()=>{i===this._fetchDataInfoPromise&&(this._fetchDataInfoPromise=null,this._fetchDataInfoAbortController=null),e=null});return e&&(this._fetchDataInfoPromise=i),this._fetchDataInfoAbortController=e,r.then(()=>{},()=>{})}_cancelFetchServiceDataInfo(){let e=this._fetchDataInfoAbortController;e&&(this._fetchDataInfoAbortController=null,this._fetchDataInfoPromise=null,e.abort())}get performanceInfo(){return{storedFeatures:this._tileFetcher?.storedFeatures??0,totalFeatures:this._tileFetcher?.totalFeatures??0,totalVertices:this._tileFetcher?.totalVertices??0,missingTiles:this._tileFetcher?.missingTiles??0}}};e([v({readOnly:!0})],M.prototype,`type`,void 0),e([v({constructOnly:!0})],M.prototype,`graphics`,void 0),e([v({constructOnly:!0})],M.prototype,`layerView`,void 0),e([v({constructOnly:!0})],M.prototype,`context`,void 0),e([v({readOnly:!0})],M.prototype,`dataUpdating`,null),e([v()],M.prototype,`extent`,null),e([v()],M.prototype,`updating`,null),e([v({readOnly:!0})],M.prototype,`_updatingHandles`,void 0),e([v()],M.prototype,`updatingTotal`,null),e([v()],M.prototype,`updatingRemaining`,null),e([v()],M.prototype,`expectedFeatureDiff`,null),e([v()],M.prototype,`usedMemory`,null),e([v()],M.prototype,`usedMemoryPerFeature`,null),e([v()],M.prototype,`maximumNumberOfFeaturesExceeded`,null),e([v()],M.prototype,`snappingComplexityExceeded`,null),e([v({readOnly:!0})],M.prototype,`serviceDataExtent`,void 0),e([v({readOnly:!0})],M.prototype,`serviceDataCount`,void 0),e([v()],M.prototype,`_snapshotLimitExceeded`,void 0),e([v()],M.prototype,`displayFeatureLimit`,void 0),e([v({type:Number})],M.prototype,`maximumNumberOfFeatures`,null),e([v({readOnly:!0})],M.prototype,`hasAllFeatures`,null),e([v({readOnly:!0})],M.prototype,`hasAllFeaturesInView`,null),e([v({readOnly:!0})],M.prototype,`hasFullGeometries`,null),e([v()],M.prototype,`_forceTilesMode`,void 0),e([v({readOnly:!0})],M.prototype,`mode`,null),e([v({readOnly:!0})],M.prototype,`maxTotalSnapshotVertices`,null),e([v({readOnly:!0})],M.prototype,`tileDescriptors`,null),e([v()],M.prototype,`_tileFetcher`,void 0),e([v()],M.prototype,`_fetchDataInfoPromise`,void 0),M=e([y(`esri.layers.graphics.controllers.FeatureTileController3D`)],M);const N=has(`esri-tests-maximum-vertices-for-snapshot`)??1e6,P=5e6;function F(e,t){if(!t)return!1;for(let n of t)if(!e.has(n))return!0;return!1}class I{static{this.noServiceDataCount=1/0}static{this.maxSnapshotMinScaleFactor=5}static reset(){I.maxFeatureCountForExtent=1e4,I.queryStatisticsTimeout=12e3,I.queryExtentTimeout=1e4}}I.reset();export{M as FeatureTileController3D,I as FeatureTileController3DConstants};
|
|
@@ -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 n from"../../../../request.js";import r from"../../../../core/Error.js";import{EventEmitter as i}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{QueueProcessor as a}from"../../../../core/QueueProcessor.js";import{isBlobProtocol as o}from"../../../../core/urlUtils.js";import{createParquetFile as s,readMetadata as c}from"../../../parquet.js";import{ParquetFileInfo as l}from"./ParquetFileInfo.js";import{parseFileStatisticsMap as u}from"./ParquetFileStatistics.js";const d=`_spatial.json`,f=new a({concurrency:12,process:async e=>{let{data:t}=await n(e.url,e.options);return t}});let p=1;class m{constructor(e,t=()=>{}){this._geometryInfo=e,this._getCustomParameters=t,this.events=new i}async destroy(){await this.clear()}async clear(){if(this._infos){let e=await this._infos;for(let t of e.values())t.destroy();e.clear(),this._infos=null}}async getMetadata(){let n={stack:[],error:void 0,hasError:!1};try{let t=(await this._getParquetFileNames()).at(0);if(!t)return null;let r=e(n,await s(t,{provider:this}),!1);return c(r)}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}getGeometryInfo(){return this._geometryInfo}async getFiles(){let e=await this._getInfoMap();return Array.from(e.values())}async updateGeometryInfo(e){if(this._geometryInfo)throw Error(`GeometryInfo already set`);await this.clear(),this._geometryInfo=e}async fetchLength(e){let{byteLength:t,cacheTag:n}=await this._fetchLengthAndTag(e);if(!has(`parquetlayer-cache-enabled`))return t;try{await this._createOrResetCache(e,n)}catch{}return t}async fetchRange(e,t,n,r){let i={fileId:e,requestId:p++,range:{start:t,end:n+1}};this.events.emit(`rangeRead`,{...i,phase:`start`});try{let a=await this._fetchRangeWithCache(e,t,n,r);return this.events.emit(`rangeRead`,{...i,phase:`complete`}),a}catch(e){throw this.events.emit(`rangeRead`,{...i,phase:`error`}),e}}_getCacheFileName(e){return e}async _requestStatistics(e){let{data:t}=await n(e,{responseType:`json`,query:this._getCustomParameters()});return t}async _fetchRange(e,t,n,i){let a={url:e,options:{responseType:`array-buffer`,query:this._getCustomParameters()??{},cacheMode:`no-store`,useQueue:!0,headers:{range:`bytes=${t}-${n}`}}},o=await f.push(a),s=n-t+1;if(o.byteLength!==s)throw new r(`InvalidRangeRequest`,`request returned ${o.byteLength} bytes for range ${t}-${n}, expected ${s}.`);return o}async _fetchLengthAndTag(e){if(o(e)){let{data:t}=await n(e,{responseType:`blob`});return{byteLength:t.size,cacheTag:null}}let t=await this._requestHead(e),r=t.headers.get(`Content-Length`);if(r==null)throw Error(`Unable to parse content length`);let i=t.headers.get(`etag`)??t.headers.get(`Last-Modified`);return{byteLength:parseInt(r,10),cacheTag:i}}async _getInfoMap(){return this._infos||=this._fetchParquetFiles(),this._infos}async _updateParquetFileInfos(e){let t=await this._getInfoMap(),n=new Set(e);for(let e of n)if(!t.get(e)){let n=t.size,r=await l.create(this.getGeometryInfo(),this,e,n,null);t.set(e,r)}for(let e of t.keys())if(!n.has(e))throw Error(`Deletion not supported`)}async _getFileStatistics(e){this._statistics||=this._fetchStatistics();let t=await this._statistics,n=g(e);return t.get(n)}async _fetchParquetFiles(){let e=(await this._getParquetFileNames()).map(async(e,t)=>{let n=t,r=await this._getFileStatistics(e);return l.create(this.getGeometryInfo(),this,e,n,r)}),t=await Promise.all(e),n=new Map;for(let e of t)n.set(e.url,e);return n}async _fetchStatistics(){let e=await this._getStatisticsFileName();if(e==null)return new Map;let t=await this._resolveFileUrl(e),n=await this._requestStatistics(t);return u(n)}async _requestHead(e){let{data:t}=await n(e,{responseType:`native`,method:`head`,query:this._getCustomParameters()});return t}async _openCache(e){return caches.open(this._getCacheName(e))}async _fetchRangeWithCache(e,t,n,r){if(!has(`parquetlayer-cache-enabled`))return this._fetchRange(e,t,n,r);let i=new URL(this._getCacheFileName(e));i.searchParams.append(`range`,`${t}-${n}`);try{let a=await this._openCache(e),o=await a.match(i);if(o)return await o.arrayBuffer();let s=await this._fetchRange(e,t,n,r);return await a.put(i,new Response(s,{headers:{"Content-Type":`application/octet-stream`,"Content-Length":s.byteLength.toString()}})),s}catch{return this._fetchRange(e,t,n,r)}}_getCacheName(e){return`parquet.v1:${this._getCacheFileName(e)}`}async _createOrResetCache(e,t){let n=this._getCacheName(e),r=new URL(this._getCacheFileName(e));if(r.searchParams.append(`metadata`,`true`),t==null){await caches.delete(n);return}let i=await caches.open(n);(await(await i.match(r))?.json())?.tag!==t&&(await caches.delete(n),i=await caches.open(n));let a=JSON.stringify({tag:t});await i.put(r,new Response(a,{headers:{"Content-Type":`application/json`,"Content-Length":a.length.toString()}}))}}function h(e){let t=e.split(/[?#]/)[0];return t===d||t.endsWith(d)}function g(e){return e.split(/[?#]/)[0].split(`/`).at(-1)??e}export{m as FileProvider,h as isStatisticsFileName,d as spatialFileName};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import n from"../../../../request.js";import r from"../../../../core/Error.js";import{EventEmitter as i}from"../../../../core/Evented.js";import has from"../../../../core/has.js";import{QueueProcessor as a}from"../../../../core/QueueProcessor.js";import{isBlobProtocol as o}from"../../../../core/urlUtils.js";import{createParquetFile as s,readMetadata as c}from"../../../parquet.js";import{ParquetFileInfo as l}from"./ParquetFileInfo.js";import{parseFileStatisticsMap as u}from"./ParquetFileStatistics.js";const d=`_spatial.json`,f=new a({concurrency:12,process:async e=>{let{data:t}=await n(e.url,e.options);return t}});let p=1;class m{constructor(e,t=()=>{}){this._geometryInfo=e,this._getCustomParameters=t,this.events=new i}async destroy(){await this.clear()}async clear(){if(this._infos){let e=await this._infos;for(let t of e.values())t.destroy();e.clear(),this._infos=null}}async getMetadata(){let n={stack:[],error:void 0,hasError:!1};try{let t=(await this._getParquetFileNames()).at(0);if(!t)return null;let r=e(n,await s(t,{provider:this}),!1);return c(r)}catch(e){n.error=e,n.hasError=!0}finally{t(n)}}getGeometryInfo(){return this._geometryInfo}async getFiles(){let e=await this._getInfoMap();return Array.from(e.values())}async updateGeometryInfo(e){if(this._geometryInfo)throw Error(`GeometryInfo already set`);await this.clear(),this._geometryInfo=e}async fetchLength(e){let{byteLength:t,cacheTag:n}=await this._fetchLengthAndTag(e);if(!has(`parquetlayer-cache-enabled`))return t;try{await this._createOrResetCache(e,n)}catch{}return t}async fetchRange(e,t,n,r){let i={fileId:e,requestId:p++,range:{start:t,end:n+1}};this.events.emit(`rangeRead`,{...i,phase:`start`});try{let a=await this._fetchRangeWithCache(e,t,n,r);return this.events.emit(`rangeRead`,{...i,phase:`complete`}),a}catch(e){throw this.events.emit(`rangeRead`,{...i,phase:`error`}),e}}_getCacheFileName(e){return e}async _requestStatistics(e){let{data:t}=await n(e,{responseType:`json`,maxUrlLength:0,query:this._getCustomParameters()});return t}async _fetchRange(e,t,n,i){let a={url:e,options:{responseType:`array-buffer`,query:this._getCustomParameters()??{},cacheMode:`no-store`,maxUrlLength:0,useQueue:!0,headers:{range:`bytes=${t}-${n}`}}},o=await f.push(a),s=n-t+1;if(o.byteLength!==s)throw new r(`InvalidRangeRequest`,`request returned ${o.byteLength} bytes for range ${t}-${n}, expected ${s}.`);return o}async _fetchLengthAndTag(e){if(o(e)){let{data:t}=await n(e,{responseType:`blob`});return{byteLength:t.size,cacheTag:null}}let t=await this._requestHead(e),r=t.headers.get(`Content-Length`);if(r==null)throw Error(`Unable to parse content length`);let i=t.headers.get(`etag`)??t.headers.get(`Last-Modified`);return{byteLength:parseInt(r,10),cacheTag:i}}async _getInfoMap(){return this._infos||=this._fetchParquetFiles(),this._infos}async _updateParquetFileInfos(e){let t=await this._getInfoMap(),n=new Set(e);for(let e of n)if(!t.get(e)){let n=t.size,r=await l.create(this.getGeometryInfo(),this,e,n,null);t.set(e,r)}for(let e of t.keys())if(!n.has(e))throw Error(`Deletion not supported`)}async _getFileStatistics(e){this._statistics||=this._fetchStatistics();let t=await this._statistics,n=g(e);return t.get(n)}async _fetchParquetFiles(){let e=(await this._getParquetFileNames()).map(async(e,t)=>{let n=t,r=await this._getFileStatistics(e);return l.create(this.getGeometryInfo(),this,e,n,r)}),t=await Promise.all(e),n=new Map;for(let e of t)n.set(e.url,e);return n}async _fetchStatistics(){let e=await this._getStatisticsFileName();if(e==null)return new Map;let t=await this._resolveFileUrl(e),n=await this._requestStatistics(t);return u(n)}async _requestHead(e){let{data:t}=await n(e,{responseType:`native`,method:`head`,maxUrlLength:0,query:this._getCustomParameters()});return t}async _openCache(e){return caches.open(this._getCacheName(e))}async _fetchRangeWithCache(e,t,n,r){if(!has(`parquetlayer-cache-enabled`))return this._fetchRange(e,t,n,r);let i=new URL(this._getCacheFileName(e));i.searchParams.append(`range`,`${t}-${n}`);try{let a=await this._openCache(e),o=await a.match(i);if(o)return await o.arrayBuffer();let s=await this._fetchRange(e,t,n,r);return await a.put(i,new Response(s,{headers:{"Content-Type":`application/octet-stream`,"Content-Length":s.byteLength.toString()}})),s}catch{return this._fetchRange(e,t,n,r)}}_getCacheName(e){return`parquet.v1:${this._getCacheFileName(e)}`}async _createOrResetCache(e,t){let n=this._getCacheName(e),r=new URL(this._getCacheFileName(e));if(r.searchParams.append(`metadata`,`true`),t==null){await caches.delete(n);return}let i=await caches.open(n);(await(await i.match(r))?.json())?.tag!==t&&(await caches.delete(n),i=await caches.open(n));let a=JSON.stringify({tag:t});await i.put(r,new Response(a,{headers:{"Content-Type":`application/json`,"Content-Length":a.length.toString()}}))}}function h(e){let t=e.split(/[?#]/)[0];return t===d||t.endsWith(d)}function g(e){return e.split(/[?#]/)[0].split(`/`).at(-1)??e}export{m as FileProvider,h as isStatisticsFileName,d as spatialFileName};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ReloadableLayer is a mixin that adds support for reloading layer's schema and properties.
|
|
3
3
|
*
|
|
4
4
|
* @since 5.2
|
|
5
5
|
*/
|
|
6
|
-
export abstract class
|
|
6
|
+
export abstract class ReloadableLayer {
|
|
7
7
|
constructor(...args: any[]);
|
|
8
8
|
/**
|
|
9
|
-
* Indicates if the layer is in the process of reloading its properties and schema after a call to
|
|
9
|
+
* Indicates if the layer is in the process of reloading its properties and schema after a call to [reload()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reload).
|
|
10
10
|
*
|
|
11
11
|
* @since 5.2
|
|
12
|
+
* @see [reload()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reload)
|
|
12
13
|
*/
|
|
13
14
|
get reloading(): boolean;
|
|
14
15
|
/**
|
|
@@ -21,6 +22,7 @@ export abstract class FeatureLayerReload {
|
|
|
21
22
|
* @returns `true` when the layer is successfully updated with data from the portal item or service;
|
|
22
23
|
* `false` when the layer is not updated, not loaded, or does not reference a service.
|
|
23
24
|
* @since 5.2
|
|
25
|
+
* @see [reloading](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reloading)
|
|
24
26
|
*/
|
|
25
27
|
reload(): Promise<boolean>;
|
|
26
28
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import{abortHandle as t}from"../../core/handleUtils.js";import{debounce as n,throwIfAbortError as r}from"../../core/promiseUtils.js";import{property as i,subclass as a}from"../../core/accessorSupport/decorators.js";import{getOwningPortalUrl as o}from"../support/layerUtils.js";import s from"../../portal/Portal.js";import c from"../../portal/PortalItem.js";const l=`reload`,u=u=>{let d=u,f=class extends d{constructor(...e){super(...e),this._loadTimestamp=0,this._pendingReloadCount=0,this._serviceItemModified=null,this._debounceReload=n(async()=>{if(this.destroyed||!this.loaded||!this.canReload())return!1;let e=new AbortController;this.addHandles(t(e),l);try{let t=null,n;if(this.portalItem?.id&&this.portalItem.id===this.serviceItemId)n=await this.reloadFromPortal({supportedTypes:this.supportedPortalItemTypes},{signal:e.signal});else{let r=await this._shouldReloadFromServiceItem(e.signal);n=r.updated,t=r.modified}return n&&await this.reloadFromService(e.signal),e.signal.throwIfAborted(),t!=null&&(this._serviceItemModified=t),n}finally{this.removeHandles(l)}}),this.when().then(()=>{this._loadTimestamp=Date.now()},()=>{})}get reloading(){return this._pendingReloadCount>0}reload(){return this.destroyed||!this.loaded||!this.canReload()?Promise.resolve(!1):(this._pendingReloadCount++,this._debounceReload().finally(()=>{this._pendingReloadCount--}))}canReload(){return this.url!=null}async _shouldReloadFromServiceItem(e){let{serviceItemId:t,url:n}=this;if(!t||!n)return{modified:null,updated:!0};try{let r=await o(n,{signal:e});if(!r)return{modified:null,updated:!0};let i=new s({url:r}),a=new c({apiKey:this.apiKey,id:t,portal:i});await a.load({signal:e});let l=a.modified?.getTime();if(l==null)return{modified:null,updated:!0};let u=this._serviceItemModified;return{modified:l,updated:u==null?l>this._loadTimestamp:u<l}}catch(e){return r(e),{modified:null,updated:!0}}}};return e([i({clonable:!1})],f.prototype,`_pendingReloadCount`,void 0),e([i({readOnly:!0})],f.prototype,`reloading`,null),f=e([a(`esri.layers.mixins.ReloadableLayer`)],f),f};export{u as ReloadableLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{deg2rad as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as i}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{sub as a,add as o,length as s,dot as c}from"../../../core/libs/gl-matrix-2/math/vec3.js";import l from"../../../geometry/Circle.js";import u from"../../../geometry/Mesh.js";import d from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectAsync as p}from"../../../geometry/projectionUtils.js";import m from"../../../geometry/SpatialReference.js";import{polygonCentroidPoint as h}from"../../../geometry/support/centroid.js";import{earth as g}from"../../../geometry/support/Ellipsoid.js";import _ from"../../../geometry/support/MeshComponent.js";import{createSphere as v}from"../../../geometry/support/meshUtils.js";import y from"../../../geometry/support/MeshVertexAttributes.js";import{create as b,fromArray as x,intersectRay as S}from"../../../geometry/support/plane.js";import{isWebMercator as C}from"../../../geometry/support/spatialReferenceUtils.js";import{getMetersPerUnitOfSR as w}from"./utils.js";import{convertToSRUnits as T,getWebMercatorScalingFactor as E,createRotationMatrixFromHPR as D,transformMat3 as O,scaleAndAddWithFactor as k,scaleWithFactor as A,computeHFOVAndVFOV as j,projectiveTransform as M}from"../transformations/utils.js";const N=Math.PI/180;function P(e,t,n){let r=T(e,t.spatialReference);return r.cameraHeight=(t.z??r.cameraHeight)-n,e.isSpherical?z(r,t):F(r,t)}function F(e,t){let{horizontalFieldOfView:n,verticalFieldOfView:r,cameraHeading:i}=e,a=E(t.y,t.spatialReference),o=e.cameraPitch,s=e.cameraRoll??0,c=150;n>150&&(o=90,s=0,c=5);let l=Math.ceil(n/c),u=I(l,i,n),d=K(e)*a,p=new f({spatialReference:t?.spatialReference});p.imageID=e.objectId;let m=null;for(let i of u)m=L(i,o,e.cameraHeight,t,d,a,r,n,l,p,s,e.nearDistance);return m.imageID=e.objectId,{polygon:p,frustum:m}}function I(e,t,n){let r=[];if(e%2==0)for(let i=0;i<e/2;i++)r.push(t-n/e*(i+.5),t+n/e*(i+.5));else{r.push(t);for(let i=1;i<e/2;i++)r.push(t-n/e*i,t+n/e*i)}return r.sort(),r}function L(e,t,s,c,l,u,d,f,p,m,h=0,g=0){let _=i(n(),D([e,t,h??0])),v=U({cameraHeight:s,cameraPitch:t,farDistance:l,location:c,horizontalFieldOfView:f,nearDistance:g,verticalFieldOfView:d},_),y=O([0,0,-1],_),{x:b,y:x}=c,S=k([b,x,c.z??s],y,l,u),C=2*Math.tan(d*N/2)*l,w=2*Math.tan(f/p*N/2)*l,T=O([0,1,0],_),E=O([1,0,0],_),j=A(T,C/2,u),M=A(E,w/2,u),P=a(r(),j,M),F=o(r(),j,M),I=R([o(r(),S,P),o(r(),S,F),a(r(),S,P),a(r(),S,F)],s,c,u);return I.push(I[0]),m.addRing(I),v}function R(e,t,n,r){return e.map(e=>W(e,t,n,r))}function z(e,t){let{farDistance:n,objectId:r,nearDistance:i,cameraHeight:a}=e,o=E(t.y,t.spatialReference),s=new l({center:t.clone(),radius:n*o});if(s.imageID=r,i){let e=new l({center:t.clone(),radius:i*o});s.addRing(e.rings[0])}let c=t.clone();c.z=(t.z??a)-n*o;let u=v(c,{size:2*n*o});return u.imageID=r,{polygon:s,frustum:u}}function B(e,t){return e.contains(t)}function V(e,t){let r=T(e,e.location.spatialReference);if(t.z==null)return!1;let{horizontalFieldOfView:a,location:o,nearDistance:l=0,verticalFieldOfView:u}=r,d=K(r);if(a==null||u==null||d<=0)return!1;let f=E(o.y,o.spatialReference),p=o.z??0,m=[(t.x-o.x)/f,(t.y-o.y)/f,t.z-p];if(r.isSpherical){let e=s(m);return l<=e&&e<=d}let h=i(n(),D([r.cameraHeading,r.cameraPitch,r.cameraRoll??0])),g=O([0,0,-1],h),_=c(m,g);return _>0&&_>=l&&_<=d}function H(e,t){return Math.sign(e)!==Math.sign(t)}function U(e,t,n){let{cameraHeight:i,cameraPitch:s,farDistance:c,location:l,horizontalFieldOfView:d,nearDistance:f,verticalFieldOfView:p}=e,m=l.z??i,h=m-i,g=q(l),_=!(s+p/2>=90),v=2*Math.tan(p*N/2)*f,b=2*Math.tan(d*N/2)*f,x=2*Math.tan(p*N/2)*c,S=2*Math.tan(d*N/2)*c,C,w=[0,0,-1];w=O(w,t),C=k([l.x,l.y,m],w,c,g),_&&(C[2]=h);let T=k([l.x,l.y,m],w,f,g),E=[0,1,0];E=O(E,t);let D=[1,0,0];D=O(D,t);let j=[],M=[];f?(M=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],j=j.concat(o(r(),T,a(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(o(r(),T,o(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(a(r(),T,a(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(a(r(),T,o(r(),A(E,v/2,g),A(D,b/2,g))))):(j=[l.x,l.y,m],M=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),j=j.concat(o(r(),C,a(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(o(r(),C,o(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(a(r(),C,a(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(a(r(),C,o(r(),A(E,x/2,g),A(D,S/2,g))));let P=new y({position:Float64Array.from(j)});return new u({vertexAttributes:P,components:M,spatialReference:l.spatialReference})}function W(e,t,n,i){{let o=n.z??t,s=o-t,c=Math.sqrt((e[2]-o)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/i)**2)*i,l=A(a(r(),[e[0],e[1],e[2]],[n.x,n.y,o]),1/c,1/i),u=t/(o-e[2]),d={x:(1-u)*n.x+u*e[0],y:(1-u)*n.y+u*e[1],z:(1-u)*o+u*e[2]},f=Math.sqrt((d.z-o)**2+(Math.sqrt((d.x-n.x)**2+(d.y-n.y)**2)/i)**2)*i,p=A(a(r(),[d.x,d.y,d.z],[n.x,n.y,o]),1/f,1/i);return H(l[0],p[0])&&H(l[1],p[1])&&H(l[2],p[2])||e[2]>=s?[e[0],e[1],s]:[d.x,d.y,d.z]}}function G(e){let{spatialReference:t,x:n,y:r}=e.geometry,{cameraHeading:i,cameraPitch:a,farDistance:o,nearDistance:s}=e,c=q(e.geometry),l=new f({spatialReference:t}),u=Math.abs(1.44*o*c),d=Math.abs(1.44*s*c);(a<20||i==null)&&(d=u);let p=[];return p[0]={x:n+u*Math.sin((i-45)*N),y:r+u*Math.cos((i-45)*N)},p[1]={x:n+u*Math.sin((i+45)*N),y:r+u*Math.cos((i+45)*N)},p[2]={x:n+d*Math.sin((i+135)*N),y:r+d*Math.cos((i+135)*N)},p[3]={x:n+d*Math.sin((i+225)*N),y:r+d*Math.cos((i+225)*N)},l.addRing([[p[0].x,p[0].y,0],[p[1].x,p[1].y,0],[p[2].x,p[2].y,0],[p[3].x,p[3].y,0],[p[0].x,p[0].y,0]]),l}function K(t){let{cameraHeight:n,cameraPitch:r,farDistance:i,location:a,verticalFieldOfView:o}=t;return i??(r+o/2>=90?20/w(a.spatialReference):n/Math.cos(e(r)))}function q(e){return e&&C(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/g.radius))):1}function ee(e,t){let n=1+t/100;if(e.declaredClass===`esri.geometry.Circle`){let{radius:t,center:r}=e,i=t*n,a=new l({radius:i,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if(e.declaredClass===`esri.geometry.Polygon`){let t=new f({spatialReference:e.spatialReference}),i=h(e);if(i){let o=[];for(let t=0;t<e.rings[0].length;t++){let s=Math.sqrt((i.x-e.rings[0][t][0])**2+(i.y-e.rings[0][t][1])**2),c=A(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[i.x,i.y,0]),1/s,1),l=k([i.x,i.y,0],c,s*n,1);o.push({x:l[0],y:l[1]})}t.addRing([[o[0].x,o[0].y,0],[o[1].x,o[1].y,0],[o[2].x,o[2].y,0],[o[3].x,o[3].y,0],[o[0].x,o[0].y,0]])}return t}return e}async function te(e,t,n){let{cameraHeight:r,cameraLocation:i,cameraPitch:a,frustumVertices:o,horizontalFieldOfView:s,imageHeight:c,imageWidth:l,inSRS:u,outSRS:d,verticalFieldOfView:f,cameraRoll:p,options:h}=n,g=new m(u),_=new m(d),v=j(s,f,p??0),y=o.length>15;return a+v.vfov/2>=90?await oe(o,e,l,c,g,_,y,h):await ne(o,e,t,i,r,y,g,_,h)}async function ne(e,t,n,r,i,a,o,s,c){let l=re(e,t,n,r,i);if(!l)return;let{farPlane:d,nearPlane:f}=l,p=await J([...f?.vertexPositions??e.slice(0,3),...d.vertexPositions],o,s,c),m=$(p);return new u({vertexAttributes:new y({position:p}),components:Q(a?X(m,!0):Z(m,!0)),spatialReference:s})}function re(e,t,n,r,i){let a=Y(e),o=Y(e,`near`);if(!a)return;let s=t.length;for(let e=0;e<s;e++){let t=Array.from(n[e]),s=[t[0]-r[0],t[1]-r[1],t[2]-(r[2]??i)];ae(r,s,e,o),ie(r,s,e,a)}return{farPlane:a,nearPlane:o}}function ie(e,t,n,i){let{coefficients:a,vertexPositions:o}=i,s=r();S(a,{origin:e,direction:t},s)&&o.splice(n*3,3,...s)}function ae(e,t,n,i){if(!i)return;let a=r();S(i.coefficients,{origin:e,direction:t},a)&&i.vertexPositions.splice(n*3,3,...a)}async function oe(e,t,n,r,i,a,o,s){let c=o?[]:[e[0],e[1],e[2]],l,d=[];for(let i of t)o?(l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),c=c.concat(...l),l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),d=d.concat(...l)):(l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),c=c.concat(...l));c=c.concat(d);let f=await J(c,i,a,s),p=$(f);return new u({vertexAttributes:new y({position:f}),components:Q(o?X(p,!0):Z(p,!0)),spatialReference:a})}async function J(e,n,r,i){if(n.equals(r))return e;let a=e.reduce((e,t,n)=>{let r=Math.floor(n/3);return e[r]||(e[r]=[]),e[r].push(t),e},[]),{points:o}=await p(new d({points:a,spatialReference:n}),r,i);return t(i),o.flat()}function Y(e,t=`far`){let n=b(),r;switch(t){case`far`:if(r=Array.from(e.length===15?e.slice(3):e.slice(12)),x(n,r,!1))return{coefficients:n,vertexPositions:r};break;case`near`:return r=Array.from(e.slice(0,12)),e.length===15||!x(n,r,!1)?void 0:{coefficients:n,vertexPositions:r}}}const X=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw Error(`Invalid number of vertices`);let n=[],r=e/2,i=Math.round((t?e-2:e)/2);for(let a=0;a<i;a++){let i=a+r,o=t?i+1:i,s=o%e,c=(t?i:o+1)%e;n.push({faces:new Uint32Array([a,c,s,a,a+1,s])})}return n};function Z(e,t=!1){if(e<3||t&&e-1<3)throw Error(`Invalid number of vertices`);let n=[],r=t?e-2:e-1;for(let e=0;e<r;e++)n.push({faces:new Uint32Array([0,e+1,e+2])});return n}const Q=e=>e.map(e=>new _(e)),$=e=>e.length/3;export{V as checkIfFrustumContainsSelectedPoint,B as checkIfPolygonContainsSelectedPoint,G as computePolygonForInspection,P as createCoveragePolygon,R as limitZToGround,J as projectVertices,ee as resizePolygon,te as updateFrustum};
|
|
2
|
+
import{deg2rad as e}from"../../../core/mathUtils.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose as i}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{sub as a,add as o,length as s,dot as c}from"../../../core/libs/gl-matrix-2/math/vec3.js";import l from"../../../geometry/Circle.js";import u from"../../../geometry/Mesh.js";import d from"../../../geometry/Multipoint.js";import f from"../../../geometry/Polygon.js";import{projectAsync as p}from"../../../geometry/projectionUtils.js";import m from"../../../geometry/SpatialReference.js";import{polygonCentroidPoint as h}from"../../../geometry/support/centroid.js";import{earth as g}from"../../../geometry/support/Ellipsoid.js";import _ from"../../../geometry/support/MeshComponent.js";import{createSphere as v}from"../../../geometry/support/meshUtils.js";import y from"../../../geometry/support/MeshVertexAttributes.js";import{create as b,fromArray as x,intersectRay as S}from"../../../geometry/support/plane.js";import{isWebMercator as C}from"../../../geometry/support/spatialReferenceUtils.js";import{getMetersPerUnitOfSR as w}from"./utils.js";import{convertToSRUnits as T,getWebMercatorScalingFactor as E,createRotationMatrixFromHPR as D,transformMat3 as O,scaleAndAddWithFactor as k,scaleWithFactor as A,computeHFOVAndVFOV as j,projectiveTransform as M}from"../transformations/utils.js";const N=Math.PI/180;function P(e,t,n){let r=T(e,t.spatialReference);return r.cameraHeight=(t.z??r.cameraHeight)-n,e.isSpherical?te(r,t):F(r,t)}function F(e,t){let{horizontalFieldOfView:n,verticalFieldOfView:r,cameraHeading:i}=e,a=E(t.y,t.spatialReference),o=e.cameraPitch,s=e.cameraRoll??0,c=150;n>150&&(o=90,s=0,c=5);let l=Math.ceil(n/c),u=I(l,i,n),d=V(e)*a,p=new f({spatialReference:t?.spatialReference});p.imageID=e.objectId;let m=null;for(let i of u)m=ee(i,o,e.cameraHeight,t,d,a,r,n,l,p,s,e.nearDistance);return m.imageID=e.objectId,{polygon:p,frustum:m}}function I(e,t,n){let r=[];if(e%2==0)for(let i=0;i<e/2;i++)r.push(t-n/e*(i+.5),t+n/e*(i+.5));else{r.push(t);for(let i=1;i<e/2;i++)r.push(t-n/e*i,t+n/e*i)}return r.sort(),r}function ee(e,t,s,c,l,u,d,f,p,m,h=0,g=0){let _=i(n(),D([e,t,h??0])),v=re({cameraHeight:s,cameraPitch:t,farDistance:l,location:c,horizontalFieldOfView:f,nearDistance:g,verticalFieldOfView:d},_),y=O([0,0,-1],_),{x:b,y:x}=c,S=k([b,x,c.z??s],y,l,u),C=2*Math.tan(d*N/2)*l,w=2*Math.tan(f/p*N/2)*l,T=O([0,1,0],_),E=O([1,0,0],_),j=A(T,C/2,u),M=A(E,w/2,u),P=a(r(),j,M),F=o(r(),j,M),I=L([o(r(),S,P),o(r(),S,F),a(r(),S,P),a(r(),S,F)],s,c,u);return I.push(I[0]),m.addRing(I),v}function L(e,t,n,r){return e.map(e=>ie(e,t,n,r))}function te(e,t){let{farDistance:n,objectId:r,nearDistance:i,cameraHeight:a}=e,o=E(t.y,t.spatialReference),s=new l({center:t.clone(),radius:n*o});if(s.imageID=r,i){let e=new l({center:t.clone(),radius:i*o});s.addRing(e.rings[0])}let c=t.clone();c.z=(t.z??a)-n*o;let u=v(c,{size:2*n*o});return u.imageID=r,{polygon:s,frustum:u}}function ne(e,t){return e.contains(t)}function R({cameraHeading:e,cameraPitch:t,cameraRoll:r,farDistance:a,horizontalFieldOfView:o,nearDistance:s,vectorToPoint:l,verticalFieldOfView:u}){let d=i(n(),D([e,t,r])),f=O([1,0,0],d),p=O([0,1,0],d),m=O([0,0,-1],d),h=c(l,f),g=c(l,p),_=c(l,m);if(_<=0||_<s||_>a)return!1;let v=_*Math.tan(o*N/2),y=_*Math.tan(u*N/2);return Math.abs(h)<=v&&Math.abs(g)<=y}function z(e,t){let n=T(e,e.location.spatialReference);if(t.z==null)return!1;let{horizontalFieldOfView:r,location:i,nearDistance:a,verticalFieldOfView:o}=n,c=V(n);if(r==null||o==null||!Number.isFinite(a)||a<0||!Number.isFinite(c)||c<=0)return!1;let l=E(i.y,i.spatialReference),u=i.z??0,d=[(t.x-i.x)/l,(t.y-i.y)/l,t.z-u];if(n.isSpherical){let e=s(d);return a<=e&&e<=c}let f={vectorToPoint:d,verticalFieldOfView:o,nearDistance:a,farDistance:c};if(r>150){let e=Math.ceil(r/5),t=r/e;return I(e,n.cameraHeading,r).some(e=>R({...f,cameraHeading:e,cameraPitch:90,cameraRoll:0,horizontalFieldOfView:t}))}return R({...f,cameraHeading:n.cameraHeading,cameraPitch:n.cameraPitch,cameraRoll:n.cameraRoll??0,horizontalFieldOfView:r})}function B(e,t){return Math.sign(e)!==Math.sign(t)}function re(e,t,n){let{cameraHeight:i,cameraPitch:s,farDistance:c,location:l,horizontalFieldOfView:d,nearDistance:f,verticalFieldOfView:p}=e,m=l.z??i,h=m-i,g=H(l),_=!(s+p/2>=90),v=2*Math.tan(p*N/2)*f,b=2*Math.tan(d*N/2)*f,x=2*Math.tan(p*N/2)*c,S=2*Math.tan(d*N/2)*c,C,w=[0,0,-1];w=O(w,t),C=k([l.x,l.y,m],w,c,g),_&&(C[2]=h);let T=k([l.x,l.y,m],w,f,g),E=[0,1,0];E=O(E,t);let D=[1,0,0];D=O(D,t);let j=[],M=[];f?(M=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],j=j.concat(o(r(),T,a(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(o(r(),T,o(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(a(r(),T,a(r(),A(E,v/2,g),A(D,b/2,g)))),j=j.concat(a(r(),T,o(r(),A(E,v/2,g),A(D,b/2,g))))):(j=[l.x,l.y,m],M=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),j=j.concat(o(r(),C,a(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(o(r(),C,o(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(a(r(),C,a(r(),A(E,x/2,g),A(D,S/2,g)))),j=j.concat(a(r(),C,o(r(),A(E,x/2,g),A(D,S/2,g))));let P=new y({position:Float64Array.from(j)});return new u({vertexAttributes:P,components:M,spatialReference:l.spatialReference})}function ie(e,t,n,i){{let o=n.z??t,s=o-t,c=Math.sqrt((e[2]-o)**2+(Math.sqrt((e[0]-n.x)**2+(e[1]-n.y)**2)/i)**2)*i,l=A(a(r(),[e[0],e[1],e[2]],[n.x,n.y,o]),1/c,1/i),u=t/(o-e[2]),d={x:(1-u)*n.x+u*e[0],y:(1-u)*n.y+u*e[1],z:(1-u)*o+u*e[2]},f=Math.sqrt((d.z-o)**2+(Math.sqrt((d.x-n.x)**2+(d.y-n.y)**2)/i)**2)*i,p=A(a(r(),[d.x,d.y,d.z],[n.x,n.y,o]),1/f,1/i);return B(l[0],p[0])&&B(l[1],p[1])&&B(l[2],p[2])||e[2]>=s?[e[0],e[1],s]:[d.x,d.y,d.z]}}function ae(e){let{spatialReference:t,x:n,y:r}=e.geometry,{cameraHeading:i,cameraPitch:a,farDistance:o,nearDistance:s}=e,c=H(e.geometry),l=new f({spatialReference:t}),u=Math.abs(1.44*o*c),d=Math.abs(1.44*s*c);(a<20||i==null)&&(d=u);let p=[];return p[0]={x:n+u*Math.sin((i-45)*N),y:r+u*Math.cos((i-45)*N)},p[1]={x:n+u*Math.sin((i+45)*N),y:r+u*Math.cos((i+45)*N)},p[2]={x:n+d*Math.sin((i+135)*N),y:r+d*Math.cos((i+135)*N)},p[3]={x:n+d*Math.sin((i+225)*N),y:r+d*Math.cos((i+225)*N)},l.addRing([[p[0].x,p[0].y,0],[p[1].x,p[1].y,0],[p[2].x,p[2].y,0],[p[3].x,p[3].y,0],[p[0].x,p[0].y,0]]),l}function V(t){let{cameraHeight:n,cameraPitch:r,farDistance:i,location:a,verticalFieldOfView:o}=t;return i??(r+o/2>=90?20/w(a.spatialReference):n/Math.cos(e(r)))}function H(e){return e&&C(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/g.radius))):1}function U(e,t){let n=1+t/100;if(e.declaredClass===`esri.geometry.Circle`){let{radius:t,center:r}=e,i=t*n,a=new l({radius:i,center:r});return e.rings.length>1&&a.addRing(e.rings[1]),a}if(e.declaredClass===`esri.geometry.Polygon`){let t=new f({spatialReference:e.spatialReference}),i=h(e);if(i){let o=[];for(let t=0;t<e.rings[0].length;t++){let s=Math.sqrt((i.x-e.rings[0][t][0])**2+(i.y-e.rings[0][t][1])**2),c=A(a(r(),[e.rings[0][t][0],e.rings[0][t][1],0],[i.x,i.y,0]),1/s,1),l=k([i.x,i.y,0],c,s*n,1);o.push({x:l[0],y:l[1]})}t.addRing([[o[0].x,o[0].y,0],[o[1].x,o[1].y,0],[o[2].x,o[2].y,0],[o[3].x,o[3].y,0],[o[0].x,o[0].y,0]])}return t}return e}async function W(e,t,n){let{cameraHeight:r,cameraLocation:i,cameraPitch:a,frustumVertices:o,horizontalFieldOfView:s,imageHeight:c,imageWidth:l,inSRS:u,outSRS:d,verticalFieldOfView:f,cameraRoll:p,options:h}=n,g=new m(u),_=new m(d),v=j(s,f,p??0),y=o.length>15;return a+v.vfov/2>=90?await se(o,e,l,c,g,_,y,h):await G(o,e,t,i,r,y,g,_,h)}async function G(e,t,n,r,i,a,o,s,c){let l=K(e,t,n,r,i);if(!l)return;let{farPlane:d,nearPlane:f}=l,p=await J([...f?.vertexPositions??e.slice(0,3),...d.vertexPositions],o,s,c),m=$(p);return new u({vertexAttributes:new y({position:p}),components:Q(a?X(m,!0):Z(m,!0)),spatialReference:s})}function K(e,t,n,r,i){let a=Y(e),o=Y(e,`near`);if(!a)return;let s=t.length;for(let e=0;e<s;e++){let t=Array.from(n[e]),s=[t[0]-r[0],t[1]-r[1],t[2]-(r[2]??i)];oe(r,s,e,o),q(r,s,e,a)}return{farPlane:a,nearPlane:o}}function q(e,t,n,i){let{coefficients:a,vertexPositions:o}=i,s=r();S(a,{origin:e,direction:t},s)&&o.splice(n*3,3,...s)}function oe(e,t,n,i){if(!i)return;let a=r();S(i.coefficients,{origin:e,direction:t},a)&&i.vertexPositions.splice(n*3,3,...a)}async function se(e,t,n,r,i,a,o,s){let c=o?[]:[e[0],e[1],e[2]],l,d=[];for(let i of t)o?(l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[0],e[1],e[2]],[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]]]),c=c.concat(...l),l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[12],e[13],e[14]],[e[15],e[16],e[17]],[e[18],e[19],e[20]],[e[21],e[22],e[23]]]),d=d.concat(...l)):(l=M([i[0],i[1],1],[[0,0,1],[n,0,1],[n,r,1],[0,r,1]],[[e[3],e[4],e[5]],[e[6],e[7],e[8]],[e[9],e[10],e[11]],[e[12],e[13],e[14]]]),c=c.concat(...l));c=c.concat(d);let f=await J(c,i,a,s),p=$(f);return new u({vertexAttributes:new y({position:f}),components:Q(o?X(p,!0):Z(p,!0)),spatialReference:a})}async function J(e,n,r,i){if(n.equals(r))return e;let a=e.reduce((e,t,n)=>{let r=Math.floor(n/3);return e[r]||(e[r]=[]),e[r].push(t),e},[]),{points:o}=await p(new d({points:a,spatialReference:n}),r,i);return t(i),o.flat()}function Y(e,t=`far`){let n=b(),r;switch(t){case`far`:if(r=Array.from(e.length===15?e.slice(3):e.slice(12)),x(n,r,!1))return{coefficients:n,vertexPositions:r};break;case`near`:return r=Array.from(e.slice(0,12)),e.length===15||!x(n,r,!1)?void 0:{coefficients:n,vertexPositions:r}}}const X=(e,t=!1)=>{if(t&&e-2<=4||e<=4||e%2!=0)throw Error(`Invalid number of vertices`);let n=[],r=e/2,i=Math.round((t?e-2:e)/2);for(let a=0;a<i;a++){let i=a+r,o=t?i+1:i,s=o%e,c=(t?i:o+1)%e;n.push({faces:new Uint32Array([a,c,s,a,a+1,s])})}return n};function Z(e,t=!1){if(e<3||t&&e-1<3)throw Error(`Invalid number of vertices`);let n=[],r=t?e-2:e-1;for(let e=0;e<r;e++)n.push({faces:new Uint32Array([0,e+1,e+2])});return n}const Q=e=>e.map(e=>new _(e)),$=e=>e.length/3;export{z as checkIfFrustumContainsSelectedPoint,ne as checkIfPolygonContainsSelectedPoint,ae as computePolygonForInspection,P as createCoveragePolygon,L as limitZToGround,J as projectVertices,U as resizePolygon,W as updateFrustum};
|
|
@@ -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"../../../request.js";import n from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{debounce as a,onAbort as o}from"../../../core/promiseUtils.js";import{QueueProcessor as s}from"../../../core/QueueProcessor.js";import{property as c,subclass as l}from"../../../core/accessorSupport/decorators.js";import{ensureClass as u}from"../../../core/accessorSupport/ensureType.js";import d from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import p from"../../../geometry/SpatialReference.js";import{isFunctionRaster as m,getPixelSpaceCoverage as h}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as g,getSliceIndex as _,createSlices as v,getSliceIds as y}from"./multidimensionalUtils.js";import{clearRegisteredIds as b,getRasterId as x,getBlock as S,putBlock as C,deleteBlock as w,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as E}from"../formats/pixelRangeUtils.js";import{decode as D}from"../formats/RasterCodec.js";import{convertPixelSize as O}from"../functions/clipUtils.js";import{mosaic as k,approximateTransform as A,getLocalArithmeticNorthRotations as j,compositeBands as M}from"../functions/pixelUtils.js";import{getWorldWidth as N,load as P,projectPoint as F,snapPyramid as I,shiftExtent as L,getWorldWrapCount as R,projectExtent as z,getProjectionOffsetGrid as B,getRasterDatasetAlignmentInfo as V,projectResolution as H}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as U,uvComponentToVector as W}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as G}from"../../support/arcgisLayerUrl.js";import{url as K}from"../../support/commonProperties.js";import q from"../../support/DimensionalDefinition.js";import J from"../../support/LOD.js";import Y from"../../support/RasterStorageInfo.js";import X from"../../support/TileInfo.js";let Z=0,Q=class extends r{constructor(){super(...arguments),this._tileFetchQueue=new s({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:`closest`},this.rawBlockRegistryIds=[],this.refresh=a(async e=>{await this._openPromise;let t=await this._refresh(e);return t.dataChanged&&b(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:`closest`,tileInfo:X.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){let{rasterInfo:e}=this,t=N(e.spatialReference);return t!=null&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){let{transform:e}=this.rasterInfo;return e==null||e.type===`gcs-shift`}set rasterJobHandler(e){this._set(`rasterJobHandler`,e),m(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||`rasterId-${Z++}`}set url(e){this._set(`url`,G(e,i.getLogger(this)))}async open(e){return this._openPromise??=P().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,r,i={}){let a=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,r,a);if(!o)throw new n(`imagery-tile:out-of-bounds`,`Level for fetch tile out of range`);return i={noClip:!0,...i},this.fetchPixels(o,a.size[0],a.size[1],i)}async identify(e,t={}){e=u(f,e).clone().normalize();let{multidimensionalDefinition:n,timeExtent:r}=t,{rasterInfo:i}=this,{hasMultidimensionalTranspose:a,multidimensionalInfo:o}=i,{transposedVariableName:s}=t,c=o!=null&&a&&(r!=null||g(n));c&&!s&&(s=n!=null&&n.length>0?n[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:s}),t=this._getRequestOptionsWithSliceId(t);let{spatialReference:l,extent:p}=i,{datumTransformation:h}=t,_=F(e,l,h);if(!p.intersects(_))return{location:_,value:null};if(i.transform!=null){let e=i.transform.inverseTransform(_);if(!i.nativeExtent.intersects(e))return{location:e,value:null};_=e}let v=s!=null&&o!=null&&i.hasMultidimensionalTranspose;if(m(this)){let e=this.primaryRasters.rasters[0];if(v)return e.identify(_,t);let{pixelSize:r}=i,a=r.x*3/2,o=r.y*3/2,s=new d({xmin:_.x-a,xmax:_.x+a,ymin:_.y-o,ymax:_.y+o,spatialReference:l}),c={interpolation:`nearest`,multidimensionalDefinition:n,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(s,3,3,c),{pixelBlock:f}=await this.fetchPixels(s,3,3,c);if(u==null)return{location:_,value:null};let p=!u.mask||u.mask[4]?u.pixels.map(e=>e[4]):null,m;return f!=null&&(m=!f.mask||f.mask[4]?f.pixels.map(e=>e[4]):void 0),{location:_,value:p,processedValue:m,pyramidLevel:0}}let y=0;if(!v){let{srcResolution:n}=t;if(n)n.spatialReference&&(n=O(new f(n),l)),y=I(n,i,this.ioConfig.sampling).pyramidLevel;else if(y=await this.computeBestPyramidLevelForLocation(e,t),y==null)return{location:_,value:null}}let b=this.identifyPixelLocation(_,y,null,v);if(b===null)return{location:_,value:null};let{row:x,col:S,rowOffset:C,colOffset:w,blockWidth:T}=b,E=await this._fetchRawTile(y,x,S,t);if(!E?.pixels?.length)return{location:_,value:null};let D=C*T+w;return this._processIdentifyResult(E,{srcLocation:_,position:D,pyramidLevel:y,useTransposedTile:!!v,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,n,r={}){e=L(e),r=this._getRequestOptionsWithSliceId(r);let{_hasNoneOrGCSShiftTransform:i}=this;if(r.requestRawData&&i)return this._fetchPixels(e,t,n,r);let a=N(e.spatialReference),o=R(e);if(a==null||o===0||o===1&&this._isGlobalWrappableSource&&i)return this._fetchPixels(e,t,n,r);if(o>=3)return{extent:e,pixelBlock:null};let s=[],{xmin:c,xmax:l}=e,u=Math.round(a/(l-c)*t),f=u-Math.round((a/2-c)/(l-c)*t),p=0,m=[];for(let i=0;i<=o;i++){let h=i===0?c:-a/2,g=i===o?l-a*i:a/2,_=new d({xmin:h,xmax:g,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),v=i===0?u-f:i===o?t-p:u;p+=v,m.push(v);let y=r.disableWrapAround&&i>0?null:this._fetchPixels(_,v,n,r);s.push(y)}let h=(await Promise.all(s)).map(e=>e?.pixelBlock),g=null,_={width:t,height:n};g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:_,destDimension:null,coefs:null,sampleSpacing:null,interpolation:`nearest`,alignmentInfo:null,blockWidths:m},r)).pixelBlock:k(h,_,{blockWidths:m});let v=z(e,this.rasterInfo.spatialReference,r.datumTransformation);return{extent:e,srcExtent:v,pixelBlock:g}}async fetchRawPixels(e,t,n,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};let i=await this._fetchRawTiles(e,t,n,r),{nativeExtent:a,nativePixelSize:o,storageInfo:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,f=new d({xmin:a.xmin+l*t.x,xmax:a.xmin+l*(t.x+n.width-1),ymin:a.ymax-u*(t.y+n.height-1),ymax:a.ymax-u*t.y,spatialReference:a.spatialReference});if(!i)return{extent:f,srcExtent:f,pixelBlock:null};let{pixelBlocks:p,mosaicSize:m}=i;if(p.length===1&&p[0]!=null&&p[0].width===n.width&&p[0].height===n.height)return{extent:f,srcExtent:f,pixelBlock:i.pixelBlocks[0]};let h=e>0?s.pyramidBlockWidth:s.blockWidth,g=e>0?s.pyramidBlockHeight:s.blockHeight,_={x:t.x%h,y:t.y%g},v;return v=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:m,destDimension:n,clipOffset:_,clipSize:n,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock:k(p,m,{clipOffset:_,clipSize:n}),{extent:f,srcExtent:f,pixelBlock:v}}fetchRawTile(e,t,r,i){throw new n(`BaseRaster:read-not-implemented`,`fetchRawTile() is not implemented`)}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t}):D(e,t)}async request(e,n,r=0){let{customFetchParameters:i}=this.ioConfig,{range:a,query:o,headers:s}=n;r=r??n.retryCount??this.ioConfig.retryCount;let c=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...n,query:{...o,...i},headers:{...s,...c}})}catch(t){if(r>0)return r--,this.request(e,n,r);throw t}}getSliceIndex(e){let{multidimensionalInfo:t}=this.rasterInfo;return t==null||e==null||e.length===0?null:_(e,t)}getTileExtentFromTileInfo(e,t,n,r){let i=r.lodAt(e);return i?this.getTileExtent({x:i.resolution,y:i.resolution},t,n,r.origin,r.spatialReference,r.size):null}updateTileInfo(){let{storageInfo:e,spatialReference:t,extent:n,pixelSize:r}=this.rasterInfo,{pyramidResolutions:i}=e;if(!e.tileInfo){let a=[],o=e.maximumPyramidLevel||0,s=(r.x+r.y)/2,c=1/.0254*96*s;for(let e=0;e<=o&&(a.unshift(new J({level:o-e,resolution:s,scale:c})),e!==o);e++)if(i){let t=(i[e].x+i[e].y)/2;c*=t/s,s=t}else s*=2,c*=2;let l=new f({x:n.xmin,y:n.ymax,spatialReference:t});e.tileInfo=new X({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:a}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,n=512,r){let{width:i,height:a,nativeExtent:o,pixelSize:s,spatialReference:c}=e,l=new f({x:o.xmin,y:o.ymax,spatialReference:c});r??=Math.max(0,Math.round(Math.log(Math.max(i,a))/Math.LN2-8));let u=this.computeBlockBoundary(o,512,512,{x:o.xmin,y:o.ymax},[s],r);e.storageInfo=new Y({blockWidth:t,blockHeight:n,pyramidBlockWidth:t,pyramidBlockHeight:n,origin:l,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,n,r,i,a=0,o=2){if(i.length===1&&a>0){i=[...i];let{x:e,y:t}=i[0];for(let n=0;n<a;n++)e*=o,t*=o,i.push({x:e,y:t})}let s=[],{x:c,y:l}=r;for(let r=0;r<i.length;r++){let{x:a,y:o}=i[r];s.push({minCol:Math.floor((e.xmin-c+.1*a)/t/a),maxCol:Math.floor((e.xmax-c-.1*a)/t/a),minRow:Math.floor((l-e.ymax+.1*o)/n/o),maxRow:Math.floor((l-e.ymin-.1*o)/n/o)})}return s}getPyramidPixelSize(e){let{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:n,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(e===0)return t;if(n!=null&&n.length)return n[e-1];let i=r**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,n,r){let{spatialReference:i,nativeExtent:a,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:s,origin:c,transposeInfo:l}=o,u=r&&l!=null?l.tileSize[0]:o.blockWidth,d=r&&l!=null?l.tileSize[1]:o.blockHeight,f=F(e,i,n);if(!a.intersects(f)||t<0||t>s)return null;let{x:p,y:m}=this.getPyramidPixelSize(t),h=(c.y-f.y)/m/d,g=(f.x-c.x)/p/u,_=Math.min(d-1,Math.floor((h-Math.floor(h))*d)),v=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(g),rowOffset:_,colOffset:v,blockWidth:u,srcLocation:f}}getTileExtent(e,t,n,r,i,a){let[o,s]=a,c=r.x+n*o*e.x,l=c+o*e.x,u=r.y-t*s*e.y,f=u-s*e.y;return new d({xmin:c,xmax:l,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,n){let r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<n||r.minRow>t||r.minCol>n}updateImageSpaceRasterInfo(e){let{pixelSize:t}=e,{width:n,height:r}=e,i=p.WebMercator;e.spatialReference=i,e.extent=e.nativeExtent=new d({xmin:-.5,ymax:.5,xmax:n-.5,ymin:.5-r,spatialReference:i}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new f({x:1,y:1,spatialReference:i});let{extent:a,storageInfo:o}=e;if(o){o.origin=new f({x:a.xmin,y:a.ymax,spatialReference:i});let{pyramidResolutions:n,tileInfo:r}=o;if(n&&n.forEach(e=>{e.x/=t.x,e.y/=t.y}),r){r.origin=o.origin;let t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;r.lods.forEach((e,n)=>{e.resolution=t*2**n,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,n,r={}){let i=R(e);if(i>=2)return{extent:e,pixelBlock:null};let a=this._getSourceDataInfo(e,t,n,r),{pyramidLevel:o,srcResolution:s,srcWidth:c,srcHeight:l,ul:u}=a,{srcExtent:d}=a;if(c===0||l===0)return{extent:e,srcExtent:d,pixelBlock:null};let{rasterInfo:p}=this,m=p.transform,h=m?.type===`gcs-shift`,g=N(e.spatialReference)!=null;(h||!g)&&(i=R(d,h));let _=await this._fetchRawTiles(o,u,{width:c,height:l,wrapCount:i},r);if(!_)return{extent:e,srcExtent:d,pixelBlock:null};d=_.extent;let v=p.storageInfo,y=o>0?v.pyramidBlockWidth:v.blockWidth,b=o>0?v.pyramidBlockHeight:v.blockHeight,{x,y:S}=p.pixelSize;if(o>0){let{pyramidResolutions:e,pyramidScalingFactor:t}=v;if(e!=null&&e[o-1])({x,y:S}=e[o-1]);else{let e=t**o;x*=e,S*=e}}let C=p.spatialReference,w=new f({x,y:S,spatialReference:C}),T=y===c&&b===l&&u.x%y===0&&u.y%b===0,E=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),D=!e.spatialReference.equals(C),O=C.isGeographic?1e-9:1e-4,{datumTransformation:M}=r;if(!D&&T&&_.pixelBlocks.length===1&&y===t&&b===n&&$(s,E,O))return{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:_.pixelBlocks[0]};let F=g&&N(d.spatialReference)!=null&&this._hasNoneOrGCSShiftTransform,I=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith(`vector`);I&&!this.rasterJobHandler&&await P();let L=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:d,pixelSize:E.toJSON(),datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:this.ioConfig.optimizeProjectionAccuracy!==!1,includeGCSGrid:I},r):B({projectedExtent:e,srcBufferExtent:d,pixelSize:E,datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:!1,includeGCSGrid:I}),z,V=!r.requestRawData,H={rows:L.spacing[0],cols:L.spacing[1]},W=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,d.xmin):void 0,{pixelBlocks:G,mosaicSize:K,isPartiallyFilled:q}=_,J=null;if(this.rasterJobHandler){let e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:G,srcMosaicSize:K,destDimension:V?{width:t,height:n}:null,coefs:V?L.coefficients:null,sampleSpacing:V?H:null,projectDirections:I,gcsGrid:I?L.gcsGrid:null,isUV:this.rasterInfo.dataType===`vector-uv`,interpolation:r.interpolation,alignmentInfo:W,blockWidths:null},r);({pixelBlock:z,localNorthDirections:J}=e)}else{let e=k(G,K,{alignmentInfo:W});z=V?A(e,{width:t,height:n},L.coefficients,H,r.interpolation):e,I&&L.gcsGrid&&(J=j({width:t,height:n},L.gcsGrid),z=U(z,this.rasterInfo.dataType,J))}return r.requestRawData||I?{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:z,transformGrid:L,localNorthDirections:J,isPartiallyFilled:q}:{extent:e,srcExtent:e,srcTilePixelSize:w,pixelBlock:z}}async _fetchRawTiles(e,t,n,r){let{origin:i,blockBoundary:a}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:s}=this.getBlockWidthHeight(e),{x:c,y:l}=t,{width:u,height:f,wrapCount:p}=n,m=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(c-=r.buffer.cols,l-=r.buffer.rows,u+=r.buffer.cols*2,f+=r.buffer.rows*2);let h=0,g=0,_=0;p&&m!=null&&({worldColumnCountFromOrigin:g,originColumnOffset:_,rightPadding:h}=m,g*m.blockWidth-h>=c+u&&(h=0));let v=Math.floor(c/o),y=Math.floor(l/s),b=Math.floor((c+u+h-1)/o),x=Math.floor((l+f+h-1)/s),S=a[e];if(!S)return null;let{minRow:C,minCol:w,maxCol:T,maxRow:E}=S;if(p===0&&(x<C||b<w||y>E||v>T))return null;let D=[],O=!1,k=this.ioConfig.allowPartialFill==null?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=y;t<=x;t++)for(let n=v;n<=b;n++){let i=n;if(!r.disableWrapAround&&p&&m!=null&&g<=n&&(i=n-g-_),t>=C&&i>=w&&E>=t&&T>=i){let n=this._fetchRawTile(e,t,i,r);k?D.push(new Promise(e=>{n.then(t=>e(t)).catch(()=>{O=!0,e(null)})})):D.push(n)}else D.push(Promise.resolve(null))}if(D.length===0)return null;let A=await Promise.all(D),j={height:(x-y+1)*s,width:(b-v+1)*o},{spatialReference:M}=this.rasterInfo,{x:N,y:P}=this.getPyramidPixelSize(e);return{extent:new d({xmin:i.x+v*o*N,xmax:i.x+(b+1)*o*N,ymin:i.y-(x+1)*s*P,ymax:i.y-y*s*P,spatialReference:M}),pixelBlocks:A,mosaicSize:j,isPartiallyFilled:O}}_fetchRawTile(e,t,n,r){let{storageInfo:i}=this.rasterInfo,a=i.transposeInfo!=null&&!!r.transposedVariableName;if(!a){let r=i.blockBoundary[e];if(!r)return Promise.resolve(null);let{minRow:a,minCol:o,maxCol:s,maxRow:c}=r;if(t<a||n<o||t>c||n>s)return Promise.resolve(null)}let s=a?r.transposeVariableName:r.sliceId,c=i.isBsqTile?r.bandIds:null,l=x(this.rasterId,s,c),u=`${e}/${t}/${n}`,d=S(l,r.registryId,u);if(d==null){let a=new AbortController,o=r.bandIds?.slice();if(o?.length&&i.isBsqTile){let i=new Set(o),s=[],c=Array.from(i);for(let i of c)s.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:{...r,bandIds:[i]}},{signal:a.signal}));d=Promise.all(s).then(e=>{if(e.some(e=>e==null))return null;if(c.length!==o.length){let t=[];for(let n of o){let r=e[c.indexOf(n)];t.includes(r)&&(r=r.clone()),t.push(r)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:a.signal,transferPixelsToWorker:!0}):M(e)})}else d=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:r},{signal:a.signal});C(l,r.registryId,u,d,a),d.catch(()=>w(l,r.registryId,u))}return r.signal&&o(r,()=>{T(l,r.registryId,u)}),d}_computeMagDirValues(e){let{bandCount:t,dataType:n}=this.rasterInfo;if(!(t===2&&n===`vector-magdir`||n===`vector-uv`)||e?.length!==2||!e[0]?.length)return null;let r=e[0].length;if(n===`vector-magdir`){let t=e[1].map(e=>(e+360)%360);return[e[0],t]}let[i,a]=e,o=[],s=[];for(let e=0;e<r;e++){let[t,n]=W([i[e],a[e]]);o.push(t),s.push(n)}return[o,s]}_getRasterTileAlignmentInfo(e,t){return this._rasterTileAlignmentInfo??=V(this.rasterInfo),this._rasterTileAlignmentInfo.pyramidsInfo==null?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,n,r={}){let i={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(i.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,i));let a=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:s,pyramidLevel:c}=i,l=o/t,u=s/n,d=c<a&&l*u>=16,p=c===a&&this._requireTooManySrcTiles(o,s,t,n);if(d||p||o===0||s===0){let o=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),s=H(o,this.rasterInfo.spatialReference,e,i.datumTransformation),p=!s||r.srcResolution&&s.x+s.y<r.srcResolution.x+r.srcResolution.y;if(d&&r.srcResolution&&p){let e=Math.round(Math.log(Math.max(l,u))/Math.LN2)-1;if(a-c+3>=e){let t=2**e;s={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}s&&(i.srcResolution=s,this._updateSourceDataInfo(e,i))}return this._requireTooManySrcTiles(i.srcWidth,i.srcHeight,t,n)&&(i.srcWidth=0,i.srcHeight=0),i}_requireTooManySrcTiles(e,t,n,r){let{tileInfo:i}=this.rasterInfo.storageInfo,a=Math.ceil(e/i.size[0])*Math.ceil(t/i.size[1]),o=e/n,s=t/r;return a>=256*Math.max(1,(n+r)/1024)||o>8||s>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;let{rasterInfo:n}=this,r=n.spatialReference,{srcResolution:i,datumTransformation:a}=t,{pyramidLevel:o,pyramidResolution:s,excessiveReading:c}=I(i,n,this.ioConfig.sampling);if(c)return;let l=t.srcExtent||z(e,r,a);if(l==null)return;let u=n.transform;u&&(l=u.inverseTransform(l)),t.srcExtent=l;let{origin:d}=n.storageInfo,{width:f,height:p,ul:m}=h(l,d,s,o);t.pyramidLevel=o,t.pyramidResolution=s,t.srcWidth=f,t.srcHeight=p,t.ul=m}_getRequestOptionsWithSliceId(e){return this.rasterInfo.multidimensionalInfo!=null&&e.sliceId==null&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){let{srcLocation:n,position:r,pyramidLevel:i,useTransposedTile:a}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[r])return{location:n,value:null};let{multidimensionalInfo:s}=this.rasterInfo;if(s==null||!a){let t=e.pixels.map(e=>e[r]),a={location:n,value:t,pyramidLevel:i},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(a.magdirValue=o.map(e=>e[0])),a}let c=e.pixels.map(e=>e.slice(r*o,r*o+o)),l=this._computeMagDirValues(c),{requestSomeSlices:u,identifyOptions:d}=t,f=v(s,d.transposedVariableName);if(u){let e=y(f,d.multidimensionalDefinition,d.timeExtent);c=c.map(t=>e.map(e=>t[e])),l=l?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}let p=e.noDataValues||this.rasterInfo.noDataValue,m={pixels:c,pixelType:e.pixelType},h;return p!=null&&(E(m,p),h=m.mask),{location:n,value:null,dataSeries:f.map((e,t)=>{let n={value:h?.[t]===0?null:c.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new q({...e,isSlice:!0}))};return l?.length&&(n.magdirValue=[l[0][t],l[1][t]]),n}),pyramidLevel:i}}};e([c()],Q.prototype,`_rasterTileAlignmentInfo`,void 0),e([c()],Q.prototype,`_tileFetchQueue`,void 0),e([c({readOnly:!0})],Q.prototype,`_isGlobalWrappableSource`,null),e([c({readOnly:!0})],Q.prototype,`_hasNoneOrGCSShiftTransform`,null),e([c()],Q.prototype,`_openPromise`,void 0),e([c()],Q.prototype,`rasterJobHandler`,null),e([c({readOnly:!0})],Q.prototype,`rasterId`,null),e([c(K)],Q.prototype,`url`,null),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetName`,void 0),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetFormat`,void 0),e([c()],Q.prototype,`hasUniqueSourceStorageInfo`,void 0),e([c()],Q.prototype,`rasterInfo`,void 0),e([c()],Q.prototype,`ioConfig`,void 0),e([c()],Q.prototype,`sourceJSON`,void 0),e([c()],Q.prototype,`rawBlockRegistryIds`,void 0),Q=e([l(`esri.layers.raster.datasets.BaseRaster`)],Q);function $(e,t,n){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}export{Q as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../request.js";import n from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{debounce as a,onAbort as o}from"../../../core/promiseUtils.js";import{QueueProcessor as s}from"../../../core/QueueProcessor.js";import{property as c,subclass as l}from"../../../core/accessorSupport/decorators.js";import{ensureClass as u}from"../../../core/accessorSupport/ensureType.js";import d from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import p from"../../../geometry/SpatialReference.js";import{isFunctionRaster as m,getPixelSpaceCoverage as h}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as g,getSliceIndex as _,createSlices as v,getSliceIds as y}from"./multidimensionalUtils.js";import{clearRegisteredIds as b,getRasterId as x,getBlock as S,putBlock as C,deleteBlock as w,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as E}from"../formats/pixelRangeUtils.js";import{decode as D}from"../formats/RasterCodec.js";import{convertPixelSize as O}from"../functions/clipUtils.js";import{mosaic as k,approximateTransform as A,getLocalArithmeticNorthRotations as j,compositeBands as M}from"../functions/pixelUtils.js";import{getWorldWidth as N,load as P,projectPoint as F,snapPyramid as I,shiftExtent as L,getWorldWrapCount as R,projectExtent as z,getProjectionOffsetGrid as B,getRasterDatasetAlignmentInfo as V,projectResolution as H}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as U,uvComponentToVector as W}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as G}from"../../support/arcgisLayerUrl.js";import{url as K}from"../../support/commonProperties.js";import q from"../../support/DimensionalDefinition.js";import J from"../../support/LOD.js";import Y from"../../support/RasterStorageInfo.js";import X from"../../support/TileInfo.js";let Z=0,Q=class extends r{constructor(){super(...arguments),this._tileFetchQueue=new s({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:`closest`},this.rawBlockRegistryIds=[],this.refresh=a(async e=>{await this._openPromise;let t=await this._refresh(e);return t.dataChanged&&b(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:`closest`,tileInfo:X.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){let{rasterInfo:e}=this,t=N(e.spatialReference);return t!=null&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){let{transform:e}=this.rasterInfo;return e==null||e.type===`gcs-shift`}set rasterJobHandler(e){this._set(`rasterJobHandler`,e),m(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||`rasterId-${Z++}`}set url(e){this._set(`url`,G(e,i.getLogger(this)))}async open(e){return this._openPromise??=P().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,r,i={}){let a=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,r,a);if(!o)throw new n(`imagery-tile:out-of-bounds`,`Level for fetch tile out of range`);return i={noClip:!0,...i},this.fetchPixels(o,a.size[0],a.size[1],i)}async identify(e,t={}){e=u(f,e).clone().normalize();let{multidimensionalDefinition:n,timeExtent:r}=t,{rasterInfo:i}=this,{hasMultidimensionalTranspose:a,multidimensionalInfo:o}=i,{transposedVariableName:s}=t,c=o!=null&&a&&(r!=null||g(n));c&&!s&&(s=n!=null&&n.length>0?n[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:s}),t=this._getRequestOptionsWithSliceId(t);let{spatialReference:l,extent:p}=i,{datumTransformation:h}=t,_=F(e,l,h);if(!p.intersects(_))return{location:_,value:null};if(i.transform!=null){let e=i.transform.inverseTransform(_);if(!i.nativeExtent.intersects(e))return{location:e,value:null};_=e}let v=s!=null&&o!=null&&i.hasMultidimensionalTranspose;if(m(this)){let e=this.primaryRasters.rasters[0];if(v)return e.identify(_,t);let{pixelSize:r}=i,a=r.x*3/2,o=r.y*3/2,s=new d({xmin:_.x-a,xmax:_.x+a,ymin:_.y-o,ymax:_.y+o,spatialReference:l}),c={interpolation:`nearest`,multidimensionalDefinition:n,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(s,3,3,c),{pixelBlock:f}=await this.fetchPixels(s,3,3,c);if(u==null)return{location:_,value:null};let p=!u.mask||u.mask[4]?u.pixels.map(e=>e[4]):null,m;return f!=null&&(m=!f.mask||f.mask[4]?f.pixels.map(e=>e[4]):void 0),{location:_,value:p,processedValue:m,pyramidLevel:0}}let y=0;if(!v){let{srcResolution:n}=t;if(n)n.spatialReference&&(n=O(new f(n),l)),y=I(n,i,this.ioConfig.sampling).pyramidLevel;else if(y=await this.computeBestPyramidLevelForLocation(e,t),y==null)return{location:_,value:null}}let b=this.identifyPixelLocation(_,y,null,v);if(b===null)return{location:_,value:null};let{row:x,col:S,rowOffset:C,colOffset:w,blockWidth:T}=b,E=await this._fetchRawTile(y,x,S,t);if(!E?.pixels?.length)return{location:_,value:null};let D=C*T+w;return this._processIdentifyResult(E,{srcLocation:_,position:D,pyramidLevel:y,useTransposedTile:!!v,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,n,r={}){e=L(e),r=this._getRequestOptionsWithSliceId(r);let{_hasNoneOrGCSShiftTransform:i}=this;if(r.requestRawData&&i)return this._fetchPixels(e,t,n,r);let a=N(e.spatialReference),o=R(e);if(a==null||o===0||o===1&&this._isGlobalWrappableSource&&i)return this._fetchPixels(e,t,n,r);if(o>=3)return{extent:e,pixelBlock:null};let s=[],{xmin:c,xmax:l}=e,u=Math.round(a/(l-c)*t),f=u-Math.round((a/2-c)/(l-c)*t),p=0,m=[];for(let i=0;i<=o;i++){let h=i===0?c:-a/2,g=i===o?l-a*i:a/2,_=new d({xmin:h,xmax:g,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),v=i===0?u-f:i===o?t-p:u;p+=v,m.push(v);let y=r.disableWrapAround&&i>0?null:this._fetchPixels(_,v,n,r);s.push(y)}let h=(await Promise.all(s)).map(e=>e?.pixelBlock),g=null,_={width:t,height:n};g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:_,destDimension:null,coefs:null,sampleSpacing:null,interpolation:`nearest`,alignmentInfo:null,blockWidths:m},r)).pixelBlock:k(h,_,{blockWidths:m});let v=z(e,this.rasterInfo.spatialReference,r.datumTransformation);return{extent:e,srcExtent:v,pixelBlock:g}}async fetchRawPixels(e,t,n,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};let i=await this._fetchRawTiles(e,t,n,r),{nativeExtent:a,nativePixelSize:o,storageInfo:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,f=new d({xmin:a.xmin+l*t.x,xmax:a.xmin+l*(t.x+n.width-1),ymin:a.ymax-u*(t.y+n.height-1),ymax:a.ymax-u*t.y,spatialReference:a.spatialReference});if(!i)return{extent:f,srcExtent:f,pixelBlock:null};let{pixelBlocks:p,mosaicSize:m}=i;if(p.length===1&&p[0]!=null&&p[0].width===n.width&&p[0].height===n.height)return{extent:f,srcExtent:f,pixelBlock:i.pixelBlocks[0]};let h=e>0?s.pyramidBlockWidth:s.blockWidth,g=e>0?s.pyramidBlockHeight:s.blockHeight,_={x:t.x%h,y:t.y%g},v;return v=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:m,destDimension:n,clipOffset:_,clipSize:n,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock:k(p,m,{clipOffset:_,clipSize:n}),{extent:f,srcExtent:f,pixelBlock:v}}fetchRawTile(e,t,r,i){throw new n(`BaseRaster:read-not-implemented`,`fetchRawTile() is not implemented`)}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t,n){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t},n):D(e,t,n)}async request(e,n,r=0){let{customFetchParameters:i}=this.ioConfig,{range:a,query:o,headers:s}=n;r=r??n.retryCount??this.ioConfig.retryCount;let c=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...n,query:{...o,...i},headers:{...s,...c}})}catch(t){if(r>0)return r--,this.request(e,n,r);throw t}}getSliceIndex(e){let{multidimensionalInfo:t}=this.rasterInfo;return t==null||e==null||e.length===0?null:_(e,t)}getTileExtentFromTileInfo(e,t,n,r){let i=r.lodAt(e);return i?this.getTileExtent({x:i.resolution,y:i.resolution},t,n,r.origin,r.spatialReference,r.size):null}updateTileInfo(){let{storageInfo:e,spatialReference:t,extent:n,pixelSize:r}=this.rasterInfo,{pyramidResolutions:i}=e;if(!e.tileInfo){let a=[],o=e.maximumPyramidLevel||0,s=(r.x+r.y)/2,c=1/.0254*96*s;for(let e=0;e<=o&&(a.unshift(new J({level:o-e,resolution:s,scale:c})),e!==o);e++)if(i){let t=(i[e].x+i[e].y)/2;c*=t/s,s=t}else s*=2,c*=2;let l=new f({x:n.xmin,y:n.ymax,spatialReference:t});e.tileInfo=new X({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:a}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,n=512,r){let{width:i,height:a,nativeExtent:o,pixelSize:s,spatialReference:c}=e,l=new f({x:o.xmin,y:o.ymax,spatialReference:c});r??=Math.max(0,Math.round(Math.log(Math.max(i,a))/Math.LN2-8));let u=this.computeBlockBoundary(o,512,512,{x:o.xmin,y:o.ymax},[s],r);e.storageInfo=new Y({blockWidth:t,blockHeight:n,pyramidBlockWidth:t,pyramidBlockHeight:n,origin:l,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,n,r,i,a=0,o=2){if(i.length===1&&a>0){i=[...i];let{x:e,y:t}=i[0];for(let n=0;n<a;n++)e*=o,t*=o,i.push({x:e,y:t})}let s=[],{x:c,y:l}=r;for(let r=0;r<i.length;r++){let{x:a,y:o}=i[r];s.push({minCol:Math.floor((e.xmin-c+.1*a)/t/a),maxCol:Math.floor((e.xmax-c-.1*a)/t/a),minRow:Math.floor((l-e.ymax+.1*o)/n/o),maxRow:Math.floor((l-e.ymin-.1*o)/n/o)})}return s}getPyramidPixelSize(e){let{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:n,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(e===0)return t;if(n!=null&&n.length)return n[e-1];let i=r**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,n,r){let{spatialReference:i,nativeExtent:a,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:s,origin:c,transposeInfo:l}=o,u=r&&l!=null?l.tileSize[0]:o.blockWidth,d=r&&l!=null?l.tileSize[1]:o.blockHeight,f=F(e,i,n);if(!a.intersects(f)||t<0||t>s)return null;let{x:p,y:m}=this.getPyramidPixelSize(t),h=(c.y-f.y)/m/d,g=(f.x-c.x)/p/u,_=Math.min(d-1,Math.floor((h-Math.floor(h))*d)),v=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(g),rowOffset:_,colOffset:v,blockWidth:u,srcLocation:f}}getTileExtent(e,t,n,r,i,a){let[o,s]=a,c=r.x+n*o*e.x,l=c+o*e.x,u=r.y-t*s*e.y,f=u-s*e.y;return new d({xmin:c,xmax:l,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,n){let r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<n||r.minRow>t||r.minCol>n}updateImageSpaceRasterInfo(e){let{pixelSize:t}=e,{width:n,height:r}=e,i=p.WebMercator;e.spatialReference=i,e.extent=e.nativeExtent=new d({xmin:-.5,ymax:.5,xmax:n-.5,ymin:.5-r,spatialReference:i}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new f({x:1,y:1,spatialReference:i});let{extent:a,storageInfo:o}=e;if(o){o.origin=new f({x:a.xmin,y:a.ymax,spatialReference:i});let{pyramidResolutions:n,tileInfo:r}=o;if(n&&n.forEach(e=>{e.x/=t.x,e.y/=t.y}),r){r.origin=o.origin;let t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;r.lods.forEach((e,n)=>{e.resolution=t*2**n,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,n,r={}){let i=R(e);if(i>=2)return{extent:e,pixelBlock:null};let a=this._getSourceDataInfo(e,t,n,r),{pyramidLevel:o,srcResolution:s,srcWidth:c,srcHeight:l,ul:u}=a,{srcExtent:d}=a;if(c===0||l===0)return{extent:e,srcExtent:d,pixelBlock:null};let{rasterInfo:p}=this,m=p.transform,h=m?.type===`gcs-shift`,g=N(e.spatialReference)!=null;(h||!g)&&(i=R(d,h));let _=await this._fetchRawTiles(o,u,{width:c,height:l,wrapCount:i},r);if(!_)return{extent:e,srcExtent:d,pixelBlock:null};d=_.extent;let v=p.storageInfo,y=o>0?v.pyramidBlockWidth:v.blockWidth,b=o>0?v.pyramidBlockHeight:v.blockHeight,{x,y:S}=p.pixelSize;if(o>0){let{pyramidResolutions:e,pyramidScalingFactor:t}=v;if(e!=null&&e[o-1])({x,y:S}=e[o-1]);else{let e=t**o;x*=e,S*=e}}let C=p.spatialReference,w=new f({x,y:S,spatialReference:C}),T=y===c&&b===l&&u.x%y===0&&u.y%b===0,E=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),D=!e.spatialReference.equals(C),O=C.isGeographic?1e-9:1e-4,{datumTransformation:M}=r;if(!D&&T&&_.pixelBlocks.length===1&&y===t&&b===n&&$(s,E,O))return{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:_.pixelBlocks[0]};let F=g&&N(d.spatialReference)!=null&&this._hasNoneOrGCSShiftTransform,I=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith(`vector`);I&&!this.rasterJobHandler&&await P();let L=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:d,pixelSize:E.toJSON(),datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:this.ioConfig.optimizeProjectionAccuracy!==!1,includeGCSGrid:I},r):B({projectedExtent:e,srcBufferExtent:d,pixelSize:E,datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:!1,includeGCSGrid:I}),z,V=!r.requestRawData,H={rows:L.spacing[0],cols:L.spacing[1]},W=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,d.xmin):void 0,{pixelBlocks:G,mosaicSize:K,isPartiallyFilled:q}=_,J=null;if(this.rasterJobHandler){let e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:G,srcMosaicSize:K,destDimension:V?{width:t,height:n}:null,coefs:V?L.coefficients:null,sampleSpacing:V?H:null,projectDirections:I,gcsGrid:I?L.gcsGrid:null,isUV:this.rasterInfo.dataType===`vector-uv`,interpolation:r.interpolation,alignmentInfo:W,blockWidths:null},r);({pixelBlock:z,localNorthDirections:J}=e)}else{let e=k(G,K,{alignmentInfo:W});z=V?A(e,{width:t,height:n},L.coefficients,H,r.interpolation):e,I&&L.gcsGrid&&(J=j({width:t,height:n},L.gcsGrid),z=U(z,this.rasterInfo.dataType,J))}return r.requestRawData||I?{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:z,transformGrid:L,localNorthDirections:J,isPartiallyFilled:q}:{extent:e,srcExtent:e,srcTilePixelSize:w,pixelBlock:z}}async _fetchRawTiles(e,t,n,r){let{origin:i,blockBoundary:a}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:s}=this.getBlockWidthHeight(e),{x:c,y:l}=t,{width:u,height:f,wrapCount:p}=n,m=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(c-=r.buffer.cols,l-=r.buffer.rows,u+=r.buffer.cols*2,f+=r.buffer.rows*2);let h=0,g=0,_=0;p&&m!=null&&({worldColumnCountFromOrigin:g,originColumnOffset:_,rightPadding:h}=m,g*m.blockWidth-h>=c+u&&(h=0));let v=Math.floor(c/o),y=Math.floor(l/s),b=Math.floor((c+u+h-1)/o),x=Math.floor((l+f+h-1)/s),S=a[e];if(!S)return null;let{minRow:C,minCol:w,maxCol:T,maxRow:E}=S;if(p===0&&(x<C||b<w||y>E||v>T))return null;let D=[],O=!1,k=this.ioConfig.allowPartialFill==null?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=y;t<=x;t++)for(let n=v;n<=b;n++){let i=n;if(!r.disableWrapAround&&p&&m!=null&&g<=n&&(i=n-g-_),t>=C&&i>=w&&E>=t&&T>=i){let n=this._fetchRawTile(e,t,i,r);k?D.push(new Promise(e=>{n.then(t=>e(t)).catch(()=>{O=!0,e(null)})})):D.push(n)}else D.push(Promise.resolve(null))}if(D.length===0)return null;let A=await Promise.all(D),j={height:(x-y+1)*s,width:(b-v+1)*o},{spatialReference:M}=this.rasterInfo,{x:N,y:P}=this.getPyramidPixelSize(e);return{extent:new d({xmin:i.x+v*o*N,xmax:i.x+(b+1)*o*N,ymin:i.y-(x+1)*s*P,ymax:i.y-y*s*P,spatialReference:M}),pixelBlocks:A,mosaicSize:j,isPartiallyFilled:O}}_fetchRawTile(e,t,n,r){let{storageInfo:i}=this.rasterInfo,a=i.transposeInfo!=null&&!!r.transposedVariableName;if(!a){let r=i.blockBoundary[e];if(!r)return Promise.resolve(null);let{minRow:a,minCol:o,maxCol:s,maxRow:c}=r;if(t<a||n<o||t>c||n>s)return Promise.resolve(null)}let s=a?r.transposeVariableName:r.sliceId,c=i.isBsqTile?r.bandIds:null,l=x(this.rasterId,s,c),u=`${e}/${t}/${n}`,d=S(l,r.registryId,u);if(d==null){let a=new AbortController,o=r.bandIds?.slice();if(o?.length&&i.isBsqTile){let i=new Set(o),s=[],c=Array.from(i);for(let i of c)s.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:{...r,bandIds:[i]}},{signal:a.signal}));d=Promise.all(s).then(e=>{if(e.some(e=>e==null))return null;if(c.length!==o.length){let t=[];for(let n of o){let r=e[c.indexOf(n)];t.includes(r)&&(r=r.clone()),t.push(r)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:a.signal,transferPixelsToWorker:!0}):M(e)})}else d=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:r},{signal:a.signal});C(l,r.registryId,u,d,a),d.catch(()=>w(l,r.registryId,u))}return r.signal&&o(r,()=>{T(l,r.registryId,u)}),d}_computeMagDirValues(e){let{bandCount:t,dataType:n}=this.rasterInfo;if(!(t===2&&n===`vector-magdir`||n===`vector-uv`)||e?.length!==2||!e[0]?.length)return null;let r=e[0].length;if(n===`vector-magdir`){let t=e[1].map(e=>(e+360)%360);return[e[0],t]}let[i,a]=e,o=[],s=[];for(let e=0;e<r;e++){let[t,n]=W([i[e],a[e]]);o.push(t),s.push(n)}return[o,s]}_getRasterTileAlignmentInfo(e,t){return this._rasterTileAlignmentInfo??=V(this.rasterInfo),this._rasterTileAlignmentInfo.pyramidsInfo==null?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,n,r={}){let i={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(i.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,i));let a=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:s,pyramidLevel:c}=i,l=o/t,u=s/n,d=c<a&&l*u>=16,p=c===a&&this._requireTooManySrcTiles(o,s,t,n);if(d||p||o===0||s===0){let o=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),s=H(o,this.rasterInfo.spatialReference,e,i.datumTransformation),p=!s||r.srcResolution&&s.x+s.y<r.srcResolution.x+r.srcResolution.y;if(d&&r.srcResolution&&p){let e=Math.round(Math.log(Math.max(l,u))/Math.LN2)-1;if(a-c+3>=e){let t=2**e;s={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}s&&(i.srcResolution=s,this._updateSourceDataInfo(e,i))}return this._requireTooManySrcTiles(i.srcWidth,i.srcHeight,t,n)&&(i.srcWidth=0,i.srcHeight=0),i}_requireTooManySrcTiles(e,t,n,r){let{tileInfo:i}=this.rasterInfo.storageInfo,a=Math.ceil(e/i.size[0])*Math.ceil(t/i.size[1]),o=e/n,s=t/r;return a>=256*Math.max(1,(n+r)/1024)||o>8||s>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;let{rasterInfo:n}=this,r=n.spatialReference,{srcResolution:i,datumTransformation:a}=t,{pyramidLevel:o,pyramidResolution:s,excessiveReading:c}=I(i,n,this.ioConfig.sampling);if(c)return;let l=t.srcExtent||z(e,r,a);if(l==null)return;let u=n.transform;u&&(l=u.inverseTransform(l)),t.srcExtent=l;let{origin:d}=n.storageInfo,{width:f,height:p,ul:m}=h(l,d,s,o);t.pyramidLevel=o,t.pyramidResolution=s,t.srcWidth=f,t.srcHeight=p,t.ul=m}_getRequestOptionsWithSliceId(e){return this.rasterInfo.multidimensionalInfo!=null&&e.sliceId==null&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){let{srcLocation:n,position:r,pyramidLevel:i,useTransposedTile:a}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[r])return{location:n,value:null};let{multidimensionalInfo:s}=this.rasterInfo;if(s==null||!a){let t=e.pixels.map(e=>e[r]),a={location:n,value:t,pyramidLevel:i},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(a.magdirValue=o.map(e=>e[0])),a}let c=e.pixels.map(e=>e.slice(r*o,r*o+o)),l=this._computeMagDirValues(c),{requestSomeSlices:u,identifyOptions:d}=t,f=v(s,d.transposedVariableName);if(u){let e=y(f,d.multidimensionalDefinition,d.timeExtent);c=c.map(t=>e.map(e=>t[e])),l=l?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}let p=e.noDataValues||this.rasterInfo.noDataValue,m={pixels:c,pixelType:e.pixelType},h;return p!=null&&(E(m,p),h=m.mask),{location:n,value:null,dataSeries:f.map((e,t)=>{let n={value:h?.[t]===0?null:c.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new q({...e,isSlice:!0}))};return l?.length&&(n.magdirValue=[l[0][t],l[1][t]]),n}),pyramidLevel:i}}};e([c()],Q.prototype,`_rasterTileAlignmentInfo`,void 0),e([c()],Q.prototype,`_tileFetchQueue`,void 0),e([c({readOnly:!0})],Q.prototype,`_isGlobalWrappableSource`,null),e([c({readOnly:!0})],Q.prototype,`_hasNoneOrGCSShiftTransform`,null),e([c()],Q.prototype,`_openPromise`,void 0),e([c()],Q.prototype,`rasterJobHandler`,null),e([c({readOnly:!0})],Q.prototype,`rasterId`,null),e([c(K)],Q.prototype,`url`,null),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetName`,void 0),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetFormat`,void 0),e([c()],Q.prototype,`hasUniqueSourceStorageInfo`,void 0),e([c()],Q.prototype,`rasterInfo`,void 0),e([c()],Q.prototype,`ioConfig`,void 0),e([c()],Q.prototype,`sourceJSON`,void 0),e([c()],Q.prototype,`rawBlockRegistryIds`,void 0),Q=e([l(`esri.layers.raster.datasets.BaseRaster`)],Q);function $(e,t,n){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}export{Q as default};
|
|
@@ -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/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.neatlineExtent,this._extent=r,this._ctm=this.frame.ctm,this._neatlineRing=this.frame.sourceMediaBoxPolygon.rings[0];let i=f(this.frame.ctm,this._extent);this._width=i[0],this._height=i[1];let a={x:r.width/this._width,y:r.height/this._height},o=new c({width:this._width,height:this._height,pixelType:`u8`,extent:r,pixelSize:a,spatialReference:r.spatialReference,bandCount:3,keyProperties:{DataType:`Processed`}});this.createRemoteDatasetStorageInfo(o,this._tileSize,this._tileSize),this._set(`rasterInfo`,o),this.updateTileInfo()}getTileExtentPDF(e,t,n){let r=this._extent,a=2**e,o=r.width/this._width*a,s=r.height/this._height*a,c=new i({x:r.xmin,y:r.ymax});return this.getTileExtent({x:o,y:s},t,n,c,r.spatialReference,[512,512])}};e([n({type:String,json:{write:!0}})],l.prototype,`datasetFormat`,void 0),e([n({constructOnly:!0})],l.prototype,`page`,void 0),e([n({readOnly:!0})],l.prototype,`tileType`,void 0),l=e([r(`esri.layers.raster.datasets.GeospatialPDFRaster`)],l);const u=l;function d(e){return new s({width:e.width,height:e.height,pixelType:`u8`,pixels:[e.red,e.green,e.blue],mask:e.mask})}function f(e,n){let[r,i,a,o]=e,s=r*o-i*a;if(!Number.isFinite(s)||s===0)throw new t(`geospatial-pdf-raster:open`,`Failed to derive raster dimensions from an invalid PDF CTM.`);let c=10*Math.hypot(o,i)/Math.abs(s),l=10*Math.hypot(a,r)/Math.abs(s),u=Math.max(1,Math.ceil(n.width*c)),d=Math.max(1,Math.ceil(n.height*l));if(!Number.isFinite(u)||!Number.isFinite(d))throw new t(`geospatial-pdf-raster:open`,`PDF CTM produced invalid raster dimensions.`);return[u,d]}export{u as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n,createAbortError as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import l from"./InMemoryRaster.js";import{parsePAMInfo as u}from"./pamParser.js";import{parseHeader as d}from"../formats/JpgPlus.js";import{getFormat as f}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../transforms/PolynomialTransform.js";import h from"../../support/RasterInfo.js";let g=class extends c{set rasterJobHandler(e){this._set(`rasterJobHandler`,e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}fetchRawTile(e,t,n,r={}){if(this._imageBlob){let{blockWidth:
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n,createAbortError as r}from"../../../core/promiseUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import l from"./InMemoryRaster.js";import{parsePAMInfo as u}from"./pamParser.js";import{parseHeader as d}from"../formats/JpgPlus.js";import{getFormat as f}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../transforms/PolynomialTransform.js";import h from"../../support/RasterInfo.js";let g=class extends c{set rasterJobHandler(e){this._set(`rasterJobHandler`,e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}fetchRawTile(e,t,n,r={}){if(this._imageBlob){let{blockWidth:i,blockHeight:a}=this.rasterInfo.storageInfo;return this.decodePixelBlock(this._imageBlob,{tileSize:[i,a],tileIndex:[e,t,n],canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},{signal:r.signal})}return this._inMemoryRaster?this._inMemoryRaster.fetchRawTile(e,t,n,r):Promise.resolve(null)}async _open(e){let n=await this._fetchData(e);if(n==null)throw new t(`image-aux-raster:open`,`the data cannot be decoded`);let{spatialReference:r,statistics:i,histograms:a,transform:c}=await this._fetchAuxiliaryData(e),u=!r;u&&(r=new s({wkid:3857})),a?.length&&i==null&&(i=p(a));let{width:d,height:f,pixelBlock:m}=n,g=new o({xmin:-.5,ymin:.5-f,xmax:d-.5,ymax:.5,spatialReference:r}),_=c?c.forwardTransform(g):g,v=!0;if(c){let e=c.forwardCoefficients;v=e&&e[1]===0&&e[2]===0,v&&(c=null,g=_)}if(!m){let e=new h({width:d,height:f,bandCount:3,pixelType:`u8`,extent:_,nativeExtent:g,transform:c,pixelSize:{x:_.width/d,y:_.height/f},spatialReference:_.spatialReference,keyProperties:{DataType:`Processed`}});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(e),this.createRemoteDatasetStorageInfo(e,512,512),this._set(`rasterInfo`,e),this.updateTileInfo();return}let{rasterJobHandler:y,ioConfig:b}=this,x=new l({preGenerateTiles:!1,rasterJobHandler:y,source:{extent:_,nativeExtent:g,transform:c,pixelBlocks:[m],statistics:i,histograms:a,keyProperties:{DataType:`Processed`},isPseudoSpatialReference:u},ioConfig:{...b,sampling:`closest`,skipStatistics:!0}});await x.open(),x.source=null,this._set(`rasterInfo`,x.rasterInfo),this._inMemoryRaster=x}async _fetchData(e){let{data:n}=await this.request(this.url,{responseType:`array-buffer`,signal:e?.signal}),r=f(n);if(r===`jpg`||r===`png`||r===`gif`||r===`bmp`)this._set(`datasetFormat`,r.toUpperCase());else throw new t(`image-aux-raster:open`,`the data is not a supported format`);if(r===`jpg`){let e=d(n);if(e==null)throw new t(`image-aux-raster:open`,`the data is not a supported format`);return this._imageBlob=n,e}try{let t=await this.decodePixelBlock(n,{format:r,canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},e);return this._imageBlob=n,t?{width:t.width,height:t.height,pixelBlock:t}:null}catch{let t=await this.decodePixelBlock(n,{format:r,canvasUsage:`no-canvas`,skipStatistics:!0},e);return t?{width:t.width,height:t.height,pixelBlock:t}:null}}async _fetchAuxiliaryData(e){let t=e?.signal,{skipExtensions:i=[],skipMapInfo:a}=this.ioConfig,o=a||i.includes(`aux.xml`)?null:this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:t}),s=this.datasetFormat,c=s===`JPG`?`jgw`:s===`PNG`?`pgw`:s===`BMP`?`bpw`:null,l=c&&i.includes(c)?null:this.request(this.url.slice(0,this.url.lastIndexOf(`.`))+`.`+c,{responseType:`text`,signal:t}),d=await n([o,l]);if(t?.aborted)throw r();let f=u(d[0].value?.data);if(!f.transform){let e=d[1].value?d[1].value.data.split(`
|
|
3
3
|
`).slice(0,6).map(e=>Number(e)):null;f.transform=e?.length===6?new m({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return f}};e([i({type:String,json:{write:!0}})],g.prototype,`datasetFormat`,void 0),e([i()],g.prototype,`rasterJobHandler`,null),g=e([a(`esri.layers.raster.datasets.ImageAuxRaster`)],g);const _=g;export{_ as default};
|
|
@@ -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/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g},{signal:r.signal});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
|
|
@@ -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/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1}
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1},{signal:r.signal});if(E==null)return null;let{noDataValue:D}=this.rasterInfo;if(D!=null&&w!==`lerc`&&!E.mask&&(D=D[0],D!=null)){let e=E.width*E.height,t=new Uint8Array(e);if(Math.abs(D)>1e24)for(_=0;_<e;_++)Math.abs((E.pixels[0][_]-D)/D)>1e-6&&(t[_]=1);else for(_=0;_<e;_++)E.pixels[0][_]!==D&&(t[_]=1);E.mask=t}let O=0,k=0;if(d!==i||f!==a){let e=E.mask;if(e)for(_=0;_<a;_++)if(k=_*i,_<f)for(O=d;O<i;O++)e[k+O]=0;else for(O=0;O<i;O++)e[k+O]=0;else for(e=new Uint8Array(i*a),E.mask=e,_=0;_<f;_++)for(k=_*i,O=0;O<d;O++)e[k+O]=1}return E}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1);let t=e?e.signal:null,n=await this.request(this.url,{responseType:`xml`,signal:t}),{rasterInfo:r,files:i}=this._parseHeader(n.data),{skipMapInfo:a,skipExtensions:o=[]}=this.ioConfig;if(!o.includes(`aux.xml`)&&!a){let t=await this._fetchAuxiliaryData(e);t!=null&&(r.statistics=t.statistics??r.statistics,r.histograms=t.histograms,t.histograms&&r.statistics==null&&(r.statistics=p(t.histograms)))}a&&this.updateImageSpaceRasterInfo(r),this._set(`rasterInfo`,r),this._files=i;let s=await this.request(i.index,{responseType:`array-buffer`,signal:t});this._storageIndex=b(s.data);let{blockWidth:c,blockHeight:l}=this.rasterInfo.storageInfo,u=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:d,height:f}=this.rasterInfo,m=[],h=this._getBandSegmentCount(),g=0,_=-1;for(;g<this._storageIndex.length;){_++;let e=Math.ceil(d/c/u**_)-1,t=Math.ceil(f/l/u**_)-1;g+=(e+1)*(t+1)*h*4,m.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=m,_>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=_),this.updateTileInfo()}_getBandSegmentCount(){return this._isBsq?this.rasterInfo.bandCount:1}_getTileLocation(e,t,n){let{blockWidth:r,blockHeight:i,pyramidScalingFactor:a}=this.rasterInfo.storageInfo,{width:o,height:s}=this.rasterInfo,c=this._getBandSegmentCount(),l,u,d,f=0,p=0;for(d=0;d<e;d++)p=a**d,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=l*u;p=a**e,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=t*l+n,f*=c*4;let m=this._storageIndex.subarray(f,f+4*c),h=0,g=0,_=[];for(let e=0;e<c;e++)h=m[e*4]*2**32+m[e*4+1],g=h+m[e*4+2]*2**32+m[e*4+3]-1,_.push({from:h,to:g});return{ranges:_,actualTileWidth:n<l-1?r:Math.ceil(o/p)-r*(l-1),actualTileHeight:t<u-1?i:Math.ceil(s/p)-i*(u-1)}}_parseHeader(e){let n=u(e,`MRF_META/Raster`);if(!n)throw new t(`mrf:open`,`not a valid MRF format`);let r=u(n,`Size`),s=parseInt(r.getAttribute(`x`),10),l=parseInt(r.getAttribute(`y`),10),f=parseInt(r.getAttribute(`c`),10),p=(d(n,`Compression`)||`none`).toLowerCase();if(!v.has(p))throw new t(`mrf:open`,`currently does not support compression `+p);let m=d(n,`DataType`)||`UInt8`,y=_.get(m.toLowerCase());if(y==null)throw new t(`mrf:open`,`currently does not support pixel type `+m);let b=u(n,`PageSize`),x=parseInt(b.getAttribute(`x`),10),S=parseInt(b.getAttribute(`y`),10),C=b.getAttribute(`c`),w=C?C===String(f):v.get(p).isOneSegment;this._isBsq=!w;let T=u(n,`DataValues`),E;if(T){let e=T.getAttribute(`NoData`);e!=null&&(E=e.trim().split(` `).map(e=>parseFloat(e)))}if(u(e,`MRF_META/CachedSource`))throw new t(`mrf:open`,`currently does not support MRF referencing other data files`);let D=u(e,`MRF_META/GeoTags`),O=u(D,`BoundingBox`),k=!1,A;if(O!=null){let e=parseFloat(O.getAttribute(`minx`)),t=parseFloat(O.getAttribute(`miny`)),n=parseFloat(O.getAttribute(`maxx`)),r=parseFloat(O.getAttribute(`maxy`)),a=d(D,`Projection`)||``,s=o.WGS84;if(a!==`LOCAL_CS[]`){if(a.toLowerCase().startsWith(`epsg:`)){let e=Number(a.slice(5));!isNaN(e)&&e!==0&&(s=new o({wkid:e}))}else s=c(a)??o.WGS84}else k=!0,s=new o({wkid:3857});A=new i(e,t,n,r),A.spatialReference=s}else k=!0,A=new i({xmin:-.5,ymin:.5-l,xmax:s-.5,ymax:.5,spatialReference:new o({wkid:3857})});let j=u(e,`MRF_META/Rsets`),M=parseInt(j?.getAttribute(`scale`)||`2`,10),N=A.spatialReference,P=new g({origin:new a({x:A.xmin,y:A.ymax,spatialReference:N}),blockWidth:x,blockHeight:S,pyramidBlockWidth:x,pyramidBlockHeight:S,compression:p,pyramidScalingFactor:M}),F=new a({x:A.width/s,y:A.height/l,spatialReference:N}),I=new h({width:s,height:l,extent:A,isPseudoSpatialReference:k,spatialReference:N,bandCount:f,pixelType:y,pixelSize:F,noDataValue:E,storageInfo:P}),L=this._getAuxFullPath(d(n,`DataFile`)),R=this._getAuxFullPath(d(n,`IndexFile`));return{rasterInfo:I,files:{mrf:this.url,index:R||this.url.replace(`.mrf`,`.idx`),data:L||this.url.replace(`.mrf`,v.get(p).blobExtension)}}}_getAuxFullPath(e){return!e||e.includes(`\\`)?null:e.includes(`/`)?e.startsWith(new URL(this.url).origin)?e:null:`${this.url.slice(0,this.url.lastIndexOf(`/`))}/${e}`}async _fetchAuxiliaryData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return l(t)}catch{return null}}};e([n()],y.prototype,`_files`,void 0),e([n()],y.prototype,`_storageIndex`,void 0),e([n()],y.prototype,`_isBsq`,void 0),e([n({type:String,json:{write:!0}})],y.prototype,`datasetFormat`,void 0),y=e([r(`esri.layers.raster.datasets.MRFRaster`)],y);function b(e){if(e.byteLength%16>0)throw Error(`invalid array buffer must be multiples of 16`);let t;if(f){let n=new Uint8Array(e),r=new ArrayBuffer(e.byteLength),i=new Uint8Array(r);for(let t=0;t<e.byteLength/4;t++)for(let e=0;e<4;e++)i[t*4+e]=n[t*4+3-e];t=new Uint32Array(r)}else t=new Uint32Array(e);return t}const x=y;export{x as default};
|