forked from meetar/projection-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
origami.yaml
116 lines (107 loc) · 4.51 KB
/
origami.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
cameras:
perspective:
type: perspective
vanishing_point: [0, 0]
fov: .00001 # perspective correction
styles:
stereo:
lighting: false
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:
uniforms:
u_zoom_scale: 1.
u_lat_scale: 1.
u_lng_scale: 1.
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; }
// rotation matrix transformations
mat3 rotateX3D(float phi){
return mat3(
vec3(1.,0.,0.),
vec3(0.,cos(phi),-sin(phi)),
vec3(0.,sin(phi),cos(phi))
);
}
mat3 rotateY3D(float theta){
return mat3(
vec3(cos(theta),0.,-sin(theta)),
vec3(0.,1.,0.),
vec3(sin(theta),0.,cos(theta)));
}
mat3 rotateZ3D(float psi){
return mat3(
vec3(cos(psi),-sin(psi),0.),
vec3(sin(psi),cos(psi),0.),
vec3(0.,0.,1.)
);
}
// convert the positions from a lat, lon to a position on a sphere.
vec3 latLongToVector3(float lat, float lon, float centerlat, float centerlon, float radius) {
// convert lat/long degrees to radians
float zoom = u_map_position.z;
//radius /= pow(2., zoom) / zoom;
float phi = (lat)*PI/180.0;
float theta = (lon)*PI/180.0;
float x = radius * sin(phi) * cos(theta);
float y = radius * cos(phi) * sin(theta);
float z = radius * sin(phi);
// u_map_position.z;
return vec3(x,z,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 = y2lat_m(u_map_position.y) * u_map_position.z;
// Central_Meridian
float centerlon = x2lon_m(u_map_position.x) * u_map_position.z;
// bend map into globe
position.xyz = latLongToVector3(lat, lon, centerlat, centerlon, 2.) * EARTH_RADIUS ;
// rotate globe with map navigation
position.xyz *= rotateY3D((-centerlon - 90.) * PI/180.0);
position.xyz *= rotateX3D((-centerlat) * PI/180.0);
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: 1px
water:
data: { source: osm }
draw:
stereolines:
order: 2
color: pink
width: 1px
boundaries:
data: { source: osm }
draw:
stereolines:
order: 10
color: cyan
width: 1px