UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

38 lines (37 loc) 1.47 kB
import AbstractSearchClient from './abstractsearchclient.js'; /** * A search provider for the GeoMapFish backend. * Extends the AbstractSearchClient and provides methods tailored to processing GMF-specific search results. * * Configuration: * - providerName: The name of the search provider, or geomapfish. * - url: The URL of the GMF search service. * - resultSrid: The spatial reference system (SRID) of the search results. Default same as map SRID. */ class GmfSearchClient extends AbstractSearchClient { constructor(context, config) { super(context, 'geomapfish', config.providerName, config.url, config.resultSrid); } groupedResults(results) { const groupedResults = {}; for (const result of results) { let group = 'Unknown layer type'; if (result.get('layer_name')) { group = result.get('layer_name'); } else if (result.get('actions')[0].action.startsWith('add_theme')) { group = 'add_theme'; } else if (result.get('actions')[0].action.startsWith('add_group')) { group = 'add_group'; } else if (result.get('actions')[0].action.startsWith('add_layer')) { group = 'add_layer'; } groupedResults[group] ??= []; groupedResults[group].push(result); } return groupedResults; } } export default GmfSearchClient;