[GRASS-user] Problem with r.reclas on ubuntu feisty

Jarekj Jasiewicz jarekj at amu.edu.pl
Thu Apr 26 01:24:27 EDT 2007


Glynn Clements napisał(a):
> Maciej Sieczka wrote:
>
>   
>>> I have problem with r.reclass (and r.reclas.rules) from latest cvs
>>> (updated wensday morning)
>>> on whatever map I use it I recive segmentation fault error
>>>       
>> I confirm for current GRASS 6.3 CVS built and running on Ubuntu Dapper,
>> 32 bit, GCC 4.0.3, Pentium M, kernel 2.6.15-28-686.
>>
>> Any r.reclass session ends up with a segfault after the 'end' command;
>> eg. in spearfish:
>>
>> $ r.reclass in=aspect output=tryit
>>
>>     
>>> 1 thru 9.9 = 1
>>>       
>> 10.400000 rounded up to 10
>>     
>>> 30 thru 31 = 32
>>> end
>>>       
>> Segmentation fault
>>     
>
> I changed the name/mapset fields in struct Reclass from fixed-size
> char[] to dynamically-allocated char*. I missed some of the cases
> which were relying upon the old structure (AFAICT, I got all of the
> ones in libgis, but missed r.reclass).
>
> This should be sufficient for r.reclass:
>
> --- raster/r.reclass/reclass.c	15 Dec 2006 09:05:02 -0000	2.2
> +++ raster/r.reclass/reclass.c	25 Apr 2007 22:49:33 -0000
> @@ -200,8 +200,8 @@
>  {
>      struct Reclass mid;
>  
> -    strcpy(mid.name, input_name);
> -    strcpy(mid.mapset, input_mapset);
> +    mid.name = G_store(input_name);
> +    mid.mapset = G_store(input_mapset);
>  
>      _reclass(rules, cats, &mid);
>  
> @@ -225,14 +225,14 @@
>  
>      if (is_reclass)
>      {
> -	strcpy (new.name, old.name);
> -	strcpy (new.mapset, old.mapset);
> +	new.name = G_store(old.name);
> +	new.mapset = G_store(old.mapset);
>  	re_reclass (rules, cats, &old, &new, old_name, old_mapset);
>      }
>      else
>      {
> -	strcpy (new.name, old_name);
> -	strcpy (new.mapset, old_mapset);
> +	new.name = G_store(old.name);
> +	new.mapset = G_store(old.mapset);
>  	_reclass (rules, cats, &new);
>      }
>  
>
> Now I need to go through and see what else I might have missed.
>   


unfortunatly not, error remains
>   
>> Why "10.400000 rounded up to 10". I specified range "1 thru 9.9"...
>>  Maciek
>>     
>
> Reclassing only works on integers; FP maps have to be quantised. This
> is done by rounding to the nearest integer, i.e. adding 0.5 then
> truncating. The code which prints the message uses the value after the
> 0.5 has been added to it. I'll look into that later.




More information about the grass-user mailing list