geoview-core - v2.3.0
    Preparing search index...

    Class WFS

    A class to add WFS layer.

    Hierarchy (View Summary)

    Index
    addLayerLoadError allLayerStatusAreGreaterThanOrEqualTo createGeoViewLayers createGVLayer createVectorSource emitLayerEntryRegisterInit emitMessage fetchServiceMetadata fetchServiceMetadataVector fetchServiceMetadataWFS getAllLayerEntryConfigs getClassName getConfigProxyUrl getConfigServiceUrls getGeoviewLayerConfig getGeoviewLayerId getGeoviewLayerName getIsUsingProxy getLayerEntryNameOrGeoviewLayerName getLayerLoadErrors getMetadata getMetadataAccessPath getMetadataAccessPathIfExists getProxyUrl getUrlWithProxyWhenNeeded hasMetadataAccessPath helperFetchServiceMetadataWithFJson initGeoViewLayerEntries initGVLayer offLayerConfigCreated offLayerEntryProcessed offLayerEntryRegisterInit offLayerGroupCreated offLayerGVCreated offLayerMessage onCreateGVLayer onCreateVectorSource onCreateVectorSourceLoadFeatures onFetchServiceMetadata onInitGVLayer onInitLayerEntries onLayerConfigCreated onLayerEntryProcessed onLayerEntryRegisterInit onLayerGroupCreated onLayerGVCreated onLayerMessage onProcessLayerMetadata onProcessOneLayerEntry onValidateLayerEntryConfig onValidateListOfLayerEntryConfig setConfigProxyUrl setConfigServiceUrls setMetadataAccessPath setProxyUrl validateLayerEntryConfig validateListOfLayerEntryConfig createGeoviewLayerConfig extractDescribeFeatureOutputFormat fetchJson fetchMetadata fetchText fetchWithFormatFallback getFieldType initGeoviewLayerConfig initLayerMetadata isGmlGeometryField processConfig processFeatureInfoConfig processGeoviewLayerConfig throwIfMetatadaHasError
    hitTolerance: number = AbstractGeoViewLayer.DEFAULT_HIT_TOLERANCE

    The default hit tolerance

    listOfLayerEntryConfig: TypeLayerEntryConfig[] = []

    An array of layer settings. In the schema, this attribute is optional. However, we define it as mandatory and if the configuration does not provide a value, we use an empty array instead of an undefined attribute.

    olRootLayer?: BaseLayer<{ [x: string]: any }>

    The OpenLayer root layer representing this GeoView Layer.

    DEFAULT_DISPLAY_DATE_MODE_TO_GENERATE_CONFIGS: DisplayDateMode = 'long'

    The default display date mode used when generating default configurations

    DEFAULT_HIT_TOLERANCE: number = 4

    The default hit tolerance the query should be using

    DEFAULT_WAIT_PERIOD_METADATA_WARNING: number = ...

    The default waiting time before showing a warning about the metadata taking a long time to get processed.

    DEFAULT_WAIT_PERIOD_METADATA_WARNING_RECALL: number = ...

    The interval between repeated metadata fetch warnings after the initial one has been shown.

    DEFAULT_WAIT_SLOW_FETCH_WARNING: number = ...

    The maximum delay to wait before we warn about the features fetch taking a long time

    EXCLUDED_HEADERS: string[] = ...
    EXCLUDED_HEADERS_GEN: string[] = ...
    EXCLUDED_HEADERS_LAT: string[] = ...
    EXCLUDED_HEADERS_LNG: string[] = ...
    EXCLUDED_HEADERS_STYLE: string[] = ...
    MAX_ESRI_FEATURES: 200000
    • This method is used to create the layers specified in the listOfLayerEntryConfig attribute inherited from its parent.

      Normally, it is the second method called in the life cycle of a GeoView layer, the first one being the constructor. Its code is the same for all child classes. It must first validate that the olLayers attribute is null indicating that the method has never been called before for this layer. If this is not the case, an error message must be sent. Then, it calls the abstract method getAdditionalServiceDefinition. For example, when the child is a WFS service, this method executes the GetCapabilities request and saves the result in the metadata attribute of the class. It also process the layer's metadata for each layer in the listOfLayerEntryConfig tree in order to define the missing pieces of the layer's configuration. Layer's configuration can come from the configuration of the GeoView layer or from the information saved by the method #processListOfLayerMetadata, priority being given to the first of the two. When the GeoView layer does not have a service definition, the getAdditionalServiceDefinition method does nothing.

      Finally, the processListOfLayerEntryConfig is called to instantiate each layer identified by the listOfLayerEntryConfig attribute. This method will also register the layers to all layer sets that offer this possibility. For example, if a layer is queryable, it will subscribe to the details-panel and every time the user clicks on the map, the panel will ask the layer to return the descriptive information of all the features in a tolerance radius. This information will be used to populate the details-panel.

      Parameters

      • displayDateMode: DisplayDateMode

        The display date mode to use for processing time dimensions in the metadata

      • OptionalmapProjection: Projection

        Optional map projection

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process

      Returns Promise<ConfigBaseClass[]>

      A promise that resolves with the config base classes created

    • Emits a layer-specific message event with localization support.

      Parameters

      • messageKey: string

        The key used to lookup the localized message OR message

      • messageParams: Record<string, unknown> | undefined = {}

        Optional array of parameters to be interpolated into the localized message

      • messageType: SnackbarType = 'info'

        The message type

      Returns void

      this.emitMessage(
      'layers.fetchProgress',
      ['50', '100'],
      'error',
      );
    • Fetches the WFS service metadata.

      Parameters

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the fetch process

      Returns Promise<TypeMetadataWFSCapabilities>

      A promise that resolves with the WFS metadata

      When the metadata fetch fails or contains an error

      When the metadata is empty (no Capabilities)

    • Fetches and validates service metadata for layers that use the ?f=json convention.

      This helper builds the metadata URL by appending ?f=json to the metadataAccessPath, then fetches it using GeoUtilities.fetchJsonWithProxyFallback. If the initial request fails with a network error, the fallback automatically retries through the configured proxy. When a proxy is used successfully, it is stored on the GeoView layer instance via setProxyUrl so that subsequent requests (legend, identify, layer metadata) can reuse it.

      After a successful fetch, the response is validated via throwIfMetatadaHasError to detect ESRI-level error payloads (e.g., { error: { code, message } }) embedded in an otherwise successful HTTP response.

      Type Parameters

      • T

      Parameters

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the metadata fetch

      Returns Promise<T>

      A promise that resolves with the parsed JSON metadata object

      When the metadata fetch fails (network, proxy, or HTTP error)

      When the response contains an ESRI error payload (propagated from throwIfMetatadaHasError())

    • Overridable function to create a source configuration for the vector layer.

      Parameters

      • layerConfig: VectorLayerEntryConfig

        The layer entry configuration

      • sourceOptions: Options<Feature<Geometry, { [x: string]: any }>>

        The source options (default: { strategy: all })

      Returns GVVectorSource

      The source configuration that will be used to create the vector layer

    • Overrides the loading of the vector features for the layer by fetching WFS data and converting it into OpenLayers Feature feature instances.

      Parameters

      • layerConfig: VectorLayerEntryConfig

        The configuration object for the vector layer, containing source and data access information

      • sourceOptions: Options<Feature<Geometry, { [x: string]: any }>>

        The OpenLayers vector source options associated with the layer

      • readOptions: ReadOptions

        Options controlling how features are read, including the target featureProjection

      Returns Promise<SourceFeaturesInfo>

      A promise that resolves to an array of OpenLayers features

    • Overrides the way the metadata is fetched.

      Resolves with the Json object or undefined when no metadata is to be expected for a particular layer type.

      Type Parameters

      • T = TypeMetadataWFSCapabilities

      Parameters

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process

      Returns Promise<T>

      A promise that resolves with the metadata or undefined when no metadata for the particular layer type

      When the metadata fetch fails or contains an error

      When the metadata is empty (no Capabilities)

    • Overrides the way a geoview layer config initializes its layer entries.

      Parameters

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process

      Returns Promise<TypeGeoviewLayerConfig>

      A promise that resolves once the layer entries have been initialized

      When the metadata fetch fails or contains an error

      When the metadata is empty (no Capabilities)

    • Overrides the way the layer metadata is processed.

      Parameters

      • layerConfig: VectorLayerEntryConfig

        The layer entry configuration to process

      • displayDateMode: DisplayDateMode

        The display date mode to use for processing time dimensions in the metadata

      • OptionalmapProjection: Projection

        Optional map projection

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process

      Returns Promise<VectorLayerEntryConfig>

      A promise that resolves once the layer entry configuration has gotten its metadata processed

      When the Data Access Path was undefined, likely because initDataAccessPath wasn't called

    • Creates a configuration object for an WFS Feature layer.

      This function constructs a TypeWFSLayerConfig object that describes an WFS Feature layer and its associated entry configurations based on the provided parameters.

      Parameters

      • geoviewLayerId: string

        A unique identifier for the GeoView layer

      • geoviewLayerName: string

        The display name of the GeoView layer

      • metadataAccessPath: string

        The full service URL to the layer endpoint

      • isTimeAware: boolean | undefined

        Indicates whether the layer supports time-based filtering

      • strategy: VectorStrategy

        Indicates the strategy to use to fetch vector data

      • layerEntries: TypeLayerEntryShell[]

        An array of layer entries objects to be included in the configuration

      Returns TypeWFSLayerConfig

      The constructed configuration object for the WFS Feature layer

    • Extracts the preferred output format value for a WFS DescribeFeatureType operation from the parsed WFS capabilities metadata.

      The method navigates through the ows:OperationsMetadata section of the capabilities document to locate the "DescribeFeatureType" operation and returns the first available output format value.

      Parameters

      • metadata: TypeMetadataWFSCapabilities

        The parsed WFS capabilities metadata object

      Returns string

      The detected output format string for the DescribeFeatureType operation, or an empty string if no suitable value is found

    • Fetches json data from the given URL using settings defined in the vector source configuration.

      Supports both GET and POST requests depending on the presence of postSettings.

      Parameters

      • url: string

        The URL to fetch data from

      • OptionalpostSettings: TypePostSettings

        Optional POST settings from the layer config

      Returns Promise<unknown>

      A promise that resolves to the fetched JSON response

    • Fetches the metadata for a typical WFS class.

      Parameters

      • url: string

        The url to query the metadata from

      • configProxyUrl: string | undefined

        Proxy URL to use when necessary

      • OptionalcallbackNewMetadataUrl: CallbackNewMetadataDelegate

        Optional callback executed when a proxy had to be used to fetch the metadata.

      • OptionalabortSignal: AbortSignal

        Optional AbortSignal used to cancel the layer creation process

      Returns Promise<TypeMetadataWFSCapabilities>

      A promise that resolves with the metadata when fetched or undefined when capabilities weren't found

      When the request exceeds the timeout duration

      When the request was aborted by the caller's signal

      When the response is not OK (non-2xx)

      When the JSON response is empty

      When a network issue happened

    • Fetches text data from the given URL using settings defined in the vector source configuration.

      Supports both GET and POST requests depending on the presence of postSettings.

      Parameters

      • url: string

        The URL to fetch data from

      • OptionalpostSettings: TypePostSettings

        Optional POST settings from the layer config

      Returns Promise<string>

      A promise that resolves to the fetched text response

    • Generic format fallback strategy: tries the preferred format first, then falls back to no specific format. Accepts custom parse functions so callers can plug in their own fetch+parse pipeline.

      Type Parameters

      • T

      Parameters

      • layerConfig: OgcWfsLayerEntryConfig

        The WFS layer entry configuration

      • queryFnJSON: (url: string) => Promise<T>
      • queryFnFallback: (url: string) => Promise<T>
      • OptionalbboxExtent: string

        Optional bbox extent string (e.g., 'minx,miny,maxx,maxy,EPSG:3978')

      • Optionaloutfields: TypeOutfields[]

        Optional list of fields to return (propertyName parameter)

      • Optionalfilter: string

        Optional OGC XML filter string

      • OptionalsrsName: string

        Optional output projection code (e.g., 'EPSG:3857')

      Returns Promise<T>

      A promise that resolves with the result of the parse function

      When no format produces usable results

    • Determines the simplified data type of a specified field from a WFS layer configuration.

      Extracts the field definition from the layer's metadata, interprets its WFS type (e.g., xsd:int, xsd:date), and maps it to a normalized internal type ('string', 'number', 'date', or 'dateTime').

      Parameters

      • fieldName: string

        The name of the field whose type should be retrieved

      • layerConfig: OgcWfsLayerEntryConfig

        The WFS layer configuration containing metadata definitions

      Returns TypeOutfieldsType

      The normalized field type ('string', 'number', 'date', or 'dateTime')

    • Initializes a GeoView layer configuration for a WFS layer.

      This method creates a basic TypeGeoviewLayerConfig using the provided ID, name, and metadata access path URL. It then initializes the layer entries by calling initGeoViewLayerEntries, which may involve fetching metadata or sublayer info.

      Parameters

      • geoviewLayerId: string

        A unique identifier for the layer

      • geoviewLayerName: string

        The display name of the layer

      • metadataAccessPath: string

        The full service URL to the layer endpoint

      • OptionalisTimeAware: boolean

        Optional to indicates whether the layer supports time-based filtering

      Returns Promise<TypeGeoviewLayerConfig>

      A promise that resolves to an initialized GeoView layer configuration with layer entries

    • Initializes the layer metadata for a WFS layer entry configuration based on the provided feature type properties.

      This method processes the list of feature type properties obtained from a DescribeFeatureType response, identifies geometry fields, and sets the appropriate metadata on the layer configuration.

      Parameters

      • layerConfig: OgcWfsLayerEntryConfig

        The vector layer entry to configure

      • fields: TypeOutfields[] | undefined

        An array of field names and its aliases

      Returns void

    • Determines whether a given WFS feature type field represents a geometry property.

      Checks if the field's type string starts with the "gml:" prefix, which indicates a GML geometry type such as gml:PointPropertyType, gml:PolygonPropertyType, etc.

      Parameters

      • field: TypeOutfields

        The feature type field definition to evaluate

      Returns boolean

      true if the field is a geometry field; otherwise, false

    • Processes a WFS (Web Feature Service) GeoviewLayerConfig and returns a promise that resolves to an array of ConfigBaseClass layer entry configurations.

      This method:

      1. Creates a Geoview layer configuration using the provided parameters.
      2. Instantiates a layer with that configuration.
      3. Processes the layer configuration and returns the result.

      Parameters

      • geoviewLayerId: string

        The unique identifier for the GeoView layer

      • geoviewLayerName: string

        The display name for the GeoView layer

      • url: string

        The URL of the service endpoint

      • configProxyUrl: string | undefined

        Proxy URL to use when necessary

      • layerIds: string[]

        An array of layer IDs to include in the configuration

      • isTimeAware: boolean

        Indicates if the layer is time aware

      • vectorStrategy: VectorStrategy

        The strategy to use for fetching vector data

      • fetchStylesOnWMS: boolean

        Indicates whether to fetch styles from WMS

      • OptionalcallbackCreateLayerEntryConfig: (wfsEntry: TypeLayerEntryShell) => TypeLayerEntryShell

        Optional callback to customize each layer entry configuration

      Returns Promise<ConfigBaseClass[]>

      A promise that resolves to an array of layer configurations