index.js 731 B

123456789101112131415161718192021
  1. // index.ts
  2. import { destination } from "@turf/destination";
  3. import { polygon } from "@turf/helpers";
  4. function circle(center, radius, options = {}) {
  5. const steps = options.steps || 64;
  6. const properties = options.properties ? options.properties : !Array.isArray(center) && center.type === "Feature" && center.properties ? center.properties : {};
  7. const coordinates = [];
  8. for (let i = 0; i < steps; i++) {
  9. coordinates.push(
  10. destination(center, radius, i * -360 / steps, options).geometry.coordinates
  11. );
  12. }
  13. coordinates.push(coordinates[0]);
  14. return polygon([coordinates], properties);
  15. }
  16. var turf_circle_default = circle;
  17. export {
  18. circle,
  19. turf_circle_default as default
  20. };
  21. //# sourceMappingURL=index.js.map