Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

turf-centroid

Package Overview
Dependencies
Maintainers
8
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-centroid - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

fixtures/in/block.geojson

2

package.json
{
"name": "turf-centroid",
"version": "1.0.3",
"version": "1.1.0",
"description": "turf centroid module",

@@ -5,0 +5,0 @@ "main": "index.js",

var test = require('tape');
var center = require('./');
var fs = require('fs');
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
]
]
]
}
}
]
};
var boxFC = JSON.parse(fs.readFileSync(__dirname+'/fixtures/in/box.geojson'));
var blockFC = JSON.parse(fs.readFileSync(__dirname+'/fixtures/in/block.geojson'));
test('center', function(t){
var centered = center(fc);
var boxFcCenter = center(boxFC);
t.ok(boxFcCenter, 'should return the proper center for a FeatureCollection');
t.deepEqual(boxFcCenter.geometry.coordinates, [65.56640625, 43.59448261855401]);
t.ok(centered, 'should return the proper center for a FeatureCollection');
t.deepEqual(centered.geometry.coordinates, [65.56640625, 43.59448261855401]);
var blockFcCenter = center(blockFC.features[0]);
t.ok(blockFcCenter, 'should return the proper center for a FeatureCollection');
t.deepEqual(blockFcCenter.geometry.coordinates, [-114.02900261988646,51.05007001220118]);
var polyCenter = center(fc.features[0])
t.ok(polyCenter, 'should return the proper center for a Polygon');
t.deepEqual(centered, polyCenter);
boxFC.features.push(boxFcCenter);
blockFC.features.push(blockFcCenter);
fs.writeFileSync(__dirname+'/fixtures/out/box_out.geojson', JSON.stringify(boxFC,null,2));
fs.writeFileSync(__dirname+'/fixtures/out/block_out.geojson', JSON.stringify(blockFC,null,2));
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc