[GRASS-SVN] r30020 - in grass/trunk/vector/v.edit: cmd lib

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Feb 8 16:04:05 EST 2008


Author: martinl
Date: 2008-02-08 16:04:05 -0500 (Fri, 08 Feb 2008)
New Revision: 30020

Modified:
   grass/trunk/vector/v.edit/cmd/args.c
   grass/trunk/vector/v.edit/cmd/description.html
   grass/trunk/vector/v.edit/cmd/global.h
   grass/trunk/vector/v.edit/cmd/main.c
   grass/trunk/vector/v.edit/cmd/proto.h
   grass/trunk/vector/v.edit/cmd/select.c
   grass/trunk/vector/v.edit/lib/break.c
   grass/trunk/vector/v.edit/lib/cats.c
   grass/trunk/vector/v.edit/lib/copy.c
   grass/trunk/vector/v.edit/lib/delete.c
   grass/trunk/vector/v.edit/lib/distance.c
   grass/trunk/vector/v.edit/lib/flip.c
   grass/trunk/vector/v.edit/lib/merge.c
   grass/trunk/vector/v.edit/lib/move.c
   grass/trunk/vector/v.edit/lib/snap.c
   grass/trunk/vector/v.edit/lib/vedit.h
   grass/trunk/vector/v.edit/lib/vertex.c
   grass/trunk/vector/v.edit/lib/zbulk.c
Log:
v.edit: Tool for changing feature type added (points<->centroids, lines<->boundaries).
Doxygen fixes in lib.
Selecting features by id fixed (type is not ignored).


Modified: grass/trunk/vector/v.edit/cmd/args.c
===================================================================
--- grass/trunk/vector/v.edit/cmd/args.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/args.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -86,9 +86,11 @@
 				     "Connect two lines;"
 				     "zbulk;"
 				     "Z bulk-labeling (automated assignment of z coordinate to "
-				     "vector lines)");
+				     "vector lines);"
+				     "chtype;"
+				     "Change feature type (point<->centroid, line<->boundary)");
     params -> tool->options     = "create,add,delete,copy,move,flip,catadd,catdel,"
-      "merge,break,snap,connect,"
+      "merge,break,snap,connect,chtype,"
       "vertexadd,vertexdel,vertexmove,zbulk,select";
 
     params -> in = G_define_standard_option (G_OPT_F_INPUT);
@@ -275,33 +277,29 @@
 	*action_mode = MODE_VERTEX_MOVE;
     }
     else if(G_strcasecmp (params -> tool -> answer, "select") == 0) { 
-        /* del requires a cats or or bbox or coords */
 	*action_mode = MODE_SELECT;
     }
     else if(G_strcasecmp (params -> tool -> answer, "catadd") == 0) { 
-        /* cat requires a cats or or bbox or coords */
 	*action_mode = MODE_CATADD;
     }
     else if(G_strcasecmp (params -> tool -> answer, "catdel") == 0) {
-        /* cat requires a cats or or bbox or coords */
 	*action_mode = MODE_CATDEL;
     }
     else if(G_strcasecmp(params -> tool -> answer, "copy") == 0) { 
-        /* del requires a cats or or bbox or coords */
 	*action_mode = MODE_COPY;
     }
     else if(G_strcasecmp (params -> tool -> answer, "snap") == 0) {
-	/* del requires a cats or or bbox or coords */ 
 	*action_mode = MODE_SNAP;
     }
     else if(G_strcasecmp (params -> tool -> answer, "flip") == 0) {
-	/* del requires a cats or or bbox or coords */ 
 	*action_mode = MODE_FLIP;
     }
     else if(G_strcasecmp (params -> tool -> answer, "zbulk") == 0) {
-	/* del requires a cats or or bbox or coords */ 
 	*action_mode = MODE_ZBULK;
     }
+    else if(G_strcasecmp (params -> tool -> answer, "chtype") == 0) {
+      	*action_mode = MODE_CHTYPE;
+    }
     else
     {
 	G_fatal_error (_("Operation '%s' not implemented"),

Modified: grass/trunk/vector/v.edit/cmd/description.html
===================================================================
--- grass/trunk/vector/v.edit/cmd/description.html	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/description.html	2008-02-08 21:04:05 UTC (rev 30020)
@@ -122,6 +122,10 @@
     is broken if necessary. The lines are connected regarding
     threshold distance <b>thresh</b>.</li>
 
+    <li><b>chtype</b> - Change feature type of selected geometry
+    objects. Points are converted to centroids, centroids to points,
+    lines to boundaries and boundaries to lines.
+
     <li><b>vertexadd</b> - Add vertex(ces) to the given vector lines
     or boundaries. Location of the new vertex is given by <b>coord</b>
     option. If <b>-1</b> is given only first found line or boundary in bounding

Modified: grass/trunk/vector/v.edit/cmd/global.h
===================================================================
--- grass/trunk/vector/v.edit/cmd/global.h	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/global.h	2008-02-08 21:04:05 UTC (rev 30020)
@@ -34,6 +34,8 @@
     MODE_NONE,
     /* z bulk-labeling */
     MODE_ZBULK,
+    /* change feature type (point<->centroid, line<->boundary) */
+    MODE_CHTYPE,
 };
 
 struct GParams { 

Modified: grass/trunk/vector/v.edit/cmd/main.c
===================================================================
--- grass/trunk/vector/v.edit/cmd/main.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/main.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -346,6 +346,35 @@
 	G_message(_("%d lines labeled"), ret);
 	break;
     }
+    case MODE_CHTYPE: {
+	int npoints, nlines, ncentroids, nboundaries;
+	ret = Vedit_chtype_lines(&Map, List,
+				 &npoints, &ncentroids,
+				 &nlines, &nboundaries);
+
+	if (ret > 0) {
+	    if (npoints > 0) {
+		G_message(_("%d points converted to centroids"),
+			  npoints);
+	    }
+	    if (ncentroids > 0) {
+		G_message(_("%d centroids converted to points"),
+			  ncentroids);
+	    }
+	    if (nlines > 0) {
+		G_message(_("%d lines converted to boundaries"),
+			  nlines);
+	    }
+	    if (nboundaries > 0) {
+		G_message(_("%d boundaries converted to lines"),
+			  nboundaries);
+	    }
+	}
+	else {
+	    G_message(_("No feature modified"));
+	}
+	break;
+    }
     default:
 	G_warning(_("Operation not implemented"));
 	ret = -1;

Modified: grass/trunk/vector/v.edit/cmd/proto.h
===================================================================
--- grass/trunk/vector/v.edit/cmd/proto.h	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/proto.h	2008-02-08 21:04:05 UTC (rev 30020)
@@ -27,7 +27,7 @@
 		   int, struct line_pnts *,
 		   struct ilist *);
 int sel_by_id(struct Map_info *,
-	      char *,
+	      int, char *,
 	      struct ilist *);
 int sel_by_where(struct Map_info *,
 		 int, int, char *,

Modified: grass/trunk/vector/v.edit/cmd/select.c
===================================================================
--- grass/trunk/vector/v.edit/cmd/select.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/cmd/select.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -47,7 +47,7 @@
     /* select by id's */
     if (params -> id -> answer != NULL) {
 	sel_by_id(Map,
-		  params -> id -> answer,
+		  type, params -> id -> answer,
 		  List);
     }
 
@@ -429,16 +429,17 @@
    \brief Select features by id
 
    \param[in] Map vector map
+   \param[in] type feature type
    \param[in] ids ids list
    \param[in,out] List list of selected features
  
    \return number of selected lines
 */
 int sel_by_id(struct Map_info *Map,
-	      char *ids,
+	      int type, char *ids,
 	      struct ilist* List)
 {
-    int i, j;
+    int i;
     int num, id;
     struct cat_list *il; /* NOTE: this is not cat list, but list of id's */
     struct ilist *List_tmp;
@@ -457,13 +458,14 @@
     num = Vect_get_num_lines (Map);
 
     for(i = 0; i < il -> n_ranges; i++) {
-	for(id = il -> min[i]; id <= il -> max[i]; id++) {
-	    for (j = 1; j <= num; j++) {
-		if (id == j) {
-		    Vect_list_append (List_tmp, id);
-		}
-            }
-        }
+	for (id = 1; id <= num; id++) {
+	    if (!(Vect_read_line(Map, NULL, NULL, id) & type)) {
+		continue;
+	    }
+	    if (id >= il -> min[i] && id <= il -> max[i]) {
+		Vect_list_append (List_tmp, id);
+	    }
+	}
     }
     
     G_debug (1, "  %d lines selected (by id)", List_tmp -> n_values);

Modified: grass/trunk/vector/v.edit/lib/break.c
===================================================================
--- grass/trunk/vector/v.edit/lib/break.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/break.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file break.c
+
    \brief Vedit library - split/break lines
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/cats.c
===================================================================
--- grass/trunk/vector/v.edit/lib/cats.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/cats.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file cats.c
+
    \brief Vedit library - category manipulation
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/copy.c
===================================================================
--- grass/trunk/vector/v.edit/lib/copy.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/copy.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file copy.c
+
    \brief Vedit library - copy features
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/delete.c
===================================================================
--- grass/trunk/vector/v.edit/lib/delete.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/delete.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file delete.c
+
    \brief Vedit library - delete features
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/distance.c
===================================================================
--- grass/trunk/vector/v.edit/lib/distance.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/distance.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file distance.c
+
    \brief Vedit library - distance calculation
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/flip.c
===================================================================
--- grass/trunk/vector/v.edit/lib/flip.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/flip.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file flip.c
+
    \brief Vedit library - lines flipping
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/merge.c
===================================================================
--- grass/trunk/vector/v.edit/lib/merge.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/merge.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file merge.c
+
    \brief Vedit library - merge lines
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/move.c
===================================================================
--- grass/trunk/vector/v.edit/lib/move.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/move.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file move.c
+
    \brief Vedit library - snapping
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/snap.c
===================================================================
--- grass/trunk/vector/v.edit/lib/snap.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/snap.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file snap.c
+
    \brief Vedit library - snapping
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/vedit.h
===================================================================
--- grass/trunk/vector/v.edit/lib/vedit.h	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/vedit.h	2008-02-08 21:04:05 UTC (rev 30020)
@@ -28,6 +28,10 @@
 int Vedit_copy_lines (struct Map_info *, struct Map_info *,
 		      struct ilist *);
 
+/* chtype.c */
+int Vedit_chtype_lines(struct Map_info *, struct ilist *,
+		       int *, int *, int *, int *);
+
 /* delete.c */
 
 int Vedit_delete_lines(struct Map_info *, struct ilist *);

Modified: grass/trunk/vector/v.edit/lib/vertex.c
===================================================================
--- grass/trunk/vector/v.edit/lib/vertex.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/vertex.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file vertex.c
+
    \brief Vedit library - vertex manipulation
 
    This program is free software under the

Modified: grass/trunk/vector/v.edit/lib/zbulk.c
===================================================================
--- grass/trunk/vector/v.edit/lib/zbulk.c	2008-02-08 20:35:54 UTC (rev 30019)
+++ grass/trunk/vector/v.edit/lib/zbulk.c	2008-02-08 21:04:05 UTC (rev 30020)
@@ -1,4 +1,6 @@
 /**
+   \file zbulk.c
+
    \brief Vedit library - Bulk labeling (automated labeling of vector features)
 
    This program is free software under the



More information about the grass-commit mailing list