/**
* BeNomad BeMap JavaScript API - TraceRouteDestination
*
* One GPS-trace sample posted to the TraceRoute endpoint.
*
* Wire shape mirrors the BeMap server contract (cross-checked against
* `bemap-flutter-api/lib/service/trace_route/model/request/trace_route_destination.dart`):
*
* { coordinateSat: { lon, lat, alt?, heading?, speed?, time?, sat? },
* keptByMinimalWp?: bool,
* customData?: [...] }
*
* @since 1.5.0
* @public
* @constructor
* @param {Object} [options]
* @param {bemap.CoordinateSat|bemap.Coordinate|Object} [options.coordinateSat] Required in practice.
* @param {Boolean} [options.keptByMinimalWp] Keep this waypoint in the response even when
* the NO_MINIMAL_WAYPOINTS option is not set.
* @param {Array.<Object>} [options.customData]
*/
bemap.TraceRouteDestination = function(options) {
var opts = options || {};
this.coordinateSat = bemap.RoutingDestination._coerceCoordinateSat(opts.coordinateSat);
this.keptByMinimalWp = (typeof opts.keptByMinimalWp === 'boolean') ? opts.keptByMinimalWp : null;
this.customData = Array.isArray(opts.customData) ? opts.customData.slice() : null;
};
bemap.TraceRouteDestination.prototype.setCoordinateSat = function(v) {
this.coordinateSat = bemap.RoutingDestination._coerceCoordinateSat(v);
return this;
};
bemap.TraceRouteDestination.prototype.setKeptByMinimalWp = function(v) { this.keptByMinimalWp = !!v; return this; };
/**
* Convenience factory — accepts a `Coordinate`, `CoordinateSat`, or
* plain `{lon, lat, alt?, heading?, speed?, time?, sat?}` object.
*
* @public
* @static
* @param {bemap.Coordinate|bemap.CoordinateSat|Object} input
* @param {Object} [options] Extra fields forwarded to the constructor.
* @return {bemap.TraceRouteDestination}
*/
bemap.TraceRouteDestination.fromCoordinate = function(input, options) {
var opts = options || {};
opts.coordinateSat = bemap.RoutingDestination._coerceCoordinateSat(input);
return new bemap.TraceRouteDestination(opts);
};
bemap.TraceRouteDestination.prototype.toJson = function() {
var out = {};
if (this.coordinateSat) out.coordinateSat = this.coordinateSat.toJson();
if (this.keptByMinimalWp !== null) out.keptByMinimalWp = this.keptByMinimalWp;
if (this.customData && this.customData.length) out.customData = this.customData.slice();
return out;
};