Opened 13 years ago

Closed 9 years ago

#1498 closed enhancement (fixed)

patch proposal: new option for v.category to copy category values from one layer to another

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.0.2
Component: Vector Version: svn-releasebranch70
Keywords: v.category Cc:
CPU: Unspecified Platform: Unspecified

Description

In the attached patch againts trunk I propose an implementation of a feature in v.category requested regularly in the mailing lists: copying category values from one layer to another.

I don't think that it is a very invasive addition, but someone should probably check before we apply this to trunk. It could possibly also go into 6.5 as it doesn't break backwards compatibility.

I used the word 'transfer' for this option as the way the parser works I needed a word with a different first letter than the others, and 'c'(opy) was already taken by 'c'(hlayer).

On thing I did not put in is a way how to work with type=area. I just exit with a message proposing to use type=centroid to copy category values for areas. If someone wants to implement the same with type=area working, please do so.

Moritz

Attachments (2)

v_category_transfer_option.diff (3.8 KB ) - added by mlennert 13 years ago.
v_category_transfer_option_2.diff (3.9 KB ) - added by mmetz 13 years ago.
copy all cats of first layer to second layer

Download all attachments as: .zip

Change History (8)

by mlennert, 13 years ago

by mmetz, 13 years ago

copy all cats of first layer to second layer

comment:1 by mmetz, 13 years ago

Very useful addition, the transfer option!

The attached second patch copies not only the first cat encountered but all cats of the first layer to the second layer. Type = centroid is now automatically activated if type = area and not type=area,centroid.

Markus M

in reply to:  1 ; comment:2 by mlennert, 13 years ago

Replying to mmetz:

Very useful addition, the transfer option!

The attached second patch copies not only the first cat encountered but all cats of the first layer to the second layer. Type = centroid is now automatically activated if type = area and not type=area,centroid.

Thanks, Markus, for looking into this. Can we apply to trunk ? And what about 6.x ?

Moritz

in reply to:  2 comment:3 by mmetz, 13 years ago

Replying to mlennert:

Replying to mmetz:

Very useful addition, the transfer option!

The attached second patch copies not only the first cat encountered but all cats of the first layer to the second layer. Type = centroid is now automatically activated if type = area and not type=area,centroid.

Thanks, Markus, for looking into this. Can we apply to trunk ? And what about 6.x ?

I have added the new feature of copying categories in r49413, but with further modifications because the category/layer design of GRASS vectors is quite flexible and thus probably a bit complicated:

  • A warning is printed if categories already exist in the target layer (where categories are copied to). This could lead to all sorts of complications. I was contemplating a fatal error, but then I decided to follow GRASS policy: allow a lot, warn if it may be dangerous.
  • There is a new hidden feature for option=transfer, if only one layer number is given for the layer option, the module will find the next free layer number and copy categories to that new layer. No danger of confusion with already existing categories in that layer since it's new. This feature is hidden in the sense that it is documented somewhat further down the manual.

Since I was on it, I changed the behaviour of option=chlayer a bit: the layer number of categories is changed (as before) if the current category number does not exist for the target layer, otherwise it is only deleted from the source layer (new). This avoids duplicate category entries of a given geometry object in the target layer.

All changes are tested and should be backported to 6.x since they maintain backwards compatibility and fix an obscure but potentially disastrous bug.

Markus M

comment:4 by neteler, 9 years ago

Milestone: 7.0.06.4.6
Version: unspecifiedsvn-releasebranch70

trunk and relbr70 are in sync.

Backport of r49413 to G6 still open.

comment:5 by mlennert, 9 years ago

I don't think that we should still worry about backporting such new functionality. We have a new stable release and we sould rather encourage people to use that if they need this functionality.

So I suggest closing this bug.

comment:6 by neteler, 9 years ago

Milestone: 6.4.67.0.2
Resolution: fixed
Status: newclosed

Closing as proposed.

Note: See TracTickets for help on using tickets.