Переглянути джерело

d.vect: add option to display vertices (`display=vert`)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58356 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 роки тому
батько
коміт
c93778ab3f

+ 3 - 0
display/d.vect/local_proto.h

@@ -59,5 +59,8 @@ void option_to_where(struct Map_info *, struct cat_list *, const char *);
 /* 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 *);

+ 6 - 2
display/d.vect/main.c

@@ -86,14 +86,15 @@ int main(int argc, char **argv)
     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 @@ int main(int argc, char **argv)
 	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);
     }

+ 3 - 0
display/d.vect/opt.c

@@ -19,6 +19,9 @@ int option_to_display(const struct Option *opt)
 	case 'c':
 	    display |= DISP_CAT;
 	    break;
+	case 'v':
+	    display |= DISP_VERT;
+	    break;
 	case 't':
 	    display |= DISP_TOPO;
 	    break;

+ 4 - 3
display/d.vect/plot.h

@@ -34,9 +34,10 @@ typedef struct
 #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

+ 44 - 0
display/d.vect/vert.c

@@ -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;
+}