22 lines
918 B
TypeScript
Executable File
22 lines
918 B
TypeScript
Executable File
import { Properties, Feature, Point } from "@turf/helpers";
|
|
/**
|
|
* 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).
|
|
*
|
|
* @name centerOfMass
|
|
* @param {GeoJSON} geojson GeoJSON to be centered
|
|
* @param {Object} [options={}] Optional Parameters
|
|
* @param {Object} [options.properties={}] Translate Properties to Feature
|
|
* @returns {Feature<Point>} the center of mass
|
|
* @example
|
|
* var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
|
|
*
|
|
* var center = turf.centerOfMass(polygon);
|
|
*
|
|
* //addToMap
|
|
* var addToMap = [polygon, center]
|
|
*/
|
|
declare function centerOfMass<P = Properties>(geojson: any, options?: {
|
|
properties?: P;
|
|
}): Feature<Point, P>;
|
|
export default centerOfMass;
|