@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 6.15 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{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import s from"../../../core/Loadable.js";import{escapeRegExpString as r}from"../../../core/string.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../../geometry/SpatialReference.js";import{typeKebabDictionary as a}from"../../../geometry/support/typeUtils.js";import{queryFeatureSetJSON as u,crsDefault as n,getSpatialReferenceWkid as c,getServerLandingPage as l,getServerConformance as d,getServerCollections as m,getServerOpenApi as y,getCollectionDefinition as f,crsPrefix as g}from"../../ogc/ogcFeatureUtils.js";import{zeroQueryBins as h}from"../../support/capabilities.js";import S from"../../../rest/support/FeatureSet.js";let C=class extends s{constructor(){super(...arguments),this.featureDefinition=null,this.type="ogc-feature"}load(t){return this.addResolvingPromise(this._loadOGCServices(this.layer,t)),this.when()}getSource(){const{featureDefinition:{collection:t,layerDefinition:e,spatialReference:s,supportedCrs:r},layer:{apiKey:o,customParameters:p,effectiveMaxRecordCount:i}}=this;return{type:"ogc-source",collection:t,layerDefinition:e,maxRecordCount:i,queryParameters:{apiKey:o,customParameters:p},spatialReference:s,supportedCrs:r}}queryExtent(t,e={}){return null}queryFeatureCount(t,e={}){return null}queryFeatures(t,e={}){return this.queryFeaturesJSON(t,e).then((t=>S.fromJSON(t)))}queryFeaturesJSON(t,e={}){const s=this.getSource();return this.load(e).then((()=>u(s,t,e)))}queryObjectIds(t,e={}){return null}serviceSupportsSpatialReference(t){return!(!t.isWGS84&&!t.isWebMercator)||!!this.featureDefinition.supportedCrs[t.wkid]}_conformsToType(t,e){const s=new RegExp(`^${r(e)}$`,"i");return t.conformsTo.some((t=>s.test(t)))??!1}_getCapabilities(t,e){return{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportsAttachment:!1,supportsM:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!1,supportsQueryBins:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:e,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,standardMaxRecordCount:void 0,supportsCacheHint:!1,supportsCentroid:!1,supportsCurrentUser:!1,supportsDisjointSpatialRelationship:!1,supportsDistance:!1,supportsDistinct:!1,supportsExtent:!1,supportsFormatPBF:!1,supportsGeometryProperties:!1,supportsHavingClause:!1,supportsHistoricMoment:!1,supportsMaxRecordCountFactor:!1,supportsOrderBy:!1,supportsPagination:!1,supportsPaginationOnAggregatedQueries:!1,supportsPercentileStatistics:!1,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsStandardizedQueriesOnly:!1,supportsTopFeaturesQuery:!1,supportsStatistics:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!1,supportsFullTextSearch:!1,supportsCompactGeometry:!1,supportsSqlExpression:!1,supportsTrueCurve:!1,tileMaxRecordCount:void 0},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},queryAttributeBins:h,editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}_getMaxRecordCount(t){const e=t?.components?.parameters;return e?.limit?.schema?.maximum??e?.limitFeatures?.schema?.maximum}_getStorageSpatialReference(t){const e=t.storageCrs??n,s=c(e);return null==s?i.WGS84:new i({wkid:s})}_getSupportedSpatialReferences(t,e){const s="#/crs",r=t.crs??[n],o=r.includes(s)?r.filter((t=>t!==s)).concat(e.crs??[]):r,p=/^http:\/\/www\.opengis.net\/def\/crs\/epsg\/.*\/3785$/i;return o.filter((t=>!p.test(t)))}async _loadOGCServices(t,s){const o=null!=s?s.signal:null,{apiKey:p,collectionId:i,customParameters:u,fields:n,geometryType:h,hasZ:S,objectIdField:C,timeInfo:R,url:w}=t,v={fields:n?.map((t=>t.toJSON())),geometryType:a.toJSON(h),hasZ:S??!1,objectIdField:C,timeInfo:R?.toJSON()},x={apiKey:p,customParameters:u,signal:o},j=await l(w,x),[F,O]=await Promise.all([d(j,x),m(j,x)]);if(!this._conformsToType(F,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/geojson"))throw new e("ogc-feature-layer:no-geojson-support","Server does not support geojson");const D=O.collections.find((({id:t})=>t===i));if(!D)throw new e("ogc-feature-layer:collection-not-found","Server does not contain the named collection");const T=this._conformsToType(F,"http://www.opengis.net/spec/ogcapi-features-1/1.0/conf/oas30")?await y(j,x):null,A=await f(D,v,x),b=this._getMaxRecordCount(T),q=this._getCapabilities(A.hasZ,b),P=this._getStorageSpatialReference(D).toJSON(),_=this._getSupportedSpatialReferences(D,O),Q=new RegExp(`^${r(g)}`,"i"),B={};for(const e of _){const t=c(e);null!=t&&(B[t]||(B[t]=e.replace(Q,"")))}this.featureDefinition={capabilities:q,collection:D,layerDefinition:A,spatialReference:P,supportedCrs:B}}};t([o()],C.prototype,"featureDefinition",void 0),t([o({constructOnly:!0})],C.prototype,"layer",void 0),t([o()],C.prototype,"type",void 0),C=t([p("esri.layers.graphics.sources.OGCFeatureSource")],C);export{C as OGCFeatureSource};