@@ -26,6 +26,7 @@ import type {
2626 TypeMetadataEsriLayerSummary ,
2727 TypeMetadataEsriImage ,
2828 TypeMosaicRule ,
29+ TypeLayerMetadataFields ,
2930} from '@/api/types/layer-schema-types' ;
3031import { Fetch } from '@/core/utils/fetch-helper' ;
3132import type { ConfigBaseClass } from '@/api/config/validation-classes/config-base-class' ;
@@ -377,7 +378,7 @@ export class EsriUtilities {
377378 throw new LayerServiceMetadataUnableToFetchError ( layerConfig . getGeoviewLayerId ( ) , layerConfig . getLayerName ( ) , formatError ( error ) ) ;
378379 }
379380 } else {
380- // The layer metadata was alredy queried (same as the service metadata), use that
381+ // In the case of an EsriImage, the layer metadata was already queried (same as the service metadata), use that
381382 layerMetadata = layerConfig . getServiceMetadata ( ) ! ;
382383 }
383384
@@ -435,7 +436,8 @@ export class EsriUtilities {
435436
436437 // Read variables
437438 const queryable = layerMetadata . capabilities . includes ( 'Query' ) || layerMetadata . capabilities . includes ( 'Catalog' ) ;
438- const hasFields = ! ! layerMetadata . fields ?. length ;
439+ const { fields } = layerMetadata ;
440+ const hasFields = ! ! fields ?. length ;
439441 const isGroupLayer = layerMetadataEsriDynamicLayer . type === 'Group Layer' ;
440442 const isMetadataGroup = layerConfig . getIsMetadataLayerGroup ( ) ;
441443
@@ -444,7 +446,7 @@ export class EsriUtilities {
444446
445447 // Initialize the outfields
446448 // dynamic group layer doesn't have fields definition
447- if ( layerMetadata . fields && ! isGroupLayer ) {
449+ if ( hasFields && ! isGroupLayer ) {
448450 // Get the outfields
449451 let outfields = layerConfig . getOutfields ( ) ;
450452
@@ -454,7 +456,7 @@ export class EsriUtilities {
454456 outfields = [ ] ;
455457
456458 // Loop
457- layerMetadata . fields . forEach ( ( fieldEntry ) => {
459+ fields . forEach ( ( fieldEntry ) => {
458460 // If the field is the geometry field
459461 if ( layerMetadataEsriDynamicLayer . geometryField && fieldEntry ?. name === layerMetadataEsriDynamicLayer . geometryField ?. name ) {
460462 // Keep the geometry field for future use
@@ -472,8 +474,8 @@ export class EsriUtilities {
472474 const newOutfield : TypeOutfields = {
473475 name : fieldEntry . name ,
474476 alias : fieldEntry . alias || fieldEntry . name ,
475- type : this . esriGetFieldType ( layerConfig , fieldEntry . name ) ,
476- domain : this . esriGetFieldDomain ( layerConfig , fieldEntry . name ) ,
477+ type : this . esriGetFieldType ( layerConfig , fields , fieldEntry . name ) ,
478+ domain : this . esriGetFieldDomain ( fields , fieldEntry . name ) ,
477479 } ;
478480
479481 outfields ! . push ( newOutfield ) ;
@@ -782,18 +784,32 @@ export class EsriUtilities {
782784
783785 /**
784786 * Returns the type of the specified field.
785- * @param {EsriDynamicLayerEntryConfig | EsriFeatureLayerEntryConfig | EsriImageLayerEntryConfig } layerConfig The ESRI layer config
786- * @param {string } fieldName field name for which we want to get the type.
787- * @returns {TypeOutfieldsType } The type of the field.
788- * @static
787+ *
788+ * For ESRI Image layers, well-known pixel fields (`PixelValue`, `ProcessedValue`, `Name`)
789+ * are short-circuited to `'string'` because they have no metadata entry.
790+ *
791+ * @param layerConfig - The ESRI layer config, used to detect EsriImage-specific fields.
792+ * @param fields - The metadata field definitions to search.
793+ * @param fieldName - Field name for which we want to get the type.
794+ * @returns The mapped outfield type (`'date'`, `'oid'`, `'number'`, or `'string'`).
789795 */
790796 static esriGetFieldType (
791797 layerConfig : EsriDynamicLayerEntryConfig | EsriFeatureLayerEntryConfig | EsriImageLayerEntryConfig ,
798+ fields : TypeLayerMetadataFields [ ] ,
792799 fieldName : string
793800 ) : TypeOutfieldsType {
794- const esriFieldDefinitions = layerConfig . getLayerMetadata ( ) ?. fields ;
795- const fieldDefinition = esriFieldDefinitions ?. find ( ( metadataEntry ) => metadataEntry . name === fieldName ) ;
801+ // For EsriImage layers, handle well-known pixel fields that have no metadata entry
802+ if ( layerConfig instanceof EsriImageLayerEntryConfig ) {
803+ const lowerFieldName = fieldName . toLowerCase ( ) ;
804+ if ( lowerFieldName === 'pixelvalue' || lowerFieldName === 'processedvalue' || lowerFieldName === 'name' ) {
805+ return 'string' ;
806+ }
807+ }
808+
809+ // Find the field definition in the provided fields array
810+ const fieldDefinition = fields ?. find ( ( metadataEntry ) => metadataEntry . name === fieldName ) ;
796811 if ( ! fieldDefinition ) return 'string' ;
812+
797813 const esriFieldType = fieldDefinition . type ;
798814 if ( esriFieldType === 'esriFieldTypeDate' ) return 'date' ;
799815 if ( esriFieldType === 'esriFieldTypeOID' ) return 'oid' ;
@@ -808,20 +824,16 @@ export class EsriUtilities {
808824
809825 /**
810826 * Returns the domain of the specified field.
811- * @param { EsriDynamicLayerEntryConfig | EsriFeatureLayerEntryConfig | EsriImageLayerEntryConfig } layerConfig The ESRI layer config
812- * @param { string } fieldName field name for which we want to get the domain .
813- * @returns { codedValueType | rangeDomainType | null } The domain of the field .
814- * @static
827+ *
828+ * @param fields - The metadata field definitions to search .
829+ * @param fieldName - Field name for which we want to get the domain .
830+ * @returns The domain of the field, or `null` if not found.
815831 */
816832 // TODO: ESRI domains are translated to GeoView domains in the configuration. Any GeoView layer that support geoview domains can
817833 // TO.DOCONT: call a method getFieldDomain that use config.source.featureInfo.outfields to find a field domain.
818- static esriGetFieldDomain (
819- layerConfig : EsriDynamicLayerEntryConfig | EsriFeatureLayerEntryConfig | EsriImageLayerEntryConfig ,
820- fieldName : string
821- ) : codedValueType | rangeDomainType | null {
822- const esriFieldDefinitions = layerConfig . getLayerMetadata ( ) ?. fields ;
823- const fieldDefinition = esriFieldDefinitions ?. find ( ( metadataEntry ) => metadataEntry . name === fieldName ) ;
824- return fieldDefinition ? fieldDefinition . domain : null ;
834+ static esriGetFieldDomain ( fields : TypeLayerMetadataFields [ ] , fieldName : string ) : codedValueType | rangeDomainType | null {
835+ // Find the field definition in the provided fields array
836+ return fields ?. find ( ( metadataEntry ) => metadataEntry . name === fieldName ) ?. domain ?? null ;
825837 }
826838
827839 // #endregion PARSING METHODS
0 commit comments