UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 4.17 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import has from"../../../../../core/has.js";import{clone as e}from"../../../../../core/lang.js";import{isHostedAgolService as t}from"../../../../../layers/support/arcgisLayerUrl.js";import{getEffectiveFeatureReduction as r}from"./featureReductionUtils.js";import{exceedsMinimumSnapshotCoverage as s}from"./featureServiceUtils.js";import{addFloorFilter as o,hasFloorFilter as i}from"./floorFilterUtils.js";import{getServiceGeometryType as a}from"./geometryUtils.js";import{getFeatureReductionDeconflictionEnabled as l,getLayerDeconflictionEnabled as n,createLabelVVEvaluator as p}from"./labelingUtils.js";import{createFeatureSourceSchema as d}from"../schema/SourceSchema.js";import{createSimpleProcessorSchema as u}from"../schema/processor/SimpleProcessorSchema.js";import{isRendererSupported as y}from"../support/rendererUtils.js";class c{constructor(e){this.layer=e}getLabelingDeconflictionInfo(e){const t=this.layer,r=l(t,e)??n(t);return[{vvEvaluators:{0:p(t.renderer)},deconflictionEnabled:r}]}async createServiceOptions(r){const o=this.layer,{capabilities:i,editingInfo:l,objectIdField:n,typeIdField:p,globalIdField:d,datesInUnknownTimezone:u,dateFieldsTimeZone:y,orderBy:c,subtypeField:m,refreshInterval:h}=o,f=o.fieldsIndex.toJSON(),b=a(o),g=o.timeInfo?.toJSON(),F=o.spatialReference.toJSON(),S=o.types?.map((e=>e.toJSON())),I=e(this.layer.parsedUrl);this.layer.dynamicDataSource&&(I.query={layer:JSON.stringify({source:this.layer.dynamicDataSource})});let x=this.layer.objectIdField;if(c?.length){const e=!c[0].valueExpression&&c[0].field;e&&(x=e)}const j=!(null!=l?.lastEditDate)&&h>0,R=!!has("featurelayer-snapshot-enabled")&&"point"===o.geometryType&&i?.query.supportsPagination&&!i?.operations.supportsEditing&&!j,E=R&&s(r,o.fullExtent),C=t(I.path),T=r.spatialReference.toJSON();return{type:"feature-service",source:I,isSourceHosted:C,orderByFields:x,outSpatialReference:T,metadata:{typeIdField:p??void 0,types:S,timeReferenceUnknownClient:u,dateFieldsTimeZone:y,subtypeField:m,globalIdField:d,fieldsIndex:f,geometryType:b,objectIdField:n,timeInfo:g,spatialReference:F,outSpatialReference:T,subtypes:this.layer.subtypes?.map((e=>e.toJSON()))},queryMetadata:{maxRecordCount:i.query.maxRecordCount,supportsCompactGeometry:i.query.supportsCompactGeometry,supportsDefaultSpatialReference:i.query.supportsDefaultSpatialReference,supportsFormatPBF:i.query.supportsFormatPBF,supportsMaxRecordCountFactor:i.query.supportsMaxRecordCountFactor,supportsQuantization:i.query.supportsQuantization,lastEditDate:l?.lastEditDate?.getTime(),snapshotInfo:{supportsSnapshotMinThreshold:R,supportsSnapshotMaxThreshold:E,snapshotCountThresholds:{min:has("featurelayer-snapshot-point-min-threshold"),max:has("featurelayer-snapshot-point-max-threshold")}}}}}createSourceSchema(e,t){const{apiKey:r,definitionExpression:s,displayFilterInfo:o,customParameters:i,gdbVersion:a,historicMoment:l,subtypeCode:n,subtypeField:p,timeExtent:u}=this.layer;return d({definitionExpression:s,displayFilterInfo:o,customParameters:i,gdbVersion:a,historicMoment:l,subtypeCode:n,subtypeField:p,timeExtent:u},e,t,r)}createProcessorSchema(e,t,s){const{fields:o,renderer:i,geometryType:a,labelingInfo:l,labelsVisible:n,orderBy:p,objectIdField:d,trackInfo:y}=this.layer,c={fields:o.map((e=>e.toJSON())),renderer:i?.clone(),featureReduction:r(this.layer,t),geometryType:a,labelingInfo:l,labelsVisible:n,objectIdField:d,orderBy:p??"default",trackInfo:y};return u(e,t,c,s)}get hasRequiredSupport(){return y(this.layer.renderer)}get timeOptions(){return this.layer}addFilters(e,t){return o(this.layer,e,t)}getUpdateHashProperties(e){return[()=>this.layer.apiKey,()=>this.layer.customParameters,()=>this.layer.definitionExpression,()=>r(this.layer,e),()=>i(this.layer,e)?e.floors:null,()=>this.layer.gdbVersion,()=>this.layer.historicMoment,()=>this.layer.labelsVisible?this.layer.labelingInfo:null,()=>this.layer.orderBy,()=>this.layer.outFields,()=>this.layer.renderer,()=>this.layer.subtypeCode,()=>this.layer.trackInfo]}}export{c as FeatureLayerAdapter};