/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import e from"../Extent.js";import t from"../Point.js";import{polygonCentroidPoint as n}from"./centroid.js";import{getExtentForScale as r}from"./scaleUtils.js";function o(e){switch(e?.type){case"point":return e;case"extent":return e.center;case"polygon":{const r=n(e);return r?t.fromJSON(r):null}case"multipoint":case"polyline":return e.extent?.center;default:return null}}async function a(e,t){if(e.hasZ||"2d"===t.type)return e;const n=t.map?.ground;return n?.layers.length?(await n.queryElevation(e,{cache:t.basemapTerrain?.elevationQueryCache})).geometry:e}function i(e,t,n){return s(e.center,t,n)}function c(e,t,n){switch(e?.type){case"extent":return e;case"multipoint":case"polygon":case"polyline":return e.extent;case"point":return s(e,t,n);default:return null}}function s(t,n,o){const a=t.hasZ?t.z:void 0;if(n?.map){return(null!=o?r(n,o):n.extent).clone().centerAt(t).set({zmax:a,zmin:a})}const{x:i,y:c,spatialReference:s}=t;return new e({xmin:i-.25,ymin:c-.25,xmax:i+.25,ymax:c+.25,spatialReference:s,zmin:a,zmax:a})}export{c as createExtentFromGeometry,s as createExtentFromPoint,o as getPointFromGeometry,a as getPointWithElevation,i as scaleExtent};
