-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpolar.yaml
124 lines (110 loc) · 4.93 KB
/
polar.yaml
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
cameras:
perspective:
type: perspective
vanishing_point: [0, -500]
lights:
directional1:
type: directional
direction: [.1, .5, -1]
diffuse: .7
ambient: .5
scene:
background:
color: black
styles:
stereo:
base: polygons
animated: true
shaders:
defines:
EARTH_RADIUS: 6378137.0 //radius of ellipsoid, WGS84
PI: 3.14159265358979323846
HALF_PI: 1.570796327
QUARTER_PI: .785398163
deg2rad(d): (d)*PI/180.0
rad2deg(d): (d)*180.0/PI
blocks:
global: |
// http://wiki.openstreetmap.org/wiki/Mercator
float y2lat_m (float y) { return rad2deg(2.0*atan(exp((y/EARTH_RADIUS)))-HALF_PI); }
float x2lon_m (float x) { return rad2deg(x/EARTH_RADIUS); }
float lat2y_m (float lat) { return EARTH_RADIUS*log(tan(QUARTER_PI+ deg2rad(lat)/2.0)); }
float lon2x_m (float lon) { return deg2rad(lon)*EARTH_RADIUS; }
// vec2 stereographic(float lat, float lng, float a, float e, float phi_c, float lambda_0) {
vec2 stereographic(float lat, float lng, float phi_c, float lambda_0) {
float e=0.08181919; //eccentricity, WGS84
// float phi_c=70.; //standard parallel, latitude of true scale
// float lambda_0=0.; //meridian along positive Y axis
float phi = lat; // this convention varies --
float lambda = lng; // sometimes these are switched
// convert to radians
phi=deg2rad(phi);
phi_c=deg2rad(phi_c);
lambda=deg2rad(lambda);
lambda_0=deg2rad(lambda_0);
float pm = 1.;
// if the standard parallel is in S.Hemi., switch signs.
if (phi_c < 0.) {
pm=-1.; //plus or minus, north lat. or south
phi=-phi;
phi_c=-phi_c;
lambda=-lambda;
lambda_0=-lambda_0;
}
float t=tan(PI/4.-phi/2.)/pow(((1.-e*sin(phi))/(1.+e*sin(phi))),(e/2.));
float t_c=tan(PI/4. - phi_c/2.)/pow(((1.-e*sin(phi_c))/(1.+e*sin(phi_c))),(e/2.));
float m_c=cos(phi_c)/sqrt(pow(1.-pow(e,2.)*(sin(phi_c)),2.));
float rho=EARTH_RADIUS*m_c*t/t_c; //true scale at lat phi_c
float m=cos(phi)/sqrt(pow(1.-pow(e,2.)*(sin(phi)),2.));
float x=pm*rho*sin(lambda-lambda_0);
float y=-pm*rho*cos(lambda - lambda_0);
float k=rho/(EARTH_RADIUS*m);
return vec2(x, y) / 1.;
}
float flip(float lat) {
if (lat > 0.) return mod(lat + 9455000., 18910000.) - 9455000.;
if (lat <= 0.) return mod(lat - 9455000., 18910000.) + 9455000.;
}
position: |
// mercator position of the current vertex, u_map_position = center of screen,
// position.xy = vertex screen position in meters from the center of the screen
vec2 mercator = u_map_position.xy + position.xy;
//float lat = y2lat_m(flip(mercator.y + u_map_position.y));
//float lat = y2lat_m(mercator.y + u_map_position.y);
float lat = y2lat_m(mercator.y);
float lon = x2lon_m(mercator.x);
// Latitude_Of_Origin
float centerlat = y2lat_m(u_map_position.y);
// Central_Meridian
float centerlon = x2lon_m(u_map_position.x);
// position.xy = stereographic(lat, lon);
position.xy = stereographic(lat, lon, centerlat, centerlon);
stereolines:
base: lines
mix: stereo
sources:
osm:
type: TopoJSON
url: https://meetar.github.io/mapzen-tiles/vector/v1/256/all/{z}/{x}/{y}.topojson
layers:
earth:
data: { source: osm }
draw:
stereo:
order: function() { return feature.sort_key || 0; }
color: purple
width: 3px
water:
data: { source: osm }
draw:
stereo:
order: function() { return feature.sort_key || 0; }
color: pink
width: 1px
boundaries:
data: { source: osm }
draw:
stereolines:
order: function() { return feature.sort_key || 0; }
color: cyan
width: 3px