@arcgis/core 4.29.0-next.20240221 → 4.29.0
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/0bc21d2a0b65bd4e9d76.js +1 -0
- package/assets/esri/core/workers/chunks/{6e50220f8e2d392e2855.js → 5b275309d78453a9319e.js} +1 -1
- package/assets/esri/core/workers/chunks/{6fd8047741a0df006ddd.js → 69f6558b538d1b2d3086.js} +1 -1
- package/assets/esri/core/workers/chunks/{63c2ca47e8df5e9b5574.js → 87fb028c66de06bf6d75.js} +1 -1
- package/assets/esri/core/workers/chunks/9307d485a9e5f9fa77d1.js +1 -0
- package/assets/esri/core/workers/chunks/{958402a4f6dd0d23546d.js → a4c3da057ec2a07bbbe8.js} +1 -1
- package/assets/esri/core/workers/chunks/{48c6a9ed53cf4f9255b0.js → b454c6b992bcdbab36a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
- package/config.js +1 -1
- package/copyright.txt +56 -28
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/interfaces.d.ts +8 -8
- package/kernel.js +1 -1
- package/layers/orientedImagery/core/CameraOrientation.js +1 -1
- package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
- package/layers/orientedImagery/transformations/updateElevation.js +5 -0
- package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +5 -0
- package/layers/support/EditingCapabilities.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/package.json +1 -1
- package/rest/print.js +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/meshFastUpdateUtils.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/layers/support/editableLayerViews.js +5 -0
- package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
- package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.js +0 -1
package/config.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"./core/has.js";import{deepMerge as e}from"./core/object.js";
|
|
5
|
+
import"./core/has.js";import{deepMerge as e}from"./core/object.js";const s={apiKey:void 0,applicationName:"",applicationUrl:globalThis.location?.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",userPrivilegesApplied:!0,portalUrl:"https://www.arcgis.com",routeServiceUrl:"https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{crossOriginNoCorsDomains:null,httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,priority:"high",proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(globalThis.esriConfig&&(e(s,globalThis.esriConfig,!0),delete s.has),!s.assetsPath){{const e="4.29";s.assetsPath=`https://js.arcgis.com/${e}/@arcgis/core/assets`}s.defaultAssetsPath=s.assetsPath}export{s as default};
|
package/copyright.txt
CHANGED
|
@@ -172,34 +172,6 @@ THE SOFTWARE.
|
|
|
172
172
|
|
|
173
173
|
-----------------------------------------------------------------
|
|
174
174
|
|
|
175
|
-
libpannellum.js
|
|
176
|
-
pannellum.js
|
|
177
|
-
|
|
178
|
-
https://github.com/mpetroff/pannellum/
|
|
179
|
-
|
|
180
|
-
MIT License
|
|
181
|
-
|
|
182
|
-
Copyright (c) 2011-2022 Matthew Petroff
|
|
183
|
-
|
|
184
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
185
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
186
|
-
the Software without restriction, including without limitation the rights to
|
|
187
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
188
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
189
|
-
subject to the following conditions:
|
|
190
|
-
|
|
191
|
-
The above copyright notice and this permission notice shall be included in all
|
|
192
|
-
copies or substantial portions of the Software.
|
|
193
|
-
|
|
194
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
195
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
196
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
197
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
198
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
199
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
200
|
-
|
|
201
|
-
-----------------------------------------------------------------
|
|
202
|
-
|
|
203
175
|
esri/libs/popper
|
|
204
176
|
|
|
205
177
|
The MIT License (MIT)
|
|
@@ -1234,3 +1206,59 @@ Copyright (c) 2022 Gildas Lormeau. All rights reserved.
|
|
|
1234
1206
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
1235
1207
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
1236
1208
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
1209
|
+
|
|
1210
|
+
-----------------------------------------------------------------
|
|
1211
|
+
|
|
1212
|
+
stencil/
|
|
1213
|
+
|
|
1214
|
+
https://github.com/ionic-team/stencil
|
|
1215
|
+
|
|
1216
|
+
The MIT License (MIT)
|
|
1217
|
+
|
|
1218
|
+
Copyright (c) 2019-present Drifty Co.
|
|
1219
|
+
|
|
1220
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1221
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1222
|
+
in the Software without restriction, including without limitation the rights
|
|
1223
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1224
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1225
|
+
furnished to do so, subject to the following conditions:
|
|
1226
|
+
|
|
1227
|
+
The above copyright notice and this permission notice shall be included in
|
|
1228
|
+
all copies or substantial portions of the Software.
|
|
1229
|
+
|
|
1230
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1231
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1232
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1233
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1234
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1235
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1236
|
+
THE SOFTWARE.
|
|
1237
|
+
|
|
1238
|
+
-----------------------------------------------------------------
|
|
1239
|
+
|
|
1240
|
+
monaco-editor/
|
|
1241
|
+
|
|
1242
|
+
https://github.com/microsoft/monaco-editor
|
|
1243
|
+
|
|
1244
|
+
The MIT License (MIT)
|
|
1245
|
+
|
|
1246
|
+
Copyright (c) 2016 - present Microsoft Corporation
|
|
1247
|
+
|
|
1248
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1249
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1250
|
+
in the Software without restriction, including without limitation the rights
|
|
1251
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1252
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1253
|
+
furnished to do so, subject to the following conditions:
|
|
1254
|
+
|
|
1255
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1256
|
+
copies or substantial portions of the Software.
|
|
1257
|
+
|
|
1258
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1259
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1260
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1261
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1262
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1263
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1264
|
+
SOFTWARE.
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import e from"../../../core/Logger.js";import{fromMat4 as t}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromRotation as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as n,g as a,t as s,e as l}from"../../../chunks/vec32.js";import{create as c,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getSphericalPCPF as m}from"../../spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as f}from"../../projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as g}from"../../projection/projectPointToVector.js";import{create as u,compose as j,axis as x,angleRad as d}from"../axisAngleDegrees.js";import b from"../MeshTransform.js";import{isRelativeVertexSpace as h}from"../meshVertexSpaceUtils.js";import{usesLocalTangentPlaneOnECEFForOperations as v}from"./geographicUtils.js";import{projectToPCPF as A,projectNormalToPCPF as w,projectTangentToPCPF as y,projectFromPCPF as R,projectNormalFromPCPF as k,projectTangentFromPCPF as L}from"./projection.js";const F="esri.geometry.support.meshUtils.rotate";function T(e,t,r){if(!e.vertexAttributes?.position||0===t[3])return;const{spatialReference:o,vertexSpace:i}=e,n=r?.origin??e.anchor,a=r?.geographic;if(h(i))U(e,t,n);else{v(F,i,o,a)?$(e,t,n):P(e,t,n)}}function U(t,r,o){t.transform??=new b;const{vertexSpace:i,transform:s}=t,l=i.origin,p=C;if(!g(o,p,t.spatialReference))return void e.getLogger(F).error(`Failed to project specified origin (wkid:${o.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}). Projection may be possible after calling projection.load().`);const m=n(C,p,l),f=s.applyLocalInverse(m,I);s.rotation=j(s.rotation,r,u());const x=s.applyLocalInverse(m,V),d=n(C,x,f),h=s.applyLocal(d,C);s.translation=a(c(),s.translation,h)}function $(e,r,o){const i=e.spatialReference,n=m(i),a=M;g(o,a,n)||g(e.origin,a,n);const l=e.vertexAttributes.position,c=e.vertexAttributes.normal,p=e.vertexAttributes.tangent,u=new Float64Array(l.length),j=null!=c?new Float32Array(c.length):null,d=null!=p?new Float32Array(p.length):null;f(n,a,D,n),t(E,D);const b=z;s(x(z),x(r),E),b[3]=r[3],A(l,i,u),null!=c&&null!=j&&w(c,l,u,i,j),null!=p&&null!=d&&y(p,l,u,i,d),S(u,b,3,a),R(u,l,i),null!=c&&null!=j&&(S(j,b,3),k(j,l,u,i,c)),null!=p&&null!=d&&(S(d,b,4),L(d,l,u,i,p)),e.vertexAttributesChanged()}function P(t,r,o){const i=M;if(!g(o,i,t.spatialReference)){const r=t.origin;i[0]=r.x,i[1]=r.y,i[2]=r.z,e.getLogger(F).error(`Failed to project specified origin (wkid:${o.spatialReference.wkid}) to mesh spatial reference (wkid:${t.spatialReference.wkid}). Projection may be possible after calling projection.load().`)}S(t.vertexAttributes.position,r,3,i),S(t.vertexAttributes.normal,r,3),S(t.vertexAttributes.tangent,r,4),t.vertexAttributesChanged()}function S(e,t,r,i=p){if(null!=e){o(D,d(t),x(t));for(let t=0;t<e.length;t+=r){for(let r=0;r<3;r++)C[r]=e[t+r]-i[r];l(C,C,D);for(let r=0;r<3;r++)e[t+r]=C[r]+i[r]}}}const C=c(),I=c(),V=c(),z=u(),D=i(),E=r(),M=c();export{T as rotate};
|
package/interfaces.d.ts
CHANGED
|
@@ -7276,7 +7276,7 @@ declare namespace __esri {
|
|
|
7276
7276
|
*/
|
|
7277
7277
|
readonly type: "georeferenced";
|
|
7278
7278
|
/**
|
|
7279
|
-
* A
|
|
7279
|
+
* A mesh vertex space that indicates mesh vertices to be either absolute georeferenced map coordinates or relative offsets in map space to a fully georeferenced origin.
|
|
7280
7280
|
*
|
|
7281
7281
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshGeoreferencedVertexSpace.html)
|
|
7282
7282
|
*/
|
|
@@ -7310,7 +7310,7 @@ declare namespace __esri {
|
|
|
7310
7310
|
*/
|
|
7311
7311
|
readonly type: "local";
|
|
7312
7312
|
/**
|
|
7313
|
-
* A
|
|
7313
|
+
* A mesh vertex space that indicates mesh vertices to be in a plain cartesian space as often encountered in 3D modeling and CAD applications.
|
|
7314
7314
|
*
|
|
7315
7315
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-support-MeshLocalVertexSpace.html)
|
|
7316
7316
|
*/
|
|
@@ -14561,7 +14561,7 @@ declare namespace __esri {
|
|
|
14561
14561
|
*/
|
|
14562
14562
|
url: string;
|
|
14563
14563
|
/**
|
|
14564
|
-
* The IntegratedMesh3DTilesLayer is designed for visualizing accurate representations in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
|
|
14564
|
+
* The IntegratedMesh3DTilesLayer is designed for visualizing accurate representations of built and natural environments in a [SceneView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html).
|
|
14565
14565
|
*
|
|
14566
14566
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-IntegratedMesh3DTilesLayer.html)
|
|
14567
14567
|
*/
|
|
@@ -45913,7 +45913,7 @@ declare namespace __esri {
|
|
|
45913
45913
|
|
|
45914
45914
|
export class UniqueValueRenderer {
|
|
45915
45915
|
/**
|
|
45916
|
-
* This property is only relevant
|
|
45916
|
+
* This property is only relevant when symbolizing polygon features with marker symbols (or [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html)) in the [uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) of this renderer.
|
|
45917
45917
|
*
|
|
45918
45918
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#backgroundFillSymbol)
|
|
45919
45919
|
*/
|
|
@@ -46033,7 +46033,7 @@ declare namespace __esri {
|
|
|
46033
46033
|
|
|
46034
46034
|
interface UniqueValueRendererProperties extends RendererProperties, VisualVariablesMixinProperties {
|
|
46035
46035
|
/**
|
|
46036
|
-
* This property is only relevant
|
|
46036
|
+
* This property is only relevant when symbolizing polygon features with marker symbols (or [IconSymbol3DLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-IconSymbol3DLayer.html)) in the [uniqueValueInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#uniqueValueInfos) of this renderer.
|
|
46037
46037
|
*
|
|
46038
46038
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html#backgroundFillSymbol)
|
|
46039
46039
|
*/
|
|
@@ -101930,7 +101930,7 @@ declare namespace __esri {
|
|
|
101930
101930
|
*
|
|
101931
101931
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureTable.html#VisibleElements)
|
|
101932
101932
|
*/
|
|
101933
|
-
|
|
101933
|
+
selectedRecordsShowSelectedToggle?: boolean;
|
|
101934
101934
|
/**
|
|
101935
101935
|
* Indicates whether to enable toggling column visibility within the menu.
|
|
101936
101936
|
*
|
|
@@ -111318,11 +111318,11 @@ declare namespace __esri {
|
|
|
111318
111318
|
*/
|
|
111319
111319
|
duplicate(): void;
|
|
111320
111320
|
/**
|
|
111321
|
-
* Allows creation of a graphic similar to create with the difference that
|
|
111321
|
+
* Allows creation of a graphic similar to create with the difference that the geometry can be provided directly for the graphic being created.
|
|
111322
111322
|
*
|
|
111323
111323
|
* [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#place)
|
|
111324
111324
|
*/
|
|
111325
|
-
place(): void;
|
|
111325
|
+
place(geometry: Mesh): void;
|
|
111326
111326
|
/**
|
|
111327
111327
|
* Incrementally redo actions recorded in the stack.
|
|
111328
111328
|
*
|
package/kernel.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.29";let t,
|
|
5
|
+
import has from"./core/has.js";import{addQueryParameter as o}from"./core/urlUtils.js";import{buildDate as s,commitHash as e}from"./support/revision.js";Symbol.dispose??=Symbol("Symbol.dispose"),Symbol.asyncDispose??=Symbol("Symbol.asyncDispose");const r="4.29";let t,i=r;i="4.29.0";function n(o){t=o}function m(s){const e=t?.findCredential(s);return e?.token?o(s,"token",e.token):s}has("host-webworker");export{m as addTokenParameter,s as buildDate,i as fullVersion,t as id,e as revision,n as setId,r as version};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import o from"../../../core/Accessor.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{getHeightModel as i,getVerticalUnit as s,getHorizontalUnit as n}from"../constants/utils.js";let p=class extends o{constructor(){super(...arguments),this.verticalWKID=null}get isAdvanced(){const{affineTransformations:t,focalLength:o,principalOffsetPoint:e,radialDistortionCoefficients:r,tangentialDistortionCoefficients:i}=this;return t?.length>1&&!Number.isNaN(o)&&e?.length>1&&r?.length>1&&i?.length>1}get unitAndHeightInfo(){const{horizontalWKID:t,verticalWKID:o}=this;let e=t,r=o;const p=this;if(4===p.type){const{properties:t}=p;e=4326,r=t.verticalWKID}return{heightModel:i(r,e),heightUnit:s(r,e),horizontalUnit:n(e)}}};t([e({json:{write:!0}})],p.prototype,"affineTransformations",void 0),t([e({json:{write:!0}})],p.prototype,"focalLength",void 0),t([e({json:{write:!0}})],p.prototype,"principalOffsetPoint",void 0),t([e({json:{write:!0}})],p.prototype,"radialDistortionCoefficients",void 0),t([e({json:{write:!0}})],p.prototype,"tangentialDistortionCoefficients",void 0),t([e({json:{write:!0}})],p.prototype,"horizontalWKID",void 0),t([e({json:{write:!0}})],p.prototype,"verticalWKID",void 0),t([e({json:{write:!0}})],p.prototype,"x",void 0),t([e({json:{write:!0}})],p.prototype,"y",void 0),t([e({json:{write:!0}})],p.prototype,"z",void 0),t([e({json:{write:!0}})],p.prototype,"type",void 0),t([e({readOnly:!0})],p.prototype,"unitAndHeightInfo",null),p=t([r("esri.layers.orientedImagery.core.CameraOrientation")],p);const a=p;export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as
|
|
5
|
+
import{_ as o}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{fetchArcGISServiceJSON as n}from"../../../support/requestPresets.js";let i=class extends r{constructor(){super(...arguments),this.url=null}};o([t({type:Number,json:{write:!0}})],i.prototype,"lod",void 0),o([t({type:String,json:{write:!0}})],i.prototype,"rasterFunction",void 0),o([t({type:String,json:{write:!0}})],i.prototype,"url",void 0),i=o([s("esri.layers.orientedImagery.core.ElevationSourceDefinitions.ElevationSource")],i);let p=class extends r{constructor(){super(...arguments),this.constantElevation=null}};o([t({type:Number,json:{write:!0}})],p.prototype,"constantElevation",void 0),p=o([s("esri.layers.orientedImagery.cor.ElevationSourceDefinitions.ConstantElevation")],p);const a=o=>null!=o&&"constantElevation"in o&&"number"==typeof o.constantElevation,c=o=>null!=o&&"url"in o&&!!o.url;async function l(o){const r=await n(o),{tileInfo:t,cacheType:s}=r;return r.hasOwnProperty("bandCount")&&r.hasOwnProperty("pixelSizeX")?"LERC"!==t?.format?.toUpperCase()||s&&"elevation"!==s.toLowerCase()?{isSupported:!0,isDynamic:!0}:{isSupported:!0}:{isSupported:!1,error:new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${o}`)}}export{p as ConstantElevation,i as ElevationSource,a as isConstantElevation,c as isElevationSource,l as validateElevationSourceURL};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../../../geometry.js";import{deg2rad as e}from"../../../core/mathUtils.js";import{memoize as t}from"../../../core/memoize.js";import{zeros as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{y as r,g as o}from"../../../chunks/vec32.js";import{webMercatorToGeographic as i,geographicToWebMercator as n}from"../../../geometry/support/webMercatorUtils.js";import c from"../core/cameraOrientationFactory.js";import{scaleWithFactor as s,scaleAndAddWithFactor as l,projectiveTransform2 as m,ltpToGeographic as f,computeHFOVAndVFOV as p,calculateRotationMatrix as y,transformMat3 as u}from"./utils.js";import{worldToImageWithLTPFlag as g,worldToImage as z,getScalingFactor as h}from"./worldToImage.js";import x from"../../../geometry/Point.js";function d(e,t){const a=Array.isArray(e)?e:[e],{effectiveVerticalFieldOfView:r,imageVertices:o,scalingFactor:i,shouldConvertToLatLong:n,worldFootprint:c,localTangentPlane:s,cameraLocation:l}=L(t),m=new Array;for(const f of a){const e=R(c,o,{...f,z:1},l,t,s);m.push(w(e,l,i,(l.z??0)-t.cameraHeight,t.cameraPitch,r,n))}return 1===m.length?m[0]:m}function w(e,t,o,n,c,m,f){let p=e.clone();const y=Math.sqrt((e.z-t.z)**2+(Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)/o)**2)*o,u=s(r(a(),[e.x,e.y,e.z],[t.x,t.y,t.z]),1/y,1/o);if(e.z<n||c+m/2<90){const a=Math.abs((t.z-n)/-u[2])*o,r=l([t.x,t.y,t.z],u,a,o);p=new x({x:r[0],y:r[1],z:r[2],spatialReference:e.spatialReference})}else p.z=n;return f&&(p=i(e)),p}function R(e,t,a,r,o,i){let n=null;const c=9;let s,l=0,f=e,p=t;for(;l<=c;){const e=F(a,p,f,{...o,cameraLocation:r},a);if(s=e.error,n=e.transformedPoint,s<=1||l===c)break;f=[{x:a.x-s,y:a.y-s,z:1},{x:a.x+s,y:a.y-s,z:1},{x:a.x+s,y:a.y+s,z:1},{x:a.x-s,y:a.y+s,z:1}].map((e=>new x({...m(e,t,f),spatialReference:r.spatialReference}))),p=g(i,f,o),l++}return n}function F(e,t,a,r,o){const{cameraLocation:i}=r,n=new x({...m(e,t,a),spatialReference:i.spatialReference});return{transformedPoint:n,error:O(o,z(n,r))}}function O(e,t){return Math.abs(e.x-t.x)+Math.abs(e.y-t.y)}function L(e){const t="string"==typeof e.cameraOrientation?c.getCameraOrientation(e.cameraOrientation):e.cameraOrientation,a=4===t?.type,r=e.cameraLocation.spatialReference.isWGS84&&a;let o=new x(e.cameraLocation);if(a){const e=t;o=new x(f(o,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}o.spatialReference.isGeographic&&(o=n(o));const i=h(o);o.z||(o.z=e.cameraHeight);const s=j({...e,scalingFactor:i});return{cameraOrientation:t,cameraLocation:o,imageVertices:g(a,s,e),localTangentPlane:a,effectiveVerticalFieldOfView:p(e.horizontalFieldOfView,e.verticalFieldOfView,e.cameraRoll??0).vfov,worldFootprint:s,scalingFactor:i,shouldConvertToLatLong:r}}const j=t((t=>{const{cameraLocation:i,scalingFactor:n}=t,c=2*Math.tan(e(t.verticalFieldOfView)/2)*t.farDistance*n,m=2*Math.tan(e(t.horizontalFieldOfView)/2)*t.farDistance*n,f=y("HPR",[t.cameraHeading,t.cameraPitch,t.cameraRoll??0]),p=u([0,0,-1],f),g=l([i.x,i.y,i.z],p,t.farDistance*n,n),z=u([0,1,0],f),h=u([1,0,0],f),d=s(z,c/2,n),w=s(h,m/2,n),R=r(a(),d,w),F=o(a(),d,w);return[o(a(),g,R),o(a(),g,F),r(a(),g,R),r(a(),g,F)].map((e=>{const[t,a,r]=e;return new x({x:t,y:a,z:r,spatialReference:i.spatialReference})}))}));export{d as imageToWorld};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{isConstantElevation as e,isElevationSource as t}from"../core/ElevationSourceDefinitions.js";import{updateUsingElevationSampler as n,updateUsingConstant as o,updateUsingElevationSource as i,updateUsingCameraProperties as a}from"./updateElevationUtils.js";async function l(l,r,v){const c="elevationSample"in r&&null!=r.elevationSample,s="elevationSource"in r?r.elevationSource:void 0,u="extent"in r?r.extent:void 0;return c?n(l,r.elevationSample,v):e(s)?o(l,s.constantElevation,!0,v):t(s)?i(l,{...s,extent:u},v):a(r,l)}export{l as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../core/Error.js";import t from"../../../core/Logger.js";import{memoize as r}from"../../../core/memoize.js";import{waitTick as o,isAbortError as a}from"../../../core/promiseUtils.js";import{projectWithZConversion as n}from"../../../geometry/projection.js";import{fromExtent as i}from"../../../geometry/support/aaBoundingRect.js";import s from"../../ElevationLayer.js";import c from"../../ImageryLayer.js";import{TileElevationSampler as l}from"../../support/ElevationSampler.js";import{ElevationTile as p}from"../../support/ElevationTile.js";import{ElevationTileData as u}from"../../support/ElevationTileData.js";import m from"../../support/RasterFunction.js";import f from"../../support/TileInfo.js";import{TileKey as w}from"../../support/TileKey.js";import{fetchArcGISServiceJSON as y}from"../../../support/requestPresets.js";import{logAndThrow as g}from"../../../widgets/OrientedImageryViewer/utils.js";async function v(t,r,o){const a="url"in r?await j(r):r;if(!a)throw g("esri.layers.orientedImagery.transformations",new e("update-elevation:elevation-source","could not create a sampler using provided elevation source",r));return d(t,a,o)}async function d(e,t,r){await o(r);const a=new Array,n=z(t,r);for(const o of e){const e=await n(o);a.push(e)}return a}async function E(e,t,r=!0,a){await o(a);const{cameraHeight:n,cameraLocation:i,cameraOrientation:s}=e;return A(t,s&&"number"==typeof i.z?i.z-n:0,r,a)}var h;!function(e){e[e.DYNAMIC=0]="DYNAMIC",e[e.ELEVATION=1]="ELEVATION"}(h||(h={}));const j=r((async(e,r)=>{let o;const{extent:n,rasterFunction:i,url:s}=e;try{o=await R(s)}catch(c){if(a(c))return;t.getLogger("esri.layers.orientedImagery.transformations").error("updateElevationUsingElevationSource",c)}switch(o){case h.DYNAMIC:return await L(s,n,i,r);case h.ELEVATION:return await I(s,n,r);default:return}}));async function I(e,r,o){const n=new s(e);let i;try{await n.load(),i=await n.createElevationSampler(r,o)}catch(c){if(a(c))return;t.getLogger(n).error(c)}finally{n.destroy()}return i}async function L(e,t,r,o){const a=r?new m({functionName:r}):void 0,n=new c({url:e,rasterFunction:a,format:"lerc"});await n.load(o);let s,y=512,g=512;const v=t.width/t.height;v>1?(g/=v,s=t.height/g):(y*=v,s=t.width/y);const d=await n.fetchImage(t,y,g,o),E=f.create({scales:[s],size:512,spatialReference:t.spatialReference}),h=new w(null,0,0,0,i(t)),j=new u(d.pixelData.pixelBlock.pixels[0],y,g,0),I=new p(h,j);return new l(I,E,void 0)}async function R(t){const r=await y(t),{tileInfo:o,cacheType:a}=r;if(!r.hasOwnProperty("bandCount")||!r.hasOwnProperty("pixelSizeX"))throw new e("elevation-source:invalid-service-url",`ElevationSource URL expects an elevation 3D image service but given ${t}`);return"LERC"!==o?.format?.toUpperCase()||a&&"elevation"!==a.toLowerCase()?h.DYNAMIC:h.ELEVATION}function z(e,t){return async r=>{let o=r.clone();const a=r.spatialReference.equals(e.spatialReference)?o:await n(r,e.spatialReference,t),i=e.queryElevation(a);if(i){o=r.spatialReference.equals(e.spatialReference)?i.clone():await n(i,r.spatialReference,t)}return o.z=o.z??1,o}}async function A(e,t,r=!0,a){if(await o(a),r)return e.map((e=>(e.z=t,e)));for(const o of e)o.z=t;return e}export{j as getElevationSampler,E as updateUsingCameraProperties,A as updateUsingConstant,d as updateUsingElevationSampler,v as updateUsingElevationSource,R as validateElevationSourceURL};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{invertOrIdentity as M}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{initializeProjection as i,projectWithZConversion as o}from"../../../geometry/projection.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as c}from"../../../geometry/support/spatialReferenceUtils.js";import{defaultImageSphereSize as e}from"../../../widgets/PanoramicViewer/constants.js";function z(t,a,n){const[s,h,M,i]=a,[o,r,c,e]=n;return u(t,s,h,M,i,o,r,c,e)}function u(t,a,n,h,i,o,r,c,e){let z=!1;0===a.z&&0===n.z&&0===h.z&&0===i.z&&(a.z=n.z=h.z=i.z=1,t.z=1),a.z=a.z??1,n.z=n.z??1,h.z=h.z??1,i.z=i.z??1,0===o.z&&0===r.z&&0===c.z&&0===e.z&&(z=!0,o.z=r.z=c.z=e.z=1),o.z=o.z??1,r.z=r.z??1,c.z=c.z??1,e.z=e.z??1;const u=m(a,n,h,i),f=m(o,r,c,e),x=M(s(),u),y=s();y[0]=f[0]*x[0]+f[1]*x[4]+f[2]*x[8]+f[3]*x[12],y[1]=f[0]*x[1]+f[1]*x[5]+f[2]*x[9]+f[3]*x[13],y[2]=f[0]*x[2]+f[1]*x[6]+f[2]*x[10]+f[3]*x[14],y[3]=f[0]*x[3]+f[1]*x[7]+f[2]*x[11]+f[3]*x[15],y[4]=f[4]*x[0]+f[5]*x[4]+f[6]*x[8]+f[7]*x[12],y[5]=f[4]*x[1]+f[5]*x[5]+f[6]*x[9]+f[7]*x[13],y[6]=f[4]*x[2]+f[5]*x[6]+f[6]*x[10]+f[7]*x[14],y[7]=f[4]*x[3]+f[5]*x[7]+f[6]*x[11]+f[7]*x[15],y[8]=f[8]*x[0]+f[9]*x[4]+f[10]*x[8]+f[11]*x[12],y[9]=f[8]*x[1]+f[9]*x[5]+f[10]*x[9]+f[11]*x[13],y[10]=f[8]*x[2]+f[9]*x[6]+f[10]*x[10]+f[11]*x[14],y[11]=f[8]*x[3]+f[9]*x[7]+f[10]*x[11]+f[11]*x[15],y[12]=f[12]*x[0]+f[13]*x[4]+f[14]*x[8]+f[15]*x[12],y[13]=f[12]*x[1]+f[13]*x[5]+f[14]*x[9]+f[15]*x[13],y[14]=f[12]*x[2]+f[13]*x[6]+f[14]*x[10]+f[15]*x[14],y[15]=f[12]*x[3]+f[13]*x[7]+f[14]*x[11]+f[15]*x[15];const p=y[0]*t.x+y[1]*t.y+y[2]*t.z+y[3],l=y[4]*t.x+y[5]*t.y+y[6]*t.z+y[7],b=y[8]*t.x+y[9]*t.y+y[10]*t.z+y[11];let g=y[12]*t.x+y[13]*t.y+y[14]*t.z+y[15];return 0===g&&(g=1),{x:p/g,y:l/g,z:z?0:b/g}}function m(t,a,n,s){const h=p([s.x,s.y,s.z,1],M(new Array(16),[t.x,a.x,n.x,0,t.y,a.y,n.y,0,t.z,a.z,n.z,0,1,1,1,1])),i=h[0],o=h[1],r=h[2],c=new Array(16);return c[0]=i*t.x,c[1]=o*a.x,c[2]=r*n.x,c[3]=0,c[4]=i*t.y,c[5]=o*a.y,c[6]=r*n.y,c[7]=0,c[8]=i*t.z,c[9]=o*a.z,c[10]=r*n.z,c[11]=0,c[12]=i,c[13]=o,c[14]=r,c[15]=1,c}function f(t,a,n,s,M=h()){return M[0]=t[0]+a[0]*n,M[1]=t[1]+a[1]*n,M[2]=t[2]+a[2]*(n/s),M}function x(t,a,n){const s=h();return s[0]=t[0]*a,s[1]=t[1]*a,s[2]=t[2]*(a/n),s}function y(t,a){const[n,s,M]=t,i=h();return i[0]=n*a[0]+s*a[3]+M*a[6],i[1]=n*a[1]+s*a[4]+M*a[7],i[2]=n*a[2]+s*a[5]+M*a[8],i}function p(t,a){const[n,s,h,M]=t,i=new Array(4);return i[0]=n*a[0]+s*a[1]+h*a[2]+M*a[3],i[1]=n*a[4]+s*a[5]+h*a[6]+M*a[7],i[2]=n*a[8]+s*a[9]+h*a[10]+M*a[11],i[3]=n*a[12]+s*a[13]+h*a[14]+M*a[15],i}function l(t,a){const s=Math.PI/180,h=n();if("OPK"===t){const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(n)*Math.cos(M),h[1]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.sin(n)*Math.cos(M),h[2]=Math.sin(t)*Math.sin(M)-Math.cos(t)*Math.sin(n)*Math.cos(M),h[3]=-Math.cos(n)*Math.sin(M),h[4]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.sin(n)*Math.sin(M),h[5]=Math.sin(t)*Math.cos(M)+Math.cos(t)*Math.sin(n)*Math.sin(M),h[6]=Math.sin(n),h[7]=-Math.sin(t)*Math.cos(n),h[8]=Math.cos(t)*Math.cos(n)}else{const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.cos(n)*Math.sin(M),h[1]=Math.sin(t)*Math.cos(M)*-1-Math.cos(t)*Math.cos(n)*Math.sin(M),h[2]=Math.sin(M)*Math.sin(n)*-1,h[3]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.cos(n)*Math.cos(M),h[4]=Math.sin(t)*Math.sin(M)*-1+Math.cos(t)*Math.cos(n)*Math.cos(M),h[5]=Math.cos(M)*Math.sin(n),h[6]=Math.sin(t)*Math.sin(n)*-1,h[7]=Math.cos(t)*Math.sin(n)*-1,h[8]=Math.cos(n)}return h}function b(t,a,n){const s=Math.sin(n*Math.PI/180),h=Math.cos(n*Math.PI/180),M=[[t,0],[t,a],[0,a]];M.forEach(((t,a)=>{M[a]=[h*t[0]-s*t[1],s*t[0]+h*t[1]]}));const i={xmin:Math.min(0,M[0][0],M[1][0],M[2][0]),xmax:Math.max(0,M[0][0],M[1][0],M[2][0]),ymin:Math.min(0,M[0][1],M[1][1],M[2][1]),ymax:Math.max(0,M[0][1],M[1][1],M[2][1])};return{hfov:Math.abs(i.xmax-i.xmin),vfov:Math.abs(i.ymax-i.ymin)}}function g(t,a,n,s,h,M){const i=n*(a.x-t.x)+s*(a.y-t.y)+h*(a.z-t.z);if(0===i)return null;const o=-(n*t.x+s*t.y+h*t.z+M)/i;return{x:t.x+o*(a.x-t.x),y:t.y+o*(a.y-t.y),z:t.z+o*(a.z-t.z)}}function j(t,a){const n=Math.PI/180,s=t.y*n,h=t.x*n,M=t.z||0,i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=h-o,e=a[2]/Math.sqrt(1-a[3]*Math.sin(s)**2),z=a[3]*(r*Math.sin(i)-e*Math.sin(s));return{x:(e+M)*Math.cos(s)*Math.sin(c),y:(e+M)*(Math.sin(s)*Math.cos(i)-Math.sin(i)*Math.cos(s)*Math.cos(c))+z*Math.cos(i),z:(e+M)*(Math.sin(s)*Math.sin(i)+Math.cos(i)*Math.cos(s)*Math.cos(c))-r+z*Math.sin(i)}}function q(t,a){const n=Math.PI/180,s=Number(t.x),h=Number(t.y),M=Number(t.z),i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=s/r,e=h/r,z=M/r,u=Math.cos(i)-Math.sin(i)*e+Math.cos(i)*z,m=Math.sin(i)+Math.cos(i)*e+Math.sin(i)*z,f=Math.sqrt(u**2+c**2),x=a[3]*r*Math.sin(i),y=i,p=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(y)**2))*Math.sin(y))/(r*f)),l=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(p)**2))*Math.sin(p))/(r*f)),b=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(l)**2))*Math.sin(l))/(r*f)),g=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(b)**2))*Math.sin(b))/(r*f)),j=Math.atan(s/(r*u))+o;return{x:j/n,y:g/n,z:s/(Math.cos(g)*Math.sin(j-o))-a[2]/Math.sqrt(1-a[3]*Math.sin(g)**2),spatialReference:{wkid:4326}}}function N(t){return t&&c(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}function d(t,a,n){const s=360/a,h=180/n;return{heading:(t.x-a/2)*s,pitch:90-(t.y-n/2)*h}}function w(t,a,n,s=e/2){const{heading:h,pitch:M}=I(t,s);return P(h,M,a,n)}function P(t,a,n,s){return{x:n/2+t/(360/n),y:s-a/(180/s),heading:t,pitch:a}}function I(a,n){const s=t(Math.acos(-a.z/n));return{heading:t(Math.atan2(a.x,a.y)),pitch:s}}function R(t,n,s=e/2){return[s*(Math.sin(a(t))*Math.sin(a(n))),s*(Math.cos(a(t))*Math.sin(a(n))),s*Math.cos(a(180-n))]}async function v(a,n,s){await i(n.spatialReference,a.spatialReference,null,s);const h=await o(n,a.spatialReference,s);let M=t(Math.atan2(h.y-a.y,h.x-a.x));return M=M>=0&&M<=90?90-M:M>90&&M<=180?360-M+90:90+Math.abs(M),M}export{l as calculateRotationMatrix,b as computeHFOVAndVFOV,R as convertHeadingPitchToSphereVertex,P as convertOrientationToPixelLocation,d as convertPixelToHeadingPitch,I as convertSphereVertexToOrientation,w as convertSphereVertexToPixelLocation,j as geographicToLTP,v as getInitialAngle,g as getPlaneLineIntersectionPoint,N as getWebMercatorScalingFactor,m as linearEquationSolve,q as ltpToGeographic,u as projectiveTransform,z as projectiveTransform2,f as scaleAndAddWithFactor,x as scaleWithFactor,y as transformMat3,p as transformMat4};
|
|
5
|
+
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{zeros as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{invertOrIdentity as M}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{initializeProjection as i,projectWithZConversion as o}from"../../../geometry/projection.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as c}from"../../../geometry/support/spatialReferenceUtils.js";import{defaultImageSphereSize as e}from"../../../widgets/PanoramicViewer/constants.js";function z(t,a,n){const[s,h,M,i]=a,[o,r,c,e]=n;return u(t,s,h,M,i,o,r,c,e)}function u(t,a,n,h,i,o,r,c,e){let z=!1;0===a.z&&0===n.z&&0===h.z&&0===i.z&&(a.z=n.z=h.z=i.z=1,t.z=1),a.z=a.z??1,n.z=n.z??1,h.z=h.z??1,i.z=i.z??1,0===o.z&&0===r.z&&0===c.z&&0===e.z&&(z=!0,o.z=r.z=c.z=e.z=1),o.z=o.z??1,r.z=r.z??1,c.z=c.z??1,e.z=e.z??1;const u=m(a,n,h,i),f=m(o,r,c,e),x=M(s(),u),y=s();y[0]=f[0]*x[0]+f[1]*x[4]+f[2]*x[8]+f[3]*x[12],y[1]=f[0]*x[1]+f[1]*x[5]+f[2]*x[9]+f[3]*x[13],y[2]=f[0]*x[2]+f[1]*x[6]+f[2]*x[10]+f[3]*x[14],y[3]=f[0]*x[3]+f[1]*x[7]+f[2]*x[11]+f[3]*x[15],y[4]=f[4]*x[0]+f[5]*x[4]+f[6]*x[8]+f[7]*x[12],y[5]=f[4]*x[1]+f[5]*x[5]+f[6]*x[9]+f[7]*x[13],y[6]=f[4]*x[2]+f[5]*x[6]+f[6]*x[10]+f[7]*x[14],y[7]=f[4]*x[3]+f[5]*x[7]+f[6]*x[11]+f[7]*x[15],y[8]=f[8]*x[0]+f[9]*x[4]+f[10]*x[8]+f[11]*x[12],y[9]=f[8]*x[1]+f[9]*x[5]+f[10]*x[9]+f[11]*x[13],y[10]=f[8]*x[2]+f[9]*x[6]+f[10]*x[10]+f[11]*x[14],y[11]=f[8]*x[3]+f[9]*x[7]+f[10]*x[11]+f[11]*x[15],y[12]=f[12]*x[0]+f[13]*x[4]+f[14]*x[8]+f[15]*x[12],y[13]=f[12]*x[1]+f[13]*x[5]+f[14]*x[9]+f[15]*x[13],y[14]=f[12]*x[2]+f[13]*x[6]+f[14]*x[10]+f[15]*x[14],y[15]=f[12]*x[3]+f[13]*x[7]+f[14]*x[11]+f[15]*x[15];const p=y[0]*t.x+y[1]*t.y+y[2]*t.z+y[3],l=y[4]*t.x+y[5]*t.y+y[6]*t.z+y[7],b=y[8]*t.x+y[9]*t.y+y[10]*t.z+y[11];let g=y[12]*t.x+y[13]*t.y+y[14]*t.z+y[15];return 0===g&&(g=1),{x:p/g,y:l/g,z:z?0:b/g}}function m(t,a,n,s){const h=p([s.x,s.y,s.z,1],M(new Array(16),[t.x,a.x,n.x,0,t.y,a.y,n.y,0,t.z,a.z,n.z,0,1,1,1,1])),i=h[0],o=h[1],r=h[2],c=new Array(16);return c[0]=i*t.x,c[1]=o*a.x,c[2]=r*n.x,c[3]=0,c[4]=i*t.y,c[5]=o*a.y,c[6]=r*n.y,c[7]=0,c[8]=i*t.z,c[9]=o*a.z,c[10]=r*n.z,c[11]=0,c[12]=i,c[13]=o,c[14]=r,c[15]=1,c}function f(t,a,n,s,M=h()){return M[0]=t[0]+a[0]*n,M[1]=t[1]+a[1]*n,M[2]=t[2]+a[2]*(n/s),M}function x(t,a,n){const s=h();return s[0]=t[0]*a,s[1]=t[1]*a,s[2]=t[2]*(a/n),s}function y(t,a){const[n,s,M]=t,i=h();return i[0]=n*a[0]+s*a[3]+M*a[6],i[1]=n*a[1]+s*a[4]+M*a[7],i[2]=n*a[2]+s*a[5]+M*a[8],i}function p(t,a){const[n,s,h,M]=t,i=new Array(4);return i[0]=n*a[0]+s*a[1]+h*a[2]+M*a[3],i[1]=n*a[4]+s*a[5]+h*a[6]+M*a[7],i[2]=n*a[8]+s*a[9]+h*a[10]+M*a[11],i[3]=n*a[12]+s*a[13]+h*a[14]+M*a[15],i}function l(t,a){const s=Math.PI/180,h=n();if("OPK"===t){const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(n)*Math.cos(M),h[1]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.sin(n)*Math.cos(M),h[2]=Math.sin(t)*Math.sin(M)-Math.cos(t)*Math.sin(n)*Math.cos(M),h[3]=-Math.cos(n)*Math.sin(M),h[4]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.sin(n)*Math.sin(M),h[5]=Math.sin(t)*Math.cos(M)+Math.cos(t)*Math.sin(n)*Math.sin(M),h[6]=Math.sin(n),h[7]=-Math.sin(t)*Math.cos(n),h[8]=Math.cos(t)*Math.cos(n)}else{const t=Number(a[0])*s,n=Number(a[1])*s,M=Number(a[2])*s;h[0]=Math.cos(t)*Math.cos(M)-Math.sin(t)*Math.cos(n)*Math.sin(M),h[1]=Math.sin(t)*Math.cos(M)*-1-Math.cos(t)*Math.cos(n)*Math.sin(M),h[2]=Math.sin(M)*Math.sin(n)*-1,h[3]=Math.cos(t)*Math.sin(M)+Math.sin(t)*Math.cos(n)*Math.cos(M),h[4]=Math.sin(t)*Math.sin(M)*-1+Math.cos(t)*Math.cos(n)*Math.cos(M),h[5]=Math.cos(M)*Math.sin(n),h[6]=Math.sin(t)*Math.sin(n)*-1,h[7]=Math.cos(t)*Math.sin(n)*-1,h[8]=Math.cos(n)}return h}function b(t,a,n){const s=Math.sin(n*Math.PI/180),h=Math.cos(n*Math.PI/180),M=[[t,0],[t,a],[0,a]];M.forEach(((t,a)=>{M[a]=[h*t[0]-s*t[1],s*t[0]+h*t[1]]}));const i={xmin:Math.min(0,M[0][0],M[1][0],M[2][0]),xmax:Math.max(0,M[0][0],M[1][0],M[2][0]),ymin:Math.min(0,M[0][1],M[1][1],M[2][1]),ymax:Math.max(0,M[0][1],M[1][1],M[2][1])};return{hfov:Math.abs(i.xmax-i.xmin),vfov:Math.abs(i.ymax-i.ymin)}}function g(t,a,n,s,h,M){const i=n*(a.x-t.x)+s*(a.y-t.y)+h*(a.z-t.z);if(0===i)return null;const o=-(n*t.x+s*t.y+h*t.z+M)/i;return{x:t.x+o*(a.x-t.x),y:t.y+o*(a.y-t.y),z:t.z+o*(a.z-t.z)}}function j(t,a){const n=Math.PI/180,s=t.y*n,h=t.x*n,M=t.z||0,i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=h-o,e=a[2]/Math.sqrt(1-a[3]*Math.sin(s)**2),z=a[3]*(r*Math.sin(i)-e*Math.sin(s));return{x:(e+M)*Math.cos(s)*Math.sin(c),y:(e+M)*(Math.sin(s)*Math.cos(i)-Math.sin(i)*Math.cos(s)*Math.cos(c))+z*Math.cos(i),z:(e+M)*(Math.sin(s)*Math.sin(i)+Math.cos(i)*Math.cos(s)*Math.cos(c))-r+z*Math.sin(i)}}function q(t,a){const n=Math.PI/180,s=Number(t.x),h=Number(t.y),M=Number(t.z),i=a[0]*n,o=a[1]*n,r=a[2]/Math.sqrt(1-a[3]*Math.sin(i)**2),c=s/r,e=h/r,z=M/r,u=Math.cos(i)-Math.sin(i)*e+Math.cos(i)*z,m=Math.sin(i)+Math.cos(i)*e+Math.sin(i)*z,f=Math.sqrt(u**2+c**2),x=a[3]*r*Math.sin(i),y=i,p=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(y)**2))*Math.sin(y))/(r*f)),l=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(p)**2))*Math.sin(p))/(r*f)),b=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(l)**2))*Math.sin(l))/(r*f)),g=Math.atan(m/f-(x-a[3]*(a[2]/Math.sqrt(1-a[3]*Math.sin(b)**2))*Math.sin(b))/(r*f)),j=Math.atan(s/(r*u))+o;return{x:j/n,y:g/n,z:s/(Math.cos(g)*Math.sin(j-o))-a[2]/Math.sqrt(1-a[3]*Math.sin(g)**2),spatialReference:{wkid:4326}}}function N(t){return t&&c(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}function d(t,a,n){const s=360/a,h=180/n;return{heading:(t.x-a/2)*s,pitch:90-(t.y-n/2)*h}}function w(t,a,n,s=e/2){const{heading:h,pitch:M}=I(t,s);return P(h,M,a,n)}function P(t,a,n,s){return{x:n/2+t/(360/n),y:s-a/(180/s),heading:t,pitch:a}}function I(a,n){const s=t(Math.acos(-a.z/n));return{heading:t(Math.atan2(a.x,a.y)),pitch:s}}function R(t,n,s=e/2){return[s*(Math.sin(a(t))*Math.sin(a(n))),s*(Math.cos(a(t))*Math.sin(a(n))),s*Math.cos(a(180-n))]}async function v(a,n,s){await i(n.spatialReference,a.spatialReference,null,s);const h=await o(n,a.spatialReference,s);let M=t(Math.atan2(h.y-a.y,h.x-a.x));return M=M>=0&&M<=90?90-M:M>90&&M<=180?360-M+90:90+Math.abs(M),M}function A(t,a,n){const s=Math.cos(n),h=Math.sin(n),M=[1,0,0,1,0,0],i=M[0]*s+M[2]*h,o=M[1]*s+M[3]*h,r=-M[0]*h+M[2]*s,c=-M[1]*h+M[3]*s;M[0]=i,M[1]=o,M[2]=r,M[3]=c;return[t*M[0]+a*M[2]+M[4],t*M[1]+a*M[3]+M[5]]}export{l as calculateRotationMatrix,b as computeHFOVAndVFOV,R as convertHeadingPitchToSphereVertex,P as convertOrientationToPixelLocation,d as convertPixelToHeadingPitch,I as convertSphereVertexToOrientation,w as convertSphereVertexToPixelLocation,j as geographicToLTP,v as getInitialAngle,g as getPlaneLineIntersectionPoint,N as getWebMercatorScalingFactor,m as linearEquationSolve,q as ltpToGeographic,u as projectiveTransform,z as projectiveTransform2,A as rotatePixel,f as scaleAndAddWithFactor,x as scaleWithFactor,y as transformMat3,p as transformMat4};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import"../../../geometry.js";import{deg2rad as t}from"../../../core/mathUtils.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{mul as e}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as i}from"../../../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as o,geographicToWebMercator as n}from"../../../geometry/support/webMercatorUtils.js";import c from"../core/cameraOrientationFactory.js";import{geographicToLTP as s,calculateRotationMatrix as m}from"./utils.js";import f from"../../../geometry/Point.js";function l(t,a){const{cameraOrientation:e,cameraLocation:r,pointsToTransform:i,rotationMatrix:o,scalingFactor:n}=g(t,a),c=new Array;return e?.isAdvanced?u(i,c,o,{...a,cameraOrientation:e,scalingFactor:n,cameraLocation:r}):h(i,c,o,{...a,cameraOrientation:e,scalingFactor:n,cameraLocation:r}),1===c.length?c[0]:c}function p(t,a,e){return l(t?a.map((t=>o(t))):a,e).map((t=>({...t,z:1})))}function u(t,a,e,r){const{cameraOrientation:i,cameraLocation:o,scalingFactor:n}=r,{principalOffsetPoint:c,focalLength:s,radialDistortionCoefficients:m,affineTransformations:f,tangentialDistortionCoefficients:l}=i;for(const p of t){const[t,r,u]=y(p,i,o,n),g=(e[0]*t+e[1]*r+e[2]*u)/(e[6]*t+e[7]*r+e[8]*u),h=(e[3]*t+e[4]*r+e[5]*u)/(e[6]*t+e[7]*r+e[8]*u),O=g**2+h**2;let d=0,x=0,M=0,b=0,R=0,j=0,F=0;m&&(d=m[0]??0,x=m[1]??0,M=m[2]??0),l&&(b=l[0],R=l[1]),c&&(j=c[0]??0,F=c[1]??0);const P=1+(d||0)*O+(x||0)*O*O+(M||0)*O*O*O;let z=g*P+(b||0)*(O+2*g**2)+2*(R||0)*g*h,L=h*P+(R||0)*(O+2*h**2)+2*(b||0)*g*h;z=-(s??0)*z+j,L=-(s??0)*L+F;const w=Number(f[0])+Number(f[1])*z+Number(f[2])*L,N=Number(f[3])+Number(f[4])*z+Number(f[5])*L;a.push({x:w,y:N})}}function g(t,a){const e=Array.isArray(t)||"items"in t?t:[t],r="string"==typeof a.cameraOrientation?c.getCameraOrientation(a.cameraOrientation):a.cameraOrientation,i=O({...a,cameraOrientation:r});let o=new f(a.cameraLocation);(o.spatialReference.isWGS84&&4!==r?.type||o.spatialReference.isGeographic)&&(o=n(o)),o.z||(o.z=a.cameraHeight);return{cameraOrientation:r,pointsToTransform:e,rotationMatrix:i,scalingFactor:d(o),cameraLocation:o}}function h(r,i,o,n){const{horizontalFieldOfView:c,verticalFieldOfView:s,cameraOrientation:m,cameraLocation:f,scalingFactor:l}=n,p=t(n.imageRotation??0),u=Math.sin(p),g=Math.cos(p),h=n.imageWidth||1,O=n.imageHeight||1,d=[Math.abs(g*h+u*O),Math.abs(g*O-u*h)],x={horizontal:1/(2*Math.tan(t(c)/2)),vertical:1/(2*Math.tan(t(s)/2))},M=a();M[0]=-x.horizontal,M[2]=.5,M[4]=x.vertical,M[5]=.5;const b=e(a(),o,M);for(const t of r){const[a,e,r]=y(t,m,f,l),o=(b[0]*a+b[1]*e+b[2]*r)/(b[6]*a+b[7]*e+b[8]*r),n=(b[3]*a+b[4]*e+b[5]*r)/(b[6]*a+b[7]*e+b[8]*r),c={x:o*d[0],y:n*d[1]};i.push({x:g*(c.x-d[0]/2)+u*(c.y-d[1]/2)+h/2,y:-u*(c.x-d[0]/2)+g*(c.y-d[1]/2)+O/2})}}function y(t,a,e,r){let i=new f(t);if(i.spatialReference.isGeographic)if(i.spatialReference.isWGS84&&4===a?.type){const{latitude:t,longitude:e,ellipsoidRadius:r,squaredEccentricity:o}=a;i=new f(s(i,[t,e,r,o]))}else i=n(i);const o=(i.z??0)-(e.z??0),c=(i.y-e.y)/r;return[(i.x-e.x)/r,c,o]}function O(t){const{cameraHeading:a,cameraPitch:e,cameraRoll:r,cameraOrientation:i}=t;if("OPK"===(i?.isAdvanced&&2===i.type?"OPK":"HPR")){const{omega:t,phi:a,kappa:e}=i;return m("OPK",[t,a,e])}return m("HPR",[a,e,r])}function d(t){return i(t?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t.y/r.radius))):1}export{d as getScalingFactor,l as worldToImage,p as worldToImageWithLTPFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveEditingEnabled as s,getEffectiveLayerCapabilities as a}from"./layerUtils.js";let
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveEditingEnabled as s,getEffectiveLayerCapabilities as a}from"./layerUtils.js";let n=class extends t{constructor(e){super(e),this.layer=null}get attachments(){return{enabled:this._effectiveEnabled&&!!this._effectiveCapabilities?.data.supportsAttachment}}get create(){const{_effectiveCapabilities:e,layer:t}=this,r=this._createEnabled,i=r,s=t.capabilities?.operations.supportsAdd,a=!!e?.operations.supportsAdd;return{attachments:{enabled:r&&this.attachments.enabled},attributes:r,enabled:r,geometry:i,reliesOnOwnerAdminPrivileges:!s&&a}}get delete(){const{_effectiveCapabilities:e,layer:t}=this,r=t.capabilities?.operations.supportsDelete,i=!!e?.operations.supportsDelete;return{enabled:this._effectiveEnabled&&!!e?.operations.supportsDelete,reliesOnOwnerAdminPrivileges:!r&&i}}get reliesOnOwnerAdminPrivileges(){return this._effectiveEnabled&&!this.layer.editingEnabled||this.create.reliesOnOwnerAdminPrivileges||this.update.reliesOnOwnerAdminPrivileges||this.delete.reliesOnOwnerAdminPrivileges}get update(){const{_effectiveCapabilities:e,layer:t}=this,r=this._updateEnabled,i=!(!r||!e?.editing.supportsGeometryUpdate),s=t.capabilities?.operations.supportsUpdate,a=!!e?.operations.supportsUpdate,n=this.attachments.enabled,p=n&&this._canCreateOrUpdate;return{attachments:{enabled:n,create:p,update:p},attributes:r,enabled:r,geometry:i,reliesOnOwnerAdminPrivileges:!s&&a}}get _createEnabled(){return this._effectiveEnabled&&!!this._effectiveCapabilities?.operations.supportsAdd}get _updateEnabled(){return this._effectiveEnabled&&!!this._effectiveCapabilities?.operations.supportsUpdate}get _canCreateOrUpdate(){return!(!this._createEnabled&&!this._updateEnabled)}get _effectiveEnabled(){return s(this.layer)}get _effectiveCapabilities(){return a(this.layer)}};e([r()],n.prototype,"attachments",null),e([r()],n.prototype,"create",null),e([r()],n.prototype,"delete",null),e([r()],n.prototype,"layer",void 0),e([r()],n.prototype,"reliesOnOwnerAdminPrivileges",null),e([r()],n.prototype,"update",null),e([r()],n.prototype,"_createEnabled",null),e([r()],n.prototype,"_updateEnabled",null),e([r()],n.prototype,"_canCreateOrUpdate",null),e([r()],n.prototype,"_effectiveEnabled",null),e([r()],n.prototype,"_effectiveCapabilities",null),n=e([i("esri.layers.support.EditingCapabilities")],n);const p=n;export{p as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON;if(void 0===e.layerId)return null;const n=t.hasContingentValuesDefinition;if(n)return new h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((t=>({name:t.name,isEditingRestrictive:t.isEditingRestrictive,fields:t.fieldNames.names.map((t=>e.fieldsIndex.normalizeFieldName(t)))})));return new h({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):[]}return 1===a.length&&n&&(o=[]),new p({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?null!=t&&null!=n?n<s.minValue?(i.push(new c({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new c({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new c({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new c({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups))}async _initializeContingentValues(e,t){const n=e??await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){if(void 0===this.layer.layerId)return[];const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=a(this.layer.url).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups))}async _fetchEnterpriseFieldGroup(e,t,n){return h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){if(void 0===this.layer.layerId)return[];const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n?.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n??[]){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r?.name));e&&(t=e.entries[t])}const u=r?.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e?.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=m.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=m.fromJSON(i)}return n||null}_findDomainByFieldName(e,t){const n=e.domains;if(n){const[e,i]=Object.entries(n).find((([e])=>e.trim().toLowerCase()===t.trim().toLowerCase()))||[];return i||null}return null}_getDomain(e,t){const n=e?this._findDomainByFieldName(e,t):this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import{isSome as n}from"../../core/arrayUtils.js";import{JSONSupportMixin as i}from"../../core/JSONSupport.js";import s from"../../core/Loadable.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{parse as a}from"./arcgisLayerUrl.js";import l from"./Contingency.js";import u from"./ContingencyConstraintViolation.js";import c from"./ContingentValue.js";import p from"./ContingentValuesResult.js";import d from"./FieldGroup.js";import{isStringField as f,isDateField as y}from"./fieldUtils.js";import m from"./Subtype.js";var h;let g=h=class extends(i(s)){constructor(e){super(e),this.request=t,this.fieldGroups=null,this.fieldGroupDefinitions=null}initialize(){}get subtypeFieldName(){const{layer:e}=this;return"subtype-group"===e.type?e.subtypeField:e.typeIdField}static async createLoadedLayerContingentValuesCache(e){await e.load();const t=e.sourceJSON;if(void 0===e.layerId)return null;const n=t.hasContingentValuesDefinition;if(n)return new h({layer:e}).load();if(void 0===n){const t=a(e.url);if(null==t)return null;const n=t.url.path;if((await h._staticFetchEnterpriseFeatureRoot(n)).supportsQueryDataElements){const t=e.layerId.toString(),i=await h._staticFetchEnterpriseFieldGroup(n,t);if(i){const t=i.map((t=>({name:t.name,isEditingRestrictive:t.isEditingRestrictive,fields:t.fieldNames.names.map((t=>e.fieldsIndex.normalizeFieldName(t)))})));return new h({layer:e,fieldGroupDefinitions:t}).load()}}}return null}async load(e){const t=this.layer.load(e).then((()=>this._initializeContingentValues(this.fieldGroupDefinitions,e)));return this.addResolvingPromise(t),this}validateContingencyConstraints(e,t){const n=Object.keys(e),i=[],s=[];for(const r of this.fieldGroups){const o=r.isEditingRestrictive?"error":"warning";if(t&&!r.fields.some((e=>t.includes(e))))continue;if(!r.fields.every((e=>n.includes(e)))){s.push(new u({fieldGroup:r,type:o}));continue}let a=!1;const l=e[this.subtypeFieldName],c=r.contingencies.filter((e=>!(!e.isRetired&&e.subtype)||e.subtype.code===l));for(const t of c){let n=!0;for(const i in t.values){const s=t.values[i];if("any"!==s.objectType)if("null"===s.objectType){if(null!=e[i]){n=!1;break}}else if("code"===s.objectType){if(e[i]!==s.codedValue.code){n=!1;break}}else if("range"===s.objectType){const t=e[i];if(t<s.minValue||t>s.maxValue){n=!1;break}}}if(n){a=!0;break}}a||i.push(new u({fieldGroup:r,type:o}))}return{invalid:i,incomplete:s}}getContingentValues(e,t,n=!1){const i=e[this.subtypeFieldName],s=null!=i,r={};let o=[];const a=this.fieldGroups.filter((e=>e.fields.includes(t)));o.push(new c({objectType:"any"}));for(const l of a){let a=[];const u=l.contingencies.filter((e=>!(e.isRetired||e.subtype&&s&&e.subtype.code!==i)));let c=!1;const p={};for(const n of u){let i,s=!0;for(const r in n.values){const o=n.values[r];if(t!==r){if(void 0!==e[r]&&"any"!==o.objectType)if("null"===o.objectType)null!==e[r]&&(s=!1);else if("code"===o.objectType)e[r]!==o.codedValue.code&&(s=!1);else if("range"===o.objectType){const t=e[r];(t<o.minValue||t>o.maxValue)&&(s=!1)}}else i=o,c=c||"range"===o.objectType}if(i&&s){if("any"===i.objectType){a.length=0,a.push(i);break}const e=this._generateKey(i);p[e]||a.push(i),p[e]=!0}}c&&(a=this._joinRange(a)),r[l.name]=a,o=n?this._filterIntersection(o,a):[]}return 1===a.length&&n&&(o=[]),new p({contingentValuesAllGroups:o,contingentValuesByFieldGroup:r})}_generateKey(e){switch(e.objectType){case"any":return"@any@";case"null":return"@null@";case"code":return e.codedValue.name+e.codedValue.code.toString();case"range":return e.minValue.toString()+"-"+e.maxValue.toString()}}_joinRange(e){let t,n;e.sort(((e,t)=>"null"===e.objectType?-1:"null"===t.objectType?1:e.minValue-t.minValue));const i=[];for(const s of e)"null"!==s.objectType?null!=t&&null!=n?n<s.minValue?(i.push(new c({objectType:"range",minValue:t,maxValue:n})),t=s.minValue,n=s.maxValue):n<s.maxValue&&(n=s.maxValue):(t=s.minValue,n=s.maxValue):i.push(s);return i.push(new c({objectType:"range",minValue:t,maxValue:n})),i}_filterIntersection(e,t){if(0===e.length||0===t.length)return[];if("any"===e[0].objectType)return t;if("any"===t[0].objectType)return e;const n="range"===e[0].objectType||"range"===e[1]?.objectType,i="range"===t[0].objectType||"range"===t[1]?.objectType;return n||i?this._intersectRanges(e,t):this._intersectValues(e,t)}_intersectRanges(e,t){const n=[];let i,s=0;for(const r of e)for(;s<t.length;s++){const e=t[s];if("null"===r.objectType&&"null"===e.objectType)n.push(new c({objectType:"null"}));else{if("null"===r.objectType)break;if("null"===e.objectType)continue}if(r.maxValue<e.minValue)break;if(r.maxValue===e.minValue){n.push(new c({objectType:"range",minValue:r.maxValue,maxValue:e.minValue}));break}if(!(r.minValue>e.maxValue))if(r.minValue!==e.maxValue){if(i=r.minValue>e.minValue?r.minValue:e.minValue,r.maxValue<e.maxValue){n.push(new c({objectType:"range",minValue:i,maxValue:r.maxValue}));break}n.push(new c({objectType:"range",minValue:i,maxValue:e.maxValue}))}else n.push(new c({objectType:"range",minValue:r.minValue,maxValue:e.maxValue}))}return n}_intersectValues(e,t){const n=[];for(const i of e)t.some((e=>{if(i.objectType===e.objectType)switch(i.objectType){case"any":case"null":return!0;case"code":return i.codedValue.code===e.codedValue.code&&i.codedValue.name===e.codedValue.name}return!1}))&&n.push(i);return n}static async _staticFetchEnterpriseFeatureRoot(e,n){return t(e,{responseType:"json",query:{f:"json"},...n}).then((e=>e.data))}static async _staticFetchEnterpriseFieldGroup(e,n,i){return t(`${e}/queryDataElements`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.layerDataElements?.[0].dataElement.fieldGroups??[]))}async _initializeContingentValues(e,t){const n=e??await this._fetchFieldGroupDefs(t);if(0===n.length)return void(this.fieldGroups=[]);const i=await this._fetchContingentValues(n,t);this.fieldGroups=i}async _fetchFieldGroupDefs(e){if(void 0===this.layer.layerId)return[];const t=this.layer.sourceJSON,n=this.layer.layerId.toString(),i=a(this.layer.url).url.path;if(t.hasContingentValuesDefinition){return(await this._fetchAGOLFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.restrictive,fields:e.fields.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return void 0!==t.hasContingentValuesDefinition?[]:this._fetchEnterpriseFeatureRoot(i,e).then((async t=>{if(t.supportsQueryDataElements){return(await this._fetchEnterpriseFieldGroup(i,n,e)).map((e=>({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fieldNames.names.map((e=>this.layer.fieldsIndex.normalizeFieldName(e)))})))}return[]}))}async _fetchAGOLFieldGroup(e,n,i){return t(`${e}/${n}/fieldgroups`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data.fieldGroups??[]))}async _fetchEnterpriseFieldGroup(e,t,n){return h._staticFetchEnterpriseFieldGroup(e,t,n)}async _fetchEnterpriseFeatureRoot(e,t){return h._staticFetchEnterpriseFeatureRoot(e,t)}async _fetchContingentValues(e,t){if(void 0===this.layer.layerId)return[];const n=this.layer.sourceJSON,i=this.layer.layerId.toString(),s=a(this.layer.url).url.path;if(n.hasContingentValuesDefinition){const n=await this._fetchAGOLContingentValues(s,i,t);return this._constructFieldGroupsAGOL(e,n)}const r=await this._fetchEnterpriseContingentValues(s,i,t);return this._constructFieldGroupsEnterprise(e,r)}_constructFieldGroupsAGOL(e,t){return e.map((e=>{const n=t.contingentValuesDefinition.fieldGroups.find((t=>t.name===e.name));if(n){let i=[];return i=t.contingentValuesDefinition.hasSubType?this._parseAGOLFieldGroupSubtype(e,t,n.subTypes):this._parseAGOLFieldGroup(e,t,n.contingentValues),new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}_parseAGOLFieldGroupSubtype(e,t,n){let i=[];return n?.forEach((n=>{const s=this._getSubtypeAGOL(n.name);i=i.concat(this._parseAGOLFieldGroup(e,t,n.contingentValues,s))})),i}_parseAGOLFieldGroup(e,t,n,i=null){const s=[];for(const r of n??[]){const n=this._parseAGOLContingency(r,e,t,i);s.push(n)}return s}_parseAGOLContingency(e,t,n,i){const s=e.id,r=!!e.retired&&1===e.retired,o={};for(let a=0,l=0;a<t.fields.length;a++){const s=t.fields[a],r=n.typeCodes[e.types[a]];if("Code"===r){let t=e.values[l];l++;const r=this._getDomain(i,s),a=this.layer.getField(s);if("string"===a?.type){const e=n.stringDicts.find((e=>e.domain===r?.name));e&&(t=e.entries[t])}const u=r?.codedValues.find((e=>e.code===t)),p=new c({codedValue:u,objectType:"code"});o[s]=p}else if("Range"===r){const t=e.values[l];l++;const n=t.range[0],i=t.range[1],r=new c({minValue:n,maxValue:i,objectType:"range"});o[s]=r}else if("Any"===r){const e=new c({objectType:"any"});o[s]=e}else{const e=new c({objectType:"null"});o[s]=e}}return new l({id:s,isRetired:r,subtype:i,values:o})}_constructFieldGroupsEnterprise(e,t){const i=t.fieldGroups;return e.map((e=>{const n=i.find((t=>t.name===e.name));if(n){const i=n.contingencies.map((n=>{const i=n.id,s=n.isRetired||!1,r=this._getSubtypeEnterprise(n.subtypeCode),o={};for(let a=0;a<e.fields.length;a++){const i=e.fields[a];let s=n.values[a];if("number"==typeof s||"string"==typeof s){const e=this._getDomain(r,i),n=this.layer.getField(i);if(f(n))s=t.stringDictionary[s];else if(y(n)){const e=new Date(`${s}+00:00`);s=e.getTime()}const a=e?.codedValues.find((e=>e.code===s)),l=new c({codedValue:a,objectType:"code"});o[i]=l}else if("object"==typeof s){const e=s.minValue,t=s.maxValue,n=new c({minValue:e,maxValue:t,objectType:"range"});o[i]=n}else if(s){const e=new c({objectType:"any"});o[i]=e}else{const e=new c({objectType:"null"});o[i]=e}}return new l({id:i,isRetired:s,subtype:r,values:o})}));return new d({name:e.name,isEditingRestrictive:e.isEditingRestrictive,fields:e.fields,contingencies:i})}return null})).filter(n)}async _fetchEnterpriseContingentValues(e,n,i){return t(`${e}/queryContingentValues`,{responseType:"json",query:{layers:JSON.stringify([n]),f:"json"},...i}).then((e=>e.data.contingentValueSets?.[0]))}async _fetchAGOLContingentValues(e,n,i){return t(`${e}/${n}/contingentValues`,{responseType:"json",query:{f:"json"},...i}).then((e=>e.data))}_getSubtypeEnterprise(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.code===e));n=m.fromJSON(i)}return n||null}_getSubtypeAGOL(e){const t=this.layer.sourceJSON;let n;if(t.subtypes){const i=t.subtypes.find((t=>t.name===e));n=m.fromJSON(i)}return n||null}_findDomainByFieldName(e,t){const n=e.domains;if(n){const[e,i]=Object.entries(n).find((([e])=>e.trim().toLowerCase()===t.trim().toLowerCase()))||[];return i||null}return null}_getDomain(e,t){const n=e?this._findDomainByFieldName(e,t):this.layer.getFieldDomain(t);return"inherited"===n?.type?this.layer.getFieldDomain(t):n}};e([r({constructOnly:!0})],g.prototype,"layer",void 0),e([r({constructOnly:!0})],g.prototype,"request",void 0),e([r({type:[d]})],g.prototype,"fieldGroups",void 0),e([r({constructOnly:!0})],g.prototype,"fieldGroupDefinitions",void 0),e([r()],g.prototype,"subtypeFieldName",null),g=h=e([o("esri.layers.support.LayerContingentValuesCache")],g);const V=g;export{V as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import{getEffectiveLayerCapabilities as t,getEffectiveEditingEnabled as e}from"./layerUtils.js";function i(i){return!(!(i&&"object"==typeof i&&"loaded"in i&&i.loaded&&t(i)?.operations?.supportsEditing&&"type"in i)||"editingEnabled"in i&&!e(i))}export{i as isEditableLayer};
|
package/package.json
CHANGED
package/rest/print.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../kernel.js";import t from"../request.js";import i from"../core/Error.js";import{JSONMap as r}from"../core/jsonMap.js";import{createScreenPoint as a,pt2px as n,px2pt as s}from"../core/screenUtils.js";import{normalize as o,dataComponents as l}from"../core/urlUtils.js";import c from"../geometry/Polygon.js";import{collectLabelingFields as u}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as y}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as p}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as f,getToken as m}from"./utils.js";import{execute as d}from"./geoprocessor/execute.js";import{submitJob as g}from"./geoprocessor/submitJob.js";import{toJSON as b}from"./support/fileFormat.js";import{toJSON as h}from"./support/layoutTemplate.js";import{getVisibleLayerViews as w,isScreenshotRequired as S,isBingMapsLayer as x,isCSVLayer as v,isBlendLayer as I,applyVisualVariables as D,getContextBoundingBox as L,createPolygonLayer as T,createPolylineLayer as O,createPointLayer as E,createMultipointLayer as M}from"./support/printTaskUtils.js";import V from"./support/PrintTemplate.js";import{toJSON as P}from"./support/reportTemplate.js";const F={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},R=new r({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),N=new r({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),J=new Map;async function U(e,i,r){const a=k(e);let n=J.get(a);return Promise.resolve().then((()=>n?{data:n.gpMetadata}:(n={gpServerUrl:a,is11xService:!1,legendLayerNameMap:{},legendLayers:[]},t(a,f({f:"json"},r))))).then((e=>(n.gpMetadata=e.data,n.cimVersion=n.gpMetadata.cimVersion,n.is11xService=!!n.cimVersion,J.set(a,n),C(i,n)))).then((t=>{const a=pe(n);let s;const o=e=>"sync"===a?e.results?.[0]?.value:s.fetchResultData("Output_File",null,r).then((e=>e.value));return"async"===a?g(e,t,void 0,r).then((e=>(s=e,e.waitForJobCompletion({interval:i.updateDelay}).then(o)))):d(e,t,void 0,r).then(o)}))}async function j(e){const t=k(e);return pe(J.get(t))}async function C(t,r){r=r||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const a=t.template||new V;null==a.showLabels&&(a.showLabels=!0);const n=a.exportOptions;let s;const o=h(a.layout);if(n){if(s={dpi:n.dpi},"map_only"===o.toLowerCase()||""===o){const e=n.width,t=n.height;s.outputSize=null!=e&&null!=t?[e,t]:void 0}}const l=a.layoutOptions;let c;if(l){let e,t;"Miles"===l.scalebarUnit||"Kilometers"===l.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==l.scalebarUnit&&"Feet"!==l.scalebarUnit||(e="Meters",t="Feet"),c={titleText:l.titleText,authorText:l.authorText,copyrightText:l.copyrightText,customTextElements:l.customTextElements,elementOverrides:l.elementOverrides,scaleBarOptions:{metricUnit:R.toJSON(e),metricLabel:e?F[e]:void 0,nonMetricUnit:R.toJSON(t),nonMetricLabel:t?F[t]:void 0}}}let u=null;l?.legendLayers&&(u=l.legendLayers.map((e=>{const t=e.layerId;r.legendLayerNameMap[t]=e.title;const i={id:t};return e.subLayerIds&&(i.subLayerIds=e.subLayerIds),i})));const y=await A(t,a,r);if(y.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,a=i=>{const r=i.text,a=i.font,n=a?.family?.toLowerCase();r&&a&&("arial"===n||"arial unicode ms"===n)&&(a.family=e.test(r)?"Arial Unicode MS":"Arial","normal"!==a.style&&t.test(r)&&(a.family="Arial Unicode MS"))},n=()=>{throw new i("print:cim-symbol-unsupported","CIMSymbol is not supported by a print service published from ArcMap")};for(const i of y.operationalLayers)if(i.featureCollection?.layers)for(const e of i.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type?a(t.symbol):"CIMSymbolReference"!==t.symbol.type||r.is11xService||n()}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&("esriTS"===t.symbol.type?a(t.symbol):"CIMSymbolReference"!==t.symbol.type||r.is11xService||n())}else!r.is11xService&&i.layerDefinition?.drawingInfo?.renderer&&JSON.stringify(i.layerDefinition.drawingInfo.renderer).includes('"type":"CIMSymbolReference"')&&n()}t.outSpatialReference&&(y.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(y,{exportOptions:s,layoutOptions:c||{}}),Object.assign(y.layoutOptions,{legendOptions:{operationalLayers:null!=u?u:r.legendLayers.slice()}}),r.legendLayers.length=0,J.set(r.gpServerUrl,r);const p={Web_Map_as_JSON:JSON.stringify(y),Format:b(a.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:P(a.report),Report_Item_ID:void 0};if(a.layoutItem){delete p.Layout_Template;const t=a.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(r.gpServerUrl),p.Layout_Item_ID=JSON.stringify({id:t.id})}if(a.reportItem){delete p.Report_Template;const t=a.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(r.gpServerUrl),p.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(p,t.extraParameters),p}async function A(e,t,i){const r=e.view;let a=r.spatialReference;const n={operationalLayers:await _(r,t,i)};t.includeTables&&(n.tables=await ie(r));let s=i.ssExtent||e.extent||r.extent;if(a&&a.isWrappable&&(s=s.clone()._normalize(!0),a=s.spatialReference),n.mapOptions={extent:s&&s.toJSON(),spatialReference:a&&a.toJSON(),showAttribution:t.attributionVisible},i.ssExtent=null,r.background&&(n.background=r.background.toJSON()),r.rotation&&(n.mapOptions.rotation=-r.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||r.scale),null!=r.timeExtent){const e=null!=r.timeExtent.start?r.timeExtent.start.getTime():null,t=null!=r.timeExtent.end?r.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function k(e){let t=e;const i=t.lastIndexOf("/GPServer/");return i>0&&(t=t.slice(0,i+9)),t}async function _(e,t,i){const r=[],a={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const s=w(e,n);for(const o of s){const e=o.layer;if(!e.loaded||"group"===e?.type)continue;let t;a.layerView=o,t=S(o)?await ee(e,a,i):x(e)?z(e):v(e)?await $(e,a,i):"feature"===e?.type?await W(e,a,i):"geojson"===e?.type?await q(e,a,i):"graphics"===e?.type?await B(e,a,i):"imagery"===e?.type?G(e,i):"imagery-tile"===e?.type?await Q(e,a,i):"kml"===e?.type?await H(e,a,i):"map-image"===e?.type?X(e,a,i):"map-notes"===e?.type?await Y(a,i):"open-street-map"===e?.type?Z():"stream"===e?.type?await te(e,a,i):"tile"===e?.type?re(e,i):"vector-tile"===e?.type?await ae(e,a,i):"web-tile"===e?.type?ne(e):"wms"===e?.type?se(e,i):"wmts"===e?.type?oe(e):await ee(e,a,i),t&&(Array.isArray(t)?r.push(...t):(t.id=e.id,t.title=i.legendLayerNameMap[e.id]||e.title,t.opacity=o.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,I(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),r.push(t)))}if(n)for(const o of r)o.minScale=0,o.maxScale=0;if(e.graphics?.length){const a=await K(null,e.graphics,t,i);a&&r.push(a)}return r}function z(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function $(e,t,i){e.legendEnabled&&i.legendLayers.push({id:e.id});const r=t.layerView,a=t.printTemplate;let n;if(!i.is11xService||r.filter||e.portalItem&&"public"!==e.portalItem.access){return K(e,await ye(r),a,i)}return n={type:"CSV"},e.write(n,{origin:"web-map"}),delete n.popupInfo,delete n.layerType,n.showLabels=a.showLabels&&e.labelsVisible,n}async function K(e,t,i,r){let a;const n=T(),s=O(),o=E(),l=M(),y=E();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=s.layerDefinition.name=o.layerDefinition.name=l.layerDefinition.name=r.legendLayerNameMap[e.id]||e.get("arcgisProps.title")||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),i=n.layerDefinition.drawingInfo;i&&(i.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const a=o.layerDefinition.drawingInfo;a&&(a.renderer=t);const c=l.layerDefinition.drawingInfo;c&&(c.renderer=t)}if(i.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=e.write({},{origin:"web-map"}),i=t.layerDefinition?.drawingInfo?.labelingInfo;if(i){a=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=i);const t=s.layerDefinition.drawingInfo;t&&(t.labelingInfo=i);const r=o.layerDefinition.drawingInfo;r&&(r.labelingInfo=i);const c=l.layerDefinition.drawingInfo;c&&(c.labelingInfo=i)}}}let p;e?.renderer||a||(delete n.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete l.layerDefinition.drawingInfo);const f=e?.fieldsIndex,m=e?.renderer;if(f){const t=new Set;a&&await u(t,e),m&&"function"==typeof m.collectRequiredFields&&await m.collectRequiredFields(t,f),p=Array.from(t);const i=f.fields.map((e=>e.toJSON()));n.layerDefinition.fields=i,s.layerDefinition.fields=i,o.layerDefinition.fields=i,l.layerDefinition.fields=i}const d=t?.length;let g;for(let u=0;u<d;u++){const a=t[u]||t.at(u);if(!1===a.visible||!a.geometry)continue;if(g=a.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol?.outline&&"esriCLS"===g.symbol.outline.type&&!r.is11xService)continue;!r.is11xService&&g.symbol?.outline?.color?.[3]&&(g.symbol.outline.color[3]=255);const f=e?.renderer&&("valueExpression"in e.renderer&&e.renderer.valueExpression||"hasVisualVariables"in e.renderer&&e.renderer.hasVisualVariables());if(!g.symbol&&e?.renderer&&f&&!r.is11xService){const t=e.renderer,i=await t.getSymbolAsync(a);if(!i)continue;g.symbol=i.toJSON(),"hasVisualVariables"in t&&t.hasVisualVariables()&&D(g.symbol,{renderer:t,graphic:a,symbol:i})}if(g.symbol&&(g.symbol.angle||delete g.symbol.angle,fe(g.symbol)?g.symbol=await ce(g.symbol,r):g.symbol.text&&delete g.attributes),(!i||!i.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===a.geometry.type?n.featureSet.features.push(g):"polyline"===a.geometry.type?s.featureSet.features.push(g):"point"===a.geometry.type?g.symbol?.text?y.featureSet.features.push(g):o.featureSet.features.push(g):"multipoint"===a.geometry.type?l.featureSet.features.push(g):"extent"===a.geometry.type&&(g.geometry=c.fromExtent(a.geometry).toJSON(),n.featureSet.features.push(g))}const b=[n,s,l,o,y].filter((e=>e.featureSet.features.length>0));for(const c of b){const e=c.featureSet.features.every((e=>e.symbol));if(e&&(!i||!i.forceFeatureAttributes))for(const t of c.featureSet.features)delete t.attributes;e&&delete c.layerDefinition.drawingInfo,c.layerDefinition.drawingInfo?.renderer&&await ue(c.layerDefinition.drawingInfo.renderer,r)}return b.length?{featureCollection:{layers:b},showLabels:a}:null}async function W(e,t,i){let r;const a=e.renderer,n=parseFloat(i.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&(!i.is11xService||n<2.9)||"pie-chart"===a?.type||"dot-density"===a?.type&&(!i.is11xService||n<2.6))return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const s=t.layerView,{printTemplate:o,view:l}=t,c=a&&("valueExpression"in a&&a.valueExpression||"hasVisualVariables"in a&&a.hasVisualVariables()),u="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(!i.is11xService&&c||s.filter||u||!a||"field"in a&&null!=a.field&&("string"!=typeof a.field||!e.getField(a.field))){const t=await ye(s);r=await K(e,t,o,i)}else{if(r={id:(f=e.write()).id,title:f.title,url:f.url,layerType:f.layerType,customParameters:f.customParameters,layerDefinition:f.layerDefinition,charts:o.includeCharts?f.charts:void 0},r.showLabels=o.showLabels&&e.labelsVisible,le(r,e),r.layerDefinition?.drawingInfo?.renderer&&(delete r.layerDefinition.minScale,delete r.layerDefinition.maxScale,await ue(r.layerDefinition.drawingInfo.renderer,i),"visualVariables"in a&&a.visualVariables&&a.visualVariables[0])){const e=a.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=p(e,l.scale);r.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,r.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=y(s);t&&(r.layerDefinition||(r.layerDefinition={}),r.layerDefinition.definitionExpression=r.layerDefinition.definitionExpression?`(${r.layerDefinition.definitionExpression}) AND (${t})`:t)}var f;return r}async function q(e,t,i){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});return K(e,await ye(t.layerView),t.printTemplate,i)}async function B(e,{printTemplate:t},i){return K(e,null,t,i)}function G(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(r=e.write()).layerType,customParameters:r.customParameters};var r;if(i.bandIds=e.bandIds,i.compressionQuality=e.compressionQuality,i.format=e.format,i.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(i.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction||e.renderer)if(t.is11xService)e.rasterFunction&&(i.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(i.layerDefinition=i.layerDefinition||{},i.layerDefinition.drawingInfo=i.layerDefinition.drawingInfo||{},i.layerDefinition.drawingInfo.renderer=e.renderer.toJSON());else{const t=e.exportImageServiceParameters.combineRendererWithRenderingRule();t&&(i.renderingRule=t.toJSON())}return le(i,e),i}async function Q(e,t,i){if("flow"===e.renderer?.type)return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const r={bandIds:(a=e.write()||{}).bandIds,customParameters:a.customParameters,interpolation:a.interpolation,layerDefinition:a.layerDefinition};var a;return r.layerType="ArcGISImageServiceLayer",le(r,e),r}async function H(e,t,i){const r=t.printTemplate;if(i.is11xService){const t={type:"kml"};return e.write(t,{origin:"web-map"}),delete t.layerType,t.url=o(e.url),t}const a=[],n=t.layerView;n.allVisibleMapImages.forEach(((t,i)=>{const r={id:`${e.id}_image${i}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};"data:image/png;base64,"===t.href.substr(0,22)?r.imageData=t.href.substr(22):r.url=t.href,a.push(r)}));const s=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],l={id:e.id,...await K(null,s,r,i)};return a.push(l),a}function X(e,{view:t},i){let r;const a={id:e.id,subLayerIds:[]};let n=[];const s=t.scale,o=e=>{const t=0===s,i=0===e.minScale||s<=e.minScale,r=0===e.maxScale||s>=e.maxScale;if(e.visible&&(t||i&&r))if(e.sublayers)e.sublayers.forEach(o);else{const t=e.toExportImageJSON(),i={id:e.id,name:e.title,layerDefinition:{drawingInfo:t.drawingInfo,definitionExpression:t.definitionExpression,source:t.source}};n.unshift(i),a.subLayerIds.push(e.id)}};var l;return e.sublayers&&e.sublayers.forEach(o),n.length&&(n=n.map((({id:e,name:t,layerDefinition:i})=>({id:e,name:t,layerDefinition:i}))),r={layerType:(l=e.write()).layerType,customParameters:l.customParameters},r.layers=n,r.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:a.subLayerIds,le(r,e),e.legendEnabled&&i.legendLayers.push(a)),r}async function Y({layerView:e,printTemplate:t},i){const r=[],a=e.layer;if(null!=a.featureCollections)for(const n of a.featureCollections){const e=await K(n,n.source,t,i);e&&r.push(...e.featureCollection.layers)}else if(null!=a.sublayers)for(const n of a.sublayers){const e=await K(null,n.graphics,t,i);e&&r.push(...e.featureCollection.layers)}return{featureCollection:{layers:r}}}function Z(){return{type:"OpenStreetMap"}}async function ee(e,{printTemplate:t,view:i},r){const n={type:"image"},s={format:"png",ignoreBackground:!0,layers:[e],rotation:0},o=r.ssExtent||i.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==i.width%2),null!=e.height&&e.height>0&&(y=e.height%2==i.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===i.scale)&&96===c&&(!u||!y)&&(s.area={x:0,y:0,width:i.width,height:i.height},u||(s.area.width-=1),y||(s.area.height-=1),!r.ssExtent)){const e=i.toMap(a(s.area.width,s.area.height));o.ymin=e.y,o.xmax=e.x,r.ssExtent=o}n.extent=o.clone()._normalize(!0).toJSON();const p=await i.takeScreenshot(s);return n.imageData=l(p.dataUrl)?.data,n}async function te(e,{layerView:t,printTemplate:i},r){e.legendEnabled&&r.legendLayers.push({id:e.id});return K(e,await ye(t),i,r)}async function ie(e){const t=[],i=[];for(const a of e.map.allTables)"feature"!==a.type||a.loaded||i.push(a.load());i.length&&await Promise.allSettled(i);for(const a of e.map.allTables)if("feature"===a.type&&a.loaded&&a.isTable&&"feature-layer"===a.source?.type){const e={id:(r=a.write()).id,title:r.title,customParameters:r.customParameters,layerDefinition:{definitionExpression:r.layerDefinition?.definitionExpression},url:r.url};le(e,a),t.push(e)}var r;return t.length?t:void 0}function re(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(r=e.write()).layerType,customParameters:r.customParameters};var r;return le(i,e),i}async function ae(e,t,i){if(i.is11xService&&e.serviceUrl&&e.styleUrl){const t=m(e.styleUrl,e.apiKey),r=m(e.serviceUrl,e.apiKey);if(!t&&!r||"2.1.0"!==i.cimVersion){const i={type:"VectorTileLayer"};return i.styleUrl=o(e.styleUrl),i.token=t,r!==t&&(i.additionalTokens=[{url:e.serviceUrl,token:r}]),i}}return ee(e,t,i)}function ne(e){const t=e.urlTemplate?.replace(/\${/g,"{"),i={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(i.subDomains=e.subDomains),i}function se(e,t){let i;const r=[],a=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(a):e.name&&r.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(a),r.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:r}),i={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:r,url:o(e.url),version:e.version}),i}function oe(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:o(e.url)}}function le(e,t){t.url&&(e.url=o(e.url||t.url),e.token=m(e.url,t.apiKey))}async function ce(e,i){i.canvas||(i.canvas=document.createElement("canvas"));const r=1024;i.canvas.width=r,i.canvas.height=r;const a=i.canvas.getContext("2d");let o,l;if(e.path){const t=new Path2D(e.path);t.closePath(),a.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",a.fill(t);const i=L(a);if(!i)return null;a.clearRect(0,0,r,r);const s=n(e.size)/Math.max(i.width,i.height);a.scale(s,s);const c=r/s,u=c/2-i.width/2-i.x,y=c/2-i.height/2-i.y;if(a.translate(u,y),Array.isArray(e.color)&&a.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const r=e.outline;a.lineWidth=n(r.width)/s,a.lineJoin="round",a.strokeStyle=`rgba(${r.color[0]},${r.color[1]},${r.color[2]},${r.color[3]/255})`,a.stroke(t),i.width+=a.lineWidth,i.height+=a.lineWidth}i.width*=s,i.height*=s;const p=a.getImageData(r/2-i.width/2,r/2-i.height/2,Math.ceil(i.width),Math.ceil(i.height));o=p.width,l=p.height,a.canvas.width=o,a.canvas.height=l,a.putImageData(p,0,0)}else{const i="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,r=(await t(i,{responseType:"image"})).data;o=n(e.width),l=n(e.height),a.canvas.width=o,a.canvas.height=l,a.drawImage(r,0,0,a.canvas.width,a.canvas.height)}return{type:"esriPMS",imageData:a.canvas.toDataURL("image/png").substr(22),angle:e.angle,contentType:"image/png",height:s(l),width:s(o),xoffset:e.xoffset,yoffset:e.yoffset}}async function ue(e,t){const i=e.type;if("simple"===i&&fe(e.symbol))e.symbol=await ce(e.symbol,t);else if("uniqueValue"===i||"classBreaks"===i){fe(e.defaultSymbol)&&(e.defaultSymbol=await ce(e.defaultSymbol,t));const r=e["uniqueValue"===i?"uniqueValueInfos":"classBreakInfos"];if(r)for(const e of r)fe(e.symbol)&&(e.symbol=await ce(e.symbol,t))}}async function ye(e){return e.queryFeatures(e.createQuery()).then((e=>e.features))}function pe(e){return e.gpMetadata?.executionType?N.fromJSON(e.gpMetadata.executionType):"sync"}function fe(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{U as execute,C as getGpPrintParams,k as getGpServerUrl,j as getMode,J as printCacheMap};
|
|
5
|
+
import{id as e}from"../kernel.js";import t from"../request.js";import i from"../core/Error.js";import{JSONMap as r}from"../core/jsonMap.js";import{createScreenPoint as a,pt2px as n,px2pt as s}from"../core/screenUtils.js";import{normalize as o,dataComponents as l}from"../core/urlUtils.js";import c from"../geometry/Polygon.js";import{collectLabelingFields as u}from"../layers/support/fieldUtils.js";import{getFloorFilterClause as y}from"../layers/support/floorFilterUtils.js";import{getSizeRangeAtScale as p}from"../renderers/visualVariables/support/visualVariableUtils.js";import{asValidOptions as f,getToken as d}from"./utils.js";import{execute as m}from"./geoprocessor/execute.js";import{submitJob as g}from"./geoprocessor/submitJob.js";import{toJSON as h}from"./support/fileFormat.js";import{toJSON as b}from"./support/layoutTemplate.js";import{getVisibleLayerViews as w,isScreenshotRequired as S,isBingMapsLayer as x,isCSVLayer as v,isBlendLayer as I,applyVisualVariables as D,getContextBoundingBox as L,createPolygonLayer as T,createPolylineLayer as O,createPointLayer as E,createMultipointLayer as M}from"./support/printTaskUtils.js";import V from"./support/PrintTemplate.js";import{toJSON as P}from"./support/reportTemplate.js";const F={Feet:"ft",Kilometers:"km",Meters:"m",Miles:"mi"},R=new r({esriFeet:"Feet",esriKilometers:"Kilometers",esriMeters:"Meters",esriMiles:"Miles"}),N=new r({esriExecutionTypeSynchronous:"sync",esriExecutionTypeAsynchronous:"async"}),J=new Map;async function U(e,i,r){const a=k(e);let n=J.get(a);return Promise.resolve().then((()=>n?{data:n.gpMetadata}:(n={gpServerUrl:a,is11xService:!1,legendLayerNameMap:{},legendLayers:[]},t(a,f({f:"json"},r))))).then((e=>(n.gpMetadata=e.data,n.cimVersion=n.gpMetadata.cimVersion,n.is11xService=!!n.cimVersion,J.set(a,n),C(i,n)))).then((t=>{const a=pe(n);let s;const o=e=>"sync"===a?e.results?.[0]?.value:s.fetchResultData("Output_File",null,r).then((e=>e.value));return"async"===a?g(e,t,void 0,r).then((e=>(s=e,e.waitForJobCompletion({interval:i.updateDelay}).then(o)))):m(e,t,void 0,r).then(o)}))}async function j(e){const t=k(e);return pe(J.get(t))}async function C(t,r){r=r||{is11xService:!1,legendLayerNameMap:{},legendLayers:[]};const a=t.template||new V;null==a.showLabels&&(a.showLabels=!0);const n=a.exportOptions;let s;const o=b(a.layout);if(n){if(s={dpi:n.dpi},"map_only"===o.toLowerCase()||""===o){const e=n.width,t=n.height;s.outputSize=null!=e&&null!=t?[e,t]:void 0}}const l=a.layoutOptions;let c;if(l){let e,t;"Miles"===l.scalebarUnit||"Kilometers"===l.scalebarUnit?(e="Kilometers",t="Miles"):"Meters"!==l.scalebarUnit&&"Feet"!==l.scalebarUnit||(e="Meters",t="Feet"),c={titleText:l.titleText,authorText:l.authorText,copyrightText:l.copyrightText,customTextElements:l.customTextElements,elementOverrides:l.elementOverrides,scaleBarOptions:{metricUnit:R.toJSON(e),metricLabel:e?F[e]:void 0,nonMetricUnit:R.toJSON(t),nonMetricLabel:t?F[t]:void 0}}}let u=null;l?.legendLayers&&(u=l.legendLayers.map((e=>{const t=e.layerId;r.legendLayerNameMap[t]=e.title;const i={id:t};return e.subLayerIds&&(i.subLayerIds=e.subLayerIds),i})));const y=await A(t,a,r);if(y.operationalLayers){const e=new RegExp("[\\u4E00-\\u9FFF\\u0E00-\\u0E7F\\u0900-\\u097F\\u3040-\\u309F\\u30A0-\\u30FF\\u31F0-\\u31FF]"),t=/[\u0600-\u06FF]/,a=i=>{const r=i.text,a=i.font,n=a?.family?.toLowerCase();r&&a&&("arial"===n||"arial unicode ms"===n)&&(a.family=e.test(r)?"Arial Unicode MS":"Arial","normal"!==a.style&&t.test(r)&&(a.family="Arial Unicode MS"))},n=()=>{throw new i("print:cim-symbol-unsupported","CIMSymbol is not supported by a print service published from ArcMap")};for(const i of y.operationalLayers)if(i.featureCollection?.layers)for(const e of i.featureCollection.layers){if(e.layerDefinition?.drawingInfo?.renderer?.symbol){const t=e.layerDefinition.drawingInfo.renderer;"esriTS"===t.symbol.type?a(t.symbol):"CIMSymbolReference"!==t.symbol.type||r.is11xService||n()}if(e.featureSet?.features)for(const t of e.featureSet.features)t.symbol&&("esriTS"===t.symbol.type?a(t.symbol):"CIMSymbolReference"!==t.symbol.type||r.is11xService||n())}else!r.is11xService&&i.layerDefinition?.drawingInfo?.renderer&&JSON.stringify(i.layerDefinition.drawingInfo.renderer).includes('"type":"CIMSymbolReference"')&&n()}t.outSpatialReference&&(y.mapOptions.spatialReference=t.outSpatialReference.toJSON()),Object.assign(y,{exportOptions:s,layoutOptions:c||{}}),Object.assign(y.layoutOptions,{legendOptions:{operationalLayers:null!=u?u:r.legendLayers.slice()}}),r.legendLayers.length=0,J.set(r.gpServerUrl,r);const p={Web_Map_as_JSON:JSON.stringify(y),Format:h(a.format),Layout_Template:o,Layout_Item_ID:void 0,Report_Template:P(a.report),Report_Item_ID:void 0};if(a.layoutItem){delete p.Layout_Template;const t=a.layoutItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(r.gpServerUrl),p.Layout_Item_ID=JSON.stringify({id:t.id})}if(a.reportItem){delete p.Report_Template;const t=a.reportItem;await t.load(),"public"!==t.access&&e&&await e.getCredential(r.gpServerUrl),p.Report_Item_ID=JSON.stringify({id:t.id})}return t.extraParameters&&Object.assign(p,t.extraParameters),p}async function A(e,t,i){const r=e.view;let a=r.spatialReference;const n={operationalLayers:await _(r,t,i)};t.includeTables&&(n.tables=await ie(r));let s=i.ssExtent||e.extent||r.extent;if(a&&a.isWrappable&&(s=s.clone()._normalize(!0),a=s.spatialReference),n.mapOptions={extent:s&&s.toJSON(),spatialReference:a&&a.toJSON(),showAttribution:t.attributionVisible},i.ssExtent=null,r.background&&(n.background=r.background.toJSON()),r.rotation&&(n.mapOptions.rotation=-r.rotation),t.scalePreserved&&(n.mapOptions.scale=t.outScale||r.scale),null!=r.timeExtent){const e=null!=r.timeExtent.start?r.timeExtent.start.getTime():null,t=null!=r.timeExtent.end?r.timeExtent.end.getTime():null;n.mapOptions.time=[e,t]}return t.reportOptions&&(n.reportOptions=t.reportOptions),n}function k(e){let t=e;const i=t.lastIndexOf("/GPServer/");return i>0&&(t=t.slice(0,i+9)),t}async function _(e,t,i){const r=[],a={layerView:null,printTemplate:t,view:e};let n=0;t.scalePreserved&&(n=t.outScale||e.scale);const s=w(e,n);for(const o of s){const e=o.layer;if(!e.loaded||"group"===e?.type)continue;let t;a.layerView=o,t=S(o)?await ee(e,a,i):x(e)?z(e):v(e)?await $(e,a,i):"feature"===e?.type?await W(e,a,i):"geojson"===e?.type?await q(e,a,i):"graphics"===e?.type?await B(e,a,i):"imagery"===e?.type?H(e,i):"imagery-tile"===e?.type?await G(e,a,i):"kml"===e?.type?await Q(e,a,i):"map-image"===e?.type?X(e,a,i):"map-notes"===e?.type?await Y(a,i):"open-street-map"===e?.type?Z():"stream"===e?.type?await te(e,a,i):"tile"===e?.type?re(e,i):"vector-tile"===e?.type?await ae(e,a,i):"web-tile"===e?.type?ne(e):"wms"===e?.type?se(e,i):"wmts"===e?.type?oe(e):await ee(e,a,i),t&&(Array.isArray(t)?r.push(...t):(t.id=e.id,t.title=i.legendLayerNameMap[e.id]||e.title,t.opacity=o.fullOpacity,t.minScale=e.minScale||0,t.maxScale=e.maxScale||0,I(e)&&e.blendMode&&"normal"!==e.blendMode&&(t.blendMode=e.blendMode),r.push(t)))}if(n)for(const o of r)o.minScale=0,o.maxScale=0;if(e.graphics?.length){const a=await K(null,e.graphics,t,i);a&&r.push(a)}return r}function z(e){return{culture:e.culture,key:e.key,type:"BingMaps"+("aerial"===e.style?"Aerial":"hybrid"===e.style?"Hybrid":"Road")}}async function $(e,t,i){e.legendEnabled&&i.legendLayers.push({id:e.id});const r=t.layerView,a=t.printTemplate;let n;if(!i.is11xService||r.filter||e.portalItem&&"public"!==e.portalItem.access){return K(e,await ye(r),a,i)}return n={type:"CSV"},e.write(n,{origin:"web-map"}),delete n.popupInfo,delete n.layerType,n.showLabels=a.showLabels&&e.labelsVisible,n}async function K(e,t,i,r){let a;const n=T(),s=O(),o=E(),l=M(),y=E();if(y.layerDefinition.name="textLayer",delete y.layerDefinition.drawingInfo,e){if("esri.layers.FeatureLayer"===e.declaredClass||"esri.layers.StreamLayer"===e.declaredClass?n.layerDefinition.name=s.layerDefinition.name=o.layerDefinition.name=l.layerDefinition.name=r.legendLayerNameMap[e.id]||e.get("arcgisProps.title")||e.title:"esri.layers.GraphicsLayer"===e.declaredClass&&(t=e.graphics.items),e.renderer){const t=e.renderer.toJSON(),i=n.layerDefinition.drawingInfo;i&&(i.renderer=t);const r=s.layerDefinition.drawingInfo;r&&(r.renderer=t);const a=o.layerDefinition.drawingInfo;a&&(a.renderer=t);const c=l.layerDefinition.drawingInfo;c&&(c.renderer=t)}if(i.showLabels&&e.labelsVisible&&"function"==typeof e.write){const t=e.write({},{origin:"web-map"}),i=t.layerDefinition?.drawingInfo?.labelingInfo;if(i){a=!0;const e=n.layerDefinition.drawingInfo;e&&(e.labelingInfo=i);const t=s.layerDefinition.drawingInfo;t&&(t.labelingInfo=i);const r=o.layerDefinition.drawingInfo;r&&(r.labelingInfo=i);const c=l.layerDefinition.drawingInfo;c&&(c.labelingInfo=i)}}}let p;e?.renderer||a||(delete n.layerDefinition.drawingInfo,delete s.layerDefinition.drawingInfo,delete o.layerDefinition.drawingInfo,delete l.layerDefinition.drawingInfo);const f=e?.fieldsIndex,d=e?.renderer;if(f){const t=new Set;a&&await u(t,e),d&&"function"==typeof d.collectRequiredFields&&await d.collectRequiredFields(t,f),p=Array.from(t);const i=f.fields.map((e=>e.toJSON()));n.layerDefinition.fields=i,s.layerDefinition.fields=i,o.layerDefinition.fields=i,l.layerDefinition.fields=i}const m=t?.length;let g;for(let u=0;u<m;u++){const a=t[u]||t.at(u);if(!1===a.visible||!a.geometry)continue;if(g=a.toJSON(),g.hasOwnProperty("popupTemplate")&&delete g.popupTemplate,g.geometry?.z&&delete g.geometry.z,g.symbol?.outline&&"esriCLS"===g.symbol.outline.type&&!r.is11xService)continue;!r.is11xService&&g.symbol?.outline?.color?.[3]&&(g.symbol.outline.color[3]=255);const f=e?.renderer&&("valueExpression"in e.renderer&&e.renderer.valueExpression||"hasVisualVariables"in e.renderer&&e.renderer.hasVisualVariables());if(!g.symbol&&e?.renderer&&f&&!r.is11xService){const t=e.renderer,i=await t.getSymbolAsync(a);if(!i)continue;g.symbol=i.toJSON(),"hasVisualVariables"in t&&t.hasVisualVariables()&&D(g.symbol,{renderer:t,graphic:a,symbol:i})}if(g.symbol&&(g.symbol.angle||delete g.symbol.angle,fe(g.symbol)?g.symbol=await ce(g.symbol,r):g.symbol.text&&delete g.attributes),(!i||!i.forceFeatureAttributes)&&p?.length){const e={};for(const t of p)g.attributes?.hasOwnProperty(t)&&(e[t]=g.attributes[t]);g.attributes=e}"polygon"===a.geometry.type?n.featureSet.features.push(g):"polyline"===a.geometry.type?s.featureSet.features.push(g):"point"===a.geometry.type?g.symbol?.text?y.featureSet.features.push(g):o.featureSet.features.push(g):"multipoint"===a.geometry.type?l.featureSet.features.push(g):"extent"===a.geometry.type&&(g.geometry=c.fromExtent(a.geometry).toJSON(),n.featureSet.features.push(g))}const h=[n,s,l,o,y].filter((e=>e.featureSet.features.length>0));for(const c of h){const e=c.featureSet.features.every((e=>e.symbol));if(e&&(!i||!i.forceFeatureAttributes))for(const t of c.featureSet.features)delete t.attributes;e&&delete c.layerDefinition.drawingInfo,c.layerDefinition.drawingInfo?.renderer&&await ue(c.layerDefinition.drawingInfo.renderer,r)}return h.length?{featureCollection:{layers:h},showLabels:a}:null}async function W(e,t,i){let r;const a=e.renderer,n=parseFloat(i.cimVersion);if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type&&(!i.is11xService||n<2.9)||"pie-chart"===a?.type||"dot-density"===a?.type&&(!i.is11xService||n<2.6))return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const s=t.layerView,{printTemplate:o,view:l}=t,c=a&&("valueExpression"in a&&a.valueExpression||"hasVisualVariables"in a&&a.hasVisualVariables()),u="feature-layer"!==e.source?.type&&"ogc-feature"!==e.source?.type;if(!i.is11xService&&c||s.filter||u||!a||"field"in a&&null!=a.field&&("string"!=typeof a.field||!e.getField(a.field))){const t=await ye(s);r=await K(e,t,o,i)}else{if(r={id:(f=e.write()).id,title:f.title,url:f.url,layerType:f.layerType,customParameters:f.customParameters,layerDefinition:f.layerDefinition,charts:o.includeCharts?f.charts:void 0},r.showLabels=o.showLabels&&e.labelsVisible,le(r,e),r.layerDefinition?.drawingInfo?.renderer&&(delete r.layerDefinition.minScale,delete r.layerDefinition.maxScale,await ue(r.layerDefinition.drawingInfo.renderer,i),"visualVariables"in a&&a.visualVariables&&a.visualVariables[0])){const e=a.visualVariables[0];if("size"===e.type&&e.maxSize&&"number"!=typeof e.maxSize&&e.minSize&&"number"!=typeof e.minSize){const t=p(e,l.scale);r.layerDefinition.drawingInfo.renderer.visualVariables[0].minSize=t.minSize,r.layerDefinition.drawingInfo.renderer.visualVariables[0].maxSize=t.maxSize}}const t=y(s);if(t&&(r.layerDefinition||(r.layerDefinition={}),r.layerDefinition.definitionExpression=r.layerDefinition.definitionExpression?`(${r.layerDefinition.definitionExpression}) AND (${t})`:t),s.hasHighlight?.()&&"getHighlightIds"in s){const e=s;r.selectionObjectIds=e.getHighlightIds()}}var f;return r}async function q(e,t,i){if("binning"===e.featureReduction?.type||"cluster"===e.featureReduction?.type)return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});return K(e,await ye(t.layerView),t.printTemplate,i)}async function B(e,{printTemplate:t},i){return K(e,null,t,i)}function H(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(r=e.write()).layerType,customParameters:r.customParameters};var r;if(i.bandIds=e.bandIds,i.compressionQuality=e.compressionQuality,i.format=e.format,i.interpolation=e.interpolation,(e.mosaicRule||e.definitionExpression)&&(i.mosaicRule=e.exportImageServiceParameters.mosaicRule.toJSON()),e.rasterFunction||e.renderer)if(t.is11xService)e.rasterFunction&&(i.renderingRule=e.rasterFunction.toJSON()),e.renderer&&(i.layerDefinition=i.layerDefinition||{},i.layerDefinition.drawingInfo=i.layerDefinition.drawingInfo||{},i.layerDefinition.drawingInfo.renderer=e.renderer.toJSON());else{const t=e.exportImageServiceParameters.combineRendererWithRenderingRule();t&&(i.renderingRule=t.toJSON())}return le(i,e),i}async function G(e,t,i){if("flow"===e.renderer?.type)return ee(e,t,i);e.legendEnabled&&i.legendLayers.push({id:e.id});const r={bandIds:(a=e.write()||{}).bandIds,customParameters:a.customParameters,interpolation:a.interpolation,layerDefinition:a.layerDefinition};var a;return r.layerType="ArcGISImageServiceLayer",le(r,e),r}async function Q(e,t,i){const r=t.printTemplate;if(i.is11xService){const t={type:"kml"};return e.write(t,{origin:"web-map"}),delete t.layerType,t.url=o(e.url),t}const a=[],n=t.layerView;n.allVisibleMapImages.forEach(((t,i)=>{const r={id:`${e.id}_image${i}`,type:"image",title:e.id,minScale:e.minScale||0,maxScale:e.maxScale||0,opacity:n.fullOpacity,extent:t.extent};"data:image/png;base64,"===t.href.substr(0,22)?r.imageData=t.href.substr(22):r.url=t.href,a.push(r)}));const s=[...n.allVisiblePoints.items,...n.allVisiblePolylines.items,...n.allVisiblePolygons.items],l={id:e.id,...await K(null,s,r,i)};return a.push(l),a}function X(e,{view:t},i){let r;const a={id:e.id,subLayerIds:[]};let n=[];const s=t.scale,o=e=>{const t=0===s,i=0===e.minScale||s<=e.minScale,r=0===e.maxScale||s>=e.maxScale;if(e.visible&&(t||i&&r))if(e.sublayers)e.sublayers.forEach(o);else{const t=e.toExportImageJSON(),i={id:e.id,name:e.title,layerDefinition:{drawingInfo:t.drawingInfo,definitionExpression:t.definitionExpression,source:t.source}};n.unshift(i),a.subLayerIds.push(e.id)}};var l;return e.sublayers&&e.sublayers.forEach(o),n.length&&(n=n.map((({id:e,name:t,layerDefinition:i})=>({id:e,name:t,layerDefinition:i}))),r={layerType:(l=e.write()).layerType,customParameters:l.customParameters},r.layers=n,r.visibleLayers=e.capabilities?.exportMap?.supportsDynamicLayers?void 0:a.subLayerIds,le(r,e),e.legendEnabled&&i.legendLayers.push(a)),r}async function Y({layerView:e,printTemplate:t},i){const r=[],a=e.layer;if(null!=a.featureCollections)for(const n of a.featureCollections){const e=await K(n,n.source,t,i);e&&r.push(...e.featureCollection.layers)}else if(null!=a.sublayers)for(const n of a.sublayers){const e=await K(null,n.graphics,t,i);e&&r.push(...e.featureCollection.layers)}return{featureCollection:{layers:r}}}function Z(){return{type:"OpenStreetMap"}}async function ee(e,{printTemplate:t,view:i},r){const n={type:"image"},s={format:"png",ignoreBackground:!0,layers:[e],rotation:0},o=r.ssExtent||i.extent.clone();let c=96,u=!0,y=!0;if(t.exportOptions){const e=t.exportOptions;null!=e.dpi&&e.dpi>0&&(c=e.dpi),null!=e.width&&e.width>0&&(u=e.width%2==i.width%2),null!=e.height&&e.height>0&&(y=e.height%2==i.height%2)}if("map-only"===t.layout&&t.scalePreserved&&(!t.outScale||t.outScale===i.scale)&&96===c&&(!u||!y)&&(s.area={x:0,y:0,width:i.width,height:i.height},u||(s.area.width-=1),y||(s.area.height-=1),!r.ssExtent)){const e=i.toMap(a(s.area.width,s.area.height));o.ymin=e.y,o.xmax=e.x,r.ssExtent=o}n.extent=o.clone()._normalize(!0).toJSON();const p=await i.takeScreenshot(s);return n.imageData=l(p.dataUrl)?.data,n}async function te(e,{layerView:t,printTemplate:i},r){e.legendEnabled&&r.legendLayers.push({id:e.id});return K(e,await ye(t),i,r)}async function ie(e){const t=[],i=[];for(const a of e.map.allTables)"feature"!==a.type||a.loaded||i.push(a.load());i.length&&await Promise.allSettled(i);for(const a of e.map.allTables)if("feature"===a.type&&a.loaded&&a.isTable&&"feature-layer"===a.source?.type){const e={id:(r=a.write()).id,title:r.title,customParameters:r.customParameters,layerDefinition:{definitionExpression:r.layerDefinition?.definitionExpression},url:r.url};le(e,a),t.push(e)}var r;return t.length?t:void 0}function re(e,t){e.legendEnabled&&t.legendLayers.push({id:e.id});const i={layerType:(r=e.write()).layerType,customParameters:r.customParameters};var r;return le(i,e),i}async function ae(e,t,i){if(i.is11xService&&e.serviceUrl&&e.styleUrl){const t=d(e.styleUrl,e.apiKey),r=d(e.serviceUrl,e.apiKey);if(!t&&!r||"2.1.0"!==i.cimVersion){const i={type:"VectorTileLayer"};return i.styleUrl=o(e.styleUrl),i.token=t,r!==t&&(i.additionalTokens=[{url:e.serviceUrl,token:r}]),i}}return ee(e,t,i)}function ne(e){const t=e.urlTemplate?.replace(/\${/g,"{"),i={type:"WebTiledLayer",urlTemplate:t,credits:e.copyright};return e.subDomains&&e.subDomains.length>0&&(i.subDomains=e.subDomains),i}function se(e,t){let i;const r=[],a=e=>{e.visible&&(e.sublayers?e.sublayers.forEach(a):e.name&&r.unshift(e.name))};return e.sublayers&&e.sublayers.forEach(a),r.length&&(e.legendEnabled&&t.legendLayers.push({id:e.id,subLayerIds:r}),i={type:"wms",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,transparentBackground:e.imageTransparency,visibleLayers:r,url:o(e.url),version:e.version}),i}function oe(e){const t=e.activeLayer;return{type:"wmts",customLayerParameters:e.customLayerParameters,customParameters:e.customParameters,format:t.imageFormat,layer:t.id,style:t.styleId,tileMatrixSet:t.tileMatrixSetId,url:o(e.url)}}function le(e,t){t.url&&(e.url=o(e.url||t.url),e.token=d(e.url,t.apiKey))}async function ce(e,i){i.canvas||(i.canvas=document.createElement("canvas"));const r=1024;i.canvas.width=r,i.canvas.height=r;const a=i.canvas.getContext("2d");let o,l;if(e.path){const t=new Path2D(e.path);t.closePath(),a.fillStyle=Array.isArray(e.color)?`rgba(${e.color[0]},${e.color[1]},${e.color[2]},${e.color[3]/255})`:"rgb(0,0,0)",a.fill(t);const i=L(a);if(!i)return null;a.clearRect(0,0,r,r);const s=n(e.size)/Math.max(i.width,i.height);a.scale(s,s);const c=r/s,u=c/2-i.width/2-i.x,y=c/2-i.height/2-i.y;if(a.translate(u,y),Array.isArray(e.color)&&a.fill(t),e.outline?.width&&Array.isArray(e.outline.color)){const r=e.outline;a.lineWidth=n(r.width)/s,a.lineJoin="round",a.strokeStyle=`rgba(${r.color[0]},${r.color[1]},${r.color[2]},${r.color[3]/255})`,a.stroke(t),i.width+=a.lineWidth,i.height+=a.lineWidth}i.width*=s,i.height*=s;const p=a.getImageData(r/2-i.width/2,r/2-i.height/2,Math.ceil(i.width),Math.ceil(i.height));o=p.width,l=p.height,a.canvas.width=o,a.canvas.height=l,a.putImageData(p,0,0)}else{const i="image/svg+xml"===e.contentType?"data:image/svg+xml;base64,"+e.imageData:e.url,r=(await t(i,{responseType:"image"})).data;o=n(e.width),l=n(e.height),a.canvas.width=o,a.canvas.height=l,a.drawImage(r,0,0,a.canvas.width,a.canvas.height)}return{type:"esriPMS",imageData:a.canvas.toDataURL("image/png").substr(22),angle:e.angle,contentType:"image/png",height:s(l),width:s(o),xoffset:e.xoffset,yoffset:e.yoffset}}async function ue(e,t){const i=e.type;if("simple"===i&&fe(e.symbol))e.symbol=await ce(e.symbol,t);else if("uniqueValue"===i||"classBreaks"===i){fe(e.defaultSymbol)&&(e.defaultSymbol=await ce(e.defaultSymbol,t));const r=e["uniqueValue"===i?"uniqueValueInfos":"classBreakInfos"];if(r)for(const e of r)fe(e.symbol)&&(e.symbol=await ce(e.symbol,t))}}async function ye(e){return e.queryFeatures(e.createQuery()).then((e=>e.features))}function pe(e){return e.gpMetadata?.executionType?N.fromJSON(e.gpMetadata.executionType):"sync"}function fe(e){return e&&(e.path||"image/svg+xml"===e.contentType||e.url?.endsWith(".svg"))}export{U as execute,C as getGpPrintParams,k as getGpServerUrl,j as getMode,J as printCacheMap};
|