46 #include "../wire/wire_types.h" 47 #include "../cordic/cordic2c_inc.h" 48 #include "../cordic/cordic.h" 55 return (deg * 0.0174532925);
77 int main(
int argc,
char *argv[])
82 double lat_rad,lon_rad;
87 char *p, *name, *oname;
116 fprintf(
stderr,
"-f filename is the lot,lat dataset pairs\n");
119 if(
strcmp(name,oname) == 0)
121 fprintf(
stderr,
"sorce and destination file can not be the same\n");
124 FI =
fopen(name,
"r");
131 FO =
fopen(oname,
"w");
137 fprintf(FO,
"#ifndef _EARTH_DATA_H_\n");
138 fprintf(FO,
"#define _EARTH_DATA_H_\n");
143 fprintf(FO,
" By Mike Gore 2015, Earth Wireframe C Table\n");
144 fprintf(FO,
" Source: %s\n", name);
147 fprintf(FO,
"MEMSPACE_RO wire_p earth_data[] = {\n");
149 FI =
fopen(name,
"r");
156 while(
fgets(buff,
sizeof(buff)-2, FI))
160 while(len && buff[len-1] <
' ')
172 fprintf(FO,
"/* %s */\n", buff);
180 sscanf(buff,
"%lf %lf", &lon, &lat);
196 fprintf(FO,
"\t{%d,%d,%d}, /* sep */\n",
197 (
int)x ,(
int)y ,(
int)z
204 x = (cos(lat_rad) * cos(lon_rad)) *
WIRE_HALF;
205 y = (cos(lat_rad) * sin(lon_rad)) *
WIRE_HALF;
210 fprintf(FO,
"\t{%d,%d,%d}, /* %f, %f */\n",
211 (
int)x ,(
int)y ,(
int)z ,
221 fprintf(FO,
"\t{%d,%d,%d}, /* sep */\n",
222 (
int)x ,(
int)y ,(
int)z
228 fprintf(FO,
"\t{%d,%d,%d}, /* END */\n",
229 (
int)x ,(
int)y ,(
int)z
232 fprintf(FO,
"#else /* _EARTH_DATA_H */\n");
233 fprintf(FO,
" extern MEMSPACE_RO wire_p earth_data[];\n");
234 fprintf(FO,
"#endif /* _EARTH_DATA_H_ */\n");
MEMSPACE int WEAK_ATR strcmp(const char *str, const char *pat)
Compare two strings.
MEMSPACE size_t WEAK_ATR strlen(const char *str)
String Length.
Common Linux/POSIX time functions.
MEMSPACE char * fgets(char *str, int size, FILE *stream)
get a string from stdin See fdevopen() sets stream->put get for TTY devices
MEMSPACE FILE * fopen(const char *path, const char *mode)
POSIX Open a file with path name and ascii file mode string.
MEMSPACE int fprintf(FILE *fp, const char *format,...)
fprintf function Example user defined printf function using fputc for I/O This method allows I/O to d...
MEMSPACE time_t time(time_t *t)
Return second from epoch - POSIX function.
uint32_t time_t
type of EPOCH result.
MEMSPACE tm_t * localtime(time_t *tp)
Convert POSIX epoch time_t *tp into POSIX tm_t *result.
MEMSPACE char * asctime(tm_t *t)
Convert tm_t *t structure into POSIX asctime() ASCII string.
MEMSPACE int fclose(FILE *stream)
POSIX close a file stream.
double deg2rad(double deg)
Convert of Radians.
int sscanf(const char *strp, const char *fmt,...)
char * get_date()
Get the current date in a string.
int main(int argc, char *argv[])
Convert earth wireframe data to C structure Usage: s -f source -o result ",argv[0]); -f source is the...
MEMSPACE char * basename(char *str)
POSIX Basename of filename.
MEMSPACE char * getcwd(char *pathname, int len)
POSIX get current working directory.