mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:33:23 +00:00
Fix saving of salinity
Several things were wrong. - we saved it as floating point (that was stupid, given the locale issue with that and given the fact that the precision was really artificial) - we always saved it when set (we should only save it if the value is different from our default of 1030g/l == salt water) - most embarrassing - the unit we assigned was wrong. That's g/l, not kg/l... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d00be63c86
commit
a012ce0515
1 changed files with 4 additions and 3 deletions
|
@ -60,7 +60,7 @@ static void show_pressure(FILE *f, pressure_t pressure, const char *pre, const c
|
|||
static void show_salinity(FILE *f, int salinity, const char *pre, const char *post)
|
||||
{
|
||||
if (salinity)
|
||||
fprintf(f, "%s%.1f kg/l%s", pre, salinity / 10.0, post);
|
||||
fprintf(f, "%s%d g/l%s", pre, salinity / 10, post);
|
||||
}
|
||||
/*
|
||||
* We're outputting utf8 in xml.
|
||||
|
@ -170,9 +170,10 @@ static void save_airpressure(FILE *f, struct dive *dive)
|
|||
|
||||
static void save_salinity(FILE *f, struct dive *dive)
|
||||
{
|
||||
if (!dive->salinity)
|
||||
/* only save if we have a value that isn't the default of sea water */
|
||||
if (!dive->salinity || dive->salinity == 10300)
|
||||
return;
|
||||
fputs(" <water ", f);
|
||||
fputs(" <water", f);
|
||||
show_salinity(f, dive->salinity, " salinity='", "'");
|
||||
fputs(" />\n", f);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue