UNPKG

@cloudbase/js-sdk

Version:
48 lines (47 loc) 1.48 kB
import { Validate } from '../validate'; import { SYMBOL_GEO_POINT } from '../helper/symbol'; import { isArray } from '../utils/type'; var Point = (function () { function Point(longitude, latitude) { Validate.isGeopoint('longitude', longitude); Validate.isGeopoint('latitude', latitude); this.longitude = longitude; this.latitude = latitude; } Point.prototype.parse = function (key) { var _a; return _a = {}, _a[key] = { type: 'Point', coordinates: [this.longitude, this.latitude] }, _a; }; Point.prototype.toJSON = function () { return { type: 'Point', coordinates: [ this.longitude, this.latitude, ], }; }; Point.prototype.toReadableString = function () { return "[".concat(this.longitude, ",").concat(this.latitude, "]"); }; Point.validate = function (point) { return point.type === 'Point' && isArray(point.coordinates) && Validate.isGeopoint('longitude', point.coordinates[0]) && Validate.isGeopoint('latitude', point.coordinates[1]); }; Object.defineProperty(Point.prototype, "_internalType", { get: function () { return SYMBOL_GEO_POINT; }, enumerable: false, configurable: true }); return Point; }()); export { Point };