-
Notifications
You must be signed in to change notification settings - Fork 943
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into updated-docs
- Loading branch information
Showing
13 changed files
with
408 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
var test = require('tape'); | ||
var destination = require('@turf/destination'); | ||
var inside = require('@turf/inside'); | ||
var circle = require('./'); | ||
const test = require('tape'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const load = require('load-json-file'); | ||
const write = require('write-json-file'); | ||
const truncate = require('@turf/truncate'); | ||
const featureCollection = require('@turf/helpers').featureCollection; | ||
const circle = require('./'); | ||
|
||
test('circle', function(t){ | ||
var center = { | ||
type: "Feature", | ||
geometry: {type: "Point", coordinates: [-75.343, 39.984]} | ||
const directories = { | ||
in: path.join(__dirname, 'test', 'in') + path.sep, | ||
out: path.join(__dirname, 'test', 'out') + path.sep | ||
}; | ||
|
||
const fixtures = fs.readdirSync(directories.in).map(filename => { | ||
return { | ||
filename, | ||
name: path.parse(filename).name, | ||
geojson: load.sync(directories.in + filename) | ||
}; | ||
var radius = 5; | ||
var steps = 10; | ||
}); | ||
|
||
var polygon = circle(center, radius, steps, 'kilometers'); | ||
var point1 = destination(center, radius - 1, 45, 'kilometers'); | ||
var point2 = destination(center, radius + 1, 135, 'kilometers'); | ||
test('turf-circle', t => { | ||
for (const {filename, name, geojson} of fixtures) { | ||
const {radius, steps, units} = geojson.properties; | ||
const C = truncate(circle(geojson, radius, steps, units)); | ||
const results = featureCollection([geojson, C]); | ||
|
||
t.equal(inside(point1, polygon), true, 'point is inside the polygon'); | ||
t.equal(inside(point2, polygon), false, 'point is outside the polygon'); | ||
if (process.env.REGEN) write.sync(directories.out + filename, results); | ||
t.deepEquals(results, load.sync(directories.out + filename), name); | ||
} | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "Feature", | ||
"properties": { | ||
"radius": 5 | ||
}, | ||
"geometry": { | ||
"type": "Point", | ||
"coordinates": [ | ||
-75.343, | ||
39.984 | ||
] | ||
} | ||
} |
Oops, something went wrong.
45f966b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DenisCarriere @rowanwins since you are dealing with updating docs, I just noticed in
CONTRIBUTING.md
shouldn't thetest.js
file be in the main folder?45f966b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Indeed, I don't think anyone has touched the
CONTRIBUTING.md
doc.Ex: Module Folder Structure