index.js 785 B

12345678910111213141516171819202122232425262728
  1. // index.ts
  2. import { coordEach, featureEach } from "@turf/meta";
  3. import { point, featureCollection } from "@turf/helpers";
  4. function explode(geojson) {
  5. const points = [];
  6. if (geojson.type === "FeatureCollection") {
  7. featureEach(geojson, function(feature) {
  8. coordEach(feature, function(coord) {
  9. points.push(point(coord, feature.properties));
  10. });
  11. });
  12. } else if (geojson.type === "Feature") {
  13. coordEach(geojson, function(coord) {
  14. points.push(point(coord, geojson.properties));
  15. });
  16. } else {
  17. coordEach(geojson, function(coord) {
  18. points.push(point(coord));
  19. });
  20. }
  21. return featureCollection(points);
  22. }
  23. var turf_explode_default = explode;
  24. export {
  25. turf_explode_default as default,
  26. explode
  27. };
  28. //# sourceMappingURL=index.js.map