3
var vows = require("vows"),
4
assert = require("assert");
6
var suite = vows.describe("d3.geo.azimuthal");
9
"azimuthal.stereographic": {
11
return d3.geo.azimuthal().mode("stereographic").translate([0, 0]).scale(100);
13
"origin": function(azimuthal) {
14
var coords = azimuthal([0, 0]);
15
assert.inDelta(coords[0], 0, 1e-6);
16
assert.inDelta(coords[1], 0, 1e-6);
17
var lonlat = azimuthal.invert(coords);
18
assert.inDelta(lonlat[0], 0, 1e-6);
19
assert.inDelta(lonlat[1], 0, 1e-6);
21
"Arctic": function(azimuthal) {
22
var coords = azimuthal([0, 85]);
23
assert.inDelta(coords[0], 0, 1e-6);
24
assert.inDelta(coords[1], -91.633117, 1e-6);
25
var lonlat = azimuthal.invert(coords);
26
assert.inDelta(lonlat[0], 0, 1e-6);
27
assert.inDelta(lonlat[1], 85, 1e-6);
29
"Antarctic": function(azimuthal) {
30
var coords = azimuthal([0, -85]);
31
assert.inDelta(coords[0], 0, 1e-6);
32
assert.inDelta(coords[1], 91.633117, 1e-6);
33
var lonlat = azimuthal.invert(coords);
34
assert.inDelta(lonlat[0], 0, 1e-6);
35
assert.inDelta(lonlat[1], -85, 1e-6);
37
"Hawaii": function(azimuthal) {
38
var coords = azimuthal([-180, 0]);
39
assert.equal(coords[0], -Infinity);
40
assert.isTrue(isNaN(coords[1]));
42
"Phillipines": function(azimuthal) {
43
var coords = azimuthal([180, 0]);
44
assert.equal(coords[0], Infinity);
45
assert.isTrue(isNaN(coords[1]));
47
"Inversion works for non-zero translation": function() {
48
var azimuthal = d3.geo.azimuthal().mode("stereographic").translate([123, 99]).scale(100),
49
coords = azimuthal([0, 85]),
50
lonlat = azimuthal.invert(coords);
51
assert.inDelta(lonlat[0], 0, 1e-6);
52
assert.inDelta(lonlat[1], 85, 1e-6);
55
"azimuthal.orthographic": {
57
return d3.geo.azimuthal().mode("orthographic").translate([0, 0]).scale(100);
59
"origin": function(azimuthal) {
60
var coords = azimuthal([0, 0]);
61
assert.inDelta(coords[0], 0, 1e-6);
62
assert.inDelta(coords[1], 0, 1e-6);
63
var lonlat = azimuthal.invert(coords);
64
assert.inDelta(lonlat[0], 0, 1e-6);
65
assert.inDelta(lonlat[1], 0, 1e-6);
67
"Arctic": function(azimuthal) {
68
var coords = azimuthal([0, 85]);
69
assert.inDelta(coords[0], 0, 1e-6);
70
assert.inDelta(coords[1], -99.619469, 1e-6);
71
var lonlat = azimuthal.invert(coords);
72
assert.inDelta(lonlat[0], 0, 1e-6);
73
assert.inDelta(lonlat[1], 85, 1e-6);
75
"Antarctic": function(azimuthal) {
76
var coords = azimuthal([0, -85]);
77
assert.inDelta(coords[0], 0, 1e-6);
78
assert.inDelta(coords[1], 99.619469, 1e-6);
79
var lonlat = azimuthal.invert(coords);
80
assert.inDelta(lonlat[0], 0, 1e-6);
81
assert.inDelta(lonlat[1], -85, 1e-6);
83
"Hawaii": function(azimuthal) {
84
var coords = azimuthal([-180, 0]);
85
assert.inDelta(coords[0], 0, 1e-6);
86
assert.inDelta(coords[1], 0, 1e-6);
87
var lonlat = azimuthal.invert(coords);
88
assert.inDelta(lonlat[0], 0, 1e-6);
89
assert.inDelta(lonlat[1], 0, 1e-6);
91
"Phillipines": function(azimuthal) {
92
var coords = azimuthal([180, 0]);
93
assert.inDelta(coords[0], 0, 1e-6);
94
assert.inDelta(coords[1], 0, 1e-6);
95
var lonlat = azimuthal.invert(coords);
96
assert.inDelta(lonlat[0], 0, 1e-6);
97
assert.inDelta(lonlat[1], 0, 1e-6);
99
"Inversion works for non-zero translation": function() {
100
var azimuthal = d3.geo.azimuthal().mode("orthographic").translate([123, 99]).scale(100),
101
coords = azimuthal([0, 85]),
102
lonlat = azimuthal.invert(coords);
103
assert.inDelta(lonlat[0], 0, 1e-6);
104
assert.inDelta(lonlat[1], 85, 1e-6);
107
"azimuthal.gnomonic": {
109
return d3.geo.azimuthal().mode("gnomonic").translate([0, 0]).scale(100);
111
"origin": function(azimuthal) {
112
var coords = azimuthal([0, 0]);
113
assert.inDelta(coords[0], 0, 1e-6);
114
assert.inDelta(coords[1], 0, 1e-6);
115
var lonlat = azimuthal.invert(coords);
116
assert.inDelta(lonlat[0], 0, 1e-6);
117
assert.inDelta(lonlat[1], 0, 1e-6);
119
"Arctic": function(azimuthal) {
120
var coords = azimuthal([0, 85]);
121
assert.inDelta(coords[0], 0, 1e-6);
122
assert.inDelta(coords[1], -1143.005230, 1e-6);
123
var lonlat = azimuthal.invert(coords);
124
assert.inDelta(lonlat[0], 0, 1e-6);
125
assert.inDelta(lonlat[1], 85, 1e-6);
127
"Antarctic": function(azimuthal) {
128
var coords = azimuthal([0, -85]);
129
assert.inDelta(coords[0], 0, 1e-6);
130
assert.inDelta(coords[1], 1143.005230, 1e-6);
131
var lonlat = azimuthal.invert(coords);
132
assert.inDelta(lonlat[0], 0, 1e-6);
133
assert.inDelta(lonlat[1], -85, 1e-6);
135
"Hawaii": function(azimuthal) {
136
var coords = azimuthal([-180, 0]);
137
assert.inDelta(coords[0], 0, 1e-6);
138
assert.inDelta(coords[1], 0, 1e-6);
139
var lonlat = azimuthal.invert(coords);
140
assert.inDelta(lonlat[0], 0, 1e-6);
141
assert.inDelta(lonlat[1], 0, 1e-6);
143
"Phillipines": function(azimuthal) {
144
var coords = azimuthal([180, 0]);
145
assert.inDelta(coords[0], 0, 1e-6);
146
assert.inDelta(coords[1], 0, 1e-6);
147
var lonlat = azimuthal.invert(coords);
148
assert.inDelta(lonlat[0], 0, 1e-6);
149
assert.inDelta(lonlat[1], 0, 1e-6);
151
"Inversion works for non-zero translation": function() {
152
var azimuthal = d3.geo.azimuthal().mode("stereographic").translate([123, 99]).scale(100),
153
coords = azimuthal([0, 85]),
154
lonlat = azimuthal.invert(coords);
155
assert.inDelta(lonlat[0], 0, 1e-6);
156
assert.inDelta(lonlat[1], 85, 1e-6);
159
"azimuthal.equidistant": {
161
return d3.geo.azimuthal().mode("equidistant").translate([0, 0]).scale(100);
163
"origin": function(azimuthal) {
164
var coords = azimuthal([0, 0]);
165
assert.inDelta(coords[0], 0, 1e-6);
166
assert.inDelta(coords[1], 0, 1e-6);
167
var lonlat = azimuthal.invert(coords);
168
assert.inDelta(lonlat[0], 0, 1e-6);
169
assert.inDelta(lonlat[1], 0, 1e-6);
171
"Arctic": function(azimuthal) {
172
var coords = azimuthal([0, 85]);
173
assert.inDelta(coords[0], 0, 1e-6);
174
assert.inDelta(coords[1], -148.352986, 1e-6);
175
var lonlat = azimuthal.invert(coords);
176
assert.inDelta(lonlat[0], 0, 1e-6);
177
assert.inDelta(lonlat[1], 85, 1e-6);
179
"Antarctic": function(azimuthal) {
180
var coords = azimuthal([0, -90]);
181
assert.inDelta(coords[0], 0, 1e-6);
182
assert.inDelta(coords[1], 157.079632, 1e-6);
183
var lonlat = azimuthal.invert(coords);
184
assert.inDelta(lonlat[0], 0, 1e-6);
185
assert.inDelta(lonlat[1], -90, 1e-6);
187
"Hawaii": function(azimuthal) {
188
var coords = azimuthal([-180, 0]);
189
assert.inDelta(coords[0], -314.159265, 1e-6);
190
assert.inDelta(coords[1], 0, 1e-6);
191
var lonlat = azimuthal.invert(coords);
192
assert.inDelta(lonlat[0], -180, 1e-6);
193
assert.inDelta(lonlat[1], 0, 1e-6);
195
"Phillipines": function(azimuthal) {
196
var coords = azimuthal([180, 0]);
197
assert.inDelta(coords[0], 314.159265, 1e-6);
198
assert.inDelta(coords[1], 0, 1e-6);
199
var lonlat = azimuthal.invert(coords);
200
assert.inDelta(lonlat[0], 180, 1e-6);
201
assert.inDelta(lonlat[1], 0, 1e-6);
203
"Inversion works for non-zero translation": function() {
204
var azimuthal = d3.geo.azimuthal().mode("stereographic").translate([123, 99]).scale(100),
205
coords = azimuthal([0, 85]),
206
lonlat = azimuthal.invert(coords);
207
assert.inDelta(lonlat[0], 0, 1e-6);
208
assert.inDelta(lonlat[1], 85, 1e-6);
211
"azimuthal.equalarea": {
213
return d3.geo.azimuthal().mode("equalarea").translate([0, 0]).scale(100);
215
"origin": function(azimuthal) {
216
var coords = azimuthal([0, 0]);
217
assert.inDelta(coords[0], 0, 1e-6);
218
assert.inDelta(coords[1], 0, 1e-6);
219
var lonlat = azimuthal.invert(coords);
220
assert.inDelta(lonlat[0], 0, 1e-6);
221
assert.inDelta(lonlat[1], 0, 1e-6);
223
"Arctic": function(azimuthal) {
224
var coords = azimuthal([0, 85]);
225
assert.inDelta(coords[0], 0, 1e-6);
226
assert.inDelta(coords[1], -135.118041, 1e-6);
227
var lonlat = azimuthal.invert(coords);
228
assert.inDelta(lonlat[0], 0, 1e-6);
229
assert.inDelta(lonlat[1], 85, 1e-6);
231
"Antarctic": function(azimuthal) {
232
var coords = azimuthal([0, -90]);
233
assert.inDelta(coords[0], 0, 1e-6);
234
assert.inDelta(coords[1], 141.421356, 1e-6);
235
var lonlat = azimuthal.invert(coords);
236
assert.inDelta(lonlat[0], 180, 1e-6);
237
assert.inDelta(lonlat[1], -90, 1e-6);
239
"Hawaii": function(azimuthal) {
240
var coords = azimuthal([-180, 0]);
241
assert.equal(coords[0], -Infinity);
242
assert.isTrue(isNaN(coords[1]));
244
"Phillipines": function(azimuthal) {
245
var coords = azimuthal([180, 0]);
246
assert.equal(coords[0], Infinity);
247
assert.isTrue(isNaN(coords[1]));
249
"Inversion works for non-zero translation": function() {
250
var azimuthal = d3.geo.azimuthal().mode("stereographic").translate([123, 99]).scale(100),
251
coords = azimuthal([0, 85]),
252
lonlat = azimuthal.invert(coords);
253
assert.inDelta(lonlat[0], 0, 1e-6);
254
assert.inDelta(lonlat[1], 85, 1e-6);
259
suite.export(module);