Class: OpenSearchService

OpenSearchService()

Provides a service for interacting with OpenSearch servers. The service exposes two methods: - discover used to get the description document; - search used for querying the search engine. By default, this service can handle Atom for EO and GeoJSON responses. Other types of response formats can by added using the registerParser method.

Constructor

new OpenSearchService()

Constructs a service for interacting with OpenSearch servers.
Source:

Members

descriptionDocument :OpenSearchDescriptionDocument

The latest parsed OpenSearch description document.
Type:
Source:

parserRegistry :OpenSearchParserRegistry

A registry of parsers (Atom, GeoJSON) to be used by this service.
Type:
Source:

rawDescriptionDocument :XmlDocument

The latest OpenSearch description document in the raw xml form.
Type:
  • XmlDocument
Source:

url :String

URL of the OpenSearch description document.
Type:
  • String
Source:

Methods

(static) create(options) → {Promise}

Fetches and parses an OpenSearch description document.
Parameters:
Name Type Description
options OpenSearchRequest See OpenSearchRequest for possible options. A url is required.
Source:
Returns:
A promise which when resolved returns this service, or an error when rejected
Type
Promise
Example
openSearchService
                     .discover({url: 'http://example.com/opensearch'})
                     .then(result => console.log(result))
                     .catch(err => console.error(err));

findUrl(predicate, context) → {OpenSearchUrl|undefined}

Finds an URL that satisfies the provided predicate function.
Parameters:
Name Type Description
predicate function Function to execute on each value in the description document URLs array, taking three arguments: element The current element being processed in the array. index The index of the current element being processed in the array. array The array find was called upon.
context Object | null Object to use as "this" when executing the predicate function.
Source:
Returns:
The first URL in the array that satisfies the provided predicate function. Otherwise, undefined is returned.
Type
OpenSearchUrl | undefined

getParser(type, rel) → {Object|undefined}

Returns the response parser for the specified mime type and relation.
Parameters:
Name Type Description
type String Mime type of the parser.
rel String Relation type of the parser.
Source:
Returns:
The response parser.
Type
Object | undefined

getSupportedFormats() → {Array.<String>}

Returns the list of supported mime types.
Source:
Returns:
The list of supported mime types.
Type
Array.<String>

registerDefaultParsers()

Internal. Applications should not call this function. Registers the default parsers for an OpenSearchService.
Source:

registerParser(type, rel, parser)

Registers a parser for the specified mime type and relation. The parse method of the parser will be called with the response of the server when the mime type and relation type matches.
Parameters:
Name Type Description
type String Mime type of the parser to register.
rel String Relation type of the parser to register.
parser Object An object with a parse method.
Source:

removeParser(type, rel)

Removes the response parser for the specified mime type and relation.
Parameters:
Name Type Description
type String Mime type of the registered parser.
rel String Relation type of the registered parser.
Source:
Performs a search query.
Parameters:
Name Type Description
searchParams Array | null A list of objects, each object must have a name and value property.
options OpenSearchRequest | null See OpenSearchRequest for possible options.
Source:
Returns:
A promise which when resolved returns a GeoJSON collection, or an error when rejected.
Type
Promise
Example
openSearchService
                     .search([
                         {name: 'count', value: 10}, {name: 'lat', value: 50}, {name: 'lon', value: 20}
                     ])
                     .then(result => console.log(result))
                     .catch(err => console.error(err));