-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathezcod.h
129 lines (126 loc) · 3.33 KB
/
ezcod.h
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
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef _EZPWD_EZCOD_H
#define _EZPWD_EZCOD_H
/*
* "C" API for ezcod w/3m accuracy in 9 symbols, with 1, 2 or 3 parity symbols.
*
* ..._encode -- Encode the lat/lon into an ezcod 3:10 string in buffer supplied, returning length
* ..._decode -- Decode the ezcode 3:10 string into lat, lon, returning confidence percentage
*
* All return -'ve value on failure, and as much of an error message as allowed by the 'siz' of
* the supplied char* buffer.
*/
# if defined( __cplusplus )
// Standard C Javascript binding implementation
extern "C" {
# endif
/* ezcod 3:10 -- 9+1 Reed-Solomon parity symbol */
int ezcod_3_10_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre );
int ezcod_3_10_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc );
/* ezcod 3:11 -- 9+2 Reed-Solomon parity symbols */
int ezcod_3_11_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre );
int ezcod_3_11_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc );
/* ezcod 3:12 -- 9+3 Reed-Solomon parity symbols */
int ezcod_3_12_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre );
int ezcod_3_12_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc );
# if defined( __cplusplus )
} // extern "C"
# if defined( __cheerp )
// Cheerp C++ Javascript binding implementation
class [[jsexport]] ezcod_cheerp
{
public:
ezcod_cheerp()
{
;
}
/* ezcod 3:10 -- 9+1 Reed-Solomon parity symbol */
int ezcod_3_10_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre )
{
return ::ezcod_3_10_encode( lat, lon, enc, siz, pre );
}
int ezcod_3_10_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc )
{
return ::ezcod_3_10_decode( dec, siz, lat, lon, acc );
}
/* ezcod 3:11 -- 9+2 Reed-Solomon parity symbols */
int ezcod_3_11_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre )
{
return ::ezcod_3_11_encode( lat, lon, enc, siz, pre );
}
int ezcod_3_11_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc )
{
return ::ezcod_3_11_decode( dec, siz, lat, lon, acc );
}
/* ezcod 3:12 -- 9+3 Reed-Solomon parity symbols */
int ezcod_3_12_encode(
double lat,
double lon,
char *enc,
size_t siz,
size_t pre )
{
return ::ezcod_3_12_encode( lat, lon, enc, siz, pre );
}
int ezcod_3_12_decode(
char *dec,
size_t siz,
double *lat,
double *lon,
double *acc )
{
return ::ezcod_3_12_decode( dec, siz, lat, lon, acc );
}
};
# endif // __cheerp
# endif // __cplusplus
#endif // _EZPWD_EZCOD_H