0.6.3 • Published 9 years ago
otp-profile-score v0.6.3
otp-profile-score
Score OTP profiles
ProfileScore(opts, opts.factors, opts.rates)
Process & score an OTP Profile response. Tally statistics, score options.
Parameters
parameter | type | description |
---|---|---|
opts | Object | Options object. |
opts.factors | Object | optional: Factors to override the defaults. |
opts.rates | Object | optional: Rates to to override the defaults. |
Example
var ProfileScore = require('otp-profile-score');
var scorer = new ProfileScore({ factors: {}, rates: {} });
processOption(option)
Process an individual option, only uses the first access and egress modes given.
Parameters
parameter | type | description |
---|---|---|
option | Object | Option returned from OTP's profiler. |
Example
getProfileFromOTP(query, function(err, profile) {
var scoredOption = scorer.processOption(profile[0]);
});
Returns Object
, processedOption Annotated and scored.
processOptions(options)
Process an array of options that were generated by OpenTripPlanner's Profiler.
Parameters
parameter | type | description |
---|---|---|
options | Array |
Example
getProfileFromOTP(query, function(err, profile) {
var allScoredResults = scorer.processOptions(profile);
});
Returns Array
, processedOptions Options that are split up by access mode and annotated with a score.
score(option)
Get the weighted score of an option based on the factors, weights, and tallied totals for that option.
Parameters
parameter | type | description |
---|---|---|
option | Object |
Returns Number
, score
tally(option)
Tally values. Add up total calories, cost, transfers, distances, and times.
Parameters
parameter | type | description |
---|---|---|
option | Object |
Returns Object
, talliedOption
Installation
Requires nodejs.
$ npm install otp-profile-score
Tests
$ npm test