[GRASS-user] v.dissolve and r.cost problems

Moritz Lennert mlennert at club.worldonline.be
Thu Apr 2 10:51:15 EDT 2009


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> wrote:
>>> Hi all.
>>> I cannot get a result from v.dissolve:
>>>
>>> v.dissolve input=regiao at nuovo layer=1 column=REGIAO output=reg_diss
>>> dbmi: Protocol error
>>> Cannot open select cursor: SELECT cat, REGIAO FROM regiao ORDER BY REGIAO
>>> Unable to open vector map on topology level 2
>>> Table linked to vector map does not exist
>>> Vector map not found in current mapset
>> ...
>>>  6.3.0.1-gfossit20090216-1
>> I got your data set and found:
>> GRASS 6.5.svn (portugal):~ > echo "SELECT cat, REGIAO FROM regiao
>> ORDER BY REGIAO" | db.select
>> dbmi: Protocol error
>>
>> GRASS 6.5.svn (portugal):~ > echo "SELECT cat, REGIAO FROM regiao" | db.select
>> cat|REGIAO
>> 1|NOROESTE CISMONTANO
>> 2|ALTO PORTUGAL
>> 3|ALTO PORTUGAL
>>
>> but in db/driver/dbfexe.c I see
>>
>>    /* Order */
>>    if (st->command == SQLP_SELECT && st->orderCol) {
>>        G_debug(3, "Order selection by %s", st->orderCol);
>>
>>        /* Find order col */
>>        cur_cmp_ocol = -1;
>>
>> which suggests to me that ORDER BY should be supported.
>> Not sure why it fails.
> 
> 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 ?

Moritz


More information about the grass-user mailing list