@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 3.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{clone as e}from"../../../../../core/lang.js";import{isHostedAgolService as t}from"../../../../../layers/support/arcgisLayerUrl.js";import{getEffectiveFeatureReduction as r}from"./featureReductionUtils.js";import{createSnapshotInfo as i,createFeatureIdInfo as o}from"./featureServiceUtils.js";import{addFloorFilter as s,hasFloorFilter as a}from"./floorFilterUtils.js";import{getServiceGeometryType as l}from"./geometryUtils.js";import{getFeatureReductionDeconflictionEnabled as n,getLayerDeconflictionEnabled as p,createLabelVVEvaluator as d}from"./labelingUtils.js";import{createFeatureSourceSchema as u}from"../schema/SourceSchema.js";import{createSimpleProcessorSchema as y}from"../schema/processor/SimpleProcessorSchema.js";import{isRendererSupported as c}from"../support/rendererUtils.js";class m{constructor(e){this.layer=e}getLabelingDeconflictionInfo(e){const t=this.layer,i=n(t,e)??p(t),o=r(t,e),s=[...t.labelingInfo||[],...o?.labelingInfo||[]];return[{vvEvaluators:{0:d(t.renderer)},deconflictionEnabled:i,labelingInfo:s}]}async createServiceOptions(r){const s=this.layer,{capabilities:a,editingInfo:n,typeIdField:p,globalIdField:d,datesInUnknownTimezone:u,dateFieldsTimeZone:y,orderBy:c,subtypeField:m,refreshInterval:f}=s,h=s.fieldsIndex.toJSON(),b=l(s),I=s.timeInfo?.toJSON(),g=s.spatialReference.toJSON(),S=s.types?.map((e=>e.toJSON())),F=e(this.layer.parsedUrl);this.layer.dynamicDataSource&&(F.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 R=t(F.path),j=i(R,!(null!=n?.lastEditDate)&&f>0,a,b,r.extent,s.fullExtent),E=r.spatialReference.toJSON();return{type:"feature-service",source:F,isSourceHosted:R,orderByFields:x,outSpatialReference:E,metadata:{typeIdField:p??void 0,types:S,timeReferenceUnknownClient:u,dateFieldsTimeZone:y,subtypeField:m,globalIdField:d,fieldsIndex:h,geometryType:b,featureIdInfo:o(s),timeInfo:I,spatialReference:g,outSpatialReference:E,subtypes:this.layer.subtypes?.map((e=>e.toJSON()))},queryMetadata:{maxRecordCount:a.query.maxRecordCount,supportsCompactGeometry:a.query.supportsCompactGeometry,supportsDefaultSpatialReference:a.query.supportsDefaultSpatialReference,supportsFormatPBF:a.query.supportsFormatPBF,supportsMaxRecordCountFactor:a.query.supportsMaxRecordCountFactor,supportsQuantization:a.query.supportsQuantization,lastEditDate:n?.lastEditDate?.getTime(),snapshotInfo:j}}}createSourceSchema(e,t){const{apiKey:r,definitionExpression:i,displayFilterInfo:o,customParameters:s,gdbVersion:a,historicMoment:l,subtypeCode:n,subtypeField:p,timeExtent:d}=this.layer;return u({definitionExpression:i,displayFilterInfo:o,customParameters:s,gdbVersion:a,historicMoment:l,subtypeCode:n,subtypeField:p,timeExtent:d},e,t,r)}createProcessorSchema(e,t,i){const{fields:o,renderer:s,geometryType:a,labelingInfo:l,labelsVisible:n,orderBy:p,objectIdField:d,trackInfo:u}=this.layer,c={fields:o.map((e=>e.toJSON())),renderer:s?.clone(),labelingInfoSource:this.layer.id,featureReduction:r(this.layer,t),geometryType:a,labelingInfo:l,labelsVisible:n,objectIdField:d,orderBy:p??"default",trackInfo:u};return y(e,t,c,i)}get hasRequiredSupport(){return c(this.layer.renderer)}get timeOptions(){return this.layer}addFilters(e,t){return s(this.layer,e,t)}getUpdateHashProperties(e){return[()=>this.layer.apiKey,()=>this.layer.customParameters,()=>this.layer.definitionExpression,()=>r(this.layer,e),()=>a(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{m as FeatureLayerAdapter};