turf-centroid
Advanced tools
Comparing version 1.0.3 to 1.1.0
{ | ||
"name": "turf-centroid", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "turf centroid module", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
55
test.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(); | ||
}); |
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
109918
12
76
2