# otp-profile-score

> Score OTP profiles

Latest version **0.6.3** (published 2015-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install otp-profile-score
pnpm add otp-profile-score
yarn add otp-profile-score
bun add otp-profile-score
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.3 |
| Published | 2015-05-29 |
| First published | 2014-07-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Conveyal |
| Maintainers | trevorgerhardt |
| Keywords | OTP, OpenTripPlanner |

## Links

- npm: https://www.npmjs.com/package/otp-profile-score
- Repository: https://github.com/conveyal/otp-profile-score
- Issues: https://github.com/conveyal/otp-profile-score/issues
- npm.io page: https://npm.io/package/otp-profile-score

## Dependencies (1)

- [component-clone](https://npm.io/package/component-clone.md) 0

## Recent versions

- 0.6.3 (latest) — 2015-05-29
- 0.6.2 — 2015-04-09
- 0.5.4 — 2015-03-30
- 0.5.3 — 2015-03-25
- 0.5.1 — 2014-12-24
- 0.5.0 — 2014-12-24
- 0.4.2 — 2014-10-09
- 0.4.1 — 2014-10-02
- 0.4.0 — 2014-08-21
- 0.1.1 — 2014-07-31
- 0.1.0 — 2014-07-31
- 0.0.3 — 2014-07-23
- 0.0.2 — 2014-07-11
- 0.0.1 — 2014-07-09
- 0.0.0 — 2014-07-09

## README

# otp-profile-score

[![build status](https://secure.travis-ci.org/conveyal/otp-profile-score.png)](http://travis-ci.org/conveyal/otp-profile-score)

Score OTP profiles

## Installation

Requires [nodejs](http://nodejs.org/).

```sh
$ npm install otp-profile-score
```

## Tests

```sh
$ npm test
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

-   [ProfileScore](#profilescore)
    -   [processOption](#processoption)
    -   [processOptions](#processoptions)
    -   [score](#score)
    -   [tally](#tally)

### ProfileScore

Process & score an OTP Profile response. Tally statistics, score options.

**Parameters**

-   `opts` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Options object.
    -   `opts.factors` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Factors to override the defaults.
    -   `opts.rates` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Rates to to override the defaults.

**Examples**

```javascript
const ProfileScore = require('otp-profile-score')
const scorer = new ProfileScore({ factors: {}, rates: {} })
```

#### processOption

Process an individual option, only uses the first access and egress modes given.

**Parameters**

-   `option` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Option returned from OTP's profiler.

**Examples**

```javascript
getProfileFromOTP(query, function(err, profile) {
  const scoredOption = scorer.processOption(profile[0])
})
```

Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** processedOption Annotated and scored.

#### processOptions

Process an array of options that were generated by [OpenTripPlanner](http://www.opentripplanner.org)'s Profiler.

**Parameters**

-   `options` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** 

**Examples**

```javascript
getProfileFromOTP(query, function(err, profile) {
  const allScoredResults = scorer.processOptions(profile)
})
```

Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)** processedOptions Options that are split up by access mode and annotated with a score.

#### score

Get the weighted score of an option based on the factors, weights, and tallied totals for that option.

**Parameters**

-   `option` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** 

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** score

#### tally

Tally values. Add up total calories, cost, transfers, distances, and times.

**Parameters**

-   `option` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** 

Returns **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** talliedOption

---
_Source: https://npm.io/package/otp-profile-score · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
