index.d.ts 1.4 KB

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