[GRASS-dev] [GRASS GIS] #1798: all relevant vector modules should have cats and where parameters

GRASS GIS trac at osgeo.org
Fri Nov 23 11:54:03 PST 2012


#1798: all relevant vector modules should have cats and where parameters
----------------------------------+-----------------------------------------
 Reporter:  mlennert              |       Owner:  grass-dev@…              
     Type:  enhancement           |      Status:  new                      
 Priority:  normal                |   Milestone:  7.0.0                    
Component:  Vector                |     Version:  svn-trunk                
 Keywords:  where cats parameter  |    Platform:  Unspecified              
      Cpu:  Unspecified           |  
----------------------------------+-----------------------------------------

Comment(by mmetz):

 Replying to [comment:12 mlennert]:
 > IIUC, you have some boilerplate code that can be inserted into vector
 modules quite easily to add cats/where parameters. If that is the case,
 and you can explain to me how to do it, then I can spend some time adding
 this to modules. We can then still discuss whether virtual maps are a good
 and feasible idea.

 Here is a template:

 {{{
     /* define variables */
     struct cat_list *cat_list = NULL;

     /* parse options */

     /* new: set category constraints */
     if (field > 0)
         cat_list = Vect_cats_set_constraint(&In, field, where_opt->answer,
                                             cats_opt->answer);

     for (line = 1; line <= nlines; line++) {

         Vect_read_line(&In, Points, Cats, line);

         /* new: check if categories are within constraints */
         if (field > 0 && !Vect_cats_in_constraint(Cats, field, cat_list))
             continue;

         /* process line */
     }

     for (area = 1; area <= nareas; area++) {

         Vect_get_area_cats(&In, area, Cats);

         /* new: check if categories are within constraints */
         if (field > 0 && !Vect_cats_in_constraint(Cats, field, cat_list))
             continue;

         /* process area */
     }
 }}}

 I hope the template is clear enough. This is already implemented in
 v.buffer and v.hull.

 Markus M

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1798#comment:13>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list