@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
71 lines (70 loc) • 3.14 kB
TypeScript
import Feature from 'ol/Feature.js';
import { GeoJSON } from 'ol/format.js';
import GirafeSingleton from '../../base/GirafeSingleton.js';
import IGirafeContext from '../context/icontext.js';
import { Extent } from 'ol/extent.js';
export type BaseSearchClientConfig = {
type: string;
providerName: string;
url: string;
resultSrid: string;
};
export declare const SEARCH_PROVIDER_DEFAULT = "default";
export declare const SEARCH_GROUP_DEFAULT = "default";
export declare const SEARCH_GROUP_RECENTER_MAP = "recenter_map";
declare abstract class AbstractSearchClient extends GirafeSingleton {
readonly type: string;
readonly providerName: string;
protected url: URL;
protected readonly resultSrid: string;
protected readonly searchTermPlaceholder = "###SEARCHTERM###";
protected readonly searchLangPlaceholder = "###SEARCHLANG###";
protected searchTermQueryParameter: string | undefined;
protected searchLangQueryParameter: string | undefined;
protected searchFilterQueryParameter: string | undefined;
protected readonly geoJsonFormatter: GeoJSON<Feature<import("ol/geom.js").Geometry, {
[x: string]: any;
}>>;
protected constructor(context: IGirafeContext, config: BaseSearchClientConfig);
initializeSingleton(): Promise<void>;
protected get mapProjection(): import("ol/proj.js").Projection;
/**
* Sanitize the url by removing placeholders that are wrongfully interpreted as URL fragments by the URL parser.
* The parameters are introduced again and set when fetching the search results.
*/
private sanitizeUrl;
private extractQueryParamWithPlaceholder;
private sanitizePlaceholder;
/**
* Returns a list of categories that can be searched by.
*/
getSearchCategories(): Promise<string[]>;
protected buildRequestUrl(term: string, filter: string[]): URL;
/**
* Executes a search request with the provided search term.
*/
requestSearch(term: string, filter: string[], abortController: AbortController): Promise<Feature[]>;
/**
* Parses the response from the server and returns an array of features.
* Features must have the following properties to be used correctly with the search component:
* - `provider`
* - `label`
* - `label_html`: optional, for styled entries in the search results list
* - `actions`: optional, a list of SearchResultsActions
*/
protected parseResponse(response: Response): Promise<Feature[]>;
/**
* Groups the results by the default group, which equivalates to no grouping. Should be overridden by the client class
* to group results by a custom criteria like search category.
*/
groupedResults(results: Feature[]): Record<string, Feature[]>;
/**
* Returns a bbox around the geometry that is 50% larger than the geometry.
*/
getZoomToBbox(feature: Feature): Extent | undefined;
/**
* Retrieves the translation key for a given category. Default: use category string directly.
*/
getI18nKeyForCategory(category: string): string;
}
export default AbstractSearchClient;