[GRASS-dev] g.region error msg with empty WIND file

Markus Neteler neteler at osgeo.org
Tue Aug 18 04:09:59 PDT 2015


On Fri, Aug 7, 2015 at 11:53 PM, Glynn Clements
<glynn at gclements.plus.com> wrote:
> Markus Neteler wrote:
>> ERROR: Field <projection> missing
>> ... shows after longer debugging that really the WIND file was simply 0 bytes:
>>
>> ls -la /grassdata/eu_laea/sp_modis_swath/WIND
>> -rw-r--r-- 1 sajid gis 0 Aug  6 11:55 /grassdata/eu_laea/sp_modis_swath/WIND
>>
>>
>> How to change lib/gis/rd_cellhd.c to detect this and write out an
>> informative message?
>
> The higher up the call chain you detect it, the more specific the
> error message can be, but the fewer cases it will handle.
...
> Catching it in G_get_element_window() would allow you to report the
> filename, but additionally won't catch calls from Rast_get_cellhd() to
> read the <mapset>/cellhd/<map> file.
>
> --- lib/gis/get_window.c        (revision 65851)
> +++ lib/gis/get_window.c        (working copy)
> @@ -118,6 +118,10 @@
>         G_fatal_error(_("Unable to open element file <%s> for <%s@%s>"),
>                         element, name, mapset);
>
> +    G_fseek(fp, 0, SEEK_END);
> +    if (!G_ftell(fp))
> +        G_fatal_error(_("Region file %s/%s/%s is empty"), mapset, element, name);
> +    G_fseek(fp, 0, SEEK_SET);
>      G__read_Cell_head(fp, window, 0);
>      fclose(fp);
>  }

... I have submitted this variant in r65962.
To be backported later if all are happy.

Markus


More information about the grass-dev mailing list