forked from meetar/projection-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oblique.yaml
85 lines (77 loc) · 3.12 KB
/
oblique.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
cameras:
perspective:
type: perspective
vanishing_point: [0, -500]
styles:
stereo:
lighting: false
base: polygons
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; }
float flip(float lat) {
if (lat > 0.) return mod(lat + 9455000., 18910000.) - 9455000.;
if (lat <= 0.) return mod(lat - 9455000., 18910000.) + 9455000.;
}
vec2 oblique(float lat, float lon) {
float coslat = cos(lat);
float coslon = cos(lon);
float k = 1. / (1. + coslat * coslon);
return vec2(k * coslon * sin(lat), k * sin(lon));
}
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 = polar(lat, lon);
//position.xy = polar(lat, lon, centerlat, centerlon);
position.xy = oblique(deg2rad(lat), deg2rad(lon)) * EARTH_RADIUS;
stereolines:
base: lines
mix: stereo
sources:
osm:
type: TopoJSONTiles
url: //vector.mapzen.com/osm/all/{z}/{x}/{y}.topojson?api_key=vector-tiles-_vxMzew
layers:
earth:
data: { source: osm }
draw:
stereolines:
order: 1
color: purple
width: 3px
water:
data: { source: osm }
draw:
stereolines:
order: 2
color: pink
width: 1px
boundaries:
data: { source: osm }
draw:
stereolines:
order: 10
color: cyan
width: 10px