Mercurial > ~darius > hgwebdir.cgi > wh1080
annotate db/insertBoM.c @ 8:e3d2b5500b53 default tip
Missed part of earlier commit to only print the query if -vv is used as well as compiling in the mysql stuff (now that I know -n DTRT)
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 11 Feb 2010 12:48:57 +1030 |
parents | 9dab44dcb331 |
children |
rev | line source |
---|---|
0
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
1 /* |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
2 * Read in Australian Bureau of Meteorology comma-delimited files and convert |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
3 * them into INSERT commands for MySQL. |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
4 * |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
5 * $Id: insertBoM.c,v 1.4 2010/01/03 05:05:28 grog Exp $ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
6 */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
7 #include <ctype.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
8 #include <stdio.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
9 #include <stdlib.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
10 #include <string.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
11 #include <sys/file.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
12 #include <sys/stat.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
13 #include <sys/types.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
14 #include <unistd.h> |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
15 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
16 #define BUFSIZE 1024 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
17 char buf [BUFSIZE]; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
18 char sql_command [BUFSIZE]; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
19 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
20 /* We split up the input line into these fields, not all of which we use. */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
21 char *field [50]; /* pointers to beginnings of fields */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
22 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
23 /* |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
24 * We alias these structs to the input field above. Unfortunately, the data |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
25 * returned from Sheoaks is different from Ballarat and Melbourne airports: |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
26 * Sheoaks doesn't report a QNH pressure. I should really parse the input files |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
27 * to check the fields, but it's pretty messy. |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
28 */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
29 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
30 struct ballarat_row |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
31 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
32 char *order; /* sort order (backwards!) */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
33 char *station_id; /* station ID, apparently always numeric */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
34 char *name; /* name of town, it would seem */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
35 char *history; /* this looks like another station ID */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
36 char *funnydate; /* date in useless form 0D/0H:0m[ap]m */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
37 char *date; /* date as YYYYMMDDHHmmSS */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
38 char *temp; /* temperature, °C */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
39 char *apparent_temp; /* apparent temperature */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
40 char *delta_t; /* wet bulb depression */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
41 char *dewpoint; /* dew point */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
42 char *wind_gust; /* wind gust speed */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
43 char *gust_knots; /* same again in knots */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
44 char *pressure_msl; /* pressure at mean sea level */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
45 char *pressure_qnh; /* QNH pressure, whatever that may be */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
46 char *rain; /* rain as text (can be "Tce") */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
47 char *humidity; /* relative humdity */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
48 char *wind_direction_text; /* text of direction */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
49 char *wind_speed; /* speed in km/h */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
50 char *wind_speed_knots; /* and in knots */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
51 } *ballarat_readings = (struct ballarat_row *) field; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
52 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
53 struct sheoaks_row |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
54 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
55 char *order; /* sort order (backwards!) */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
56 char *station_id; /* station ID, apparently always numeric */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
57 char *name; /* name of town, it would seem */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
58 char *history; /* this looks like another station ID */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
59 char *funnydate; /* date in useless form 0D/0H:0m[ap]m */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
60 char *date; /* date as YYYYMMDDHHmmSS */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
61 char *temp; /* temperature, °C */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
62 char *apparent_temp; /* apparent temperature */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
63 char *delta_t; /* wet bulb depression */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
64 char *dewpoint; /* dew point */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
65 char *wind_gust; /* wind gust speed */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
66 char *gust_knots; /* same again in knots */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
67 char *pressure_msl; /* pressure at mean sea level */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
68 char *rain; /* rain as text (can be "Tce") */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
69 char *humidity; /* relative humdity */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
70 char *wind_direction_text; /* text of direction */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
71 char *wind_speed; /* speed in km/h */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
72 char *wind_speed_knots; /* and in knots */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
73 } *sheoaks_readings = (struct sheoaks_row *) field; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
74 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
75 void skipblanks (char **cp) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
76 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
77 while (**cp == ' ') |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
78 (*cp)++; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
79 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
80 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
81 /* |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
82 * Wind directions as text. BoM encloses them in "", so we do the same |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
83 */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
84 struct wind_directions |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
85 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
86 char *text; /* name of direction */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
87 float direction; /* and the direction it represents */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
88 } wind_directions [] = { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
89 {"\"N\"", 0}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
90 {"\"North\"", 0}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
91 {"\"NNE\"", 22.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
92 {"\"NE\"", 45}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
93 {"\"ENE\"", 67.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
94 {"\"E\"", 90}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
95 {"\"East\"", 90}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
96 {"\"ESE\"", 112.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
97 {"\"SE\"", 135}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
98 {"\"SSE\"", 157.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
99 {"\"S\"", 180}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
100 {"\"South\"", 180}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
101 {"\"SSW\"", 202.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
102 {"\"SW\"", 225}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
103 {"\"WSW\"", 247.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
104 {"\"W\"", 270}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
105 {"\"West\"", 270}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
106 {"\"WNW\"", 292.5}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
107 {"\"NW\"", 315}, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
108 {"\"NNW\"", 337.5}}; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
109 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
110 int wind_direction_count = sizeof (wind_directions) / sizeof (struct wind_directions); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
111 float previous_wind; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
112 float wind_direction (char *text) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
113 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
114 int i; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
115 if (! strcmp (text, "\"CALM\"")) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
116 return previous_wind; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
117 for (i = 0; i < wind_direction_count; i++) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
118 if (! strcmp (wind_directions [i].text, text)) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
119 return previous_wind = wind_directions [i].direction; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
120 fprintf (stderr, "Unknown wind direction: %s\n", text); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
121 return previous_wind; /* Sam Ting */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
122 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
123 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
124 int main (int argc, char *argv []) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
125 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
126 char *cp; /* pointers in buffers */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
127 int fields; /* becomes number of fields in row */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
128 char date_text [11]; /* YYYY-MM-DD */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
129 char time_text [9]; /* HH-MM-SS */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
130 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
131 if (argc > 1) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
132 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
133 fprintf (stderr, "Usage: $0 < file\n"); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
134 exit (1); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
135 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
136 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
137 while (1) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
138 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
139 memset ((void *) buf, '\0', sizeof (buf)); /* don't trip over old stuff */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
140 if (! fgets (buf, BUFSIZE - 1, stdin)) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
141 exit (0); /* empty file, just ignore */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
142 if (isdigit (buf [0])) /* valid row */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
143 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
144 fields = 0; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
145 cp = buf; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
146 while (1) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
147 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
148 skipblanks (&cp); /* though there don't seem to be any */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
149 field [fields++] = cp; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
150 while (*cp && (*cp != ',') && (*cp != '\n') && (*cp != ',')) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
151 cp++; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
152 if (! *cp) |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
153 break; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
154 *cp++ = '\0'; /* delimit the string */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
155 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
156 /* |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
157 * buf now contains "fields" strings, and field (and thus "ballarat_row" |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
158 * and "sheoaks_row") contain pointers to them. |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
159 * |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
160 * Fix a few fields. |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
161 */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
162 strcpy (date_text, "YYYY-MM-DD"); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
163 strcpy (time_text, "HH:MM:SS"); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
164 /* The date info is surrounded with " */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
165 memcpy (date_text, &ballarat_readings->date [1], 4); /* YYYY */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
166 memcpy (&date_text [5], &ballarat_readings->date [5], 2); /* MM */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
167 memcpy (&date_text [8], &ballarat_readings->date [7], 2); /* MM */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
168 memcpy (time_text, &ballarat_readings->date [9], 2); /* HH */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
169 memcpy (&time_text [3], &ballarat_readings->date [11], 2); /* MM */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
170 memcpy (&time_text [6], &ballarat_readings->date [13], 2); /* MM */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
171 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
172 if (strcmp (ballarat_readings->station_id, "94863")) /* Not Sheoaks */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
173 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
174 if (! strcmp (ballarat_readings->pressure_qnh, "-9999.0")) /* this seems to be a null value */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
175 ballarat_readings->pressure_qnh = "NULL"; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
176 sprintf (sql_command, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
177 "REPLACE INTO remote_observations (station_id, date, time, outside_temp, apparent_temp," |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
178 "delta_t, outside_dewpoint, wind_gust, pressure_msl, pressure_qnh, rain, outside_humidity, " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
179 "wind_direction, wind_direction_text, wind_speed) " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
180 "VALUES (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %s, %s, " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
181 "%s, \"%s\", %4.1f, %s, \"%s\");", |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
182 ballarat_readings->station_id, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
183 date_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
184 time_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
185 ballarat_readings->temp, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
186 ballarat_readings->apparent_temp, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
187 ballarat_readings->delta_t, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
188 ballarat_readings->dewpoint, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
189 ballarat_readings->wind_gust, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
190 ballarat_readings->pressure_msl, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
191 ballarat_readings->pressure_qnh, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
192 ballarat_readings->rain, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
193 ballarat_readings->humidity, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
194 wind_direction (ballarat_readings->wind_direction_text), |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
195 ballarat_readings->wind_direction_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
196 ballarat_readings->wind_speed ); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
197 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
198 else /* currently only sheoaks */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
199 { |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
200 if (! strcmp (sheoaks_readings->pressure_msl, "-9999.0")) /* this seems to be a null value */ |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
201 sheoaks_readings->pressure_msl = NULL; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
202 |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
203 sprintf (sql_command, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
204 "REPLACE INTO remote_observations (station_id, date, time, outside_temp, apparent_temp," |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
205 "delta_t, outside_dewpoint, wind_gust, pressure_msl, rain, outside_humidity, " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
206 "wind_direction, wind_direction_text, wind_speed) " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
207 "VALUES (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %s, " |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
208 "%s, \"%s\", %4.1f, %s, \"%s\");", |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
209 sheoaks_readings->station_id, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
210 date_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
211 time_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
212 sheoaks_readings->temp, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
213 sheoaks_readings->apparent_temp, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
214 sheoaks_readings->delta_t, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
215 sheoaks_readings->dewpoint, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
216 sheoaks_readings->wind_gust, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
217 sheoaks_readings->pressure_msl, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
218 sheoaks_readings->rain, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
219 sheoaks_readings->humidity, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
220 wind_direction (sheoaks_readings->wind_direction_text), |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
221 sheoaks_readings->wind_direction_text, |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
222 sheoaks_readings->wind_speed ); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
223 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
224 puts (sql_command); |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
225 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
226 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
227 return 0; |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
228 } |
9dab44dcb331
Initial commit of Greg's code from http://www.lemis.com/grog/tmp/wh1080.tar.gz
Daniel O'Connor <darius@dons.net.au>
parents:
diff
changeset
|
229 |