UNPKG

@terrestris/ol-util

Version:

A set of helper classes for working with openLayers

75 lines (74 loc) 2.37 kB
import OlFilter from 'ol/format/filter/Filter.js'; export interface AttributeSearchSettings { exactSearch?: boolean; matchCase?: boolean; type: 'number' | 'int' | 'string'; } /** * A nested object mapping feature types to an object of their attribute details. * * Example: * ``` * attributeDetails: { * featType1: { * attr1: { * matchCase: true, * type: 'number', * exactSearch: false * }, * attr2: { * matchCase: false, * type: 'string', * exactSearch: true * } * }, * featType2: {...} * } * ``` */ export type AttributeDetails = Record<string, Record<string, AttributeSearchSettings>>; export interface SearchConfig { attributeDetails: AttributeDetails; featureNS: string; featurePrefix: string; featureTypes?: string[]; filter?: OlFilter; geometryName?: string; maxFeatures?: number; olFilterOnly?: boolean; outputFormat?: string; propertyNames?: string[]; srsName?: string; wfsFormatOptions?: string; } /** * Helper class for building filters to be used with WFS GetFeature requests. * * @class WfsFilterUtil */ declare class WfsFilterUtil { /** * Creates a filter for a given feature type considering configured * search attributes, mapped features types to an array of attribute details and the * current search term. * Currently, supports EQUAL_TO and LIKE filters only, which can be combined with * OR filter if searchAttributes array contains multiple values though. * * @param featureType * @param {string} searchTerm Search value. * @param attributeDetails * attributes that should be searched through. * @return {OlFilter} Filter to be used with WFS GetFeature requests. * @private */ static createWfsFilter(featureType: string, searchTerm: string, attributeDetails: AttributeDetails): OlFilter | undefined; /** * Creates GetFeature request body for all provided featureTypes and * applies related filter encoding on it. * * @param {SearchConfig} searchConfig The search config * @param {string} searchTerm Search string to be used with filter. */ static getCombinedRequests(searchConfig: SearchConfig, searchTerm: string): Element | undefined; } export default WfsFilterUtil;