Skip to content

Commit

Permalink
r.external: read nan as nan (OSGeo#338)
Browse files Browse the repository at this point in the history
Fixes OSGeo#329. atof() on windows can not read "nan" and returns 0 (zero) instead. Using Rast_set_d_null_value() in this case to set nan directly.
  • Loading branch information
metzm authored and petrasovaa committed Feb 18, 2020
1 parent b979f6c commit c106583
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/raster/gdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,11 @@ struct GDAL_link *Rast_get_gdal_link(const char *name, const char *mapset)
p = G_find_key_value("null", key_val);
if (!p)
return NULL;
if (strcmp(p, "none") == 0)
/* atof on windows can not read "nan" and returns 0 instead */
if (strcmp(p, "none") == 0 ||
G_strcasecmp(p, "nan") == 0 || G_strcasecmp(p, "-nan") == 0) {
Rast_set_d_null_value(&null_val, 1);
}
else
null_val = atof(p);

Expand Down

0 comments on commit c106583

Please sign in to comment.