[GRASS5] more cats in one layer and where condition

Martin Landa landa at gama.fsv.cvut.cz
Wed May 4 14:54:19 EDT 2005


Hi all,

the problem which I described in last e-mail (d.vect disp=cat|attr where=)
is more complex (as I have found out using ps.map)...

The patch for d.vect, attached to the last e-mail, is faulty. It works only
if 'where' condition or category value is set. I forgot to check 'chcat' variable.
So there is modified patch for d.vect (d.vect-patch1.tar.gz),
I hope better than the last one...

I have similar problem with ps.map. I have tried to display centroids using where
condition. No points were displayed... For example:

one centroid/point 
	layer/cat
	   50/1
	   50/2

attribute table:
	cat | kod
	  1 | 18
	  2 | 304

input for ps.map:

vpoints bylany_hp
	type centroid	
	layer 50
	where kod=304
	symbol dkm/zahrada
	color black
	size 7
	lpos 0
	label 
end

--> no points found ... 

In function Vect_set_varray_from_db () is used Vect_cat_get () which 
finds _first_ category of given field. So in this case category '1'! 

For my purpose (I am trying to develop GRASS module for importing data in Czech 
cadastre exchange data format -- my diploma thesis) I have modified this function
(see array.c.patch). But I am not sure if this solution is good...

Best regards,

	Martin

--
Martin Landa <landa at gama.fsv.cvut.cz> * http://gama.fsv.cvut.cz/~landa *
CTU Prague, Faculty of Civil Engineering, Czech Republic
-------------- next part --------------
*** array.c.old	2005-05-04 19:43:26.000000000 +0200
--- array.c	2005-05-04 19:43:58.000000000 +0200
***************
*** 196,202 ****
  Vect_set_varray_from_db ( struct Map_info *Map, int field, char *where,
                                  int type, int value, VARRAY *varray )
  {
!     int i, n, centr, cat, *cats, ncats;
      int ni = 0; /* number of items set */
      int ltype; /* line type */
      struct line_cats *Cats;
--- 196,202 ----
  Vect_set_varray_from_db ( struct Map_info *Map, int field, char *where,
                                  int type, int value, VARRAY *varray )
  {
!     int i, n, c, centr, cat, *cats, ncats;
      int ni = 0; /* number of items set */
      int ltype; /* line type */
      struct line_cats *Cats;
***************
*** 245,256 ****
  	    if ( centr <= 0 ) continue; /* No centroid */
  	    
  	    Vect_read_line (Map, NULL, Cats, centr);
! 	    if ( !Vect_cat_get(Cats, field, &cat) ) continue; /* No such field */
! 	    
  	    if ( in_array ( cats, ncats, cat ) ) {
  		varray->c[i] = value;
  		ni++;
  	    }
  	}
      } else { /* Lines */
  	n = Vect_get_num_lines (Map);
--- 245,266 ----
  	    if ( centr <= 0 ) continue; /* No centroid */
  	    
  	    Vect_read_line (Map, NULL, Cats, centr);
! 	    /*if ( !Vect_cat_get(Cats, field, &cat) ) continue; No such field */
! 	    for (c = 0; c < Cats->n_cats; c++) {
! 	      if (Cats->field[c] == field && in_array ( cats, ncats, Cats->cat[c] )) {
! 		cat = Cats->cat[c];
! 		varray->c[i] = value;
! 		ni++;
! 		break;
! 	      }
! 	    }
! 
! 	    /*
  	    if ( in_array ( cats, ncats, cat ) ) {
  		varray->c[i] = value;
  		ni++;
  	    }
+ 	    */
  	}
      } else { /* Lines */
  	n = Vect_get_num_lines (Map);
***************
*** 265,276 ****
          
  	    if ( !(ltype & type) ) continue; /* is not specified type */
  	    
! 	    if ( !Vect_cat_get(Cats, field, &cat) ) continue; /* No such field */
! 
  	    if ( in_array ( cats, ncats, cat ) ) {
  		varray->c[i] = value;
  		ni++;
  	    }
  	}
  
      }
--- 275,295 ----
          
  	    if ( !(ltype & type) ) continue; /* is not specified type */
  	    
! 	    /* if ( !Vect_cat_get(Cats, field, &cat) ) continue;  No such field */
! 	    for (c = 0; c < Cats->n_cats; c++) {
! 	      if (Cats->field[c] == field && in_array ( cats, ncats, Cats->cat[c] )) {
! 		cat = Cats->cat[c];
! 		varray->c[i] = value;
! 		ni++;
! 		break;
! 	      }
! 	    }
! 	    /*
  	    if ( in_array ( cats, ncats, cat ) ) {
  		varray->c[i] = value;
  		ni++;
  	    }
+ 	    */
  	}
  
      }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d.vect-patch1.tar.gz
Type: application/octet-stream
Size: 1162 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20050504/9de48c80/d.vect-patch1.tar.obj


More information about the grass-dev mailing list