@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.91 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import e from"../../core/Error.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import t from"../../geometry/SpatialReference.js";import{isPoint as o}from"../../geometry/support/typeUtils.js";import a from"../OrientedImageryLayer.js";import n from"./core/ExposurePoint.js";import{convertGeographicToWebMercator as i}from"./core/utils.js";import s from"../../rest/support/Query.js";import{createExtentAroundPoint as u}from"../../widgets/OrientedImageryViewer/navigation/utils.js";const m={},c=1e3;async function l(e,t){const{point:o,queryParams:a}=e;p(o,a);const n=w(e.layerInstanceOrURL);await n.load(t);const i=y(n,o,a),s=await n.queryFeatures(i,t);return r(t),d(n)(s)}function p(r,t){if(!o(r)&&null==t?.geometry)throw new e("invalid-parameters","searchImages requires a point and query parameters to be provided.");return!0}function y(e,r,o){const a=r?i(r):null,n=o?.maximumDistance??e.maximumDistance??c,m=o?.geometry??(a?u(a,n):null);return new s({outSpatialReference:o?.outSpatialReference??e.spatialReference.isGeographic?t.WebMercator:e.spatialReference,returnGeometry:o?.returnGeometry??!0,outFields:o?.outFields??["*"],geometry:m,where:o?.where??"1=1",returnZ:e.hasZ,orderByFields:o?.orderByFields,maxRecordCountFactor:o?.maxRecordCountFactor??5})}async function f(e,r){const t=new s;t.where="1=1",t.outFields=["*"],t.orderByFields=["OffsetFromStart ASC"],t.outSpatialReference=r,t.returnGeometry=!0;const o=await e.queryFeatures(t);return d(e)(o)}function d(e){return r=>(r.features.forEach((r=>{const t=n.fromJSON({...r.toJSON(),layer:e});t&&(r.attributes=t)})),r)}function w(e){return"string"!=typeof e?e:(m.layer?.url!==e&&(m.layer?.destroy(),m.layer=new a({url:e})),m.layer)}export{f as getSortedLayerFeatures,l as searchImages};