UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 4.84 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */ import e from"../../core/Error.js";import t from"../HeightModelInfo.js";import{parse as n}from"../../layers/support/arcgisLayerUrl.js";function i(n,i){if(!n)return null;if(!o(n))return new e("webscene:unsupported-height-model-info","The vertical coordinate system of the scene is not supported",{heightModelInfo:n});const a=n.heightUnit,r=t.deriveUnitFromSR(n,i).heightUnit;return a!==r?new e("webscene:incompatible-height-unit",`The vertical units of the scene (${a}) must match the horizontal units of the scene (${r})`,{verticalUnit:a,horizontalUnit:r}):null}function a(n,i,a){const o=c(n),l=i,h=r(o,l,a);if(o){const i=t.deriveUnitFromSR(o,n.spatialReference).heightUnit;if(!a&&i!==o.heightUnit){const t=new e("layerview:unmatched-height-unit",`The vertical units of the layer must match the horizontal units (${i})`,{horizontalUnit:i});return new e("layerview:unsupported-height-model-info","The vertical coordinate system of the layer is not supported",{heightModelInfo:o,error:t})}}if(!s(n)||4===h)return new e("layerview:unsupported-height-model-info","The vertical coordinate system of the layer is not supported",{heightModelInfo:o});switch(h){case 1:{const t=o?.heightUnit||"unknown",n=l?.heightUnit||"unknown",i=new e("layerview:incompatible-height-unit",`The vertical units of the layer (${t}) must match the vertical units of the scene (${n})`,{layerUnit:t,sceneUnit:n});return new e("layerview:incompatible-height-model-info","The vertical coordinate system of the layer is incompatible with the scene",{layerHeightModelInfo:o,sceneHeightModelInfo:l,error:i})}case 2:{const t=o?.heightModel||"unknown",n=l?.heightModel||"unknown",i=new e("layerview:incompatible-height-model",`The height model of the layer (${t}) must match the height model of the scene (${n})`,{layerHeightModel:t,sceneHeightModel:n});return new e("layerview:incompatible-height-model-info","The vertical coordinate system of the layer is incompatible with the scene",{layerHeightModelInfo:o,sceneHeightModelInfo:l,error:i})}case 3:{const t=o?.vertCRS||"unknown",n=l?.vertCRS||"unknown",i=new e("layerview:incompatible-vertical-datum",`The vertical datum of the layer (${t}) must match the vertical datum of the scene (${n})`,{layerDatum:t,sceneDatum:n});return new e("layerview:incompatible-height-model-info","The vertical coordinate system of the layer is incompatible with the scene",{layerHeightModelInfo:o,sceneHeightModelInfo:l,error:i})}}return null}function r(e,t,n){if(!o(e)||!o(t))return 4;if(null==e||null==t)return 0;if(!n&&e.heightUnit!==t.heightUnit)return 1;if(e.heightModel!==t.heightModel)return 2;switch(e.heightModel){case"gravity-related-height":return 0;case"ellipsoidal":return e.vertCRS===t.vertCRS?0:3;default:return 4}}function o(e){return null==e||null!=e.heightModel&&null!=e.heightUnit}function s(e){return"heightModelInfo"in e&&null!=e.heightModelInfo||null!=e.spatialReference||!u(e)}function c(e){if("integrated-mesh-3dtiles"===e.type||"gaussian-splat"===e.type)return null;const i=e.url?n(e.url):void 0,a=e.spatialReference?.vcsWkid;return!(null==a&&null!=i&&"ImageServer"===i.serverType)&&l(e)&&e.heightModelInfo?e.heightModelInfo:u(e)?t.deriveUnitFromSR(f,e.spatialReference):null}function l(e){return"heightModelInfo"in e}function h(e){if("unknown"===e.type||!("capabilities"in e))return!1;switch(e.type){case"catalog":case"catalog-footprint":case"csv":case"feature":case"geojson":case"subtype-group":case"ogc-feature":case"oriented-imagery":case"wfs":case"knowledge-graph-sublayer":return!0;default:return!1}}function u(e){return h(e)?!!(e.capabilities&&e.capabilities.data&&e.capabilities.data.supportsZ):d(e)}function g(e){return null!=e.layers||d(e)||h(e)||l(e)}function d(e){switch(e.type){case"building-scene":case"elevation":case"gaussian-splat":case"integrated-mesh":case"integrated-mesh-3dtiles":case"point-cloud":case"scene":case"voxel":return!0;case"base-dynamic":case"base-elevation":case"base-tile":case"bing-maps":case"catalog":case"catalog-footprint":case"catalog-dynamic-group":case"csv":case"dimension":case"geojson":case"feature":case"subtype-group":case"geo-rss":case"graphics":case"group":case"imagery":case"imagery-tile":case"kml":case"knowledge-graph":case"link-chart":case"knowledge-graph-sublayer":case"line-of-sight":case"map-image":case"map-notes":case"media":case"ogc-feature":case"open-street-map":case"oriented-imagery":case"parquet":case"route":case"stream":case"tile":case"unknown":case"unsupported":case"vector-tile":case"video":case"viewshed":case"wcs":case"web-tile":case"wfs":case"wms":case"wmts":case null:return!1}return!1}const f=new t({heightModel:"gravity-related-height"});export{c as deriveHeightModelInfoFromLayer,r as isCompatible,a as rejectLayerError,g as supportsHeightModelInfo,i as validateWebSceneError};