UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) • 11.7 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import{ClonableMixin as t}from"../../../core/Clonable.js";import r from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import a from"../../../core/Logger.js";import{property as i,cast as n,subclass as s}from"../../../core/accessorSupport/decorators.js";import p from"../../../geometry/Point.js";import{getGeometryZScaler as l}from"../../../geometry/support/zscale.js";import c from"./CameraOrientation.js";import m from"./cameraOrientationFactory.js";import{appendPrefixAndSuffix as u,getEffectiveElevationSource as d,getArcGISServerUrl as y,getMetersPerUnitOfSR as f,orientedImageryTypeMap as g}from"./utils.js";import{ltpToGeographic as h}from"../transformations/utils.js";import{reader as v}from"../../../core/accessorSupport/decorators/reader.js";import{writer as w}from"../../../core/accessorSupport/decorators/writer.js";import{enumeration as O}from"../../../core/accessorSupport/decorators/enumeration.js";function b(e){throw new r("exposure-point:missing-default-value",`a value for ${e} is missing in default properties`)}function j(e,t){throw new r("exposure-point:missing-attribute-value",`a value for ${e} is missing in attribute table`,{exposurePoint:t})}const S=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}}}}),I=e=>({cast:e=>"string"==typeof e?e.split(";").map(Number):e,json:{default:e,write:{writer:(e,t,r)=>{t[r]=e?.join(";")}}}}),N="$virtualCacheDirectory:",F="/rest/directories/dsid_";let q=class extends(t(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.effectiveSequenceOrderField],i.sequenceorder=n.effectiveSequenceOrderField),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 u(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 d(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||j("imagePath",this);const{imagePathPrefix:a,imagePathSuffix:i}=o;if(r.startsWith(N)){return`${y(o.url)}${F}${r.replace(N,o.dataStoreID+"/")}`}return u(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 this.orientedImageryType?.includes("360")??!1}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(4===t){const{latitude:t,longitude:r,ellipsoidRadius:o,squaredEccentricity:a,properties:i}=e,{x:n,y:s,z:l}=i;return new p(h([n,s,l],[t,r,o,a]))}const c=new p({x:r,y:o,z:a,spatialReference:s}),m=n?l("point",{wkid:n},s):null;return m&&m(c),c}if("number"!=typeof t)throw b("cameraHeight");const o=this.geometry.clone(),i=(r??0)+t/f(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=g.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){const[t,r,o]=e.split(";").map(Number);return void this._set("radial",[t??0,r??0,o??0])}this._set("radial",e)}else this._set("radial",[0,0,0])}readSequenceOrder(e,t){const{layer:r}=t,o=r?.effectiveSequenceOrderField?.toLowerCase();return t[o]}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){const[t,r]=e.split(";").map(Number);return void this._set("tangential",[t??0,r??0])}this._set("tangential",e)}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()],q.prototype,"_geometry",void 0),e([i(S())],q.prototype,"a0",void 0),e([i(S())],q.prototype,"a1",void 0),e([i(S())],q.prototype,"a2",void 0),e([i({type:Date,json:{write:{enabled:!0,target:"acquisitionDate"},name:"acquisitiondate"}})],q.prototype,"acquisitionDate",void 0),e([i(S())],q.prototype,"b0",void 0),e([i(S())],q.prototype,"b1",void 0),e([i(S())],q.prototype,"b2",void 0),e([i({type:Number,json:{write:!0,read:{source:["cameraheading","camheading","layer.cameraHeading"]}}})],q.prototype,"cameraHeading",void 0),e([v("cameraHeading")],q.prototype,"readCameraHeading",null),e([i({type:Number,json:{write:!0}})],q.prototype,"cameraHeight",void 0),e([v("cameraHeight",["cameraheight","avghtag","layer.cameraHeight"])],q.prototype,"readCameraHeight",null),e([i()],q.prototype,"cameraOffset",void 0),e([v("cameraOffset",["cameraoffset","camoffset"])],q.prototype,"readCamOffset",null),e([w("cameraOffset")],q.prototype,"writeCameraOffset",null),e([i({json:{write:{writer:(e,t,r)=>{t[r]=e.toString()}}},type:c}),n(e=>e?m.getCameraOrientation(e):null)],q.prototype,"cameraOrientation",void 0),e([v("cameraOrientation",["cameraorientation","camori"])],q.prototype,"readCameraOrientation",null),e([i({type:Number,json:{write:!0}})],q.prototype,"cameraPitch",void 0),e([v("cameraPitch",["camerapitch","campitch","layer.cameraPitch"])],q.prototype,"readCameraPitch",null),e([i({type:Number,json:{write:!0}})],q.prototype,"cameraRoll",void 0),e([v("cameraRoll",["cameraroll","camroll","layer.cameraRoll"])],q.prototype,"readCameraRoll",null),e([i({json:{write:!0},type:String})],q.prototype,"depthImage",void 0),e([v("depthImage",["depthimage","depthimg"])],q.prototype,"readDepthImage",null),e([i({type:Number,json:{write:!0}})],q.prototype,"elevation",void 0),e([i({json:{write:!0},clonable:"reference"})],q.prototype,"elevationSource",void 0),e([v("elevationSource",["elevationsource","layer.effectiveElevationSource"])],q.prototype,"readElevationSource",null),e([i({json:{name:"exposurestationid",write:{target:"exposureStationId"}},type:String})],q.prototype,"exposureStationId",void 0),e([i({type:Number,json:{write:!0}})],q.prototype,"farDistance",void 0),e([v("farDistance",["fardistance","fardist","layer.farDistance"])],q.prototype,"readFarDistance",null),e([i(S("focallength"))],q.prototype,"focalLength",void 0),e([i({type:p,json:{name:"geometry"}})],q.prototype,"geometry",null),e([w("geometry")],q.prototype,"writeGeometry",null),e([i({type:Number,json:{write:!0}})],q.prototype,"horizontalFieldOfView",void 0),e([v("horizontalFieldOfView",["horizontalfieldofview","hfov","layer.horizontalFieldOfView"])],q.prototype,"readHFOV",null),e([i({json:{write:!0},type:String})],q.prototype,"imagePath",void 0),e([v("imagePath",["imagepath"])],q.prototype,"readImageURL",null),e([i({type:Number,json:{write:!0}})],q.prototype,"imageRotation",void 0),e([v("imageRotation",["imagerotation","imgrot","layer.imageRotation"])],q.prototype,"readImageRotation",null),e([i()],q.prototype,"isHorizontal",null),e([i()],q.prototype,"isInspection",null),e([i()],q.prototype,"isNadir",null),e([i()],q.prototype,"isOblique",null),e([i()],q.prototype,"isSpherical",null),e([i()],q.prototype,"location",null),e([i(I())],q.prototype,"matrix",null),e([i({json:{write:!0},type:String})],q.prototype,"name",void 0),e([i({type:Number,json:{write:!0}})],q.prototype,"nearDistance",void 0),e([v("nearDistance",["neardistance","neardist","layer.nearDistance"])],q.prototype,"readNearDistance",null),e([i({json:{write:!0,name:"objectid"},type:Number})],q.prototype,"objectId",void 0),e([i({type:Number,json:{write:!0}})],q.prototype,"offsetFromStart",void 0),e([v("offsetFromStart",["offsetfromstart"])],q.prototype,"readOffsetFromStart",null),e([i()],q.prototype,"orientationAccuracy",void 0),e([v("orientationAccuracy",["accuracy","orientationaccuracy"])],q.prototype,"readOrientationAccuracy",null),e([w("orientationAccuracy")],q.prototype,"writeOrientationAccuracy",null),e([O(g)],q.prototype,"orientedImageryType",void 0),e([v("orientedImageryType",["orientedimagerytype","oitype","layer.orientedImageryType"])],q.prototype,"readOIType",null),e([i({type:Number,json:{write:!0,read:{source:"principalx"}}})],q.prototype,"principalX",void 0),e([i({type:Number,json:{write:!0,read:{source:"principaly"}}})],q.prototype,"principalY",void 0),e([i(I([0,0,0]))],q.prototype,"radial",null),e([i({type:String})],q.prototype,"sequenceOrder",void 0),e([v("sequenceOrder",["sequenceorder","layer.sequenceOrderField"])],q.prototype,"readSequenceOrder",null),e([w("sequenceOrder")],q.prototype,"writeSequenceOrder",null),e([i({type:Object})],q.prototype,"sourceMap",void 0),e([i(I([0,0]))],q.prototype,"tangential",null),e([i({type:Number,json:{write:!0}})],q.prototype,"verticalFieldOfView",void 0),e([v("verticalFieldOfView",["verticalfieldofview","vfov","layer.verticalFieldOfView"])],q.prototype,"readVFOV",null),q=e([s("esri.layers.orientedImagery.core.ExposurePoint")],q);const x=q;export{x as default};