[GRASS-user] v.dissolve and r.cost problems
Moritz Lennert
mlennert at club.worldonline.be
Thu Apr 2 12:37:08 EDT 2009
On 02/04/09 18:12, Moritz Lennert wrote:
> On 02/04/09 16:58, Markus Neteler wrote:
>> On Thu, Apr 2, 2009 at 4:51 PM, Moritz Lennert
>> <mlennert at club.worldonline.be> wrote:
>>> On 02/04/09 16:00, Markus Neteler wrote:
>>>> On Thu, Apr 2, 2009 at 1:43 PM, Markus Neteler <neteler at osgeo.org>
>>>> wrote:
>>>>> On Wed, Apr 1, 2009 at 6:05 PM, Paolo Cavallini
>>>>> <cavallini at faunalia.it>
>>>>>> v.dissolve input=regiao at nuovo layer=1 column=REGIAO output=reg_diss
>>>>>> dbmi: Protocol error
>> ...
>>>> Offlist we figured it out:
>>>> If the "REGIAO" column field value is empty, then it fails. Perhaps
>>>> only happening with char columns. Somewhere here:
>>>>
>>>>
>>>> http://trac.osgeo.org/grass/browser/grass/branches/releasebranch_6_4/db/drivers/dbf/dbfexe.c#L644
>>>>
>>> My wild guess would be that the problem is rather in the cmp_row_asc
>>> function, where you have on line 481:
>>>
>>> case DBF_CHAR:
>>> c1 = tbl->rows[*row1].values[cur_cmp_ocol].c;
>>> c2 = tbl->rows[*row2].values[cur_cmp_ocol].c;
>>> return (strcmp(c1, c2));
>>> break;
>>>
>>> Don't know how strcmp handles empty values. Maybe you could add
>>> something
>>> like
>>>
>>> fprinf(stdout, "c1 = %s, c2 = %s\n", a, b);
>>>
>>> before the return statement to see the state of the respective character
>>> variables ?
>>
>> Very good :)
>>
>> echo "SELECT cat, REGIAO FROM regiao ORDER BY REGIAO" | db.select
>> D0/0: c1 = ALTO PORTUGAL, c2 = ALTO PORTUGAL
>> D0/0: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
>> D0/0: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
>> D0/0: c1 = NOROESTE CISMONTANO, c2 = ALTO PORTUGAL
>> D0/0: c1 = (null), c2 = ALTO PORTUGAL
>> dbmi: Protocol error
>>
>> BAD happens when Null is found here.
>
> And that's arguably a correct behaviour as how should NULL be handled in
> such a comparison ? Don't know how it is dealt with in other DBMS...
>
> So, before we fix this in any way, we should probably agree to how to
> handle it. One possible way would be to check for nulls and if there are
> any to assign a return value according to our choice as to where to sort
> nulls to. Don't know how to check for an uninitialised char variable in
> C, but I imagine that it should be possible.
Actually, you should be able to check
tbl->rows[*row1].values[cur_cmp_ocol].is_null
and deal with the values accordingly, but from a casual glimpse I cannot
find the possible values of is_null... I suppose 0 for false and 1 for
true, but not sure...Use your example to check, with something like
fprintf(stdout, "row 1 null status = %i\n",
tbl->rows[*row1].values[cur_cmp_ocol].is_null);
Moritz
More information about the grass-user
mailing list