UNPKG

apisearch

Version:
66 lines (65 loc) 1.45 kB
"use strict"; exports.__esModule = true; exports.Coordinate = void 0; var InvalidFormatError_1 = require("../Error/InvalidFormatError"); /** * Coordinate Type cast * @param coordinate */ var Coordinate = /** @class */ (function () { /** * Constructor * * @param {number} lat * @param {number} lon */ function Coordinate(lat, lon) { this.lat = lat; this.lon = lon; } /** * Get latitude * * @return float */ Coordinate.prototype.getLatitude = function () { return this.lat; }; /** * Get longitude * * @return float */ Coordinate.prototype.getLongitude = function () { return this.lon; }; /** * To array * * @return {{lat: number, lon: number}} */ Coordinate.prototype.toArray = function () { return { lat: this.lat, lon: this.lon }; }; /** * Create from array * * @param array * * @return Coordinate * * @throws InvalidFormatError */ Coordinate.createFromArray = function (array) { if (typeof array.lat == "undefined" || typeof array.lon == "undefined") { throw InvalidFormatError_1.InvalidFormatError.coordinateFormatNotValid(); } return new Coordinate(array.lat, array.lon); }; return Coordinate; }()); exports.Coordinate = Coordinate;