Skip to content

Commit

Permalink
Add GeoJSON test fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Oct 29, 2017
1 parent 1c213a5 commit a578f1c
Show file tree
Hide file tree
Showing 4 changed files with 743 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"package-preamble": "0.1",
"rollup": "0.49",
"tape": "4",
"uglify-js": "32"
"uglify-js": "*"
}
}
18 changes: 16 additions & 2 deletions test/geo-voronoi-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var tape = require("tape"),
geoVoronoi = require("../");
var fs = require('fs');
var path = require('path');
var tape = require("tape");
var geoVoronoi = require("../");

tape("geoVoronoi() returns a Diagram.", function(test) {
test.equal(typeof geoVoronoi, 'object');
Expand Down Expand Up @@ -43,3 +45,15 @@ tape("geoVoronoi.triangles(sites) returns circumcenters.", function(test) {
test.ok( (Math.abs(u[0]-v[0]) < 1e-6) && (Math.abs(u[1]-v[1]) < 1e-6) );
test.end();
});

tape('geoVoronoi.polygons(points) saves geojson', function(test) {
var points = require('./in/points')
var result = geoVoronoi.geoVoronoi().polygons(points)

// Save result to GeoJSON
result.features = result.features.concat(points.features)
var out = path.join(__dirname, 'out', 'points.json')
if (process.env.REGEN) fs.writeFileSync(out, JSON.stringify(result, null, 2))
test.deepEqual(JSON.parse(fs.readFileSync(out)), result)
test.end();
});
105 changes: 105 additions & 0 deletions test/in/points.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"type": "FeatureCollection",
"bbox": [143, -38, 146, -35],
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
144.33837890625,
-37.14280344371683
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
144.931640625,
-37.35269280367274
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
145.140380859375,
-36.456636011596196
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
145.469970703125,
-36.77409249464194
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
145.755615234375,
-37.090239803072066
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
145.4150390625,
-37.52715361723378
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
145.887451171875,
-37.483576550426996
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
144.60205078125,
-36.57142382346275
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
144.86572265625,
-37.596824001083654
]
}
}
]
}
Loading

0 comments on commit a578f1c

Please sign in to comment.