/**
* BeNomad BeMap JavaScript API - ReverseGeocodingRequest
*
* Typed request for `bemap.ReverseGeocoder.revGeo(request)` and for the
* convenience alias `bemap.Geocoder.reverseGeocode(coord, radius, opts)`.
*
* Wire shape mirrors the BeMap server contract (cross-checked against
* `bemap-flutter-api/lib/service/reverse_geocoding/model/request/rev_geo_request.dart`).
* Endpoint: `POST service/geocoding/1.0/reverse`.
*
* Required wire fields: `coordinateSat`, `radius`.
*
* Note on wire spelling: the server field is `maximunResult` (with the
* typo). The JS API exposes the constructor field as the typo-free
* `maxResult` for ergonomics and translates at serialisation time.
*
* @since 1.5.0
* @public
* @constructor
* @param {Object} [options]
* @param {bemap.CoordinateSat|bemap.Coordinate|Object} [options.coordinate] Mandatory in practice.
* @param {Number} [options.radius=50] Search radius in metres.
* @param {String} [options.transportMode] One of `bemap.TransportMode.*`. Defaults to CAR.
* @param {Number} [options.maxResult=1] Maximum number of items returned.
* @param {String} [options.language] ISO 639-1 language code.
* @param {Array.<String>} [options.options] Subset of `bemap.RevGeocodingOptions.*` (sent as JSON array).
* @param {String} [options.geoserver]
* @param {Number} [options.switchIndex]
*/
bemap.ReverseGeocodingRequest = function(options) {
var opts = options || {};
this.coordinate = bemap.RoutingDestination._coerceCoordinateSat(opts.coordinate);
this.radius = (typeof opts.radius === 'number') ? opts.radius : 50;
this.transportMode = opts.transportMode || null;
this.maxResult = (typeof opts.maxResult === 'number') ? opts.maxResult : 1;
this.language = opts.language || null;
this.options = Array.isArray(opts.options) ? opts.options.slice() : null;
this.geoserver = opts.geoserver || null;
this.switchIndex = (typeof opts.switchIndex === 'number') ? opts.switchIndex : null;
};
bemap.ReverseGeocodingRequest.prototype.setCoordinate = function(v) {
this.coordinate = bemap.RoutingDestination._coerceCoordinateSat(v);
return this;
};
bemap.ReverseGeocodingRequest.prototype.setRadius = function(v) { this.radius = v; return this; };
bemap.ReverseGeocodingRequest.prototype.setTransportMode = function(v) { this.transportMode = v; return this; };
bemap.ReverseGeocodingRequest.prototype.setMaxResult = function(v) { this.maxResult = v; return this; };
bemap.ReverseGeocodingRequest.prototype.setLanguage = function(v) { this.language = v; return this; };
bemap.ReverseGeocodingRequest.prototype.setOptions = function(v) {
this.options = Array.isArray(v) ? v.slice() : null;
return this;
};
bemap.ReverseGeocodingRequest.prototype.setGeoserver = function(g) { this.geoserver = g; return this; };
bemap.ReverseGeocodingRequest.prototype.toJson = function() {
var body = {};
if (this.coordinate) body.coordinateSat = this.coordinate.toJson();
body.radius = this.radius;
if (this.transportMode) body.transportMode = this.transportMode;
if (this.maxResult !== null) body.maximunResult = this.maxResult;
if (this.language) body.language = this.language;
if (this.options && this.options.length) body.options = this.options.slice();
if (this.geoserver) body.geoserver = this.geoserver;
if (this.switchIndex !== null) body.switchIndex = this.switchIndex;
return body;
};