index.d.cts 876 B

123456789101112131415161718192021222324
  1. import { GeoJsonProperties, Feature, Point } from 'geojson';
  2. import { AllGeoJSON } from '@turf/helpers';
  3. /**
  4. * Computes the centroid as the mean of all vertices within the object.
  5. *
  6. * @function
  7. * @param {GeoJSON} geojson GeoJSON to be centered
  8. * @param {Object} [options={}] Optional Parameters
  9. * @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties
  10. * @returns {Feature<Point>} the centroid of the input object
  11. * @example
  12. * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
  13. *
  14. * var centroid = turf.centroid(polygon);
  15. *
  16. * //addToMap
  17. * var addToMap = [polygon, centroid]
  18. */
  19. declare function centroid<P extends GeoJsonProperties = GeoJsonProperties>(geojson: AllGeoJSON, options?: {
  20. properties?: P;
  21. }): Feature<Point, P>;
  22. export { centroid, centroid as default };