UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 2.56 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{deepClone as e}from"../../../arcade/deepClone.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/Logger.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import a from"../../../geometry/Point.js";import r from"../../../geometry/Polygon.js";import{fromArray as n,intersectLine as i,fromPoints as o}from"../../../geometry/support/plane.js";import s from"./updateElevation.js";import{pointToArray as c,or as m}from"./utils.js";import{worldToImagePanoramic as p,worldToImage as f}from"./worldToImage.js";import{normalizeDegrees as l}from"../../../widgets/OrientedImageryViewer/components/imageNavigationUtils.js";async function g(e,r,n,s=w){const{cameraLocation:p,farPlaneVertices:f}=n,l=c(p),g=new Array;await d(f,n,g);let h=o(g[0],g[1],g[2]),u=e.clone();for(let w=0;w<s;w++){const s=t();if(!i(h,l,c(e),s))break;let f=0,w=null;if(({error:f,imagePoint:w,pointWithZ:u}=await j(r,new a(s,p.spatialReference),n)),f<=1)break;const[d,b]=y(p.spatialReference,g);if(m(d<=1,b<=1))break;g.splice(0,g.length,...await R(d,b,new a(s,p.spatialReference),n)),h=o(g[0],g[1],g[2])}return c(u)}async function h(e,r,o,s=w){const{cameraLocation:p,farPlaneVertices:f}=o,l=c(p),g=new Array;await d(f,o,g);const h=[0,0,0,0];let u=n(h,g.flat(),!1),j=e.clone();for(let w=0;w<s;w++){const s=t();if(!i(h,l,c(e),s)||!u)break;let f,w=0;if(({error:w,imagePoint:f,pointWithZ:j}=await b(r,new a(s,p.spatialReference),o)),w<=1)break;const[d,x]=y(p.spatialReference,g);if(m(d<=1,x<=1))break;g.splice(0,g.length,...await R(d,x,new a(s,p.spatialReference),o)),u=n(h,g.flat(),!1)}return c(j)}const w=10,u=10;function y(e,t){const a=new r({spatialReference:e});a.addRing(t);return[a.extent?.width?a.extent.width/u:1,a.extent?.height?a.extent.height/u:1]}async function d(t,a,r){const n=e(t),i=await s(n,a);r.push(...i.map(c))}async function j(e,t,a){const r=await s(t,a),n=f(r,a);return{error:x(n,e),imagePoint:n,pointWithZ:r}}async function b(e,t,a){const r=await s(t,a),n=p(r,a),i=l(n.heading+a.cameraHeading);return{error:Math.abs(i-e.heading)+Math.abs(n.pitch-e.pitch),imagePoint:n,pointWithZ:r}}const x=(e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y);async function R(e,t,r,n){const i=[[-e,-t],[e,-t],[e,t],[-e,t]].map((([e,t])=>new a([r.x+e,r.y+t],r.spatialReference)));return s(i,n).then((e=>e.map((e=>e.toArray()))))}export{g as rectifyMapPoint,h as rectifyMapPointPanoramic};