index.d.ts 966 B

1234567891011121314151617181920212223
  1. import { GeoJsonProperties, Feature, Point } from 'geojson';
  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. * @function
  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 extends GeoJsonProperties = GeoJsonProperties>(geojson: any, options?: {
  19. properties?: P;
  20. }): Feature<Point, P>;
  21. export { centerOfMass, centerOfMass as default };