index.js 474 B

12345678910111213141516171819
  1. // index.ts
  2. import { distance } from "@turf/distance";
  3. import { segmentReduce } from "@turf/meta";
  4. function length(geojson, options = {}) {
  5. return segmentReduce(
  6. geojson,
  7. (previousValue, segment) => {
  8. const coords = segment.geometry.coordinates;
  9. return previousValue + distance(coords[0], coords[1], options);
  10. },
  11. 0
  12. );
  13. }
  14. var turf_length_default = length;
  15. export {
  16. turf_length_default as default,
  17. length
  18. };
  19. //# sourceMappingURL=index.js.map