Source: bemap-services-v2/routing/bemap-routing-waypoint.js

/**
 * BeNomad BeMap JavaScript API - RoutingWaypoint
 *
 * One entry in `RoutingResponse.usedDestinations[]` — the per-input snap
 * info the server emits for every routing destination it received.
 *
 * Wire shape from the BeMap server (cross-checked against an actual
 * response payload):
 *   {
 *     inputOrder:           int,      // index of this destination in the request array
 *     used:                 bool,     // whether the destination was used in the route
 *     usedOrder:            int,      // order in which it was used (matrix / 1-to-N)
 *     matchedCoordinateGps: { lon, lat },
 *     confidenceValue:      double,   // 0..1 confidence of the snap
 *     distanceFromRequest:  double,   // metres between input and matched coordinate
 *     polylineIndex:        int,      // index into the polyline array (-1 = not on it)
 *     duration:             long,     // seconds from start to this waypoint (-1 if unknown)
 *     length:               long      // metres from start to this waypoint (-1 if unknown)
 *   }
 *
 * @since 1.5.0
 * @public
 * @constructor
 */
bemap.RoutingWaypoint = function(options) {
    var opts = options || {};
    this.inputOrder = (typeof opts.inputOrder === 'number') ? opts.inputOrder : null;
    this.used = (typeof opts.used === 'boolean') ? opts.used : null;
    this.usedOrder = (typeof opts.usedOrder === 'number') ? opts.usedOrder : null;
    this.matchedCoordinate = opts.matchedCoordinate || null;
    this.inputCoordinate = opts.inputCoordinate || null;
    this.confidenceValue = (typeof opts.confidenceValue === 'number') ? opts.confidenceValue : null;
    this.distanceFromRequest = (typeof opts.distanceFromRequest === 'number') ? opts.distanceFromRequest : null;
    this.polylineIndex = (typeof opts.polylineIndex === 'number') ? opts.polylineIndex : null;
    this.duration = (typeof opts.duration === 'number') ? opts.duration : null;
    this.length = (typeof opts.length === 'number') ? opts.length : null;
    this.name = opts.name || null;
    this.kind = opts.kind || null;
};

bemap.RoutingWaypoint.prototype.getInputOrder = function() { return this.inputOrder; };
bemap.RoutingWaypoint.prototype.isUsed = function() { return this.used; };
bemap.RoutingWaypoint.prototype.getUsedOrder = function() { return this.usedOrder; };
bemap.RoutingWaypoint.prototype.getMatchedCoordinate = function() { return this.matchedCoordinate; };
bemap.RoutingWaypoint.prototype.getInputCoordinate = function() { return this.inputCoordinate; };
bemap.RoutingWaypoint.prototype.getConfidenceValue = function() { return this.confidenceValue; };
bemap.RoutingWaypoint.prototype.getDistanceFromRequest = function() { return this.distanceFromRequest; };
bemap.RoutingWaypoint.prototype.getPolylineIndex = function() { return this.polylineIndex; };
bemap.RoutingWaypoint.prototype.getDuration = function() { return this.duration; };
bemap.RoutingWaypoint.prototype.getLength = function() { return this.length; };
bemap.RoutingWaypoint.prototype.getName = function() { return this.name; };
bemap.RoutingWaypoint.prototype.getKind = function() { return this.kind; };

/* Compatibility aliases (older naming) */
bemap.RoutingWaypoint.prototype.getDistanceFromStartM = function() { return this.length; };
bemap.RoutingWaypoint.prototype.getDurationFromStartS = function() { return this.duration; };

bemap.RoutingWaypoint.fromJson = function(raw) {
    if (!raw) return new bemap.RoutingWaypoint();

    function coord(c) {
        if (!c) return null;
        var lon = (c.lon !== undefined) ? c.lon
                : (c.longitude !== undefined) ? c.longitude : null;
        var lat = (c.lat !== undefined) ? c.lat
                : (c.latitude !== undefined) ? c.latitude : null;
        if (lon === null || lat === null) return null;
        return new bemap.Coordinate(lon, lat);
    }

    return new bemap.RoutingWaypoint({
        inputOrder: raw.inputOrder,
        used: raw.used,
        usedOrder: raw.usedOrder,
        matchedCoordinate: coord(raw.matchedCoordinateGps || raw.matchedCoordinate || raw.matched || raw.coordinate),
        inputCoordinate: coord(raw.inputCoordinate || raw.input),
        confidenceValue: raw.confidenceValue,
        distanceFromRequest: raw.distanceFromRequest,
        polylineIndex: (typeof raw.polylineIndex === 'number') ? raw.polylineIndex : null,
        duration: raw.duration,
        length: raw.length,
        name: raw.name,
        kind: raw.kind
    });
};