-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform.c
107 lines (92 loc) · 1.99 KB
/
transform.c
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
/* vi:ai:ts=4:sw=4:noet
*/
#include <stdio.h>
#include <math.h>
/*
* 4/50 = 65/51
* 10/50 = 447/70
* 16/50 = 829/51
* 4/45 = 12/551
* 10/45 = 447/574
* 16/45 = 882/551
*/
#define X_LON10 447
#define Y_LAT45 574
#define R 4126
#define Y_LAT0 (Y_LAT45 - R)
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
static double lon_rad(double lon)
{
return (lon - 10) * M_PI / 180;
}
static double lat_rad(double lat)
{
return ((R / 45.0) * ((94.5 - lat * 1.1)));
}
int fix2x(double lat, double lon)
{
return lat_rad(lat) * sin(lon_rad(lon)) + X_LON10;
}
int fix2y(double lat, double lon)
{
return lat_rad(lat) * cos(lon_rad(lon)) + Y_LAT0;
}
double forecast(unsigned int rgba) {
double du;
if (rgba == 0xFFFF00FF) {
du = 4.0;
} else if (rgba == 0xFFC837FF) {
du = 2.5;
} else if (rgba == 0xFF6E43FD || rgba == 0xFF6E43FE || rgba == 0xFF6D44FD || rgba == 0xFF6D43FD || rgba == 0xFF6C44FC || rgba == 0xFF6C44FD || rgba == 0xFF6F42FF || rgba == 0xFF6D44FC || rgba == 0xFF6B45FB || rgba == 0xFF6946FA) {
du = 1.5;
} else if (rgba == 0xFF4040FF) {
du = 1.0;
} else if (rgba == 0xFF5277FF) {
du = 0.75;
} else if (rgba == 0xFF6BC1FF) {
du = 0.5;
} else if (rgba == 0xFF80FFFF) {
du = 0.25;
} else if (rgba == 0xFFF3FFC1) {
du = -0.25;
} else if (rgba == 0xFFF8DC75) {
du = -0.5;
} else if (rgba == 0xFFFBC543) {
du = -0.75;
} else if (rgba == 0xFFFEA803) {
du = -1.0;
} else if (rgba == 0xFFFF9B2B) {
du = -1.5;
} else if (rgba == 0xFFFF8C59) {
du = -2.5;
} else if (rgba == 0xFFFF8080) {
du = -4.0;
} else if ((rgba & 0xFF) > 64 && (rgba & 0xFF) != 255 && (rgba & 0xFF) == ((rgba >> 8) & 0xFF) && (rgba & 0xFF) == ((rgba >> 16) & 0xFF)) {
du = 0.0;
} else {
du = 99;
}
}
#ifdef CU
#include "cu.h"
#include "assert.h"
static int fix2xy_corners()
{
/*
* 4/50 = 65/51
* 10/50 = 447/70
* 16/50 = 829/51
* 4/45 = 12/551
* 10/45 = 447/574
* 16/45 = 882/551
*/
}
int main(char **v, int c)
{
assert(fix2x(50, 4) == 65);
assert(fix2x(50, 10) == 447);
return 0;
}
#endif