[GRASS-SVN] r58356 - grass/trunk/display/d.vect

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 2 10:44:00 PST 2013


Author: martinl
Date: 2013-12-02 10:44:00 -0800 (Mon, 02 Dec 2013)
New Revision: 58356

Added:
   grass/trunk/display/d.vect/vert.c
Modified:
   grass/trunk/display/d.vect/local_proto.h
   grass/trunk/display/d.vect/main.c
   grass/trunk/display/d.vect/opt.c
   grass/trunk/display/d.vect/plot.h
Log:
d.vect: add option to display vertices (`display=vert`)


Modified: grass/trunk/display/d.vect/local_proto.h
===================================================================
--- grass/trunk/display/d.vect/local_proto.h	2013-12-02 18:04:46 UTC (rev 58355)
+++ grass/trunk/display/d.vect/local_proto.h	2013-12-02 18:44:00 UTC (rev 58356)
@@ -59,5 +59,8 @@
 /* topo.c */
 int display_topo(struct Map_info *, int, LATTR *, double);
 
+/* vertex.c */
+int display_vert(struct Map_info *, int, LATTR *, double);
+
 /* zcoor.c */
 int display_zcoor(struct Map_info *, int, LATTR *);

Modified: grass/trunk/display/d.vect/main.c
===================================================================
--- grass/trunk/display/d.vect/main.c	2013-12-02 18:04:46 UTC (rev 58355)
+++ grass/trunk/display/d.vect/main.c	2013-12-02 18:44:00 UTC (rev 58356)
@@ -86,14 +86,15 @@
     display_opt->required = YES;
     display_opt->multiple = YES;
     display_opt->answer = "shape";
-    display_opt->options = "shape,cat,topo,dir,attr,zcoor";
+    display_opt->options = "shape,cat,topo,vert,dir,attr,zcoor";
     display_opt->description = _("Display");
     desc = NULL;
     G_asprintf(&desc,
-	       "shape;%s;cat;%s;topo;%s;dir;%s;attr;%s;zcoor;%s",
+	       "shape;%s;cat;%s;topo;%s;vert;%s;dir;%s;attr;%s;zcoor;%s",
 	       _("Display geometry of features"),
 	       _("Display category numbers of features"),
 	       _("Display topology information (nodes, edges)"),
+               _("Display verteces of features"),
 	       _("Display direction of linear features"),
 	       _("Display selected attribute based on 'attrcolumn'"),
 	       _("Display z-coordinate of features (only for 3D vector maps)"));
@@ -474,6 +475,9 @@
 	if (display & DISP_ZCOOR)
 	    stat += display_zcoor(&Map, type, &lattr);
 
+	if (display & DISP_VERT)
+            stat += display_vert(&Map, type, &lattr, size);
+
 	if (display & DISP_TOPO)
             stat += display_topo(&Map, type, &lattr, size);
     }

Modified: grass/trunk/display/d.vect/opt.c
===================================================================
--- grass/trunk/display/d.vect/opt.c	2013-12-02 18:04:46 UTC (rev 58355)
+++ grass/trunk/display/d.vect/opt.c	2013-12-02 18:44:00 UTC (rev 58356)
@@ -19,6 +19,9 @@
 	case 'c':
 	    display |= DISP_CAT;
 	    break;
+	case 'v':
+	    display |= DISP_VERT;
+	    break;
 	case 't':
 	    display |= DISP_TOPO;
 	    break;

Modified: grass/trunk/display/d.vect/plot.h
===================================================================
--- grass/trunk/display/d.vect/plot.h	2013-12-02 18:04:46 UTC (rev 58355)
+++ grass/trunk/display/d.vect/plot.h	2013-12-02 18:44:00 UTC (rev 58356)
@@ -34,9 +34,10 @@
 #define DISP_SHAPE 0x01
 #define DISP_CAT   0x02
 #define DISP_TOPO  0x04
-#define DISP_DIR   0x08
-#define DISP_ATTR  0x10
-#define DISP_ZCOOR 0x20
+#define DISP_VERT  0x08
+#define DISP_DIR   0x10
+#define DISP_ATTR  0x20
+#define DISP_ZCOOR 0x40
 
 #define RENDER_DP	2
 #define RENDER_DPC	3

Added: grass/trunk/display/d.vect/vert.c
===================================================================
--- grass/trunk/display/d.vect/vert.c	                        (rev 0)
+++ grass/trunk/display/d.vect/vert.c	2013-12-02 18:44:00 UTC (rev 58356)
@@ -0,0 +1,44 @@
+#include <grass/gis.h>
+#include <grass/vector.h>
+#include <grass/display.h>
+#include <grass/glocale.h>
+#include "local_proto.h"
+#include "plot.h"
+
+int display_vert(struct Map_info *Map, int type, LATTR *lattr, double dsize)
+{
+    int ltype, i;
+    double msize;
+    struct line_pnts *Points;
+
+    msize = dsize * (D_d_to_u_col(2.0) - D_d_to_u_col(1.0));	/* do it better */
+    
+    G_debug(1, "display verteces:");
+    Points = Vect_new_line_struct();
+
+    D_RGB_color(lattr->color.R, lattr->color.G, lattr->color.B);
+
+    Vect_rewind(Map);
+    Vect_set_constraint_type(Map, type);
+    while(TRUE) {
+        ltype = Vect_read_next_line(Map, Points, NULL);
+	switch (ltype) {
+	case -1:
+	    G_fatal_error(_("Unable to read vector map"));
+	case -2:		/* EOF */
+	    return 0;
+	}
+
+        if (!(ltype & GV_LINES))
+            continue;
+        
+        for (i = 0; i < Points->n_points; i++) {
+            D_plot_icon(Points->x[i], Points->y[i], G_ICON_CROSS, 0, msize);
+        }
+    }
+    Vect_remove_constraints(Map);
+
+    Vect_destroy_line_struct(Points);
+
+    return 0;
+}


Property changes on: grass/trunk/display/d.vect/vert.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native



More information about the grass-commit mailing list