index.d.ts 918 B

123456789101112131415161718192021
  1. import { Properties, Feature, Point } from "@turf/helpers";
  2. /**
  3. * Takes any {@link Feature} or a {@link FeatureCollection} and returns its [center of mass](https://en.wikipedia.org/wiki/Center_of_mass) using this formula: [Centroid of Polygon](https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon).
  4. *
  5. * @name centerOfMass
  6. * @param {GeoJSON} geojson GeoJSON to be centered
  7. * @param {Object} [options={}] Optional Parameters
  8. * @param {Object} [options.properties={}] Translate Properties to Feature
  9. * @returns {Feature<Point>} the center of mass
  10. * @example
  11. * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
  12. *
  13. * var center = turf.centerOfMass(polygon);
  14. *
  15. * //addToMap
  16. * var addToMap = [polygon, center]
  17. */
  18. declare function centerOfMass<P = Properties>(geojson: any, options?: {
  19. properties?: P;
  20. }): Feature<Point, P>;
  21. export default centerOfMass;