StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics
https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
1.2 KiB
34 lines
1.2 KiB
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var meta_1 = require("@turf/meta");
|
|
var helpers_1 = require("@turf/helpers");
|
|
/**
|
|
* Takes one or more features and calculates the centroid using the mean of all vertices.
|
|
* This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
|
|
*
|
|
* @name centroid
|
|
* @param {GeoJSON} geojson GeoJSON to be centered
|
|
* @param {Object} [options={}] Optional Parameters
|
|
* @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties
|
|
* @returns {Feature<Point>} the centroid of the input features
|
|
* @example
|
|
* var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
|
|
*
|
|
* var centroid = turf.centroid(polygon);
|
|
*
|
|
* //addToMap
|
|
* var addToMap = [polygon, centroid]
|
|
*/
|
|
function centroid(geojson, options) {
|
|
if (options === void 0) { options = {}; }
|
|
var xSum = 0;
|
|
var ySum = 0;
|
|
var len = 0;
|
|
meta_1.coordEach(geojson, function (coord) {
|
|
xSum += coord[0];
|
|
ySum += coord[1];
|
|
len++;
|
|
});
|
|
return helpers_1.point([xSum / len, ySum / len], options.properties);
|
|
}
|
|
exports.default = centroid;
|
|
|