UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) • 11.9 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Clonable.js";import r from"../../../core/Error.js";import o from"../../../core/JSONSupport.js";import a from"../../../core/Logger.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import{cast as n}from"../../../core/accessorSupport/decorators/cast.js";import{enumeration as s}from"../../../core/accessorSupport/decorators/enumeration.js";import{reader as p}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{writer as l}from"../../../core/accessorSupport/decorators/writer.js";import m from"../../../geometry/Point.js";import{getGeometryZScaler as u}from"../../../geometry/support/zscale.js";import y from"./CameraOrientation.js";import d from"./cameraOrientationFactory.js";import{appendPrefixAndSuffix as f,getEffectiveElevationSource as g,getArcGISServerUrl as h,getMetersPerUnitOfSR as v,orientedImageryTypeMap as w}from"./utils.js";import{CameraOrientationType as O}from"../enums/CameraOrientationType.js";import{ltpToGeographic as b}from"../transformations/utils.js";function j(e){throw new r("exposure-point:missing-default-value",`a value for ${e} is missing in default properties`)}function S(e,t){throw new r("exposure-point:missing-attribute-value",`a value for ${e} is missing in attribute table`,{exposurePoint:t})}const I=e=>({cast:e=>{const t=parseFloat(e);return Number.isFinite(t)?t:void 0},json:{name:e,write:{writer:(e,t,r)=>{t[r]=Number.isFinite(e)?e:void 0}}}}),N=e=>({cast:e=>"string"==typeof e?e.split(";").map(Number):e,json:{default:e,write:{writer:(e,t,r)=>{t[r]=e?.join(";")}}}}),F="$virtualCacheDirectory:";let x=class extends(t.ClonableMixin(o)){constructor(e){super(e),this._geometry=null,this.cameraOrientation=null,this.elevation=null,this.elevationSource=null,this.name=null,this.sourceMap=null}read(e,t){const r={},{attributes:o,geometry:a}=e,i={};for(const s in o)r[s.toLowerCase()]=o[s],i[s.toLowerCase()]=s;const n=e.layer??{};n.sequenceOrderField?.length&&(r.sequenceorder=o[n.sequenceOrderField],i.sequenceorder=n.sequenceOrderField),super.read({geometry:a,layer:n,sourceMap:i,...r},t)}write(e,t){const r=super.write(e,t),{sourceMap:o}=this;if(!o||!r)return r;const a={};for(const i in r){const e=o[i.toLowerCase()];e&&(a[e]=r[i])}return a}readCameraHeading(e,t){const{cameraheading:r,camheading:o,layer:a}=t;return r??o??a.cameraHeading}readCameraHeight(e,t){const{cameraheight:r,avghtag:o,layer:a}=t;return r??o??a.cameraHeight}readCamOffset(e,t){const{cameraoffset:r,camoffset:o}=t;return r?.split(";").map(Number)??o?.split(";").map(Number)??null}writeCameraOffset(e,t){e&&(t.cameraOffset=e.join(";"))}readCameraOrientation(e,t){const{cameraorientation:r,camori:o}=t;return r??o}readCameraPitch(e,t){const{camerapitch:r,campitch:o,layer:a}=t;return r??o??a.cameraPitch}readCameraRoll(e,t){const{cameraroll:r,camroll:o,layer:a}=t;return r??o??a.cameraRoll}readDepthImage(e,t){const{depthimage:r,depthimg:o,layer:a}=t,i=r??o??null,{depthImagePathPrefix:n,depthImagePathSuffix:s}=a??{};return f(i,n,s)}readElevationSource(e,t){const{elevationsource:r,layer:o}=t,{demPathSuffix:a,demPathPrefix:i}=o;if(r){const e=this._parseIfJSON(r);return g(e,i,a)}return o.effectiveElevationSource}readFarDistance(e,t){const{fardistance:r,fardist:o,layer:a}=t;return r??o??a.farDistance}get geometry(){const e=this._geometry.clone();if(!e)return null;const{cameraOffset:t}=this;if(t){const[r,o,a]=t;e.x+=r,e.y+=o,null!=e.z&&null!=a&&(e.z+=a)}return e}set geometry(e){this._geometry=e}writeGeometry(e,t){t.geometry=this._geometry.toJSON()}readHFOV(e,t){const{horizontalfieldofview:r,hfov:o,layer:a}=t;return r??o??a.horizontalFieldOfView}readImageURL(e,t){const{imagepath:r,layer:o}=t;r||S("imagePath",this);const{imagePathPrefix:a,imagePathSuffix:i}=o;if(r.startsWith(F)){return`${h(o.url)}${r.replace(F,o.virtualCacheDirectory+"/")}`}return f(r,a,i)}readImageRotation(e,t){const{imagerotation:r,imgrot:o,layer:a}=t;return r??o??a.imageRotation}get isHorizontal(){return"horizontal"===this.orientedImageryType}get isInspection(){return"inspection"===this.orientedImageryType}get isNadir(){return"nadir"===this.orientedImageryType}get isOblique(){return"oblique"===this.orientedImageryType}get isSpherical(){return"360"===this.orientedImageryType}get location(){const{cameraOrientation:e,cameraHeight:t,elevation:r}=this;if(e){const{type:t,x:r,y:o,z:a,horizontalWKID:i,verticalWKID:n}=e,s="number"==typeof i?{wkid:i}:{wkt:i};if(t===O.LTP){const{latitude:t,longitude:r,ellipsoidRadius:o,squaredEccentricity:a,properties:i}=e,{x:n,y:s,z:p}=i;return new m(b([n,s,p],[t,r,o,a]))}const p=new m({x:r,y:o,z:a,spatialReference:s}),c=n?u("point",{wkid:n},s):null;return c&&c(p),p}if("number"!=typeof t)throw j("cameraHeight");const o=this.geometry.clone(),i=(r??0)+t/v(o.spatialReference);if("360"===this.orientedImageryType&&o.hasZ){const e=i-o.z;return null!=r&&Math.abs(e)>.001&&(a.getLogger(this).warnOnce("The elevation value is different from the geometry's z value. The geometry's z value will be updated.",{elevation:r,geometryZ:o.z}),o.z=i),o}return o.z=o.hasZ?o.z:i,o}set matrix(e){if(e)return 9!==e.length?(a.getLogger(this).warnOnce("Ignoring rotation matrix because it doesn't have 9 values",{value:e}),void this._set("matrix",null)):void this._set("matrix",e)}readNearDistance(e,t){const{neardistance:r,neardist:o,layer:a}=t;return r??o??a.nearDistance}readOffsetFromStart(e,t){return t.offsetfromstart??null}readOrientationAccuracy(e,t){const{accuracy:r,orientationaccuracy:o}=t;return o?.split(";").map(Number)??r?.split(";").map(Number)??null}writeOrientationAccuracy(e,t){e&&(t.orientationAccuracy=e.join(";"))}readOIType(e,t){const{orientedimagerytype:r,oitype:o,camerapitch:a,campitch:i,layer:n}=t,s=w.read(r??o??n.orientedImageryType),p=a??i??n.cameraPitch;return"oblique"===s?p<10?"nadir":"oblique":s}set radial(e){if(e)if("string"!=typeof e)this._set("radial",e);else{const[t,r,o]=e.split(";").map(Number);this._set("radial",[t??0,r??0,o??0])}else this._set("radial",[0,0,0])}readSequenceOrder(e,t){const{layer:r}=t;return t[r.sequenceOrderField.toLowerCase()]}writeSequenceOrder(e,t){if(!e)return;const{sourceMap:r}=this;if(r){t[r.sequenceorder]=e}}set tangential(e){if(e)if("string"!=typeof e)this._set("tangential",e);else{const[t,r]=e.split(";").map(Number);this._set("tangential",[t??0,r??0])}else this._set("tangential",[0,0])}readVFOV(e,t){const{verticalfieldofview:r,vfov:o,layer:a}=t;return r??o??a.verticalFieldOfView}_parseIfJSON(e){let t=null;try{t=JSON.parse(e)}catch(r){a.getLogger(this).error("couldn't parse the given elevation source JSON",e,r)}return t}clone(){const e=super.clone();return e._geometry=this._geometry.clone(),e}};e([i()],x.prototype,"_geometry",void 0),e([i(I())],x.prototype,"a0",void 0),e([i(I())],x.prototype,"a1",void 0),e([i(I())],x.prototype,"a2",void 0),e([i({type:Date,json:{write:{enabled:!0,target:"acquisitionDate"},name:"acquisitiondate"}})],x.prototype,"acquisitionDate",void 0),e([i(I())],x.prototype,"b0",void 0),e([i(I())],x.prototype,"b1",void 0),e([i(I())],x.prototype,"b2",void 0),e([i({type:Number,json:{write:!0,read:{source:["cameraheading","camheading","layer.cameraHeading"]}}})],x.prototype,"cameraHeading",void 0),e([p("cameraHeading")],x.prototype,"readCameraHeading",null),e([i({type:Number,json:{write:!0}})],x.prototype,"cameraHeight",void 0),e([p("cameraHeight",["cameraheight","avghtag","layer.cameraHeight"])],x.prototype,"readCameraHeight",null),e([i()],x.prototype,"cameraOffset",void 0),e([p("cameraOffset",["cameraoffset","camoffset"])],x.prototype,"readCamOffset",null),e([l("cameraOffset")],x.prototype,"writeCameraOffset",null),e([i({json:{write:{writer:(e,t,r)=>{t[r]=e.toString()}}},type:y}),n((e=>e?d.getCameraOrientation(e):null))],x.prototype,"cameraOrientation",void 0),e([p("cameraOrientation",["cameraorientation","camori"])],x.prototype,"readCameraOrientation",null),e([i({type:Number,json:{write:!0}})],x.prototype,"cameraPitch",void 0),e([p("cameraPitch",["camerapitch","campitch","layer.cameraPitch"])],x.prototype,"readCameraPitch",null),e([i({type:Number,json:{write:!0}})],x.prototype,"cameraRoll",void 0),e([p("cameraRoll",["cameraroll","camroll","layer.cameraRoll"])],x.prototype,"readCameraRoll",null),e([i({json:{write:!0},type:String})],x.prototype,"depthImage",void 0),e([p("depthImage",["depthimage","depthimg"])],x.prototype,"readDepthImage",null),e([i({type:Number,json:{write:!0}})],x.prototype,"elevation",void 0),e([i({json:{write:!0},clonable:"reference"})],x.prototype,"elevationSource",void 0),e([p("elevationSource",["elevationsource","layer.effectiveElevationSource"])],x.prototype,"readElevationSource",null),e([i({json:{name:"exposurestationid",write:{target:"exposureStationId"}},type:String})],x.prototype,"exposureStationId",void 0),e([i({type:Number,json:{write:!0}})],x.prototype,"farDistance",void 0),e([p("farDistance",["fardistance","fardist","layer.farDistance"])],x.prototype,"readFarDistance",null),e([i(I("focallength"))],x.prototype,"focalLength",void 0),e([i({type:m,json:{name:"geometry"}})],x.prototype,"geometry",null),e([l("geometry")],x.prototype,"writeGeometry",null),e([i({type:Number,json:{write:!0}})],x.prototype,"horizontalFieldOfView",void 0),e([p("horizontalFieldOfView",["horizontalfieldofview","hfov","layer.horizontalFieldOfView"])],x.prototype,"readHFOV",null),e([i({json:{write:!0},type:String})],x.prototype,"imagePath",void 0),e([p("imagePath",["imagepath"])],x.prototype,"readImageURL",null),e([i({type:Number,json:{write:!0}})],x.prototype,"imageRotation",void 0),e([p("imageRotation",["imagerotation","imgrot","layer.imageRotation"])],x.prototype,"readImageRotation",null),e([i()],x.prototype,"isHorizontal",null),e([i()],x.prototype,"isInspection",null),e([i()],x.prototype,"isNadir",null),e([i()],x.prototype,"isOblique",null),e([i()],x.prototype,"isSpherical",null),e([i()],x.prototype,"location",null),e([i(N())],x.prototype,"matrix",null),e([i({json:{write:!0},type:String})],x.prototype,"name",void 0),e([i({type:Number,json:{write:!0}})],x.prototype,"nearDistance",void 0),e([p("nearDistance",["neardistance","neardist","layer.nearDistance"])],x.prototype,"readNearDistance",null),e([i({json:{write:!0,name:"objectid"},type:Number})],x.prototype,"objectId",void 0),e([i({type:Number,json:{write:!0}})],x.prototype,"offsetFromStart",void 0),e([p("offsetFromStart",["offsetfromstart"])],x.prototype,"readOffsetFromStart",null),e([i()],x.prototype,"orientationAccuracy",void 0),e([p("orientationAccuracy",["accuracy","orientationaccuracy"])],x.prototype,"readOrientationAccuracy",null),e([l("orientationAccuracy")],x.prototype,"writeOrientationAccuracy",null),e([s(w)],x.prototype,"orientedImageryType",void 0),e([p("orientedImageryType",["orientedimagerytype","oitype","layer.orientedImageryType"])],x.prototype,"readOIType",null),e([i({type:Number,json:{write:!0,read:{source:"principalx"}}})],x.prototype,"principalX",void 0),e([i({type:Number,json:{write:!0,read:{source:"principaly"}}})],x.prototype,"principalY",void 0),e([i(N([0,0,0]))],x.prototype,"radial",null),e([i({type:String})],x.prototype,"sequenceOrder",void 0),e([p("sequenceOrder",["sequenceorder","layer.sequenceOrderField"])],x.prototype,"readSequenceOrder",null),e([l("sequenceOrder")],x.prototype,"writeSequenceOrder",null),e([i({type:Object})],x.prototype,"sourceMap",void 0),e([i(N([0,0]))],x.prototype,"tangential",null),e([i({type:Number,json:{write:!0}})],x.prototype,"verticalFieldOfView",void 0),e([p("verticalFieldOfView",["verticalfieldofview","vfov","layer.verticalFieldOfView"])],x.prototype,"readVFOV",null),x=e([c("esri.layers.orientedImagery.core.ExposurePoint")],x);export{x as default};