-
Notifications
You must be signed in to change notification settings - Fork 4
/
albers.yaml
45 lines (40 loc) · 1.98 KB
/
albers.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
# contributors: @patriciogv @meetar @burritojustice
import: mercator-functions.yaml
styles:
projection:
mix: albers
projection_points:
mix: projection
albers:
mix: mercator-functions
blend_order: 0
shaders:
blocks:
global: |
// convert from lat/long to albers -- from https://gist.github.com/RandomEtc/476238
vec2 albers(float lat, float lng, float lat0, float lng0, float phi1, float phi2) {
float n = 0.5 * (sin(phi1) + sin(phi2));
float c = cos(phi1);
float C = c*c + 2.*n*sin(phi1);
float p0 = sqrt(C - 2.*n*sin(lat0)) / n;
float theta = n * (lng * PI/180. - lng0);
float p = sqrt(C - 2.*n*sin(lat* PI/180.)) / n;
float x = p * sin(theta);
float y = p0 - p * cos(theta);
return vec2(x,y);
}
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(mercator.y);
float lon = x2lon_m(mercator.x);
// Latitude_Of_Origin
float centerlat = deg2rad(y2lat_m(u_map_position.y));
// Central_Meridian
float centerlon = deg2rad(x2lon_m(u_map_position.x));
// Standard_Parallel_1
float phi1 = deg2rad(y2lat_m(u_map_position.y) + 10.);
// Standard_Parallel_2
float phi2 = deg2rad(y2lat_m(u_map_position.y) - 10.);
position.xy = albers(lat, lon, centerlat, centerlon, phi1, phi2)*EARTH_RADIUS;