/**
* BeNomad BeMap JavaScript API - RoutingSummary
*
* Compact totals for a `RoutingRoute`. Distance is in metres, duration in
* seconds, energy in Wh (EV) or in litres × 1000 (combustion).
*
* @since 1.5.0
* @public
* @constructor
*/
bemap.RoutingSummary = function(options) {
var opts = options || {};
this.distanceM = (typeof opts.distanceM === 'number') ? opts.distanceM : 0;
this.durationS = (typeof opts.durationS === 'number') ? opts.durationS : 0;
this.durationInTrafficS = (typeof opts.durationInTrafficS === 'number') ? opts.durationInTrafficS : null;
this.energy = (typeof opts.energy === 'number') ? opts.energy : null;
this.energyUnit = opts.energyUnit || null;
this.tollCost = (typeof opts.tollCost === 'number') ? opts.tollCost : null;
this.tollCurrency = opts.tollCurrency || null;
this.taxCost = (typeof opts.taxCost === 'number') ? opts.taxCost : null;
this.taxCurrency = opts.taxCurrency || null;
this.eta = opts.eta || null;
};
bemap.RoutingSummary.prototype.getDistanceM = function() { return this.distanceM; };
bemap.RoutingSummary.prototype.getDurationS = function() { return this.durationS; };
bemap.RoutingSummary.prototype.getDurationInTrafficS = function() { return this.durationInTrafficS; };
bemap.RoutingSummary.prototype.getEnergy = function() { return this.energy; };
bemap.RoutingSummary.prototype.getEnergyUnit = function() { return this.energyUnit; };
bemap.RoutingSummary.prototype.getTollCost = function() { return this.tollCost; };
bemap.RoutingSummary.prototype.getTollCurrency = function() { return this.tollCurrency; };
bemap.RoutingSummary.prototype.getTaxCost = function() { return this.taxCost; };
bemap.RoutingSummary.prototype.getTaxCurrency = function() { return this.taxCurrency; };
bemap.RoutingSummary.prototype.getEta = function() { return this.eta; };
bemap.RoutingSummary.fromJson = function(raw) {
if (!raw) return new bemap.RoutingSummary();
return new bemap.RoutingSummary({
distanceM: raw.distanceM || raw.distance || 0,
durationS: raw.durationS || raw.duration || 0,
durationInTrafficS: raw.durationInTrafficS || raw.durationInTraffic || null,
energy: (typeof raw.energy === 'number') ? raw.energy : null,
energyUnit: raw.energyUnit || null,
tollCost: (typeof raw.tollCost === 'number') ? raw.tollCost : null,
tollCurrency: raw.tollCurrency || null,
taxCost: (typeof raw.taxCost === 'number') ? raw.taxCost : null,
taxCurrency: raw.taxCurrency || null,
eta: raw.eta || null
});
};