index.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { Feature, Point, Properties, BBox, Id } from "@turf/helpers";
  2. /**
  3. * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
  4. *
  5. * @name centerMean
  6. * @param {GeoJSON} geojson GeoJSON to be centered
  7. * @param {Object} [options={}] Optional parameters
  8. * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
  9. * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point
  10. * @param {Object} [options.id={}] Translate GeoJSON Id to Point
  11. * @param {string} [options.weight] the property name used to weight the center
  12. * @returns {Feature<Point>} a Point feature at the mean center point of all input features
  13. * @example
  14. * var features = turf.featureCollection([
  15. * turf.point([-97.522259, 35.4691], {value: 10}),
  16. * turf.point([-97.502754, 35.463455], {value: 3}),
  17. * turf.point([-97.508269, 35.463245], {value: 5})
  18. * ]);
  19. *
  20. * var options = {weight: "value"}
  21. * var mean = turf.centerMean(features, options);
  22. *
  23. * //addToMap
  24. * var addToMap = [features, mean]
  25. * mean.properties['marker-size'] = 'large';
  26. * mean.properties['marker-color'] = '#000';
  27. */
  28. declare function centerMean<P = Properties>(geojson: any, // To-Do include Typescript AllGeoJSON
  29. options?: {
  30. properties?: P;
  31. bbox?: BBox;
  32. id?: Id;
  33. weight?: string;
  34. }): Feature<Point, P>;
  35. export default centerMean;