forked from d3/d3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreatArc-test.js
35 lines (32 loc) · 1015 Bytes
/
greatArc-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var vows = require("vows"),
load = require("../load"),
assert = require("../assert");
var suite = vows.describe("d3.geo.greatArc");
suite.addBatch({
"greatArc": {
topic: load("geo/greatArc").expression("d3.geo.greatArc"),
"distance": function(arc) {
var a = arc();
assert.equal(a.distance({source: [0, 0], target: [0, 0]}), 0);
assert.inDelta(a.distance({
source: [118 + 24 / 60, 33 + 57 / 60],
target: [ 73 + 47 / 60, 40 + 38 / 60]
}), 3973 / 6371, .5);
},
"source and target can be set as constants": function(arc) {
var a = arc().source([5, 52]).target([-120, 37]);
assert.inDelta(a().coordinates, [
[ 5, 52 ],
[-120, 37 ]
], .5);
},
"geodesic": function(arc) {
var a = arc();
assert.inDelta(a({source: [5, 52], target: [-120, 37]}).coordinates, [
[ 5, 52 ],
[-120, 37 ]
], .5);
}
}
});
suite.export(module);