-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAdaptiveCompositeMapProjection.js
executable file
·212 lines (183 loc) · 5.55 KB
/
AdaptiveCompositeMapProjection.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
function PortraitMapACMP(scale, coords) {
if (coords[1] > 90) {
coords[1] = 90;
}
if (coords[1] < -90) {
coords[1] = -90;
}
//SMALL-SCALE map projection
if (scale <= 1.5) {
d3.select("#proj").text("Pseudocylindrical");
currentProj = "pseudocylindrical";
return d3.geo.transformedLambertAzimuthal()
.parameters(0, 61.9, 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate([coords[0],coords[1]]);
//Transition to MEDIUM-SCALE map projection
} else if (scale <= 2.0) {
d3.select("#proj").text("Wagner's transformation of the Lambert azimuthal");
currentProj = "wagner";
return d3.geo.transformedLambertAzimuthal()
.parameters((scale - 1.5) * 360.0, (scale - 1.5) * 56.2 + 61.9, (scale - 1.5) * 2 * (Math.sqrt(2) - 2.03) + 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate([coords[0],coords[1]]);
//MEDIUM-SCALE map projection
} else if (scale <= 4.0) {
d3.select("#proj").text("Lambert azimuthal");
currentProj = "lambert";
return d3.geo.azimuthalEqualArea()
.scale(scale * 90)
.precision(0.3)
.clipAngle(180 - 1e-3)
.rotate(coords);
//Transition to LARGE-SCALE map projection
/*
//Transition needs to be implemented
} else if (scale <= 6.0) {
}
*/
//LARGE-SCALE map projection
} else {
d3.select("#proj").text("Transverse cylindrical");
currentProj = "transCylindrical";
return d3.geo.transverseCylindricalEqualArea()
.parallel(0)
.scale(scale * 90)
.precision(0.1)
.rotate([coords[0],coords[1],90]);
}
}
function SquareMapACMP(scale, coords) {
if (coords[1] > 90) {
coords[1] = 90;
}
if (coords[1] < -90) {
coords[1] = -90;
}
//SMALL-SCALE map projection
if (scale <= 1.5) {
d3.select("#proj").text("Pseudocylindrical");
currentProj = "pseudocylindrical";
return d3.geo.transformedLambertAzimuthal()
.parameters(0, 61.9, 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate([coords[0],coords[1]]);
//Transition to MEDIUM-SCALE map projection
} else if (scale <= 2.0) {
d3.select("#proj").text("Wagner's transformation of the Lambert azimuthal");
currentProj = "wagner";
return d3.geo.transformedLambertAzimuthal()
.parameters((scale - 1.5) * 360.0, (scale - 1.5) * 56.2 + 61.9, (scale - 1.5) * 2 * (Math.sqrt(2) - 2.03) + 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate([coords[0],coords[1]]);
//MEDIUM- AND LARGE-SCALE map projection
} else {
d3.select("#proj").text("Lambert azimuthal");
currentProj = "lambert";
return d3.geo.azimuthalEqualArea()
.scale(scale * 90)
.precision(0.3)
.clipAngle(180 - 1e-3)
.rotate(coords);
}
}
function LandscapeMapACMP(scale, coords) {
if (coords[1] > 90) {
coords[1] = 90;
}
if (coords[1] < -90) {
coords[1] = -90;
}
//SMALL-SCALE map projection
if (scale <= 1.5) {
d3.select("#proj").text("Pseudocylindrical");
currentProj = "pseudocylindrical";
return d3.geo.transformedLambertAzimuthal()
.parameters(0, 61.9, 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate(coords);
//Transition to MEDIUM-SCALE map projection
} else if (scale <= 2.0) {
d3.select("#proj").text("Wagner's transformation of the Lambert azimuthal");
currentProj = "hammer";
return d3.geo.transformedLambertAzimuthal()
.parameters((scale - 1.5) * 360.0, (scale - 1.5) * 56.2 + 61.9, (scale - 1.5) * 2 * (Math.sqrt(2) - 2.03) + 2.03)
.precision(0.3)
.scale(scale * 90)
.rotate(coords);
//MEDIUM-SCALE map projection
} else if (scale <= 4.0) {
d3.select("#proj").text("Lambert azimuthal");
currentProj = "lambert";
return d3.geo.azimuthalEqualArea()
.scale(scale * 90)
.precision(0.3)
.clipAngle(180 - 1e-3)
.rotate(coords);
//Transition to LARGE-SCALE map projection
/*
//Transition needs to be implemented
} else if (scale <= 6.0) {
}
*/
//LARGE-SCALE map projection
} else {
currentProj = "albers";
/*Polar projections needs to be shifted correctly*/
if (coords[1] < -75) {
//Displaying north pole areas
d3.select("#proj").text("Lambert azimuthal polar");
return d3.geo.azimuthalEqualArea()
.scale(scale * 90)
.rotate([coords[0], -90])
.clipAngle(180 - 1e-3)
.translate([width / 2, height / 2])
.precision(.1);
} else if (coords[1] > 75) {
//Displaying south pole areas
d3.select("#proj").text("Lambert azimuthal polar");
return d3.geo.azimuthalEqualArea()
.scale(scale * 90)
.rotate([coords[0], 90])
.clipAngle(180 - 1e-3)
.translate([width / 2, height / 2])
.precision(.1);
} else if (Math.abs(coords[1]) < 15) {
d3.select("#proj").text("Lambert cylindrical");
return d3.geo.cylindricalEqualArea()
.rotate([coords[0], 0])
.center([0, -coords[1]])
.scale(scale * 90)
.translate([width / 2, height / 2])
.precision(.1);
} else {
var phi1 = -coords[1] - scale, phi2 = -coords[1] + scale, phi0 = -coords[1];
d3.select("#proj").text("Alberts conic with adjusted standard parallels");
if (Math.abs(phi0) < 22) {
phi1 = phi1 * (Math.abs(phi0) - 15) / 7;
phi2 = phi2 * (Math.abs(phi0) - 15) / 7;
} else if (phi0 > 60) {
phi1 = (90 - phi1) * (phi0 - 60) / 15 + phi1;
phi2 = (90 - phi2) * (phi0 - 60) / 15 + phi2;
} else if (phi0 < -60) {
phi1 = (-90 - phi1) * (phi0 + 60) / -15 + phi1;
phi2 = (-90 - phi2) * (phi0 + 60) / -15 + phi2;
} else {
d3.select("#proj").text("Alberts conic");
}
coords = (coords[0] == 0) ? [0.01, 0.01] : coords;
return d3.geo.albers()
.rotate([coords[0], 0])
.center([0, -coords[1]])
.parallels([phi1, phi2])
.scale(scale * 90)
.translate([width / 2, height / 2])
.precision(.1);
}
}
}