UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

64 lines (63 loc) 3 kB
import Feature from 'ol/Feature.js'; import AbstractSearchClient from './abstractsearchclient.js'; import IGirafeContext from '../context/icontext.js'; import { Extent } from 'ol/extent.js'; export type GeoAdminChSearchConfig = { type: 'geoadminch'; providerName: string; bbox?: string; locationOrigins?: string; }; /** * Search provider for the Swiss search service of geo.admin.ch. * See documentation at https://docs.geo.admin.ch/access-data/search.html * * The GeoAdmin search provider allows 3 different types of searches: * - locations: POIs like addresses, swissnames, boundaries, parcels * - layers: layers of the GeoAdmin portal * - features: features inside one or multiple layers of the GeoAdmin portal * * This client currently only supports location search. * The API returns max 50 items per request. * * Configuration: * - providerName: The name of the search provider, or geoadminch. * - resultSrid: The spatial reference system (SRID) of the search results, always EPSG:2056. * - bbox: Comma-separated list of bounding box coordinates in EPSG:2056 (e.g. "2580000,1150000,2600000,1200000") * If no bbox is set, the max extent of the map is used. * - locationOrigins: Array of categories that are searched. Default: All categories. * Available categories and data origin: * - zipcode (ch.swisstopo-vd.ortschaftenverzeichnis_plz) * - gg25 (ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill) * - district (ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill) * - kantone (ch.swisstopo.swissboundaries3d-kanton-flaeche.fill) * - gazetteer (ch.swisstopo.swissnames3d, ch.bav.haltestellen-oev) * - address (ch.swisstopo.amtliches-gebaeudeadressverzeichnis, including EGID) * - parcel */ declare class GeoAdminChSearchClient extends AbstractSearchClient { constructor(context: IGirafeContext, config: GeoAdminChSearchConfig); private setSearchExtent; requestSearch(term: string, abortController: AbortController): Promise<Feature[]>; protected parseResponse(response: Response): Promise<Feature[]>; /** * GeoAdmin geoJson responses contain coordinates as [north, east], but the GeoJson standard is [east, north]. * To be able to use the ol GeoJson format reader, the coordinates are rearranged. * Note that other spatial information in the GeoAdmin response is valid, e.g. the bbox has the correct order. */ private fixGeoAdminCoordinates; /** * Swap first (north) and second (east) coordinate in an array of coordinates. */ private swapCoordinates; /** * Property origin contains the result category: */ groupedResults(results: Feature[]): Record<string, Feature[]>; getZoomToBbox(feature: Feature): Extent | undefined; /** * Remove bold and italic HTML tags from the label */ private sanitizeHtmlLabel; } export default GeoAdminChSearchClient;