Opened 3 years ago

Closed 3 years ago

#3274 closed enhancement (wontfix)

v.net: allow connecting centroids when using option=arcs

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.4.0
Component: Vector Version: unspecified
Keywords: v.net centroids Cc:
CPU: Unspecified Platform: Unspecified

Description

v.net with option arcs allows to connect pairs of points with lines. However it does not allow connecting centroids. From what I can tell the following small change would allow this:

Index: vector/v.net/arcs.c
===================================================================
--- vector/v.net/arcs.c	(révision 70027)
+++ vector/v.net/arcs.c	(copie de travail)
@@ -80,7 +80,7 @@
 	list = Vect_new_list();
 
     /* find start node */
-    Vect_cidx_find_all(Pnts, field, GV_POINT, cat, list);
+    Vect_cidx_find_all(Pnts, field, (GV_POINT | GV_CENTROID) , cat, list);
     if (list->n_values < 1) {
 	G_warning(_("No point with category %d found"), cat);
 	return 0;

It works for me, but I'm not familiar enough with the module to be sure if this is without negative consequences.

Any objections to committing this ?

Attachments (1)

v_net_centroid_type.diff (4.7 KB) - added by mlennert 3 years ago.
patch to allow use of polygon centroids as nodes

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by marisn

Shouldn't it be exposed to user as a parser option?

comment:2 in reply to:  1 Changed 3 years ago by mlennert

Replying to marisn:

Shouldn't it be exposed to user as a parser option?

You're absolutely right. And there might also be use cases for centroids with op=connect.

Moritz

Changed 3 years ago by mlennert

Attachment: v_net_centroid_type.diff added

patch to allow use of polygon centroids as nodes

comment:3 in reply to:  description Changed 3 years ago by mlennert

Replying to mlennert:

v.net with option arcs allows to connect pairs of points with lines. However it does not allow connecting centroids.

I've just attached a patch that works for me, and that includes user choice as a parameter. Both op=arcs and op=connect now work with centroids.

I would appreciate if someone a bit more knowledgeable with the network libraries could just have a look before I commit...

comment:4 Changed 3 years ago by mlennert

Resolution: wontfix
Status: newclosed

After some offlist discussions with MarkusM, he convinced me that the need to convert centroids to points is a good extra step to ensure that users are conscious about what they are doing, knowing that centroids have arbitrary coordinates, and their location thus have no real meaning.

Closing this as wontfix.

Note: See TracTickets for help on using tickets.