turf-centroid
Advanced tools
Comparing version 1.0.2 to 1.0.3
28
index.js
@@ -13,13 +13,23 @@ var each = require('turf-meta').coordEach; | ||
* @example | ||
* var poly = turf.polygon([[ | ||
* [105.818939,21.004714], | ||
* [105.818939,21.061754], | ||
* [105.890007,21.061754], | ||
* [105.890007,21.004714], | ||
* [105.818939,21.004714] | ||
* ]]); | ||
* var poly = { | ||
* "type": "Feature", | ||
* "properties": {}, | ||
* "geometry": { | ||
* "type": "Polygon", | ||
* "coordinates": [[ | ||
* [105.818939,21.004714], | ||
* [105.818939,21.061754], | ||
* [105.890007,21.061754], | ||
* [105.890007,21.004714], | ||
* [105.818939,21.004714] | ||
* ]] | ||
* } | ||
* }; | ||
* | ||
* var centroidPt = turf.centroid(poly); | ||
* | ||
* var result = turf.featurecollection([poly, centroidPt]); | ||
* var result = { | ||
* "type": "FeatureCollection", | ||
* "features": [poly, centroidPt] | ||
* }; | ||
* | ||
@@ -34,4 +44,4 @@ * //=result | ||
len++; | ||
}); | ||
}, true); | ||
return point([xSum / len, ySum / len]); | ||
}; |
{ | ||
"name": "turf-centroid", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "turf centroid module", | ||
@@ -28,10 +28,10 @@ "main": "index.js", | ||
"benchmark": "^1.0.0", | ||
"tape": "^3.0.3", | ||
"tape": "^3.5.0", | ||
"dox": "^0.6.1", | ||
"doxme": "^1.4.2" | ||
"doxme": "^1.4.3" | ||
}, | ||
"dependencies": { | ||
"turf-meta": "^1.0.1", | ||
"turf-meta": "^1.0.2", | ||
"turf-point": "^2.0.0" | ||
} | ||
} |
44
test.js
var test = require('tape'); | ||
var center = require('./'); | ||
var fc = require('./geojson/fc'); | ||
var fc = { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"properties": {}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
60.46875, | ||
39.90973623453719 | ||
], | ||
[ | ||
60.46875, | ||
47.27922900257082 | ||
], | ||
[ | ||
70.6640625, | ||
47.27922900257082 | ||
], | ||
[ | ||
70.6640625, | ||
39.90973623453719 | ||
], | ||
[ | ||
60.46875, | ||
39.90973623453719 | ||
] | ||
] | ||
] | ||
} | ||
} | ||
] | ||
}; | ||
test('center', function(t){ | ||
@@ -9,5 +45,9 @@ var centered = center(fc); | ||
t.ok(centered, 'should return the proper center for a FeatureCollection'); | ||
t.deepEqual(centered.geometry.coordinates, [96.3, -0.25]); | ||
t.deepEqual(centered.geometry.coordinates, [65.56640625, 43.59448261855401]); | ||
var polyCenter = center(fc.features[0]) | ||
t.ok(polyCenter, 'should return the proper center for a Polygon'); | ||
t.deepEqual(centered, polyCenter); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6223
105
8
Updatedturf-meta@^1.0.2