UNPKG

@jorgenphi/staticmaps

Version:

A Node.js library for creating map images with markers, polylines, polygons and text.

56 lines (46 loc) 1.82 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")); var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")); var _circle = _interopRequireDefault(require("@turf/circle")); var _bbox = _interopRequireDefault(require("@turf/bbox")); var Circle = /*#__PURE__*/function () { function Circle() { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; (0, _classCallCheck2["default"])(this, Circle); this.options = options; this.coord = this.options.coord; this.radius = Number(this.options.radius); this.color = this.options.color || '#000000BB'; this.fill = this.options.fill || '#AA0000BB'; this.width = Number.isFinite(this.options.width) ? Number(this.options.width) : 3; if (!this.coord || !Array.isArray(this.coord) || this.coord.length < 2) throw new Error('Specify center of circle'); if (!this.radius || !Number(this.radius)) throw new Error('Specify radius of circle'); } /** * calculate the coordinates of the envelope / bounding box: (min_lon, min_lat, max_lon, max_lat) */ (0, _createClass2["default"])(Circle, [{ key: "extent", value: function extent() { var center = { type: 'Feature', geometry: { type: 'Point', coordinates: this.coord } }; var circ = (0, _circle["default"])(center, this.radius / 1000, { steps: 100 }); var circleBbox = (0, _bbox["default"])(circ); return circleBbox; } }]); return Circle; }(); exports["default"] = Circle;