digitransit-ui/digitransit-search-util/packages/digitransit-search-util-helpers/README.md
Janne Antikainen ff6c0c536a feat: readMes
2020-04-22 12:20:03 +03:00

74 lines
2.3 KiB
Markdown

# @digitransit-search-util/digitransit-search-util-helpers
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## LayerType
LayerType depicts the type of the point-of-interest.
## match
Tries to match the given search term agains the collection of properties
for a geocoding result. The best match will be returned (min: 0, max: 1.5).
### Parameters
- `normalizedTerm` **[string][1]** the normalized search term.
- `resultProperties` **any** the geocoding result's property collection.
## getLayerRank
Ranks the result based on its layer property.
### Parameters
- `layer` **[string][1]** the layer property.
- `source` **[string][1]** the source property.
## sortSearchResults
Helper function to sort the results. Orders as follows:
- current position first for an empty search
- matching routes first
- otherwise by confidence, except that:
- boost well matching stations (especially from GTFS)
- rank stops lower as they tend to occupy most of the search results
- items with no confidence (old searches and favorites):
- rank favourites better than ordinary old searches
- rank full match better than partial match
- rank match at middle word lower than match at the beginning
### Parameters
- `config`
- `results` **[Array][2]&lt;any>** The search results that were received
- `term` **[String][1]** The search term that was used (optional, default `''`)
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the digitransit-util project. -->
---
This module is part of the Digitransit-ui project. It is maintained in the
[HSLdevcom/digitransit-ui](https://github.com/HSLdevcom/digitransit-ui) repository, where you can create
PRs and issues.
### Installation
Install this module individually:
```sh
$ npm install @digitransit-search-util/digitransit-search-util-helpers
```
Or install the Digitransit-util module that includes it as a function:
```sh
$ npm install @digitransit-util/digitransit-util
```