Changeset 50501


Ignore:
Timestamp:
Jan 27, 2012, 10:10:35 AM (13 years ago)
Author:
huhabla
Message:

Enabled multi-layer transfer

Location:
grass/trunk/vector/v.category
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/vector/v.category/main.c

    r49959 r50501  
    103103                                 "chlayer;change layer number (e.g. layer=3,1 changes layer 3 to layer 1);"
    104104                                 "sum;add the value specified by cat option to the current category value;"
    105                                  "transfer;copy values from one layer to another (e.g. layer=1,2 copies values from layer 1 to layer 2);"
     105                                 "transfer;copy values from one layer to another (e.g. layer=1,2,3 copies values from layer 1 to layer 2 and 3);"
    106106                                 "report;print report (statistics), in shell style: layer type count min max;"
    107107                                 "print;print category values, more cats in the same layer are separated by '/'");
     
    234234
    235235    if (option == O_TRANS && open_level > 1) {
    236         /* check if field[1] already exists */
     236        /* check if field[>0] already exists */
    237237        if (nfields > 1) {
    238             if (Vect_cidx_get_field_index(&In, fields[1]) != -1)
    239                 G_warning(_("Categories already exist in layer %d"), fields[1]);
     238            for(i = 1; i < nfields; i++) {
     239                if (Vect_cidx_get_field_index(&In, fields[i]) != -1)
     240                    G_warning(_("Categories already exist in layer %d"), fields[i]);
     241            }
    240242        }
    241243        /* find next free layer number */
     
    340342                    if (Cats->field[i] == fields[0]) {
    341343                        scat = Cats->cat[i];
    342                         if (Vect_cat_set(Cats, fields[1], scat) > 0) {
    343                             nmodified++;
    344                         }
    345                     }
    346                 }
     344                        break;
     345                    }
     346                }
     347                for (i = 1; i < nfields; i++) {
     348                    if (Vect_cat_set(Cats, fields[i], scat) > 0) {
     349                        G_debug(4, "Copy cat %i of field %i to into field %i", scat, fields[0], fields[i]);
     350                    }
     351                }
     352                nmodified++;
    347353            }
    348354            Vect_write_line(&Out, type, Points, Cats);
     
    704710
    705711        if (option == O_TRANS && nmodified > 0)
    706             G_important_message(_("Categories copied from layer %d to layer %d"),
    707                                 fields[0], fields[1]);
     712            for(i = 0; i < nfields; i++)
     713                G_important_message(_("Categories copied from layer %d to layer %d"),
     714                                fields[0], fields[i]);
    708715        G_done_msg(_("%d features modified."), nmodified);
    709716    }
  • grass/trunk/vector/v.category/v.category.html

    r49651 r50501  
    103103using <em><a href="d.what.vect.html">d.what.vect</a></em>.
    104104
     105<h3>Copy categories from layer 1 to layer 2,3,4,5,6,7 and 8</h3>
     106Existing layer will be overwritten, non-existing will be created.
     107<div class="code"><pre>
     108v.category input=observer output=observer_new option=transfer layer=1,2,3,4,5,6,7,8
     109</pre></div>
     110
    105111<h3>Print vector categories of given layer</h3>
    106112
Note: See TracChangeset for help on using the changeset viewer.