@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.32 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import has from"../../../../../core/has.js";async function e(e,r,i){return{type:"feature",service:e,strategy:await t(e,i,r,i.cache)}}async function t(e,t,r,i){const s=t.customParameters??{};t.apiKey&&(s.token=t.apiKey);const o=t.displayFilterEnabled?t.displayFilterInfo?.toJSON():null,n=t.historicMoment?.getTime(),a=t.timeExtent?.toJSON(),l={...t,displayFilterInfo:o,customParameters:s,historicMoment:n,timeExtent:a};if("feature-service"===e.type&&null!=r&&!await i.executeExceedsLimitQuery(e,l,r))return{type:"snapshot",snapshotInfo:r,partial:{availableFields:t.availableFields},full:{displayFilterInfo:null,queryScaleRanges:null,sourceRefreshVersion:t.sourceRefreshVersion,definitionExpression:t.definitionExpression,postQueryFilter:t.postQueryFilter,customParameters:s,gdbVersion:t.gdbVersion,historicMoment:n,timeExtent:a}};return"feature-service"===e.type&&e.isSourceHosted||"memory"===e.type||"ogc"===e.type?{type:"paged-tile",partial:{availableFields:t.availableFields},full:{sourceRefreshVersion:t.sourceRefreshVersion,definitionExpression:t.definitionExpression,postQueryFilter:t.postQueryFilter,customParameters:s,gdbVersion:t.gdbVersion,historicMoment:n,queryScaleRanges:t.queryScaleRanges,timeExtent:a,displayFilterInfo:o}}:{type:"drill-down",partial:{availableFields:t.availableFields},full:{sourceRefreshVersion:t.sourceRefreshVersion,definitionExpression:t.definitionExpression,postQueryFilter:t.postQueryFilter,customParameters:s,gdbVersion:t.gdbVersion,historicMoment:n,queryScaleRanges:t.queryScaleRanges,timeExtent:a,displayFilterInfo:o}}}function r(e,t,r,a,l,u){const p=n(a);if(!(!!has("featurelayer-snapshot-enabled")&&r?.query.supportsPagination&&!t))return null;if(r?.operations.supportsEditing&&!has("featurelayer-snapshot-allow-editable"))return null;const c=o(l,u),{min:y,max:m}=p,h=c?m:y,f=s(a);let d=has("featurelayer-snapshot-initial-tolerance");return"esriGeometryPoint"!==a&&"esriGeometryMultipoint"!==a||(d=null),{supportsExceedsLimit:i(e,r),initialTolerance:d,maxFeatureCount:h,maxVertexCount:f}}function i(e,t){return!(!e&&!has("featurelayer-snapshot-non-hosted-exceedslimit-enabled"))&&t?.operations.supportsExceedsLimitStatistics}function s(e){switch(e){case"esriGeometryPoint":case"esriGeometryPolyline":case"esriGeometryPolygon":case"esriGeometryMultiPatch":case"esriGeometryMultipoint":return has("featurelayer-snapshot-max-vertex-count")}}function o(e,t){const r=t?.clone().intersection(e),i=null!=r?r.width*r.height:0,s=t?t.width*t.height:0,o=0===s?0:i/s,n=has("featurelayer-snapshot-coverage");return!isNaN(o)&&o>=n}function n(e){switch(e){case"esriGeometryMultipoint":return{min:has("featurelayer-snapshot-multipoint-min-threshold"),max:has("featurelayer-snapshot-multipoint-max-threshold")};case"esriGeometryPoint":return{min:has("featurelayer-snapshot-point-min-threshold"),max:has("featurelayer-snapshot-point-max-threshold")};case"esriGeometryMultiPatch":case"esriGeometryPolygon":return{min:has("featurelayer-snapshot-polygon-min-threshold"),max:has("featurelayer-snapshot-polygon-max-threshold")};case"esriGeometryPolyline":return{min:has("featurelayer-snapshot-polyline-min-threshold"),max:has("featurelayer-snapshot-polyline-max-threshold")}}}export{e as createFeatureSourceSchema,r as createSnapshotInfo};