@arcgis/core 4.33.5 → 4.33.7
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/README.md +5 -5
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{8b3d1973eb75b81b0fb4.js → e8972732b058fd6fbfac.js} +1 -1
- package/interfaces.d.ts +1 -1
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/webgl-engine/lib/Path.js +1 -1
- package/views/draw/support/ConnectedReshapeManager.js +5 -0
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/layerUtils.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as e,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as r}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as s,transpose as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as f,mul as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as h,f as m}from"../../../chunks/vec32.js";import{isSerializable as p}from"../../../core/support/jsonUtils.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as v}from"../../../geometry/projectionUtils.js";import{earth as g}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isConstantElevation as w,ConstantElevation as y,isElevationSource as O}from"../core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as b}from"../core/utils.js";import{getElevationSampler as j}from"./updateElevationUtils.js";import{isNumber as E}from"../../../support/guards.js";import{defaultImageSphereSize as S}from"../../../widgets/PanoramicViewer/constants.js";function z(t,n,a){const[i,o,r,c]=n,[s,l,h,m]=a;F(i,o,r,c);const p=F(s,l,h,m),M=V(i,o,r,c),v=V(s,l,h,m),g=f(e(),M),d=u(e(),g,v),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function F(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function R(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=R(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const c=H(r([...i,1]),f(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=c[0],l=c[1],u=c[2],h=e();return h[0]=s*t[0],h[1]=l*n[0],h[2]=u*a[0],h[3]=0,h[4]=s*t[1],h[5]=l*n[1],h[6]=u*a[1],h[7]=0,h[8]=s*t[2],h[9]=l*n[2],h[10]=u*a[2],h[11]=0,h[12]=s,h[13]=l,h[14]=u,h[15]=1,h}function C(t,n,a,i,e=c()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function D(t,n,a){const i=c();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=c();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function H(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,e,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=i();switch(e){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const N={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function q(n,a,e=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=i();for(let t=0;t<3;t++){const[i,r]=a[t],c=I(n[t],i,r,e);s(o,c,o)}return o}function U(t,n=!0){return q(t,N.OPK,n)}function k(t,n=!0){return q(t,N.HPR,n)}function A(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),u=a(c),h=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-u,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(h*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-h+M*Math.sin(f)]}function W(t,i){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=i,u=a(c),h=a(s),m=l/Math.sqrt(1-f*Math.sin(u)**2),p=e/m,M=o/m,v=r/m,g=Math.cos(u)-Math.sin(u)*M+Math.cos(u)*v,d=Math.sin(u)+Math.cos(u)*M+Math.sin(u)*v,x=Math.sqrt(g**2+p**2),w=f*m*Math.sin(u),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(u),b=Math.atan(e/(m*g))+h,j=n(O);return[n(b),j,e/(Math.cos(O)*Math.sin(b-h))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function T(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function X(t,n,a,i=S/2){const{heading:e,pitch:o}=Z(t,i);return Y(e,o,n,a)}function Y(t,n,a,i){return{x:a/2+t/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function Z(t,a){const i=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:i}}function G(t,n,i=S/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}function J(t,n,a,i=S/2){const{heading:e,pitch:o}=T(t,n,a);return G(e,o,i)}async function $(t,a,i){const e=await v(a,t.spatialReference,i);let o=n(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function B(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const Q=t=>t.toArray(),_=(...t)=>t.some((t=>t));function tt(t,n){if(_(0===t.length,t.some((({x:t,y:n})=>_(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function nt(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function at(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function it(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/g.radius))):1}const et=t=>n=>new M(n,t),ot=t=>null!=t&&"queryExtent"in t;function rt(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>z(x(c(),a,[n,e,0]),i,t)))}function ct({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(st);return null!=s&<(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function st(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function lt(t){return null!=t[1]&&null!=t[5]}function ft(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=St(t,t.location.spatialReference),u=r??(l.z??0)-i;return{...mt(t,n,a),averageElevation:u,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function ut(t,n,a,i){return yt(i)?U([i.omega,i.phi,i.kappa]):Ot(i)?k([i.heading,i.pitch,i.roll]):k([t,n,a??0])}function ht(t,n,a){const{cameraHeading:i,cameraHeight:e,elevation:o,farDistance:r,horizontalFieldOfView:c,location:s,verticalFieldOfView:l}=St(t,t.location.spatialReference);return{averageElevation:o??(s.z??0)-e,cameraLocation:s,cameraHeading:i,farDistance:r,horizontalFieldOfView:c,imageHeight:a,imageWidth:n,verticalFieldOfView:l}}function mt(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:u,cameraRoll:h,focalLength:m,horizontalFieldOfView:p,location:M,matrix:v,principalX:g,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=ct({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=v??ut(l,u,h,f),E=null!=g&&null!=d?[g,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const pt=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,Mt=t=>O(t?.elevationSource)&&null!=t?.extent,vt=t=>w(t?.elevationSource),gt=async(t,n,a,i,e)=>{const o=b(t),r=n-a/o;return vt(i)?(i.elevationSource=new y({constantElevation:i.elevationSource.constantElevation/o}),i):pt(i)?i:Mt(i)?{elevationSample:await j({...p(i.elevationSource)?i.elevationSource.toJSON():i.elevationSource,extent:i.extent},e),elevationSource:new y({constantElevation:r})}:{averageGroundElevation:r,spatialReference:t}},dt=t=>E(t?.heading)&&E(t?.pitch),xt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function wt(t){const{cameraLocation:n,farDistance:e,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:s,verticalFieldOfView:f}=t,u=i();l(u,r);const p=2*Math.tan(a(f)/2)*e*s,M=2*Math.tan(a(o)/2)*e*s,v=L([0,0,-1],u),g=C([n.x,n.y,n.z],v,t.farDistance*s,s),d=L([0,1,0],u),x=L([1,0,0],u),w=D(d,p/2,s),y=D(x,M/2,s),O=h(c(),w,y),b=m(c(),w,y);return[m(c(),g,O),m(c(),g,b),h(c(),g,O),h(c(),g,b)]}const yt=t=>2===t?.type,Ot=t=>1===t?.type;function bt(t){const n=t%360;return n<-180?n+360:n}function jt(t,n,a){if("panoramic"===t){const[t,i]=a;return X({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var Et;function St(t,n,a=!0){const i=b(n),e=a?t.clone():t;return e.cameraHeight/=i,e.farDistance/=i,e.nearDistance/=i,w(e.elevationSource)&&(e.elevationSource.constantElevation/=i),e}!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(Et||(Et={}));export{wt as computeFarplaneVertices,A as computeHFOVAndVFOV,rt as computeNewReferenceCoordinates,G as convertHeadingPitchToSphereVertex,Y as convertOrientationToPixelLocation,J as convertPixelLocationToSphereVertex,T as convertPixelToHeadingPitch,Z as convertSphereVertexToOrientation,X as convertSphereVertexToPixelLocation,St as convertToSRUnits,q as createRotationMatrix,k as createRotationMatrixFromHPR,U as createRotationMatrixFromOPK,K as geographicToLTP,ct as getAffinesAndFocalLength,ht as getImageToWorldPanoramicProperties,ft as getImageToWorldProperties,$ as getInitialAngle,gt as getUpdateElevationProps,it as getWebMercatorScalingFactor,mt as getWorldToImageProperties,dt as hasAngles,Ot as hasHeadingPitchRoll,yt as hasOmegaPhiKappa,ot as isElevationSampler,pt as isUpdateElevationWithElevationSampler,Mt as isUpdateElevationWithElevationSource,vt as isUpdateUsingConstantElevation,lt as isValidAffines,V as linearEquationSolve,W as ltpToGeographic,bt as normalizeHeading,_ as or,Q as pointToArray,z as projectiveTransform,xt as reducerFn,B as rotatePixel,C as scaleAndAddWithFactor,D as scaleWithFactor,jt as transformGraphicCoordinatesToPixel,L as transformMat3,H as transformMat4,tt as validatePixelsToTransform,nt as validatePointsToTransform,at as validateRotationMatrix,et as vecToPoint};
|
|
5
|
+
import t from"../../../core/Error.js";import{rad2deg as n,deg2rad as a}from"../../../core/mathUtils.js";import{create as i}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as e,fromValues as o}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromArray as r}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{zeros as c}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{multiply as s,transpose as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{invertOrIdentity as f,mul as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{a as h,f as m}from"../../../chunks/vec32.js";import{isSerializable as p}from"../../../core/support/jsonUtils.js";import M from"../../../geometry/Point.js";import{projectWithZConversion as v}from"../../../geometry/projectionUtils.js";import{earth as g}from"../../../geometry/support/Ellipsoid.js";import{isWebMercator as d}from"../../../geometry/support/spatialReferenceUtils.js";import{a as x}from"../../../chunks/vec3.js";import{isConstantElevation as w,ConstantElevation as y,isElevationSource as O}from"../core/ElevationSourceDefinitions.js";import{getMetersPerUnitOfSR as b}from"../core/utils.js";import{getElevationSampler as j}from"./updateElevationUtils.js";import{isNumber as E}from"../../../support/guards.js";import{defaultImageSphereSize as S}from"../../../widgets/PanoramicViewer/constants.js";function z(t,n,a){const[i,o,r,c]=n,[s,l,h,m]=a;F(i,o,r,c);const p=F(s,l,h,m),M=V(i,o,r,c),v=V(s,l,h,m),g=f(e(),M),d=u(e(),g,v),[x,w,y,O]=P(t,d);return[x/O,w/O,p?0:y/O]}function F(t,n,a,i){return 0===t[2]&&0===n[2]&&0===a[2]&&0===i[2]&&(t[2]=n[2]=a[2]=i[2]=1,!0)}function R(t){return 0===t?1:t}function P(t,n){const[a,i,e]=t,o=[0,0,0,0];return o[0]=a*n[0]+i*n[1]+e*n[2]+n[3],o[1]=a*n[4]+i*n[5]+e*n[6]+n[7],o[2]=a*n[8]+i*n[9]+e*n[10]+n[11],o[3]=R(a*n[12]+i*n[13]+e*n[14]+n[15]),o}function V(t,n,a,i){const c=H(r([...i,1]),f(new Array(16),o(t[0],n[0],a[0],0,t[1],n[1],a[1],0,t[2],n[2],a[2],0,1,1,1,1))),s=c[0],l=c[1],u=c[2],h=e();return h[0]=s*t[0],h[1]=l*n[0],h[2]=u*a[0],h[3]=0,h[4]=s*t[1],h[5]=l*n[1],h[6]=u*a[1],h[7]=0,h[8]=s*t[2],h[9]=l*n[2],h[10]=u*a[2],h[11]=0,h[12]=s,h[13]=l,h[14]=u,h[15]=1,h}function C(t,n,a,i,e=c()){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*(a/i),e}function D(t,n,a){const i=c();return i[0]=t[0]*n,i[1]=t[1]*n,i[2]=t[2]*(n/a),i}function L(t,n){const[a,i,e]=t,o=c();return o[0]=a*n[0]+i*n[3]+e*n[6],o[1]=a*n[1]+i*n[4]+e*n[7],o[2]=a*n[2]+i*n[5]+e*n[8],o}function H(t,n){const[a,i,e,o]=t,r=new Array(4);return r[0]=a*n[0]+i*n[1]+e*n[2]+o*n[3],r[1]=a*n[4]+i*n[5]+e*n[6]+o*n[7],r[2]=a*n[8]+i*n[9]+e*n[10]+o*n[11],r[3]=a*n[12]+i*n[13]+e*n[14]+o*n[15],r}function I(n,e,o,r=!0){if(!Number.isFinite(n))throw new t("InvalidRotationAngle","Please specify a valid angle for rotation");const c=o*(r?a(n):n),s=Math.cos(c),l=Math.sin(c),f=i();switch(e){case 0:f[4]=s,f[5]=-l,f[7]=l,f[8]=s;break;case 1:f[0]=s,f[2]=l,f[6]=-l,f[8]=s;break;case 2:f[0]=s,f[1]=-l,f[3]=l,f[4]=s;break;default:throw new t("InvalidRotationAxis","Please specify either 0, 1 or 2 for X, Y or Z axis respectively")}return f}const N={HPR:[[2,-1],[0,1],[2,-1]],OPK:[[0,1],[1,1],[2,1]]};function q(n,a,e=!0){if(3!==n?.length||3!==a?.length)throw new t("InvalidRotationAngles","Please specify three angles with config for rotation");const o=i();for(let t=0;t<3;t++){const[i,r]=a[t],c=I(n[t],i,r,e);s(o,c,o)}return o}function U(t,n=!0){return q(t,N.OPK,n)}function k(t,n=!0){return q(t,N.HPR,n)}function A(t,n,i){const e=Math.sin(a(i)),o=Math.cos(a(i)),r=[[t,0],[t,n],[0,n]];r.forEach(((t,n)=>{r[n]=[o*t[0]-e*t[1],e*t[0]+o*t[1]]}));const c={xmin:Math.min(0,r[0][0],r[1][0],r[2][0]),xmax:Math.max(0,r[0][0],r[1][0],r[2][0]),ymin:Math.min(0,r[0][1],r[1][1],r[2][1]),ymax:Math.max(0,r[0][1],r[1][1],r[2][1])};return{hfov:Math.abs(c.xmax-c.xmin),vfov:Math.abs(c.ymax-c.ymin)}}function K(t,n){const i=a(t[1]),e=a(t[0]),o=t[2],[r,c,s,l]=n,f=a(r),u=a(c),h=s/Math.sqrt(1-l*Math.sin(f)**2),m=e-u,p=s/Math.sqrt(1-l*Math.sin(f)**2),M=l*(h*Math.sin(f)-p*Math.sin(i));return[(p+o)*Math.cos(i)*Math.sin(m),(p+o)*(Math.sin(i)*Math.cos(f)-Math.sin(f)*Math.cos(f)*Math.cos(m))+M*Math.cos(f),(p+o)*(Math.sin(i)*Math.sin(f)+Math.cos(f)*Math.cos(i)*Math.cos(m))-h+M*Math.sin(f)]}function W(t,i){const e=Number(t[0]),o=Number(t[1]),r=Number(t[2]),[c,s,l,f]=i,u=a(c),h=a(s),m=l/Math.sqrt(1-f*Math.sin(u)**2),p=e/m,M=o/m,v=r/m,g=Math.cos(u)-Math.sin(u)*M+Math.cos(u)*v,d=Math.sin(u)+Math.cos(u)*M+Math.sin(u)*v,x=Math.sqrt(g**2+p**2),w=f*m*Math.sin(u),y=(t,n=5)=>{if(0===n)return t;const a=y(t,n-1);return Math.atan(d/x-(w-f*(l/Math.sqrt(1-f*Math.sin(a)**2))*Math.sin(a))/(m*x))},O=y(u),b=Math.atan(e/(m*g))+h,j=n(O);return[n(b),j,e/(Math.cos(O)*Math.sin(b-h))-l/Math.sqrt(1-f*Math.sin(O)**2)]}function T(t,n,a){const i=360/n,e=180/a;return{heading:(t.x-n/2)*i,pitch:90-(t.y-a/2)*e}}function X(t,n,a,i=S/2){const{heading:e,pitch:o}=Z(t,i);return Y(e,o,n,a)}function Y(t,n,a,i){const e=t%360;return{x:a/2+(e<-180?e+360:e>180?e-360:e)/(360/a),y:i-n/(180/i),heading:t,pitch:n}}function Z(t,a){const i=n(Math.acos(-t.z/a));return{heading:n(Math.atan2(t.x,t.y)),pitch:i}}function G(t,n,i=S/2){return[i*(Math.sin(a(t))*Math.sin(a(n))),i*(Math.cos(a(t))*Math.sin(a(n))),i*Math.cos(a(180-n))]}function J(t,n,a,i=S/2){const{heading:e,pitch:o}=T(t,n,a);return G(e,o,i)}async function $(t,a,i){const e=await v(a,t.spatialReference,i);let o=n(Math.atan2(e.y-t.y,e.x-t.x));return o=o>=0&&o<=90?90-o:o>90&&o<=180?360-o+90:90+Math.abs(o),o}function B(t,n,a){const i=Math.cos(a),e=Math.sin(a),o=[1,0,0,1,0,0],r=o[0]*i+o[2]*e,c=o[1]*i+o[3]*e,s=-o[0]*e+o[2]*i,l=-o[1]*e+o[3]*i;o[0]=r,o[1]=c,o[2]=s,o[3]=l;return[t*o[0]+n*o[2]+o[4],t*o[1]+n*o[3]+o[5]]}const Q=t=>t.toArray(),_=(...t)=>t.some((t=>t));function tt(t,n){if(_(0===t.length,t.some((({x:t,y:n})=>_(null==t,null==n))),!n.hasZ))throw new Error("Input pixels must have x, y and camera location must have z value")}function nt(t,n){if(t.some((t=>null==t.z))||null==n.z)throw new Error("Input points and camera location must have z value")}function at(t){if(9!==t?.length)throw new Error("Rotation matrix is not provided or is not a valid 3x3 matrix")}function it(t,n){return d(n)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/g.radius))):1}const et=t=>n=>new M(n,t),ot=t=>null!=t&&"queryExtent"in t;function rt(t,n,a,i){return[[-n,-n],[+n,-n],[+n,+n],[-n,+n]].map((([n,e])=>z(x(c(),a,[n,e,0]),i,t)))}function ct({a0:t,a1:n,a2:a,b0:i,b1:e,b2:o},r,c,s){const l=[t??r/2-.5,n,a??0,i??c/2-.5,e??0,o].map(st);return null!=s&<(l)?{affines:l,focalLength:s}:{affines:[r/2-.5,1,0,c/2-.5,0,-1]}}function st(t,n){if(null==t)return null;const a=parseFloat(`${t}`);return isNaN(a)?null:a}function lt(t){return null!=t[1]&&null!=t[5]}function ft(t,n,a){const{cameraHeight:i,cameraPitch:e,cameraRoll:o,elevation:r,farDistance:c,horizontalFieldOfView:s,location:l,verticalFieldOfView:f}=St(t,t.location.spatialReference),u=r??(l.z??0)-i;return{...mt(t,n,a),averageElevation:u,cameraPitch:e,cameraRoll:o??0,farDistance:c,horizontalFieldOfView:s,verticalFieldOfView:f}}function ut(t,n,a,i){return yt(i)?U([i.omega,i.phi,i.kappa]):Ot(i)?k([i.heading,i.pitch,i.roll]):k([t,n,a??0])}function ht(t,n,a){const{cameraHeading:i,cameraHeight:e,farDistance:o,horizontalFieldOfView:r,location:c,verticalFieldOfView:s}=St(t,t.location.spatialReference);return{averageElevation:(c.z??0)-e,cameraLocation:c,cameraHeading:i,farDistance:o,horizontalFieldOfView:r,imageHeight:a,imageWidth:n,verticalFieldOfView:s}}function mt(t,n,a){const{a0:i,a1:e,a2:o,b0:r,b1:c,b2:s,cameraHeading:l,cameraOrientation:f,cameraPitch:u,cameraRoll:h,focalLength:m,horizontalFieldOfView:p,location:M,matrix:v,principalX:g,principalY:d,radial:x,tangential:w,verticalFieldOfView:y}=t,{affines:O,focalLength:b}=ct({a0:i,a1:e,a2:o,b0:r,b1:c,b2:s},n,a,m),j=v??ut(l,u,h,f),E=null!=g&&null!=d?[g,d]:void 0;return{affineTransformations:f?.affineTransformations??O,cameraLocation:M.clone(),focalLength:f?.focalLength??b,horizontalFieldOfView:p,imageHeight:a,imageWidth:n,principalOffsetPoint:f?.principalOffsetPoint??E,radialDistortionCoefficients:f?.radialDistortionCoefficients??x,rotationMatrix:j,tangentialDistortionCoefficients:f?.tangentialDistortionCoefficients??w,verticalFieldOfView:y}}const pt=t=>null!=t&&"elevationSample"in t&&null!=t.elevationSample,Mt=t=>O(t?.elevationSource)&&null!=t?.extent,vt=t=>w(t?.elevationSource),gt=async(t,n,a,i,e)=>{const o=b(t),r=n-a/o;return vt(i)?(i.elevationSource=new y({constantElevation:i.elevationSource.constantElevation/o}),i):pt(i)?i:Mt(i)?{elevationSample:await j({...p(i.elevationSource)?i.elevationSource.toJSON():i.elevationSource,extent:i.extent},e),elevationSource:new y({constantElevation:r})}:{averageGroundElevation:r,spatialReference:t}},dt=t=>E(t?.heading)&&E(t?.pitch),xt=(t,n)=>[[-t,-n],[t,-n],[t,n],[-t,n]];function wt(t){const{cameraLocation:n,farDistance:e,horizontalFieldOfView:o,rotationMatrix:r,scalingFactor:s,verticalFieldOfView:f}=t,u=i();l(u,r);const p=2*Math.tan(a(f)/2)*e*s,M=2*Math.tan(a(o)/2)*e*s,v=L([0,0,-1],u),g=C([n.x,n.y,n.z],v,t.farDistance*s,s),d=L([0,1,0],u),x=L([1,0,0],u),w=D(d,p/2,s),y=D(x,M/2,s),O=h(c(),w,y),b=m(c(),w,y);return[m(c(),g,O),m(c(),g,b),h(c(),g,O),h(c(),g,b)]}const yt=t=>2===t?.type,Ot=t=>1===t?.type;function bt(t){const n=t%360;return n<-180?n+360:n}function jt(t,n,a){if("panoramic"===t){const[t,i]=a;return X({x:n.x,y:n.y,z:n.z},t,i)}return{x:n.x+.5,y:.5-n.y}}var Et;function St(t,n,a=!0){const i=b(n),e=a?t.clone():t;return e.cameraHeight/=i,e.farDistance/=i,e.nearDistance/=i,w(e.elevationSource)&&(e.elevationSource.constantElevation/=i),e}!function(t){t[t.CLOCKWISE=-1]="CLOCKWISE",t[t.COUNTERCLOCKWISE=1]="COUNTERCLOCKWISE"}(Et||(Et={}));export{wt as computeFarplaneVertices,A as computeHFOVAndVFOV,rt as computeNewReferenceCoordinates,G as convertHeadingPitchToSphereVertex,Y as convertOrientationToPixelLocation,J as convertPixelLocationToSphereVertex,T as convertPixelToHeadingPitch,Z as convertSphereVertexToOrientation,X as convertSphereVertexToPixelLocation,St as convertToSRUnits,q as createRotationMatrix,k as createRotationMatrixFromHPR,U as createRotationMatrixFromOPK,K as geographicToLTP,ct as getAffinesAndFocalLength,ht as getImageToWorldPanoramicProperties,ft as getImageToWorldProperties,$ as getInitialAngle,gt as getUpdateElevationProps,it as getWebMercatorScalingFactor,mt as getWorldToImageProperties,dt as hasAngles,Ot as hasHeadingPitchRoll,yt as hasOmegaPhiKappa,ot as isElevationSampler,pt as isUpdateElevationWithElevationSampler,Mt as isUpdateElevationWithElevationSource,vt as isUpdateUsingConstantElevation,lt as isValidAffines,V as linearEquationSolve,W as ltpToGeographic,bt as normalizeHeading,_ as or,Q as pointToArray,z as projectiveTransform,xt as reducerFn,B as rotatePixel,C as scaleAndAddWithFactor,D as scaleWithFactor,jt as transformGraphicCoordinatesToPixel,L as transformMat3,H as transformMat4,tt as validatePixelsToTransform,nt as validatePointsToTransform,at as validateRotationMatrix,et as vecToPoint};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{j as o,a as n}from"../../../chunks/vec32.js";import{webMercatorToGeographic as e}from"../../../geometry/support/webMercatorUtils.js";import{
|
|
5
|
+
import{rad2deg as t,deg2rad as a}from"../../../core/mathUtils.js";import{create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{j as o,a as n}from"../../../chunks/vec32.js";import{webMercatorToGeographic as e}from"../../../geometry/support/webMercatorUtils.js";import{getWebMercatorScalingFactor as i,convertOrientationToPixelLocation as c,validatePointsToTransform as s,validateRotationMatrix as m}from"./utils.js";import{normalizeDegrees as f}from"../../../widgets/OrientedImageryViewer/components/imageNavigationUtils.js";function l(t,a){const{cameraLocation:r,pointsToTransform:o,scalingFactor:n}=h(t,a.cameraLocation,a.rotationMatrix),e=new Array;return p(o,e,{...a,cameraLocation:r,scalingFactor:n,...d(a)}),Array.isArray(t)?e:e[0]}function u(t,a,r){return l(t?a.map((t=>e(t))):a,r).map((t=>({...t,z:1})))}function p(t,a,o){const{affineTransformations:e,cameraLocation:i,focalLengthX:c,focalLengthY:s,principalOffsetPoint:m,radialDistortionCoefficients:f,rotationMatrix:l,scalingFactor:u,tangentialDistortionCoefficients:p}=o;for(const g of t){const t=r();n(t,g,i),t[0]=t[0]/u,t[1]=t[1]/u;const o=-c*((l[0]*t[0]+l[3]*t[1]+l[6]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),h=-s*((l[1]*t[0]+l[4]*t[1]+l[7]*t[2])/(l[2]*t[0]+l[5]*t[1]+l[8]*t[2])),y=o*o+h*h;let L=0,A=0,d=0,w=0,T=0,b=0,j=0;f&&(L=f[0]??0,A=f[1]??0,d=f[2]??0),p&&(w=p[0],T=p[1]),m&&(b=m[0]??0,j=m[1]??0);const M=1+L*y+A*y*y+d*y*y*y;let N=o*M+w*(y+2*o**2)+2*T*o*h,F=h*M+T*(y+2*h**2)+2*w*o*h;N+=b,F+=j;const v=Number(e[0])+Number(e[1])*N+Number(e[2])*F,x=Number(e[3])+Number(e[4])*N+Number(e[5])*F;a.push({x:v,y:x})}}function g(a,r){const{cameraHeading:n,imageHeight:e,imageWidth:s}=r,{cameraLocation:m,pointsToTransform:l}=y(a,r.cameraLocation),u=new Array,p=i(m[1],r.cameraLocation.spatialReference);for(const i of l){const a=o([m[0],m[1],m[2]*p],[i[0],i[1],i[2]*p]),r=[(i[0]-m[0])/a,(i[1]-m[1])/a,(i[2]-m[2])*p/a],l=0!==r[0]&&0!==r[1]?f(t(Math.atan2(r[0],r[1]))-n):0,g=t(Math.acos(-r[2]));u.push(c(l,g,s,e))}return Array.isArray(a)?u:u[0]}function h(t,a,r){const o=Array.isArray(t)||"items"in t?t:[t];s(o,a),L(o,a),m(r);const n=i(a.y,a.spatialReference);return{pointsToTransform:o.map((t=>t.toArray())),scalingFactor:n,cameraLocation:a.toArray()}}function y(t,a){const r=Array.isArray(t)||"items"in t?t:[t];return s(r,a),L(r,a),{pointsToTransform:r.map((t=>t.toArray())),cameraLocation:a.toArray()}}function L(t,a){if(t.some((t=>!t.spatialReference.equals(a.spatialReference))))throw new Error("Input points and camera location must have the same spatial reference")}function A(t){return null!=t?.focalLength}function d(t){if(A(t))return{focalLengthX:t.focalLength,focalLengthY:t.focalLength};const{imageWidth:r,imageHeight:o,horizontalFieldOfView:n,verticalFieldOfView:e}=t;return{focalLengthX:r/(2*Math.tan(a(n)/2)),focalLengthY:o/(2*Math.tan(a(e)/2))}}export{l as worldToImage,g as worldToImagePanoramic,u 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{id as e}from"../../kernel.js";import t from"../../request.js";import n from"../../core/Collection.js";import"../../core/urlUtils.js";import{isLayerFromCatalog as r}from"../catalog/catalogUtils.js";function i(e){return
|
|
5
|
+
import{id as e}from"../../kernel.js";import t from"../../request.js";import n from"../../core/Collection.js";import"../../core/urlUtils.js";import{isLayerFromCatalog as r}from"../catalog/catalogUtils.js";function i(e){return b(e)||y(e)}function u(e){return null!=e&&"object"==typeof e&&"type"in e&&"feature"===e.type}function o(e){return null!=e&&"object"==typeof e&&"type"in e&&"graphics"===e.type}function s(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-image"===e.type}function a(e){return null!=e&&"object"==typeof e&&"type"in e&&"map-notes"===e.type&&"sublayers"in e}function c(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph"===e.type&&"layers"in e}function l(e){return null!=e&&"object"==typeof e&&"type"in e&&"knowledge-graph-sublayer"===e.type}function f(e){return null!=e&&"object"==typeof e&&"type"in e&&"link-chart"===e.type&&"layers"in e}function y(e){return"scene"===e?.type}function p(e){return null!=e&&"object"==typeof e&&"type"in e&&"subtype-group"===e.type&&"sublayers"in e}function g(e){return"subtype-sublayer"===e?.type}function b(e){const t=e?.type;return"imagery-tile"===t||"tile"===t||"open-street-map"===t||"vector-tile"===t||"web-tile"===t||"wmts"===t}function d(e){const t=e?.type;return"base-tile"===t||"tile"===t||"elevation"===t||"imagery-tile"===t||"base-elevation"===t||"open-street-map"===t||"wcs"===t||"web-tile"===t||"wmts"===t||"vector-tile"===t}function m(e){return null!=e&&"type"in e&&"group"===e.type}const h={Point:"SceneLayer","3DObject":"SceneLayer",IntegratedMesh:"IntegratedMeshLayer",PointCloud:"PointCloudLayer",Building:"BuildingSceneLayer"};function j(e){const t=e?.type;return"building-scene"===t||"integrated-mesh"===t||"point-cloud"===t||"scene"===t}function v(e){return"IntegratedMeshLayer"===e||"IntegratedMesh3DTilesLayer"===e}function w(e){return"integrated-mesh"===e||"integrated-mesh-3dtiles"===e}function L(e){return"voxel"===e?.type}function S(e){return"imagery-tile"===e?.type}function E(e,t){return null!=e?.parent&&"declaredClass"in e.parent&&"esri.Basemap"===e.parent.declaredClass&&e.parent[t].includes(e)}function C(e){return E(e,"baseLayers")}function M(e){return E(e,"referenceLayers")}function k(e){return"feature"===e?.type&&!e.url&&"memory"===e.source?.type}function x(e){const t=e?.type;return("feature"===t||"subtype-group"===t||"oriented-imagery"===t)&&"feature-layer"===e?.source?.type}function I(e){return"feature"===e?.type&&"feature-layer"===e.source?.type}function T(e){const t=/[:;]/,n=[];let r=!1;if(e&&(e.forEach(((e,i)=>{n.push([i,e]),!r&&t.test(e)&&(r=!0)})),n.length>0)){let e;if(r){const t={};n.forEach((e=>{t[e[0]]=e[1]})),e=JSON.stringify(t)}else{const t=[];n.forEach((e=>{t.push(e[0]+":"+e[1])})),e=t.join(";")}return e}return null}function U(e){if(!e)return;const t=[];return e.forEach(((e,n)=>{t.push('"'+n+'":'+JSON.stringify(e))})),t.length?"{"+t.join(",")+"}":void 0}function O(e){if(e.activeLayer){const t=e.activeLayer.tileMatrixSet;if(t)return t;const n=e.activeLayer.tileMatrixSets;if(n)return n}return null}async function B(n,r){const i=e?.findServerInfo(n);if(null!=i?.currentVersion)return i.owningSystemUrl||null;const u=n.toLowerCase().indexOf("/rest/services");if(-1===u)return null;const o=`${n.slice(0,u)}/rest/info`,s=null!=r?r.signal:null,{data:a}=await t(o,{query:{f:"json"},responseType:"json",signal:s});return a?.owningSystemUrl||null}function P(e){if(!("capabilities"in e))return!1;switch(e.type){case"catalog":case"catalog-footprint":case"csv":case"feature":case"geojson":case"imagery":case"knowledge-graph-sublayer":case"ogc-feature":case"oriented-imagery":case"scene":case"sublayer":case"subtype-group":case"subtype-sublayer":case"wfs":return!0;default:return!1}}function q(e){return null!=e&&"object"==typeof e&&"isTable"in e&&!!e.isTable}function D(e){return P(e)?"effectiveCapabilities"in e?e.effectiveCapabilities:e.capabilities:null}function J(e){if(!("editingEnabled"in e))return!1;switch(e.type){case"csv":case"feature":case"geojson":case"oriented-imagery":case"scene":case"subtype-group":case"subtype-sublayer":return!0;default:return!1}}function N(e){return!!J(e)&&("effectiveEditingEnabled"in e?e.effectiveEditingEnabled:e.editingEnabled)}function F(e){if(!e)return[];return("subtypes"in e?e.subtypes:p(e.parent)?e.parent.subtypes:[])??[]}function V(e){return("imagery"===e.type||"imagery-tile"===e.type)&&"flow"===e.renderer?.type}function $(e){const t=new n;for(const n of e.allLayers.concat(e.allTables))"csv"===n.type||r(n)||("charts"in n&&t.push(n),"subtype-group"===n.type&&t.push(...n.sublayers));return t}function z(e,t){return null}function A(e){return null}function G(e){return!e||"Feature Service"===e.type&&!e.sourceUrl}function H(e,t){if(!t||!G(e))return;const n=z(e.url);n&&(e.url=n)}export{H as applyPreferredHostToPortalItem,N as getEffectiveEditingEnabled,D as getEffectiveLayerCapabilities,$ as getLayersWithChartSupport,B as getOwningPortalUrl,A as getPreferredHost,z as getPreferredUrl,F as getSubtypesFromLayer,O as getTileMaxtrixSetFromActiveLayer,C as isBaseLayer,i as isBasemap3DSupportedLayer,b as isBasemapSupportedTiledLayer,k as isFeatureCollectionLayer,u as isFeatureLayer,I as isFeatureServiceLayer,o as isGraphicsLayer,m as isGroupLayer,S as isImageryTileLayer,w as isIntegratedMeshLayer,v as isIntegratedMeshOperationalLayer,c as isKnowledgeGraphLayer,l as isKnowledgeGraphSublayer,P as isLayerWithFeatureCapabilities,x as isLayerWithFeatureLayerSource,V as isLayerWithFlowRenderer,f as isLinkChartLayer,s as isMapImageLayer,a as isMapNotesLayer,G as isPreferredUrlApplicable,M as isReferenceLayer,y as isSceneLayer,j as isSceneServiceLayer,p as isSubtypeGroupLayer,g as isSubtypeSublayer,q as isTable,d as isTiledLayer,L as isVoxelLayer,h as sceneServiceLayerTypeToClassName,T as serializeLayerDefinitions,U as serializeTimeOptions};
|
package/package.json
CHANGED
package/support/revision.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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const
|
|
5
|
+
const e="20250702",b="94d082bf6e1ec315689770a80189b9b091d2852e";export{e as buildDate,b as commitHash};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as r,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as h}from"../../../../chunks/vec32.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as d}from"../../../../geometry/projection/projectBuffer.js";import{create as u,fromSubBuffer as b,intersectsClippingArea as g}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as _}from"../../../../geometry/support/DoubleArray.js";import{EmissiveSourceMode as v}from"../../../../symbols/support/materialUtils.js";import{needsElevationUpdates3D as w,evaluateElevationAlignmentAtPoint as x,SampleElevationInfo as P}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as j}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as S,pathNumRoundCapExtrusionSubdivisions as C}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{isValidSize as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as A}from"./interfaces.js";import{ConvertOptions as U,initFastSymbolUpdatesState as k,updateFastSymbolUpdatesState as R,getAttributeValue as z}from"../support/FastSymbolUpdates.js";import{SamplePosition as E}from"../../support/ElevationProvider.js";import{NormalType as L}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{Path as G}from"../../webgl-engine/lib/Path.js";import{PathBuilder as B}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as F,TriangulationCapBuilder as M,NoCapBuilder as q}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as H,MiterExtruder as N}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as W,PathGeometry as T,isPathGeometry as Z}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as J,StaticPathGeometry as K}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as Q}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as X,circleProfiles as Y}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as $}from"../../webgl-engine/lib/PathVertex.js";import{VertexAttribute as ee}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as te}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ie}from"../../webgl-engine/materials/PathMaterial.js";const re=["polyline"];class se extends D{constructor(e,t,i,r){super(e,t,i,r,ce(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=W.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,i=null!=e.width?e.width:e.height,r=null!=e.height?e.height:i;this._vvConvertOptions=new U({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[i,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:[i,1,r]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?k(this._context.renderer,this._vvConvertOptions):null;const n=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?W.World:W.Path;const c=e.profile||"circle";switch(c){default:case"circle":this._profile=Y[n];break;case"quad":this._profile=X[n]}switch(e.join){case"round":this._extruder=new N(0,S);break;case"bevel":this._extruder=new N(0,1);break;case"miter":this._extruder=new N(.8*Math.PI,1);break;default:this._extruder=new H}const h=e.cap||"butt";switch(h){case"none":this._startCap=new q,this._endCap=new q;break;case"butt":default:this._startCap=new M(this._profile,0),this._endCap=new M(this._profile,0,!0);break;case"square":this._startCap=new M(this._profile,-.5),this._endCap=new M(this._profile,.5,!0);break;case"round":{const e="quad"===c;this._startCap=new F({profile:this._profile,flip:!1,breakNormals:e,subdivisions:C}),this._endCap=new F({profile:this._profile,flip:!0,breakNormals:e,subdivisions:C});break}}const m=this.symbolLayer?.material?.color,f=this._getCombinedOpacityAndColor(m),d=p(f),u=f[3],b=this.needsDrivenTransparentPass,g=e.material?.emissive,y={diffuse:d,ambient:d,emissiveStrength:g?.strength??0,emissiveSource:v.Color,opacity:u,drivenOpacity:b,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,i,r),!V(this._intrinsicSize[0])||!V(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let _;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?_=new ie({...y,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,y.normalType=L.Compressed,_=new te(y,this._context)),_.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,cullFace:_.transparent||"none"===h?O.None:O.Back}),this._materials[0]=_}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,re,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t);return this._createAs3DShape(e,i)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e);this._materials[0]?.setParameters({opacity:t})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,w)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return A.RecreateSymbol;if(!R(this._fastUpdates,t,this._vvConvertOptions))return A.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return A.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,r=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const h of i)t+=h.length;const n=y(3*t);let l,c=0;for(const h of i){r.push({offset:c,numVertices:h.length});for(const t of h)n[c++]=t[0],n[c++]=t[1],n[c++]=e.hasZ?t[2]:0}return null==a||s.equals(a)||d(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=_(n):(l=y(3*t),d(n,a,0,l,o,0,t)),{pathVertexDataInfos:r,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const p=new Array,m=n.spatialReference,f=u(),d=this._context.renderCoordsHelper,y=new E(l.vertexDataES),_=a.uid;for(const u of l.pathVertexDataInfos){const e=u.numVertices;if(e<2)continue;const n=u.offset;if(null!=this._context.clippingExtent&&(b(l.vertexDataES,n,e,f),!g(f,this._context.clippingExtent)))continue;const v=new Array,w=n+3*e;for(let i=n;i<w;i+=3){y.offset=i;const e=x(y,this._context.elevationProvider,t,d);h(he,l.vertexDataRS[i],l.vertexDataRS[i+1],l.vertexDataRS[i+2]),d.setAltitude(he,e),l.vertexDataRS[i]=he[0],l.vertexDataRS[i+1]=he[1],l.vertexDataRS[i+2]=he[2],v.push($(this._upVectorAlignment))}const P=new G(v,l.vertexDataES,l.vertexDataRS,n);ae(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new B(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=z(e.size?.field,a)??0,i=z(e.color?.field,a)??0,r=z(e.opacity?.field,a)??0;S=new J(j,t,i,r)}else{const e=c(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];e[0]*=oe(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=oe(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;if(this._drivenProperties.color&&(t=o.color??this._getFallbackOpacityAndColor()),this._drivenProperties.opacity){const e=o.opacity??this._getFallbackOpacityAndColor()[3];t=t?[t[0],t[1],t[2],e]:[1,1,1,e]}const i=new K(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const C=S.createGeometryData(),D=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:_,layerViewUid:this._context.layerViewUid}),V=new T(this._materials[0],C,S,m,this._stencilWidth,D);V.transformation=i(s(),r,j.path.origin),p.push(V)}if(0===p.length)return null;const v=new I({geometries:p,layerViewUid:this._context.layerViewUid,graphicUid:_}),P=new j(this,v,null,((e,t,i,r,s)=>le(e,t,r,s,this._upVectorAlignment)),t,null);return P.alignedSampledElevation=0,P.needsElevationUpdates=w(t.mode),P}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??f}}function ae(e,t,i){const{origin:r,positions:s}=e;let a=e.offset;switch(t){default:case W.World:for(const t of e.vertices)he[0]=s[a++]+r[0],he[1]=s[a++]+r[1],he[2]=s[a++]+r[2],i.worldUpAtPosition(he,he),t.setFrameFromUpVector(he);break;case W.Path:he[0]=s[a]+r[0],he[1]=s[a+1]+r[1],he[2]=s[a+2]+r[2],i.worldUpAtPosition(he,he),Q(e,he)}}function oe(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function ne(e,t,i,r){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)h(he,l[p],l[p+1],l[p+2]),i(he,pe),s+=pe.sampledElevation,he[0]=n[p]+a[0],he[1]=n[p+1]+a[1],he[2]=n[p+2]+a[2],r.setAltitude(he,pe.z),n[p]=he[0]-a[0],n[p+1]=he[1]-a[1],n[p+2]=he[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function le(e,t,i,r,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!Z(l))continue;const e=l.path,o=e.builder.path;n+=ne(o,t,i,r),s!==W.World&&ae(o,s,r),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,ee.POSITION)}return n/o.length}function ce(e){return 1===(e.material?.color?.a??1)}const he=m(),pe=new P;export{se as Graphics3DPathSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as h}from"../../../../chunks/vec32.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as d}from"../../../../geometry/projection/projectBuffer.js";import{create as u,fromSubBuffer as g,intersectsClippingArea as b}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as _}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as v}from"../../../../geometry/support/FloatArray.js";import{EmissiveSourceMode as w}from"../../../../symbols/support/materialUtils.js";import{needsElevationUpdates3D as x,evaluateElevationAlignmentAtPoint as j,SampleElevationInfo as P}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as S}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as C,pathNumRoundCapExtrusionSubdivisions as D}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{isValidSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{ConvertOptions as R,initFastSymbolUpdatesState as k,updateFastSymbolUpdatesState as z,getAttributeValue as E}from"../support/FastSymbolUpdates.js";import{SamplePosition as L}from"../../support/ElevationProvider.js";import{NormalType as O}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as I}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{Path as B}from"../../webgl-engine/lib/Path.js";import{PathBuilder as F}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as M,TriangulationCapBuilder as q,NoCapBuilder as H}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as N,MiterExtruder as W}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as T,PathGeometry as Z,isPathGeometry as J}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as K,StaticPathGeometry as Q}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as X}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as Y,circleProfiles as $}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as ee}from"../../webgl-engine/lib/PathVertex.js";import{VertexAttribute as te}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as re}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ie}from"../../webgl-engine/materials/PathMaterial.js";const se=["polyline"];class ae extends V{constructor(e,t,r,i){super(e,t,r,i,he(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=T.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,r=null!=e.width?e.width:e.height,i=null!=e.height?e.height:r;this._vvConvertOptions=new R({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[r,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:[r,1,i]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?k(this._context.renderer,this._vvConvertOptions):null;const n=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?T.World:T.Path;const c=e.profile||"circle";switch(c){default:case"circle":this._profile=$[n];break;case"quad":this._profile=Y[n]}switch(e.join){case"round":this._extruder=new W(0,C);break;case"bevel":this._extruder=new W(0,1);break;case"miter":this._extruder=new W(.8*Math.PI,1);break;default:this._extruder=new N}const h=e.cap||"butt";switch(h){case"none":this._startCap=new H,this._endCap=new H;break;case"butt":default:this._startCap=new q(this._profile,0),this._endCap=new q(this._profile,0,!0);break;case"square":this._startCap=new q(this._profile,-.5),this._endCap=new q(this._profile,.5,!0);break;case"round":{const e="quad"===c;this._startCap=new M({profile:this._profile,flip:!1,breakNormals:e,subdivisions:D}),this._endCap=new M({profile:this._profile,flip:!0,breakNormals:e,subdivisions:D});break}}const m=this.symbolLayer?.material?.color,f=this._getCombinedOpacityAndColor(m),d=p(f),u=f[3],g=this.needsDrivenTransparentPass,b=e.material?.emissive,y={diffuse:d,ambient:d,emissiveStrength:b?.strength??0,emissiveSource:w.Color,opacity:u,drivenOpacity:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,r,i),!A(this._intrinsicSize[0])||!A(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let _;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?_=new ie({...y,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,y.normalType=O.Compressed,_=new re(y,this._context)),_.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,cullFace:_.transparent||"none"===h?I.None:I.Back}),this._materials[0]=_}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,se,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this._createAs3DShape(e,r)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e);this._materials[0]?.setParameters({opacity:t})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,x)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return U.RecreateSymbol;if(!z(this._fastUpdates,t,this._vvConvertOptions))return U.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return U.FastUpdate}_getVertexData(e){let t=0;const r=e.paths,i=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const h of r)t+=h.length;const n=y(3*t);let l,c=0;for(const h of r){i.push({offset:c,numVertices:h.length});for(const t of h)n[c++]=t[0],n[c++]=t[1],n[c++]=e.hasZ?t[2]:0}return null==a||s.equals(a)||d(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=_(n):(l=y(3*t),d(n,a,0,l,o,0,t)),{pathVertexDataInfos:i,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const p=new Array,m=n.spatialReference,f=u(),d=this._context.renderCoordsHelper,y=new L(l.vertexDataES),_=a.uid,w=v(l.vertexDataRS.length);for(const u of l.pathVertexDataInfos){const e=u.numVertices;if(e<2)continue;const n=u.offset;if(null!=this._context.clippingExtent&&(g(l.vertexDataES,n,e,f),!b(f,this._context.clippingExtent)))continue;const v=new Array,x=n+3*e;for(let r=n;r<x;r+=3){y.offset=r;const e=j(y,this._context.elevationProvider,t,d);h(pe,l.vertexDataRS[r],l.vertexDataRS[r+1],l.vertexDataRS[r+2]),d.setAltitude(pe,e),l.vertexDataRS[r]=pe[0],l.vertexDataRS[r+1]=pe[1],l.vertexDataRS[r+2]=pe[2],v.push(ee(this._upVectorAlignment))}const P=new B(v,l.vertexDataES,l.vertexDataRS,n,w);oe(P,this._upVectorAlignment,this._context.renderCoordsHelper);const S=new F(P,this._profile,this._extruder,this._startCap,this._endCap);let C=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=E(e.size?.field,a)??0,r=E(e.color?.field,a)??0,i=E(e.opacity?.field,a)??0;C=new K(S,t,r,i)}else{const e=c(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];e[0]*=ne(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=ne(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;if(this._drivenProperties.color&&(t=o.color??this._getFallbackOpacityAndColor()),this._drivenProperties.opacity){const e=o.opacity??this._getFallbackOpacityAndColor()[3];t=t?[t[0],t[1],t[2],e]:[1,1,1,e]}const r=new Q(S);r.bake(e),t&&r.bakeVertexColors(t),C=r}const D=C.createGeometryData(),V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:_,layerViewUid:this._context.layerViewUid}),A=new Z(this._materials[0],D,C,m,this._stencilWidth,V);A.transformation=r(s(),i,S.path.origin),p.push(A)}if(0===p.length)return null;const P=new G({geometries:p,layerViewUid:this._context.layerViewUid,graphicUid:_}),C=new S(this,P,null,((e,t,r,i,s)=>ce(e,t,i,s,this._upVectorAlignment)),t,null);return C.alignedSampledElevation=0,C.needsElevationUpdates=x(t.mode),C}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??f}}function oe(e,t,r){const{origin:i,positions:s}=e;let a=e.offset;switch(t){default:case T.World:for(const t of e.vertices)pe[0]=s[a++]+i[0],pe[1]=s[a++]+i[1],pe[2]=s[a++]+i[2],r.worldUpAtPosition(pe,pe),t.setFrameFromUpVector(pe);break;case T.Path:pe[0]=s[a]+i[0],pe[1]=s[a+1]+i[1],pe[2]=s[a+2]+i[2],r.worldUpAtPosition(pe,pe),X(e,pe)}}function ne(e,t,r){switch(e){case"symbol-value":return r;case"proportional":return t;default:return e}}function le(e,t,r,i){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)h(pe,l[p],l[p+1],l[p+2]),r(pe,me),s+=me.sampledElevation,pe[0]=n[p]+a[0],pe[1]=n[p+1]+a[1],pe[2]=n[p+2]+a[2],i.setAltitude(pe,me.z),n[p]=pe[0]-a[0],n[p+1]=pe[1]-a[1],n[p+2]=pe[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function ce(e,t,r,i,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!J(l))continue;const e=l.path,o=e.builder.path;n+=le(o,t,r,i),s!==T.World&&oe(o,s,i),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,te.POSITION)}return n/o.length}function he(e){return 1===(e.material?.color?.a??1)}const pe=m(),me=new P;export{ae as Graphics3DPathSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{baseTypedArrayMemory as t,baseArrayMemory as i,estimateNumberMemory as e}from"../../../../core/memoryEstimations.js";import{isTypedArray as s}from"../../../../core/typedArrayUtil.js";import{l as o,n as h,c as r}from"../../../../chunks/vec32.js";import{fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class f{constructor(t,i,e,s,o){this.vertices=t,this.positionsES=i,this.offset=s,this.positions=o;const h=t.length,r=Math.floor(h/2),f=this.offset+3*r,g=e[f],v=e[f+1],c=e[f+2];this.origin=n(g,v,c);const l=this.offset+3*h;for(let n=this.offset;n<l;n+=3)o[n]=e[n]-g,o[n+1]=e[n+1]-v,o[n+2]=e[n+2]-c;this.updatePathVertexInformation()}get usedMemory(){return this._getSharedBufferSliceMemory(this.positions)}_getSharedBufferSliceMemory(o){return s(o)?(0===this.offset?t:0)+3*this.vertices.length*o.BYTES_PER_ELEMENT:(0===this.offset?i:0)+3*this.vertices.length*e}updatePathVertexInformation(){const t=this.vertices.length,i=this.vertices[0];let e=this.offset;const s=this.positions;i.vRight[0]=s[e+3]-s[e],i.vRight[1]=s[e+4]-s[e+1],i.vRight[2]=s[e+5]-s[e+2],e+=3;let n=o(i.vRight);i.vMinSiblingLength=n,h(i.vRight,i.vRight);let f=i;for(let g=1;g<t;++g){const i=this.vertices[g];if(i.vLeft=f.vRight,g<t-1){i.vRight[0]=s[e+3]-s[e],i.vRight[1]=s[e+4]-s[e+1],i.vRight[2]=s[e+5]-s[e+2];const t=o(i.vRight);i.vMinSiblingLength=Math.min(n,t),n=t,h(i.vRight,i.vRight)}else r(i.vRight,i.vLeft),i.vMinSiblingLength=n;f=i,e+=3}}}export{f as Path};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import i from"../../../core/Accessor.js";import{createTask as t}from"../../../core/asyncUtils.js";import{makeHandle as r,handlesGroup as s}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{getOrCreateMapValue as o}from"../../../core/MapUtils.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{whenOnce as p,watch as d}from"../../../core/reactiveUtils.js";import{addMaybe as c}from"../../../core/SetUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as l}from"../../../core/support/UpdatingHandles.js";import m from"../../../layers/GraphicsLayer.js";import{isSubtypeSublayer as y,isKnowledgeGraphSublayer as v}from"../../../layers/support/layerUtils.js";import{getDisplayedSymbol as g}from"../../../symbols/support/symbolUtils.js";import{GraphicState as f}from"../../3d/layers/graphics/GraphicState.js";var _;!function(e){e[e.FeatureMove=0]="FeatureMove",e[e.VertexMove=1]="VertexMove"}(_||(_={}));const w=()=>a.getLogger("esri.views.draw.support.ConnectedReshapeManager"),G=Symbol();let L=class extends i{constructor(e){super(e),this.activeOperationType=null,this.providerFactories=[],this.view=null,this._activeProviders=new Set,this._graphics=new Map,this._modifiedFeatures=new Map,this._modifiedGraphicsLayer=new m({listMode:"hide",internal:!0,title:"Connected Reshape Modified Graphics (Internal)"}),this._pendingGraphicsLayer=new m({listMode:"hide",internal:!0,title:"Connected Reshape Pending Graphics (Internal)"}),this._pendingFeatures=new Map,this._updatingHandles=new l}initialize(){this.view.map.addMany([this._modifiedGraphicsLayer,this._pendingGraphicsLayer])}destroy(){this.view.destroyed||this.view.map.removeMany([this._modifiedGraphicsLayer,this._pendingGraphicsLayer]),this._modifiedGraphicsLayer.destroy(),this._pendingGraphicsLayer.destroy(),this._updatingHandles.destroy()}get updating(){return this._updatingHandles.updating||Array.from(this._activeProviders).some((e=>e.updating))}startFeatureMove(e){this.activeOperationType=_.FeatureMove,this._activeProviders.clear();for(const i of this.providerFactories)c(this._activeProviders,i.getFeatureReshapeProvider(e))}startVertexMove(e,i){this.activeOperationType=_.VertexMove,this._activeProviders.clear();for(const t of this.providerFactories)c(this._activeProviders,t.getVertexReshapeProvider(e,i))}finish(){this.activeOperationType=null,this._activeProviders.clear();for(const[e,i]of this._pendingFeatures){this._pendingFeatures.delete(e),this._modifiedFeatures.set(e,i);const t=this._graphics.get(e);t&&(this._modifiedGraphicsLayer.add(t),this._pendingGraphicsLayer.remove(t))}}translate(e,i,t=0){if(null===this.activeOperationType)return;const r=P(e),s=P(i),a=P(t);for(const o of this._activeProviders){const e=o.translate(r,s,a);this._update(e)}}async _initializeGraphic(e,i){e.symbol??=await this._updatingHandles.addPromise(g(e,{scale:this.view.scale,useSourceLayer:!0})),this._pendingFeatures.has(i.uniqueId)?this._pendingGraphicsLayer.add(e):this._modifiedFeatures.has(i.uniqueId)&&this._modifiedGraphicsLayer.add(e),this.addHandles(await F(i.originalGraphic,e,this.view),G)}_update(e){for(const i of e){const e=this._modifiedFeatures.delete(i.uniqueId);this._pendingFeatures.set(i.uniqueId,i);const t=o(this._graphics,i.uniqueId,(()=>{const e=i.graphic.cloneShallow();return this._initializeGraphic(e,i),e}));t.geometry=i.graphic.geometry,e&&(this._modifiedGraphicsLayer.remove(t),this._pendingGraphicsLayer.add(t))}}get test(){return{activeProviders:this._activeProviders,modifiedFeatures:this._modifiedFeatures,modifiedGraphicsLayer:this._modifiedGraphicsLayer,pendingFeatures:this._pendingFeatures,pendingGraphicsLayer:this._pendingGraphicsLayer}}};async function F(e,i,a){const o=e.sourceLayer,d=e.getObjectId();if(null==d)return w().error("editing:cannot-hide-graphic","Unable to hide original graphic because it has no objectId."),r();let c=null;function h(e){c?.abort(),c=t((async i=>{const t=await b(a,o);n(i),t&&t.setVisibility?.(d,e)}))}return await M(a,i),h(!1),s([j(a,i,(e=>h(!e))),r((async()=>{h(!0);const e=await b(a,o);await p((()=>!e?.updating))}))])}function j(e,i,t){if("3d"===e.type){const r=new f({graphic:i});return s([e.trackGraphicState(r),d((()=>r.displaying),t)])}return d((()=>i.visible),t)}async function M(e,i){if("3d"===e.type){const t=new f({graphic:i}),r=e.trackGraphicState(t);await p((()=>t.displaying||t.error)),r.remove()}else await p((()=>i.visible))}async function b(e,i){const t=y(i)||v(i)?i.parent:i;return t?e.whenLayerView(t):null}function P(e){return isNaN(e)?0:e}e([h()],L.prototype,"activeOperationType",void 0),e([h()],L.prototype,"providerFactories",void 0),e([h()],L.prototype,"updating",null),e([h({constructOnly:!0})],L.prototype,"view",void 0),L=e([u("esri.views.draw.support.ConnectedReshapeManager")],L);export{L as ConnectedReshapeManager,_ as ConnectedReshapeOperationType,F as swapForEditingSession,j as watchGraphicVisibility,M as whenGraphicDisplayed};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import b from"../../../layers/GraphicsLayer.js";import M from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as S}from"../../2d/interactive/SnappingVisualizer2D.js";import{cloneMove as w}from"./drawUtils.js";import E from"./GraphicMover.js";import O from"./HighlightHelper.js";import{addUniqueLayer as I}from"./layerUtils.js";import{createTooltipInfos as k,connectTooltip as C,updateTranslateTooltipInfo as T,updateTranslateVertexTooltipInfo as H}from"./reshapeTooltipUtils.js";import{settings as j}from"./settings.js";import{ViewEventPriorities as R}from"../../input/InputManager.js";import{createCoordinateHelper as A}from"../../interactive/coordinateHelper.js";import{sketchKeys as U}from"../../interactive/keybindings.js";import{EditGeometryOperations as L}from"../../interactive/editGeometry/EditGeometryOperations.js";import z from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as D}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as F,enterInputModeIfAvailable as P}from"../../interactive/tooltip/tooltipCommonUtils.js";class N{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class Z{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class X{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class Y{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class K{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class B{constructor(e){this.added=e,this.type="vertex-select"}}class J{constructor(e){this.removed=e,this.type="vertex-deselect"}}class Q{constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class W{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const $=j.reshapeGraphics,ee={vertices:{default:new M({style:"circle",size:$.vertex.size,color:$.vertex.color,outline:{color:$.vertex.outlineColor,width:1}}),hover:new M({style:"circle",size:$.vertex.hoverSize,color:$.vertex.hoverColor,outline:{color:$.vertex.hoverOutlineColor,width:1}}),selected:new M({style:"circle",size:$.selected.size,color:$.selected.color,outline:{color:$.selected.outlineColor,width:1}})},midpoints:{default:new M({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}}),hover:new M({style:"circle",size:$.midpoint.size,color:$.midpoint.color,outline:{color:$.midpoint.outlineColor,width:1}})}};let te=class extends r.EventedAccessor{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new M({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=ee,this.sketchOptions=new z,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new O({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c((()=>this.graphic?.geometry),(e=>{if(!e)return;const t=new Set(this.selectedVertices.map((e=>e.attributes?.pointIndex)));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter((e=>t.has(e.attributes.pointIndex))).forEach((e=>this._addToSelection(e)));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)}),v),this.tooltip=F((()=>({view:e,options:this.sketchOptions.tooltips}))),this.tooltipInfos=k(this.sketchOptions),this.addHandles([l((()=>e?.ready),(()=>{const{layer:e,view:t}=this;I(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),R.TOOL))}),{once:!0,initial:!0}),d((()=>this.graphic),(()=>this.refresh())),d((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),d((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),d((()=>this.enableMidpoints),(()=>this.refresh())),C(this.tooltip,(()=>this._tooltipsContext)),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??A(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=L.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new b({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new D({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new S(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=ie(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach(((e,r)=>{e.forEach(((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const h=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[e],p=n[h],c=this._getMidpoint(a,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new E({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e;if(s===this.graphic){const{geometry:o}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),void(null!=o&&"point"===o.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}if(!this.selectedVertices.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=ie(n);this._updateVertexGraphicLocations(t),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=se(e);return a(this._editGeometryOperations),this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=e.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r())}))}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(e,i,t,s,a),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[h,a]=se(e);let p=G(r);const c=p[h].length-1,l=n.pointToArray(t);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=w(r.geometry,i,s,this.view),p=G(a),c=e[t].length-1;e[t][n]=p,r.geometry=a,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of h){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=a}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=e.attributes,p=G(e.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=oe(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&P(e,this.tooltip)||U.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=oe(e);for(const h of n){const{x:e,y:t}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];e===h&&t===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,T(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,H(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i=new Y(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i=new K(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i=new q(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t=new N(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t=new Z(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t=new X(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t=new B(e);this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t=new J(e);this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s=new Q(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s=new W(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function ie(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function se({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function oe(e){return e instanceof t?[e]:[...e]}e([y()],te.prototype,"_activeOperationInfo",void 0),e([y()],te.prototype,"_coordinateHelper",null),e([y()],te.prototype,"_editGeometryOperations",void 0),e([y()],te.prototype,"tooltip",void 0),e([y()],te.prototype,"tooltipInfos",void 0),e([y()],te.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],te.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],te.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],te.prototype,"_selectedVertex",null),e([y()],te.prototype,"_tooltipsContext",null),e([y()],te.prototype,"callbacks",void 0),e([y()],te.prototype,"enableMidpoints",void 0),e([y()],te.prototype,"enableMovement",void 0),e([y()],te.prototype,"enableVertices",void 0),e([y()],te.prototype,"graphic",void 0),e([y()],te.prototype,"highlightName",void 0),e([y()],te.prototype,"highlightsEnabled",void 0),e([y()],te.prototype,"layer",void 0),e([y({readOnly:!0})],te.prototype,"midpointGraphics",void 0),e([y()],te.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],te.prototype,"selectedVertices",void 0),e([y()],te.prototype,"snappingManager",void 0),e([y({readOnly:!0})],te.prototype,"state",null),e([y()],te.prototype,"symbols",void 0),e([y({type:z})],te.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],te.prototype,"type",void 0),e([y({readOnly:!0})],te.prototype,"vertexGraphics",void 0),e([y()],te.prototype,"view",void 0),te=e([_("esri.views.draw.support.Reshape")],te);const re=te;export{re as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import{createTask as i}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import o from"../../../core/Error.js";import r from"../../../core/Evented.js";import n from"../../../core/Logger.js";import{destroyMaybe as h,assertIsSome as a,abortMaybe as p}from"../../../core/maybe.js";import{pausable as c,when as l,watch as d,initial as m,sync as v}from"../../../core/reactiveUtils.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import g from"../../../geometry/Point.js";import u from"../../../geometry/Polyline.js";import{closeRingsAndFixWinding as f,getMidpoint as x,geometryToCoordinates as G}from"../../../geometry/support/coordsUtils.js";import M from"../../../layers/GraphicsLayer.js";import b from"../../../symbols/SimpleMarkerSymbol.js";import{ViewingMode as V}from"../../ViewingMode.js";import{SnappingVisualizer2D as w}from"../../2d/interactive/SnappingVisualizer2D.js";import{ConnectedReshapeManager as S}from"./ConnectedReshapeManager.js";import{cloneMove as E}from"./drawUtils.js";import I from"./GraphicMover.js";import O from"./HighlightHelper.js";import{addUniqueLayer as k,isConnectedReshapeSupportedLayer as C}from"./layerUtils.js";import{createTooltipInfos as T,connectTooltip as R,updateTranslateTooltipInfo as H,updateTranslateVertexTooltipInfo as j}from"./reshapeTooltipUtils.js";import{settings as A}from"./settings.js";import{ViewEventPriorities as U}from"../../input/InputManager.js";import{createCoordinateHelper as L}from"../../interactive/coordinateHelper.js";import{sketchKeys as P}from"../../interactive/keybindings.js";import{EditGeometryOperations as z}from"../../interactive/editGeometry/EditGeometryOperations.js";import D from"../../interactive/sketch/SketchOptions.js";import{SnappingContext as F}from"../../interactive/snapping/SnappingContext.js";import{makeTooltip as N,enterInputModeIfAvailable as Z}from"../../interactive/tooltip/tooltipCommonUtils.js";class X{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-start"}}class Y{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape"}}class K{constructor(e,t,i){this.graphic=e,this.mover=t,this.selected=i,this.type="reshape-stop"}}class q{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-start"}}class B{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move"}}class J{constructor(e,t,i){this.mover=e,this.dx=t,this.dy=i,this.type="move-stop"}}class Q{constructor(e){this.added=e,this.type="vertex-select"}}class W{constructor(e){this.removed=e,this.type="vertex-deselect"}}class ${constructor(e,t,i,s){this.added=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-add"}}class ee{constructor(e,t,i,s){this.removed=e,this.graphic=t,this.oldGraphic=i,this.vertices=s,this.type="vertex-remove"}}const te=A.reshapeGraphics,ie={vertices:{default:new b({style:"circle",size:te.vertex.size,color:te.vertex.color,outline:{color:te.vertex.outlineColor,width:1}}),hover:new b({style:"circle",size:te.vertex.hoverSize,color:te.vertex.hoverColor,outline:{color:te.vertex.hoverOutlineColor,width:1}}),selected:new b({style:"circle",size:te.selected.size,color:te.selected.color,outline:{color:te.selected.outlineColor,width:1}})},midpoints:{default:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}}),hover:new b({style:"circle",size:te.midpoint.size,color:te.midpoint.color,outline:{color:te.midpoint.outlineColor,width:1}})}};let se=class extends r.EventedAccessor{constructor(e){super(e),this._updateHandlesOnExternalGeometryChange=null,this._activeOperationInfo=null,this._connectedReshapeManager=null,this._editGeometryOperations=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._snappingContext=null,this._snappingGraphicsLayer=null,this._hoverGraphic=null,this._snappingTask=null,this._stagedVertex=null,this.tooltip=null,this.activeTooltipInfo=null,this.callbacks={onReshapeStart(){},onReshape(){},onReshapeStop(){},onMoveStart(){},onMove(){},onMoveStop(){},onGraphicClick(){}},this.connectedReshapeProviders=[],this.enableMidpoints=!0,this.enableMovement=!0,this.enableVertices=!0,this.graphic=null,this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.midpointGraphics=new s,this.midpointSymbol=new b({style:"circle",size:6,color:[200,200,200],outline:{color:[100,100,100],width:1}}),this.selectedVertices=new s,this.snappingManager=null,this.symbols=ie,this.sketchOptions=new D,this.type="reshape",this.vertexGraphics=new s,this.view=null}initialize(){const e=this.view;this._highlightHelper=new O({view:e}),this._setup(),this._updateHandlesOnExternalGeometryChange=c((()=>this.graphic?.geometry),(e=>{if(!e)return;const t=new Set(this.selectedVertices.map((e=>e.attributes?.pointIndex)));this._highlightHelper.removeAll(),this._setUpHighlights(),this._setupGraphics(),this._clearSelection(),this.vertexGraphics.filter((e=>t.has(e.attributes.pointIndex))).forEach((e=>this._addToSelection(e)));const{enableMovement:i,_mover:s,graphic:o,midpointGraphics:r,vertexGraphics:n}=this,h=n.concat(r).items;i&&h.push(o),s?.set("graphics",h)}),v),this.tooltip=N((()=>({view:e,options:this.sketchOptions.tooltips}))),this.tooltipInfos=T(this.sketchOptions),this.addHandles([l((()=>e?.ready),(()=>{const{layer:e,view:t}=this;k(t,e),this.addHandles(t.on("key-down",(e=>this._keyDownHandler(e)),U.TOOL))}),{once:!0,initial:!0}),d((()=>this.graphic),(()=>this.refresh())),d((()=>this.layer),((e,t)=>{t&&(this._clearSelection(),this._resetGraphics(t)),this.refresh()})),d((()=>[this.highlightsEnabled,this.highlightName]),(()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()})),d((()=>this.enableMidpoints),(()=>this.refresh())),R(this.tooltip,(()=>this._tooltipsContext)),d((()=>this.view.effectiveTheme.accentColor),(()=>this._updateSymbolsForTheme()),m),this._updateHandlesOnExternalGeometryChange]),this._updateTooltip()}destroy(){this._reset(),this._mover?.destroy(),this._mover=null,this._connectedReshapeManager=h(this._connectedReshapeManager),this.tooltip=h(this.tooltip)}get _coordinateHelper(){return this._editGeometryOperations?.data.coordinateHelper??L(!!this.graphic.geometry?.hasZ,!!this.graphic.geometry?.hasM,this.view.spatialReference)}get _selectedVertex(){return 1===this.selectedVertices.length?this.selectedVertices.at(0):void 0}get _tooltipsContext(){const{automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,sketchOptions:i,activeTooltipInfo:s,graphic:o}=this;return{sketchOptions:i,activeTooltipInfo:s,graphic:o,selectedVertex:this._selectedVertex,automaticAreaMeasurementUtils:e,automaticLengthMeasurementUtils:t,updateGeometry:(e,t,i,s,o)=>{this._setUpGeometryHelper();const r=e===this.graphic;r?this._emitMoveStartEvent(0,0):this._emitReshapeStartEvent(e);const n=!0;if(this._syncGeometryAfterVertexMove(e,t,s,o,n),r){const{view:e}=this,s=e.toScreen(i),o=e.toScreen(t),r=(o?.x??0)-(s?.x??0),n=(o?.y??0)-(s?.y??0);this._emitMoveEvent(r,n),this._emitMoveStopEvent(r,n)}else this._emitReshapeEvent(e),this._emitReshapeStopEvent(e);this._editGeometryOperations=h(this._editGeometryOperations)}}}get state(){const e=this.view.ready,t=!(!this.graphic||!this.layer);return e&&t?"active":e?"ready":"disabled"}isUIGraphic(e){const t=[];return this.graphic&&t.push(this.graphic),t.concat(this.vertexGraphics.items,this.midpointGraphics.items),t.length>0&&t.includes(e)}refresh(){this._reset(),this._setup()}reset(){this.graphic=null}clearSelection(){this._clearSelection()}removeSelectedVertices(){const{selectedVertices:e}=this;e.length&&this._removeVertices(e)}_setup(){const{graphic:e,layer:t}=this;if(!t||null==e?.geometry)return;const i=e.geometry;"mesh"!==i.type&&"extent"!==i.type?("polygon"===i.type&&f(i),this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._setupConnectedReshapeManager()):this._logGeometryTypeError()}_setUpHighlights(){this.highlightsEnabled&&this.graphic&&this._highlightHelper?.add(this.graphic,this.highlightName)}_setUpGeometryHelper(){const e=this.graphic.geometry;if(null==e||"mesh"===e.type||"extent"===e.type)return void this._logGeometryTypeError();const t="multipoint"===e.type?new u({paths:[e.points],spatialReference:e.spatialReference}):e;this._editGeometryOperations=z.fromGeometry(t,V.Local)}_saveSnappingContextForHandle(e,t){this._snappingGraphicsLayer=new M({listMode:"hide",internal:!0,title:"Reshape snapping layer"}),this.view.map.layers.add(this._snappingGraphicsLayer);const i=this._editGeometryOperations;a(i),this._snappingContext=new F({editGeometryOperations:i,elevationInfo:{mode:"on-the-ground",offset:0},pointer:t.viewEvent?.pointerType||"mouse",excludeFeature:this.graphic,feature:this.graphic,visualizer:new w(this._snappingGraphicsLayer),vertexHandle:this._getVertexFromEditGeometry(e)})}_reset(){this._clearSelection(),this._highlightHelper?.removeAll(),this._updateTooltip(),this._resetGraphics(),this._resetSnappingStateVars(),this._activeOperationInfo=null,this._mover&&this._mover.destroy(),this._mover=null,this.view.cursor="default"}_resetSnappingStateVars(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),null!=this._snappingGraphicsLayer&&(this.view?.map&&this.view.map.layers.remove(this._snappingGraphicsLayer),this._snappingGraphicsLayer.destroy()),this._editGeometryOperations=h(this._editGeometryOperations),this._snappingTask=p(this._snappingTask),this._snappingTask=null,this._snappingContext=null,this._stagedVertex=null}_resetGraphics(e){this._removeMidpointGraphics(e),this._removeVertexGraphics(e),this.selectedVertices.removeAll(),this._updateTooltip()}_removeMidpointGraphics(e){const t=e||this.layer;t&&t.removeMany(this.midpointGraphics.items),this.midpointGraphics.items.forEach((e=>e.destroy())),this.midpointGraphics.removeAll()}_removeVertexGraphics(e){const t=e||this.layer;t&&t.removeMany(this.vertexGraphics.items),this.vertexGraphics.items.forEach((e=>e.destroy())),this.vertexGraphics.removeAll()}_setupGraphics(){const e=this.graphic.geometry;if(null!=e&&("polyline"===e.type||"polygon"===e.type)){const t=oe(e);this.enableMidpoints&&this._setUpMidpointGraphics(t),this.enableVertices&&this._setUpVertexGraphics(t)}}_setUpMidpointGraphics(e){this._removeMidpointGraphics();const t=this._createMidpointGraphics(e);this.midpointGraphics.addMany(t),this.layer.addMany(t)}_setUpVertexGraphics(e){this._removeVertexGraphics();const t=this._createVertexGraphics(e);this.vertexGraphics.addMany(t),this._storeRelatedVertexIndices(),this.layer.addMany(t)}_createVertexGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];return e?.forEach(((e,r)=>{e.forEach(((e,n)=>{o.push(new t({geometry:this._coordinateHelper.arrayToPoint(e),symbol:s?.vertices?.default,attributes:{...i,pathIndex:r,pointIndex:n}}))}))})),o}_createMidpointGraphics(e){const{_graphicAttributes:i,symbols:s}=this,o=[];for(let r=0;r<e.length;r++){const n=e[r];for(let e=0;e<n.length;e++){const h=(e+1)%n.length;if("polyline"===this.graphic.geometry?.type&&0===h)continue;const a=n[e],p=n[h],c=this._getMidpoint(a,p);o.push(new t({geometry:c,symbol:s.midpoints.default,attributes:{...i,pathIndex:r,pointIndexStart:e,pointIndexEnd:h}}))}}return o}_updateSymbolsForTheme(){const e=this.view.effectiveTheme.accentColor;this.symbols={vertices:{...this.symbols.vertices,default:this.symbols.vertices.default.clone().set("color",e),hover:this.symbols.vertices.hover?.clone().set("color",e)},midpoints:{...this.symbols.midpoints}};for(const t of this.vertexGraphics)this._isSelected(t)?t.symbol=this.symbols.vertices.selected:this._hoverGraphic===t?t.symbol=this.symbols.vertices.hover:t.symbol=this.symbols.vertices.default}_storeRelatedVertexIndices(){const e=this.vertexGraphics.items;if(!e)return;const t=e.map((({geometry:e})=>({x:e.x,y:e.y})));for(let i=0;i<t.length;i++){const s=[];for(let e=0;e<t.length;e++){if(i===e)continue;const o=t[i],r=t[e];o.x===r.x&&o.y===r.y&&s.push(e)}e[i].attributes.relatedGraphicIndices=s}}_setupMover(){const{enableMovement:e,graphic:t,midpointGraphics:i,vertexGraphics:s,view:o}=this,r=s.concat(i).items;e&&r.push(t),this._mover=new I({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,graphics:r,view:o,callbacks:{onGraphicClick:e=>this._onGraphicClickCallback(e),onGraphicMoveStart:e=>this._onGraphicMoveStartCallback(e),onGraphicMove:e=>this._onGraphicMoveCallback(e),onGraphicMoveStop:e=>this._onGraphicMoveStopCallback(e),onGraphicPointerOver:e=>this._onGraphicPointerOverCallback(e),onGraphicPointerOut:e=>this._onGraphicPointerOutCallback(e)}})}_setupConnectedReshapeManager(){const{connectedReshapeProviders:e}=this;0!==e.length&&(this._connectedReshapeManager=new S({providerFactories:e,view:this.view}))}_onGraphicClickCallback(e){e.viewEvent.stopPropagation();const t=e.graphic;if(t===this.graphic)this.clearSelection(),this.emit("graphic-click",e),this.callbacks.onGraphicClick?.(e);else if(this._isMidpoint(t)){if(2===e.viewEvent.button)return;const i=this.graphic.clone(),s=this._createVertexFromMidpoint(t);this.refresh(),this._emitVertexAddEvent([t],i,s)}else if(this._isVertex(t))if(e.viewEvent.stopPropagation(),2===e.viewEvent.button)this._removeVertices(t);else{e.viewEvent.native.shiftKey||this._clearSelection(),this.selectedVertices.includes(t)?this._removeFromSelection(t,!0):this._addToSelection(t)}}_setUpOperation(e){const{graphic:t,dx:i,dy:s}=e,o=t===this.graphic;this._resetSnappingStateVars(),this._setUpGeometryHelper(),this._saveSnappingContextForHandle(t,e),this._activeOperationInfo={target:this.graphic,mover:t,operationType:o?"move":"reshape",totalDx:i,totalDy:s}}_onGraphicMoveStartCallback(e){const{dx:t,dy:i,graphic:s}=e,o=this._connectedReshapeManager,r=o?he(this.graphic):null;if(s===this.graphic){const{geometry:n}=s;return this._setUpOperation(e),this._emitMoveStartEvent(t,i),r&&o?.startFeatureMove([r]),void(null!=n&&"point"===n.type&&this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(t,i)})))}const{selectedVertices:n}=this;if(!n.includes(s)){if(this._clearSelection(),this._isMidpoint(s)){const e=this.graphic.clone(),t=this._createVertexFromMidpoint(s);this._emitVertexAddEvent([s],e,t)}this._addToSelection(s)}this._setUpOperation(e),r&&o?.startVertexMove(r,ae(n)),this._emitReshapeStartEvent(s),this._onHandleMove(s,t,i,e,(()=>{this._updateTooltip(s,e.viewEvent),this._emitReshapeEvent(s)}))}_onGraphicMoveCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e;t.totalDx+=i,t.totalDy+=s;const{operationType:r}=t,{geometry:n}=o;if(null!=n)if("move"!==r)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(o,e.viewEvent),this._emitReshapeEvent(o)}));else if("point"===n.type)this._onHandleMove(o,i,s,e,(()=>{this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}));else if("polyline"===n.type||"polygon"===n.type){const t=oe(n);this._updateVertexGraphicLocations(t);const{dxMap:o,dyMap:r}=pe(i,s,this.view);this._connectedReshapeManager?.translate(o,r,0),this._updateTooltip(this.graphic,e.viewEvent),this._emitMoveEvent(i,s)}}_onGraphicMoveStopCallback(e){const t=this._activeOperationInfo;if(!t)return;const{dx:i,dy:s,graphic:o}=e,{operationType:r}=t;t.totalDx+=i,t.totalDy+=s,this._onHandleMove(o,i,s,e,(()=>"move"===r?this._emitMoveStopEvent():this._emitReshapeStopEvent(o))),this._isMidpoint(o)?this.refresh():(this._updateTooltip(this._isVertex(o)?o:null),this._resetSnappingStateVars(),this._connectedReshapeManager?.finish(),this._activeOperationInfo=null)}_updateVertexGraphicLocations(e){const{_coordinateHelper:t}=this;for(const i of this.vertexGraphics){const{pathIndex:s,pointIndex:o}=i.attributes;i.geometry=t.arrayToPoint(e[s][o])}this._updateMidpointGraphicLocations(e)}_updateMidpointGraphicLocations(e){for(const t of this.midpointGraphics){const{pathIndex:i,pointIndexStart:s,pointIndexEnd:o}=t.attributes,r=e[i];t.geometry=this._getMidpoint(r[s],r[o])}}_getMidpoint(e,t){const{_coordinateHelper:i}=this,s=i.arrayToVector(e),o=i.arrayToVector(t),r=i.toXYZ(s),n=i.toXYZ(o),[h,a,p]=x(r,n),c=i.hasM()?0:void 0;return new g({x:h,y:a,z:p,m:c,spatialReference:i.spatialReference})}_getVertexFromEditGeometry(e){const[t,i]=re(e);return a(this._editGeometryOperations),this._editGeometryOperations.data.components[t].vertices[i]}_onHandleMove(e,t,s,o,r){p(this._snappingTask);const n=this._snappingContext;if(!n)return;const h=e.geometry,a="graphic-move-stop"===o.type;if(null!=this.snappingManager&&this.selectedVertices.length<2&&!a){const o=this.snappingManager;this._stagedVertex=o.update({point:h,context:n}),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r(),this._snappingTask=i((async i=>{const p=await o.snap({point:h,context:n,signal:i});p.valid&&(this._stagedVertex=p.apply(),this._syncGeometryAfterVertexMove(e,new g(this._stagedVertex),t,s,a),r())}))}else{const i=null!=this._stagedVertex?new g(this._stagedVertex):h;this._syncGeometryAfterVertexMove(e,i,t,s,a),r()}}_syncGeometryAfterVertexMove(e,t,i,s,o=!1){const r=this._editGeometryOperations?.data.geometry;if(r)if("point"===r.type)e.geometry=t;else if("mesh"===r.type)e.geometry=r.centerAt(t);else{const{_coordinateHelper:n}=this,[h,a]=re(e);let p=G(r);const c=p[h].length-1,l=n.pointToArray(t);p[h][a]=l,"polygon"===r.type&&(0===a?p[h][c]=l:a===c&&(p[h][0]=l)),this._isVertex(e)&&(p=this._moveRelatedCoordinates(p,e,l),p=this._moveSelectedHandleCoordinates(p,e,i,s,"polygon"===r.type),this._updateMidpointGraphicLocations(p)),this._updateGraphicGeometry(r.clone());const d=n.pointToVector(t),m=this._getVertexFromEditGeometry(e),v=n.getZ(d),y=d[0]-m.pos[0],_=d[1]-m.pos[1],g=null!=v?v-m.pos[2]:0;this._editGeometryOperations?.moveVertices([m],y,_,g),this._connectedReshapeManager?.translate(y,_,g),o&&(this._mover?this._mover.updateGeometry(this._mover.graphics.indexOf(e),t):e.geometry=t)}}_moveRelatedCoordinates(e,t,i){const{relatedGraphicIndices:s}=t.attributes;for(const o of s){const s=this.vertexGraphics.at(o),{pathIndex:r,pointIndex:n}=s.attributes;e[r][n]=i,s.geometry=t.geometry}return e}_moveSelectedHandleCoordinates(e,t,i,s,o){for(const r of this.selectedVertices)if(r!==t){const{pathIndex:t,pointIndex:n,relatedGraphicIndices:h}=r.attributes,a=E(r.geometry,i,s,this.view),p=G(a),c=e[t].length-1;e[t][n]=p,r.geometry=a,o&&(0===n?e[t][c]=p:n===c&&(e[t][0]=p));for(const i of h){const t=this.vertexGraphics.at(i),{pathIndex:s,pointIndex:o}=t.attributes;e[s][o]=p,t.geometry=a}}return e}_onGraphicPointerOverCallback(e){const t=e.graphic;this._hoverGraphic=t;const i=this._isVertex(t);i&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.hover),this._updateTooltip(i?t:null),this._updateHoverCursor(t)}_onGraphicPointerOutCallback(e){const t=e.graphic;this._hoverGraphic=null,this._isVertex(t)&&!this._isSelected(t)&&(t.symbol=this.symbols.vertices.default),this.view.cursor="default",this._updateTooltip()}_createVertexFromMidpoint(e){const{_graphicAttributes:t,graphic:i}=this,s=i.geometry;if(null==s||"polygon"!==s.type&&"polyline"!==s.type)return[];const o=s.clone(),r=[],{pathIndex:n,pointIndexStart:h,pointIndexEnd:a}=e.attributes,p=G(e.geometry),c=0===a?h+1:a,l=G(o);return l[n].splice(c,0,p),e.attributes={...t,pathIndex:n,pointIndex:c,relatedGraphicIndices:[]},r.push({coordinates:l[n][c],componentIndex:n,vertexIndex:c}),this._updateGraphicGeometry(o),r}_addToSelection(e){const t=ne(e);for(const i of t)i.symbol=this.symbols.vertices.selected,this.selectedVertices.add(i),this._updateTooltip(i);this._emitSelectEvent(t)}_removeFromSelection(e,t){const{vertices:i}=this.symbols,s=t?i.hover:i.default;this.selectedVertices.remove(e),e.symbol=s,this._emitDeselectEvent([e]),this._updateTooltip()}_clearSelection(){const e=this.selectedVertices.toArray();if(e.length>0){for(const t of e)t.set("symbol",this.symbols.vertices.default);this.selectedVertices.removeAll(),this._emitDeselectEvent(e),this._updateTooltip()}}_keyDownHandler(e){null==this._activeOperationInfo&&Z(e,this.tooltip)||P.delete.includes(e.key)&&!e.repeat&&this.selectedVertices.length&&this._removeVertices(this.selectedVertices)}_removeVertices(e){const t=this.graphic.geometry;if(null==t||"polygon"!==t.type&&"polyline"!==t.type)return;if("polygon"===t.type&&this.vertexGraphics.length<4||this.vertexGraphics.length<3)return;const i=this.graphic.clone(),s=t.clone();let o=G(s);const r=[],n=ne(e);for(const h of n){const{x:e,y:t}=h.geometry;for(let i=0;i<o.length;i++){const s=o[i];for(let n=0;n<s.length;n++){const[h,a]=s[n];e===h&&t===a&&(r.push({coordinates:o[i][n],componentIndex:i,vertexIndex:n}),o[i].splice(Number(n),1))}}}if("polygon"===s.type)o=o.filter((e=>{if(e.length<2)return!1;const[t,i]=e[0],[s,o]=e[e.length-1];return(2!==e.length||t!==s||i!==o)&&(t===s&&i===o||e.push(e[0]),!0)})),s.rings=o;else{for(const e of o)1===e.length&&o.splice(o.indexOf(e),1);s.paths=o}this._updateGraphicGeometry(s),this.refresh(),this._emitVertexRemoveEvent(n,i,r)}_isVertex(e){return this.vertexGraphics.includes(e)}_isSelected(e){return this._isVertex(e)&&this.selectedVertices.includes(e)}_isMidpoint(e){return this.midpointGraphics.includes(e)}_updateHoverCursor(e){this.view.cursor=this._isMidpoint(e)?"copy":"move"}_updateTooltip(e,t){let i=null;const{graphic:s,view:o,tooltipInfos:r}=this,n=s?.geometry;"point"===n?.type?i=r.movePoint:this._selectedVertex?i=r.selectedVertex:e===this.graphic?(i=r.translateGraphic,H(i,o,this._tooltipsContext,t)):e&&this.selectedVertices.length>1&&(i=r.translateVertices,j(i,o,n,this._tooltipsContext,t)),this.activeTooltipInfo=i}_updateGraphicGeometry(e){this._updateHandlesOnExternalGeometryChange?.pause(),this.graphic.geometry=e,this._updateHandlesOnExternalGeometryChange?.resume()}_emitMoveStartEvent(e,t){const i=new q(this.graphic,e,t);this.emit("move-start",i),this.callbacks.onMoveStart?.(i)}_emitMoveEvent(e,t){const i=new B(this.graphic,e,t);this.emit("move",i),this.callbacks.onMove?.(i)}_emitMoveStopEvent(e,t){if(null==e||null==t){const i=this._activeOperationInfo;if(!i)return;e=i.totalDx,t=i.totalDy}const i=new J(this.graphic,e,t);this.emit("move-stop",i),this.callbacks.onMoveStop?.(i)}_emitReshapeStartEvent(e){const t=new X(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-start",t),this.callbacks.onReshapeStart?.(t)}_emitReshapeEvent(e){const t=new Y(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape",t),this.callbacks.onReshape?.(t)}_emitReshapeStopEvent(e){const t=new K(this.graphic,e,this.selectedVertices.toArray());this.emit("reshape-stop",t),this.callbacks.onReshapeStop?.(t)}_emitSelectEvent(e){const t=new Q(e);this.emit("select",t),this.callbacks.onVertexSelect?.(t)}_emitDeselectEvent(e){const t=new W(e);this.emit("deselect",t),this.callbacks.onVertexDeselect?.(t)}_emitVertexAddEvent(e,t,i){const s=new $(e,this.graphic,t,i);this.emit("vertex-add",s),this.callbacks.onVertexAdd?.(s)}_emitVertexRemoveEvent(e,t,i){const s=new ee(e,this.graphic,t,i);this.emit("vertex-remove",s),this.callbacks.onVertexRemove?.(s)}_logGeometryTypeError(){n.getLogger(this).error(new o("reshape:invalid-geometry","Reshape operation not supported for the provided graphic. The geometry type is not supported."))}};function oe(e){const t=G(e.clone());if("polygon"===e.type)for(const i of t){const e=i[i.length-1];i[0][0]===e[0]&&i[0][1]===e[1]&&i.length>2&&i.pop()}return t}function re({attributes:e}){return[e?.pathIndex||0,e?.pointIndex||0]}function ne(e){return e instanceof t?[e]:[...e]}function he(e){const t=e.sourceLayer??e.layer;return C(t)?{graphic:e,layer:t}:null}function ae(e){return e.toArray().map((e=>({pathIndex:e.attributes.pathIndex,vertexIndex:e.attributes.pointIndex})))}function pe(e,t,i){const s=i.state.inverseTransform;return{dxMap:s[0]*e+s[2]*t,dyMap:s[1]*e+s[3]*t}}e([y()],se.prototype,"_activeOperationInfo",void 0),e([y()],se.prototype,"_connectedReshapeManager",void 0),e([y()],se.prototype,"_coordinateHelper",null),e([y()],se.prototype,"_editGeometryOperations",void 0),e([y()],se.prototype,"tooltip",void 0),e([y()],se.prototype,"tooltipInfos",void 0),e([y()],se.prototype,"activeTooltipInfo",void 0),e([y({constructOnly:!0})],se.prototype,"automaticAreaMeasurementUtils",void 0),e([y({constructOnly:!0})],se.prototype,"automaticLengthMeasurementUtils",void 0),e([y()],se.prototype,"_selectedVertex",null),e([y()],se.prototype,"_tooltipsContext",null),e([y()],se.prototype,"callbacks",void 0),e([y()],se.prototype,"connectedReshapeProviders",void 0),e([y()],se.prototype,"enableMidpoints",void 0),e([y()],se.prototype,"enableMovement",void 0),e([y()],se.prototype,"enableVertices",void 0),e([y()],se.prototype,"graphic",void 0),e([y()],se.prototype,"highlightName",void 0),e([y()],se.prototype,"highlightsEnabled",void 0),e([y()],se.prototype,"layer",void 0),e([y({readOnly:!0})],se.prototype,"midpointGraphics",void 0),e([y()],se.prototype,"midpointSymbol",void 0),e([y({readOnly:!0})],se.prototype,"selectedVertices",void 0),e([y()],se.prototype,"snappingManager",void 0),e([y({readOnly:!0})],se.prototype,"state",null),e([y()],se.prototype,"symbols",void 0),e([y({type:D})],se.prototype,"sketchOptions",void 0),e([y({readOnly:!0})],se.prototype,"type",void 0),e([y({readOnly:!0})],se.prototype,"vertexGraphics",void 0),e([y()],se.prototype,"view",void 0),se=e([_("esri.views.draw.support.Reshape")],se);const ce=se;export{ce 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.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
function
|
|
5
|
+
import{isEditableLayer as r}from"../../../layers/support/editableLayers.js";import{isSubtypeSublayer as e,isGraphicsLayer as s,isKnowledgeGraphSublayer as n}from"../../../layers/support/layerUtils.js";function t(r,e,s){if(!e||!r?.map)return;const{map:n}=r,t=n.layers.find((r=>r===e));t||n.add(e,s),t&&null!=s&&n.layers.reorder(t,s)}function l(r,e){const s="subtype-sublayer"===e?.type?e.parent:e;return r.allLayerViews.find((r=>{const e=r.layer;return e===s||"sublayers"in e&&null!=e.sublayers&&e.sublayers.includes(s)}))}function a(t){return r(t)||e(t)||s(t)||n(t)}export{t as addUniqueLayer,l as findLayerView,a as isConnectedReshapeSupportedLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isImageSource as
|
|
5
|
+
import t from"../../request.js";import e from"../../geometry/Point.js";import{execute as r}from"../../geometry/operators/projectOperator.js";import{projectResolution as i,getProjectionOffsetGrid as a,load as s}from"../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isImageSource as n,rasterize as o}from"../2d/engine/Bitmap.js";import m from"../2d/engine/webgl/VertexStream.js";import{createProgramTemplate as c}from"../2d/engine/webgl/shaders/MaterialPrograms.js";import{TextureWrapMode as p,PixelFormat as h,PixelType as x}from"../webgl/enums.js";import{FramebufferObject as u}from"../webgl/FramebufferObject.js";import{createTransformTexture as d}from"../webgl/rasterUtils.js";import{RenderingContext as g}from"../webgl/RenderingContext.js";import{Texture as _}from"../webgl/Texture.js";import{TextureDescriptor as f}from"../webgl/TextureDescriptor.js";class l{static{this._instanceRefCount=0}constructor(t){if(this._ownsRctx=!1,t)this._ownsRctx=!1,this._rctx=t;else{if(l._instance)return l._instanceRefCount++,l._instance;l._instanceRefCount=1,l._instance=this,this._ownsRctx=!0;const t=document.createElement("canvas").getContext("webgl2");t.getExtension("OES_texture_float"),this._rctx=new g(t,{})}const e={applyProjection:!0,bilinear:!1,bicubic:!1},r=c("raster/reproject","raster/reproject",new Map([["a_position",0]]),e);this._program=this._rctx.programCache.acquire(r.shaders.vertexShader,r.shaders.fragmentShader,r.attributes),this._rctx.useProgram(this._program),this._program.setUniform1f("u_opacity",1),this._program.setUniform1i("u_image",0),this._program.setUniform1i("u_flipY",0),this._program.setUniform1i("u_transformGrid",1),this._quad=new m(this._rctx,[0,0,1,0,0,1,1,1])}reprojectTexture(t,s,n=!1){const o=r(t.extent,s),m=new e({x:(t.extent.xmax-t.extent.xmin)/t.texture.descriptor.width,y:(t.extent.ymax-t.extent.ymin)/t.texture.descriptor.height,spatialReference:t.extent.spatialReference}),{x:c,y:g}=i(m,s,t.extent);let _=(c+g)/2;const l=Math.round((o.xmax-o.xmin)/_),w=Math.round((o.ymax-o.ymin)/_);_=(o.width/l+o.height/w)/2;const b=new e({x:_,y:_,spatialReference:o.spatialReference}),j=a({projectedExtent:o,srcBufferExtent:t.extent,pixelSize:b,hasWrapAround:!0,spacing:[16,16]}),D=d(this._rctx,j),R=new f(l,w);R.wrapMode=p.CLAMP_TO_EDGE;const y=new u(this._rctx,R);this._rctx.bindFramebuffer(y),this._rctx.setViewport(0,0,l,w),this._rctx.useProgram(this._program),this._rctx.bindTexture(t.texture,0),this._rctx.bindTexture(D,1),this._quad.bind();const{width:C=0,height:E=0}=t.texture.descriptor;if(this._program.setUniform2f("u_srcImageSize",C,E),this._program.setUniform2fv("u_transformSpacing",j.spacing),this._program.setUniform2fv("u_transformGridSize",j.size),this._program.setUniform2f("u_targetImageSize",l,w),this._quad.draw(),this._quad.unbind(),this._rctx.useProgram(null),this._rctx.bindFramebuffer(null),D.dispose(),n){const{width:t,height:e}=y,r=new ImageData(t??0,e??0);y.readPixels(0,0,t??0,e??0,h.RGBA,x.UNSIGNED_BYTE,r.data);const i=y.detachColorTexture();return y.dispose(),{texture:i,extent:o,imageData:r}}const T=y.detachColorTexture();return y.dispose(),{texture:T,extent:o}}reprojectBitmapData(t,e){const r=n(t.bitmapData)?o(t.bitmapData):t.bitmapData,i=new f;i.wrapMode=p.CLAMP_TO_EDGE,i.width=t.bitmapData.width,i.height=t.bitmapData.height;const a=new _(this._rctx,i,r),s=this.reprojectTexture({texture:a,extent:t.extent},e,!0);s.texture.dispose();const m=document.createElement("canvas"),c=s.imageData;m.width=c.width,m.height=c.height;return m.getContext("2d").putImageData(c,0,0),{bitmapData:m,extent:s.extent}}async loadAndReprojectBitmapData(e,r,i){const[a]=await Promise.all([t(e,{responseType:"image"}).then((t=>t.data)),s()]),n=document.createElement("canvas");n.width=a.width,n.height=a.height;const o=n.getContext("2d");o.drawImage(a,0,0);const m=o.getImageData(0,0,n.width,n.height);if(r.spatialReference.equals(i))return{bitmapData:m,extent:r};const c=this.reprojectBitmapData({bitmapData:m,extent:r},i);return{bitmapData:c.bitmapData,extent:c.extent}}destroy(){this._ownsRctx?(l._instanceRefCount--,0===l._instanceRefCount&&(this._quad.dispose(),this._program.dispose(),this._rctx.dispose(),l._instance=null)):(this._quad.dispose(),this._program.dispose())}}export{l as ImageReprojector};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import{destroyMaybe as t}from"../../core/maybe.js";import{watch as i,initial as o}from"../../core/reactiveUtils.js";import{stripHTML as s}from"../../core/string.js";import{property as n}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 a from"../Widget.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import c from"./support/FeatureElementInfo.js";import{loadCalciteComponents as d}from"../support/componentsUtils.js";import{globalCss as p}from"../support/globalCss.js";import"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as u}from"../support/jsxFactory.js";import h from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";const y="esri-feature-utility-network-associations",g=`${y}__loading-container`,
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import{destroyMaybe as t}from"../../core/maybe.js";import{watch as i,initial as o}from"../../core/reactiveUtils.js";import{stripHTML as s}from"../../core/string.js";import{property as n}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 a from"../Widget.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import c from"./support/FeatureElementInfo.js";import{loadCalciteComponents as d}from"../support/componentsUtils.js";import{globalCss as p}from"../support/globalCss.js";import"../support/widgetUtils.js";import{messageBundle as m}from"../support/decorators/messageBundle.js";import{tsx as u}from"../support/jsxFactory.js";import h from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";const y="esri-feature-utility-network-associations",g=`${y}__loading-container`,f={base:y,listContainer:`${y}__list`,loadingContainer:g,loadingContainerSticky:`${g}--sticky`};let v=class extends a{constructor(e,t){super(e,t),this._featureElementInfo=null,this.onSelectAssociationType=()=>{},this.flowType="feature-utility-network-associations",this.flowItems=null,this.parentFeatureViewModel=null,this.headingLevel=5,this.viewModel=new h,this.messages=null,this.messagesCommon=null,this.visibleElements=new l}initialize(){this._featureElementInfo=new c,this.addHandles([i((()=>[this.viewModel.description,this.viewModel.title,this.headingLevel]),(()=>this._setupFeatureElementInfo()),o)])}loadDependencies(){return d({icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._featureElementInfo=t(this._featureElementInfo)}get description(){return this.viewModel.description}set description(e){this.viewModel.description=e}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}render(){const{state:e}=this.viewModel;return u("div",{class:this.classes(f.base,p.widget)},this._featureElementInfo?.render(),"loading"===e?this._renderLoading():"disabled"===e?this._renderAssociationNotFound():this._renderContent())}_renderStickyLoading(){return"querying"===this.viewModel.state?u("div",{class:f.loadingContainerSticky,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoadingIcon(){return u("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderLoading(){return u("div",{class:f.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderAssociationNotFound(){return u("calcite-notice",{icon:"information",key:"association-not-found",kind:"info",open:!0,scale:"s",width:"full"},u("div",{slot:"message"},this.messages?.noAssociations))}_renderAssociationType(e){const{viewModel:t}=this,i=this._getAssociationTypeTitle(e);return u("calcite-list-item",{description:s(e.description),key:`association-type-${e.type}`,label:s(i),value:e.type,onCalciteListItemSelect:()=>this.onSelectAssociationType({viewModel:t,listType:e,title:i})},u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderAssociations(e){const{viewModel:t}=this;return"featureForm"===t.source||t.getFeatureCountForAssociationType(e.type)>0?this._renderAssociationType(e):void 0}_renderContent(){const{messages:e,viewModel:t}=this,{state:i,associationTypes:o}=t;return u("div",{class:f.listContainer,key:"list-container"},"ready"===i?u("div",null,u("calcite-list",{displayMode:"flat",label:e?.associationsList},o.map((e=>this._renderAssociations(e))))):null,this._renderStickyLoading())}_getAssociationTypeTitle(e){const{messages:t}=this;if(e.title)return e.title;switch(e.type){case"attachment":return t.associationsAttachments;case"connectivity":return t.associationsConnectivity;case"structure":return t.associationsStructure;case"content":return t.associationsContents;case"container":return t.associationsContainer}}_setupFeatureElementInfo(){const{headingLevel:e,visibleElements:t}=this,i=t.description&&this.description,o=t.title&&this.title;this._featureElementInfo?.set({description:i,title:o,headingLevel:e})}};e([n({constructOnly:!0})],v.prototype,"onSelectAssociationType",void 0),e([n()],v.prototype,"flowType",void 0),e([n()],v.prototype,"flowItems",void 0),e([n()],v.prototype,"parentFeatureViewModel",void 0),e([n()],v.prototype,"featureVisibleElements",void 0),e([n()],v.prototype,"description",null),e([n()],v.prototype,"headingLevel",void 0),e([n()],v.prototype,"title",null),e([n({type:h})],v.prototype,"viewModel",void 0),e([n(),m("esri/widgets/Feature/t9n/Feature")],v.prototype,"messages",void 0),e([n(),m("esri/t9n/common")],v.prototype,"messagesCommon",void 0),e([n({type:l,nonNullable:!0})],v.prototype,"visibleElements",void 0),v=e([r("esri.widgets.Feature.FeatureUtilityNetworkAssociations")],v);export{v as default};
|