geometryUtil.ts 485 B

12345678910111213
  1. import * as turf from '@turf/turf';
  2. import BigNumber from 'bignumber.js';
  3. export function countRectangleArea(path, decimal = 4) {
  4. const polygon = turf.polygon(path);
  5. return new BigNumber(turf.area(polygon)).dp(decimal).toNumber();
  6. }
  7. export function countCircleArea(center, radius, decimal = 4, options = { steps: 64, units: 'meters' }) {
  8. // 创建圆形
  9. const circle = turf.circle(center, radius, options);
  10. return new BigNumber(turf.area(circle)).dp(decimal).toNumber();
  11. }