-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpl_project_mercator.opencl
91 lines (66 loc) · 1.66 KB
/
pl_project_mercator.opencl
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
__kernel void pl_project_mercator_s(
__global float16 *xy_in,
__global float16 *xy_out,
const unsigned int count,
float scale, float x0, float y0)
{
int i = get_global_id(0);
float8 lambda = radians(xy_in[i].even);
float8 phi = radians(xy_in[i].odd);
float8 x, y;
x = lambda;
y = asinh(tan(phi));
xy_out[i].even = x0 + scale * x;
xy_out[i].odd = y0 + scale * y;
}
__kernel void pl_unproject_mercator_s(
__global float16 *xy_in,
__global float16 *xy_out,
const unsigned int count,
float scale, float x0, float y0)
{
int i = get_global_id(0);
float8 x = (xy_in[i].even - x0) / scale;
float8 y = (xy_in[i].odd - y0) / scale;
float8 lambda, phi;
phi = atan(sinh(y));
lambda = x;
xy_out[i].even = degrees(lambda);
xy_out[i].odd = degrees(phi);
}
__kernel void pl_project_mercator_e(
__global float16 *xy_in,
__global float16 *xy_out,
const unsigned int count,
float ecc,
float ecc2,
float one_ecc2,
float scale, float x0, float y0)
{
int i = get_global_id(0);
float8 lambda = radians(xy_in[i].even);
float8 phi = radians(xy_in[i].odd);
float8 x, y;
x = lambda;
y = asinh(tan(phi)) - ecc * atanh(ecc * sin(phi));
xy_out[i].even = x0 + scale * x;
xy_out[i].odd = y0 + scale * y;
}
__kernel void pl_unproject_mercator_e(
__global float16 *xy_in,
__global float16 *xy_out,
const unsigned int count,
float ecc,
float ecc2,
float one_ecc2,
float scale, float x0, float y0)
{
int i = get_global_id(0);
float8 x = (xy_in[i].even - x0) / scale;
float8 y = (xy_in[i].odd - y0) / scale;
float8 lambda, phi;
phi = pl_phi2(-y, ecc);
lambda = x;
xy_out[i].even = degrees(lambda);
xy_out[i].odd = degrees(phi);
}