[GRASS-SVN] r35490 - grass/trunk/vector/v.net

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 19 17:31:58 EST 2009


Author: martinl
Date: 2009-01-19 17:31:57 -0500 (Mon, 19 Jan 2009)
New Revision: 35490

Added:
   grass/trunk/vector/v.net/arcs.c
   grass/trunk/vector/v.net/args.c
Modified:
   grass/trunk/vector/v.net/connect.c
   grass/trunk/vector/v.net/main.c
   grass/trunk/vector/v.net/nodes.c
   grass/trunk/vector/v.net/proto.h
   grass/trunk/vector/v.net/report.c
   grass/trunk/vector/v.net/v.net.html
Log:
v.net: general update
       new operation 'arcs'


Added: grass/trunk/vector/v.net/arcs.c
===================================================================
--- grass/trunk/vector/v.net/arcs.c	                        (rev 0)
+++ grass/trunk/vector/v.net/arcs.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -0,0 +1,103 @@
+#include <stdlib.h>
+#include <grass/gis.h>
+#include <grass/Vect.h>
+#include <grass/glocale.h>
+#include "proto.h"
+
+static int find_node(struct Map_info *, int, int);
+
+void field2n(struct line_cats *, int);
+
+/**
+ * \brief Create network arcs (edge) based on given point vector map (nodes)
+ *
+ * \param file input file defining arcs
+ * \param Points input vector point map
+ * \param Out output vector map
+ * \param afield arcs layer 
+ * \param nfield nodes layer 
+ *
+ * \return number of new arcs
+ */
+int create_arcs(FILE * file, struct Map_info *Pnts,
+		struct Map_info *Out, int afield, int nfield)
+{
+    char buff[1024];
+    int lcat, fcat, tcat;
+    int node1, node2;
+    int narcs;
+
+    struct line_pnts *points, *points2;
+    struct line_cats *cats;
+
+    points = Vect_new_line_struct();
+    points2 = Vect_new_line_struct();
+    points = Vect_new_line_struct();
+    cats = Vect_new_cats_struct();
+
+    narcs = 0;
+
+    while (G_getl2(buff, sizeof(buff) - 1, file)) {
+	if (sscanf(buff, "%d%d%d", &lcat, &fcat, &tcat) != 3)
+	    G_fatal_error(_("Error reading file: '%s'"), buff);
+
+	node1 = find_node(Pnts, afield, fcat);
+	node2 = find_node(Pnts, afield, tcat);
+
+	if (node1 < 1 || node2 < 1) {
+	    G_warning(_("Skipping arc %d"), lcat);
+	    continue;
+	}
+
+	/* geometry */
+	Vect_read_line(Pnts, points, cats, node1);
+	field2n(cats, nfield);
+	Vect_write_line(Out, GV_POINT, points, cats);
+	Vect_read_line(Pnts, points2, cats, node2);
+	field2n(cats, nfield);
+	Vect_write_line(Out, GV_POINT, points2, cats);
+	Vect_append_points(points, points2, GV_FORWARD);
+
+	/* category */
+	Vect_reset_cats(cats);
+	Vect_cat_set(cats, afield, lcat);
+	Vect_write_line(Out, GV_LINE, points, cats);
+
+	narcs++;
+    }
+
+    Vect_destroy_line_struct(points);
+    Vect_destroy_cats_struct(cats);
+
+    return narcs;
+}
+
+int find_node(struct Map_info *Pnts, int field, int cat)
+{
+    static struct ilist *list;
+
+    if (!list)
+	list = Vect_new_list();
+
+    /* find start node */
+    Vect_cidx_find_all(Pnts, field, GV_POINT, cat, list);
+    if (list->n_values < 1) {
+	G_warning(_("No point with category %d found"), cat);
+	return 0;
+    }
+    if (list->n_values > 1) {
+	G_warning(_("More points with category %d found"), cat);
+	return 0;
+    }
+
+    return list->value[0];
+}
+
+void field2n(struct line_cats *cats, int nfield)
+{
+    int n;
+
+    for (n = 0; n < cats->n_cats; n++) {
+	cats->field[n] = nfield;
+    }
+}


Property changes on: grass/trunk/vector/v.net/arcs.c
___________________________________________________________________
Name: svn:mime-type
   + text/x-csrc
Name: svn:keywords
   + Author Date Id
Name: svn:eol-style
   + native

Added: grass/trunk/vector/v.net/args.c
===================================================================
--- grass/trunk/vector/v.net/args.c	                        (rev 0)
+++ grass/trunk/vector/v.net/args.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -0,0 +1,137 @@
+#include <grass/Vect.h>
+#include <grass/glocale.h>
+
+#include "proto.h"
+
+void define_options(struct opt *opt)
+{
+    opt->input = G_define_standard_option(G_OPT_V_INPUT);
+    opt->input->required = NO;
+    opt->input->label = _("Name of input vector line map (arcs)");
+    opt->input->description = _("Required for operation 'nodes', 'connect', "
+				"'report' and 'nreport'");
+    opt->input->guisection = _("Arcs");
+
+    opt->points = G_define_standard_option(G_OPT_V_INPUT);
+    opt->points->key = "points";
+    opt->points->label = _("Name of input vector point map (nodes)");
+    opt->points->description =
+	_("Required for operation 'connect' and 'arcs'");
+    opt->points->required = NO;
+    opt->points->guisection = _("Nodes");
+
+    opt->output = G_define_standard_option(G_OPT_V_OUTPUT);
+    opt->output->required = NO;
+
+    opt->action = G_define_option();
+    opt->action->key = "operation";
+    opt->action->type = TYPE_STRING;
+    opt->action->required = YES;
+    opt->action->multiple = NO;
+    opt->action->options = "nodes,connect,arcs,report,nreport";
+    opt->action->description = _("Operation to be performed");
+    opt->action->descriptions =
+	_("nodes;"
+	  "new point is placed on each node (line end) "
+	  "if doesn't exist;"
+	  "connect;"
+	  "connect still unconnected points to vector network "
+	  "by inserting new line(s);"
+	  "arcs;"
+	  "new line is created from start point "
+	  "to end point;"
+	  "report;"
+	  "print to standard output "
+	  "{line_category start_point_category end_point_category};"
+	  "nreport;"
+	  "print to standard output "
+	  "{point_category line_category[,line_category...]}");
+
+    opt->afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    opt->afield_opt->key = "alayer";
+    opt->afield_opt->gisprompt = "new_layer,layer,layer";
+    opt->afield_opt->label = _("Arc layer");
+    opt->afield_opt->guisection = _("Arcs");
+
+    opt->nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    opt->nfield_opt->key = "nlayer";
+    opt->nfield_opt->answer = "2";
+    opt->nfield_opt->gisprompt = "new_layer,layer,layer";
+    opt->nfield_opt->label = _("Node layer");
+    opt->nfield_opt->guisection = _("Nodes");
+
+    opt->thresh_opt = G_define_option();
+    opt->thresh_opt->key = "thresh";
+    opt->thresh_opt->type = TYPE_DOUBLE;
+    opt->thresh_opt->required = NO;
+    opt->thresh_opt->multiple = NO;
+    opt->thresh_opt->label = "Threshold";
+    opt->thresh_opt->description =
+	_("Required for operation 'connect'. Connect points in given threshold.");
+
+    opt->file = G_define_standard_option(G_OPT_F_INPUT);
+    opt->file->key = "file";
+    opt->file->label = _("Name of input file");
+    opt->file->description =
+	_("Required for operation 'arcs'. '-' for standard input.");
+    opt->file->required = NO;
+
+    opt->cats_flag = G_define_flag();
+    opt->cats_flag->key = 'c';
+    opt->cats_flag->label = _("Assign unique categories to new points");
+    opt->cats_flag->description = _("For operation 'nodes'");
+    opt->cats_flag->guisection = _("Nodes");
+}
+
+void parse_arguments(const struct opt *opt,
+		     int *afield, int *nfield, double *thresh, int *act)
+{
+    *afield = atoi(opt->afield_opt->answer);
+    *nfield = atoi(opt->nfield_opt->answer);
+    *thresh = 0.0;
+
+    if (strcmp(opt->action->answer, "nodes") == 0)
+	*act = TOOL_NODES;
+    else if (strcmp(opt->action->answer, "connect") == 0)
+	*act = TOOL_CONNECT;
+    else if (strcmp(opt->action->answer, "report") == 0)
+	*act = TOOL_REPORT;
+    else if (strcmp(opt->action->answer, "nreport") == 0)
+	*act = TOOL_NREPORT;
+    else if (strcmp(opt->action->answer, "arcs") == 0)
+	*act = TOOL_ARCS;
+    else
+	G_fatal_error(_("Unknown operation"));
+
+    if (*act == TOOL_NODES || *act == TOOL_CONNECT ||
+	*act == TOOL_REPORT || *act == TOOL_NREPORT) {
+	if (opt->input->answer == NULL)
+	    G_fatal_error(_("Required parameter <%s> not set"),
+			  opt->input->key);
+    }
+
+    if (*act == TOOL_NODES || *act == TOOL_CONNECT) {
+	if (opt->output->answer == NULL)
+	    G_fatal_error(_("Required parameter <%s> not set"),
+			  opt->output->key);
+    }
+
+    if (*act == TOOL_CONNECT) {
+	if (opt->points->answer == NULL)
+	    G_fatal_error(_("Required parameter <%s> not set"),
+			  opt->points->key);
+
+	if (opt->thresh_opt->answer == NULL)
+	    G_fatal_error(_("Required parameter <%s> not set"),
+			  opt->thresh_opt->key);
+
+	*thresh = atof(opt->thresh_opt->answer);
+
+	if (*thresh < 0.0)
+	    G_fatal_error(_("Threshold value must be >= 0"));
+    }
+
+    if (*act == TOOL_ARCS && !opt->file->answer) {
+	G_fatal_error(_("Required parameter <%s> not set"), opt->file->key);
+    }
+}


Property changes on: grass/trunk/vector/v.net/args.c
___________________________________________________________________
Name: svn:mime-type
   + text/x-csrc
Name: svn:keywords
   + Author Date Id
Name: svn:eol-style
   + native

Modified: grass/trunk/vector/v.net/connect.c
===================================================================
--- grass/trunk/vector/v.net/connect.c	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/connect.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -1,24 +1,6 @@
-
-/***************************************************************
- *
- * MODULE:       v.net
- * 
- * AUTHOR(S):    Martin Landa <landa.martin gmail.com>
- *               
- * PURPOSE:      Network maintenance
- *               
- * COPYRIGHT:    (C) 2007 by the GRASS Development Team
- *
- *               This program is free software under the 
- *               GNU General Public License (>=v2). 
- *               Read the file COPYING that comes with GRASS
- *               for details.
- *
- **************************************************************/
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/Vect.h>
-#include <grass/glocale.h>
 #include "proto.h"
 
 /**
@@ -27,10 +9,10 @@
  * If there is no connection between network edge and point, new edge
  * is added, the line broken, and new point added to nfield layer
  *
- * \param[in] In,Points input vector maps
- * \param[in] Out output vector map
- * \param[in] nfield nodes layer 
- * \param[in] thresh threshold value to find neareast line
+ * \param In,Points input vector maps
+ * \param Out output vector map
+ * \param nfield nodes layer 
+ * \param thresh threshold value to find neareast line
  *
  * \return number of new arcs
  */

Modified: grass/trunk/vector/v.net/main.c
===================================================================
--- grass/trunk/vector/v.net/main.c	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/main.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -4,12 +4,11 @@
  * MODULE:       v.net
  * 
  * AUTHOR(S):    Radim Blazek
- *               Operation 'connect' added by Martin Landa
- *                <landa.martin gmail.com>, 2007/07
+ *               Martin Landa <landa.martin gmail.com> (connect/arcs)
  *               
  * PURPOSE:      Network maintenance
  *               
- * COPYRIGHT:    (C) 2001-2008 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2001-2009 by the GRASS Development Team
  *
  *               This program is free software under the 
  *               GNU General Public License (>=v2). 
@@ -21,183 +20,155 @@
 #include <stdio.h>
 #include <string.h>
 #include <grass/gis.h>
-#include <grass/glocale.h>
 #include <grass/Vect.h>
+#include <grass/glocale.h>
 #include "proto.h"
 
 int main(int argc, char **argv)
 {
     struct GModule *module;
-    struct Option *input, *points;
-    struct Option *output;
-    struct Option *action;
-    struct Option *afield_opt, *nfield_opt, *thresh_opt;
-    struct Flag *cats_flag;
-    struct Map_info In, Out, Points;
+    struct opt opt;
+    struct Map_info *In, *Out, *Points;
 
+    FILE *file_arcs;
+
     int afield, nfield;
     int act;
     double thresh;
 
-    /*  Initialize the GIS calls */
+    char message[4096];
+    
+    /*  initialize the GIS calls */
     G_gisinit(argv[0]);
 
     module = G_define_module();
     module->keywords = _("vector, networking");
     module->description = _("Performs network maintenance.");
 
-    /* Define the options */
-    input = G_define_standard_option(G_OPT_V_INPUT);
+    define_options(&opt);
 
-    points = G_define_standard_option(G_OPT_V_INPUT);
-    points->key = "points";
-    points->label = _("Name of input point vector map");
-    points->description = _("Required for operation 'connect'");
-    points->required = NO;
-
-    output = G_define_standard_option(G_OPT_V_OUTPUT);
-    output->required = NO;
-
-    action = G_define_option();
-    action->key = "operation";
-    action->type = TYPE_STRING;
-    action->required = NO;
-    action->multiple = NO;
-    action->answer = "nodes";
-    action->options = "nodes,connect,report,nreport";
-    action->description = _("Operation to be performed");
-    action->descriptions =
-	_("nodes;new point is placed on each node (line end) "
-	  "if doesn't exist;"
-	  "connect;connect still unconnected points to vector network "
-	  "by inserting new line(s);" "report;print to standard output "
-	  "{line_category start_point_category end_point_category};"
-	  "nreport;print to standard output "
-	  "{point_category line_category[,line_category...]}");
-
-    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
-    afield_opt->key = "alayer";
-    afield_opt->gisprompt = "new_layer,layer,layer";
-    afield_opt->label = _("Arc layer");
-
-    nfield_opt = G_define_standard_option(G_OPT_V_FIELD);
-    nfield_opt->key = "nlayer";
-    nfield_opt->answer = "2";
-    nfield_opt->gisprompt = "new_layer,layer,layer";
-    nfield_opt->label = _("Node layer");
-
-    thresh_opt = G_define_option();
-    thresh_opt->key = "thresh";
-    thresh_opt->type = TYPE_DOUBLE;
-    thresh_opt->required = NO;
-    thresh_opt->multiple = NO;
-    thresh_opt->label = "Threshold";
-    thresh_opt->description =
-	_("Required for operation 'connect'. Connect points in given threshold.");
-
-    cats_flag = G_define_flag();
-    cats_flag->key = 'c';
-    cats_flag->label = _("Assign unique categories to new points");
-    cats_flag->description = _("For operation 'nodes'");
-
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
 
-    afield = atoi(afield_opt->answer);
-    nfield = atoi(nfield_opt->answer);
-    thresh = 0.0;
+    parse_arguments(&opt, &afield, &nfield, &thresh, &act);
 
-    if (strcmp(action->answer, "nodes") == 0)
-	act = TOOL_NODES;
-    else if (strcmp(action->answer, "connect") == 0)
-	act = TOOL_CONNECT;
-    else if (strcmp(action->answer, "report") == 0)
-	act = TOOL_REPORT;
-    else if (strcmp(action->answer, "nreport") == 0)
-	act = TOOL_NREPORT;
-    else
-	G_fatal_error(_("Unknown operation"));
-
-    if (act == TOOL_NODES || act == TOOL_CONNECT) {
-	if (output->answer == NULL)
-	    G_fatal_error(_("Output vector map must be specified"));
+    In = Points = Out = NULL;
+    file_arcs = NULL;
+    message[0] = '\0';
+    
+    /* open input map */
+    if (act != TOOL_ARCS) {
+	In = (struct Map_info *)G_malloc(sizeof(struct Map_info));
+	Vect_set_open_level(2);
+	if (Vect_open_old(In, opt.input->answer, "") == -1)
+	    G_fatal_error(_("Unable to open vector map <%s>"),
+			  opt.input->answer);
     }
 
-    if (act == TOOL_CONNECT) {
-	if (points->answer == NULL)
-	    G_fatal_error(_("Point vector map must be specified"));
-
-	if (thresh_opt->answer == NULL)
-	    G_fatal_error(_("Threshold value must be specified"));
-
-	thresh = atof(thresh_opt->answer);
-
-	if (thresh < 0.0)
-	    G_fatal_error(_("Threshold value must be >= 0"));
-    }
-
-    /* open input map */
-    Vect_set_open_level(2);
-    Vect_open_old(&In, input->answer, "");
-
-    if (act == TOOL_NODES || act == TOOL_CONNECT) {	/* nodes */
+    if (act == TOOL_NODES || act == TOOL_CONNECT || act == TOOL_ARCS) {
 	int is3d;
 
-	Vect_check_input_output_name(input->answer, output->answer,
-				     GV_FATAL_EXIT);
+	/* non-report operations */
+	if (act != TOOL_ARCS) {
+	    /* check input-output */
+	    Vect_check_input_output_name(opt.input->answer,
+					 opt.output->answer, GV_FATAL_EXIT);
+	}
 
-	if (act == TOOL_CONNECT) {
+	if (act == TOOL_CONNECT || act == TOOL_ARCS) {
 	    /* open points map */
-	    Vect_set_open_level(1);
-	    Vect_set_fatal_error(GV_FATAL_PRINT);
-	    if (Vect_open_old(&Points, points->answer, "") == -1) {
-		Vect_close(&In);
+	    Points = (struct Map_info *)G_malloc(sizeof(struct Map_info));
+	    if (act == TOOL_CONNECT)
+		Vect_set_open_level(1);
+	    else
+		Vect_set_open_level(2);
+	    if (Vect_open_old(Points, opt.points->answer, "") == -1) {
+		if (In)
+		    Vect_close(In);
 		G_fatal_error(_("Unable to open vector map <%s>"),
-			      points->answer);
+			      opt.points->answer);
 	    }
+
+	    if (act == TOOL_ARCS) {
+		/* open input file */
+		if (strcmp(opt.file->answer, "-")) {
+		    if ((file_arcs = fopen(opt.file->answer, "r")) == NULL) {
+			G_fatal_error(_("Unable to open file <%s>"),
+				      opt.file->answer);
+		    }
+		}
+		else {
+		    file_arcs = stdin;
+		}
+	    }
 	}
 
 	/* create output map */
-	is3d = Vect_is_3d(&In);
-	Vect_set_fatal_error(GV_FATAL_PRINT);
-	if (1 > Vect_open_new(&Out, output->answer, is3d)) {
-	    Vect_close(&In);
+	Out = (struct Map_info *)G_malloc(sizeof(struct Map_info));
+	is3d = WITHOUT_Z;
+	if (In)
+	    is3d = Vect_is_3d(In);
+	else if (Points)
+	    is3d = Vect_is_3d(Points);
+
+	if (Vect_open_new(Out, opt.output->answer, is3d) == -1) {
+	    if (In)
+		Vect_close(In);
 	    G_fatal_error(_("Unable to open vector map <%s> at topology level %d"),
-			  output->answer, 2);
+			  opt.output->answer, 2);
 	}
 
-	Vect_copy_head_data(&In, &Out);
-	Vect_hist_copy(&In, &Out);
-	Vect_hist_command(&Out);
+	/* copy header */
+	if (In) {
+	    Vect_copy_head_data(In, Out);
+	    Vect_hist_copy(In, Out);
+	}
+	Vect_hist_command(Out);
 
 	if (act == TOOL_NODES) {
-	    nodes(&In, &Out, cats_flag->answer, nfield);
+	    /* nodes */
+	    int nnodes;
+	    nnodes = nodes(In, Out, opt.cats_flag->answer, nfield);
+
+	    sprintf (message, _("%d new points (nodes) written to output."), nnodes);
 	}
-	else {			/* TOOL_CONNECT */
+	else {			/* connect or arcs */
 	    int narcs;
 
-	    narcs = connect_arcs(&In, &Points, &Out, nfield, thresh);
+	    if (act == TOOL_CONNECT)
+		narcs = connect_arcs(In, Points, Out, nfield, thresh);
+	    else
+		narcs = create_arcs(file_arcs, Points, Out, afield, nfield);
 
-	    G_message(_("%d arcs added to network (nlayer %d)"), narcs,
-		      nfield);
-
-	    Vect_close(&Points);
+	    sprintf(message, _("%d lines (arcs) written to output."), narcs, nfield);
 	}
 
-        if (Vect_copy_tables(&In, &Out, 0))
-            G_warning(_("Failed to copy attribute table to output map"));
-
+	if (In) {
+	  G_message (_("Copying attributes..."));
+	  if (Vect_copy_tables(In, Out, 0))
+	    G_warning(_("Failed to copy attribute table to output map"));
+	}
+	
 	/* support */
-	Vect_build_partial(&Out, GV_BUILD_NONE);
-	Vect_build(&Out);
+	Vect_build_partial(Out, GV_BUILD_NONE);
+	Vect_build(Out);
 
-	Vect_close(&In);
-	Vect_close(&Out);
+	if (Points)
+	    Vect_close(Points);
+	if (Out)
+	    Vect_close(Out);
     }
     else {			/* report */
-
-	report(&In, afield, nfield, act);
+	report(In, afield, nfield, act);
     }
 
+    if (In)
+	Vect_close(In);
+
+    if (file_arcs)
+	fclose(file_arcs);
+
+    G_done_msg(message);
+
     return (EXIT_SUCCESS);
 }

Modified: grass/trunk/vector/v.net/nodes.c
===================================================================
--- grass/trunk/vector/v.net/nodes.c	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/nodes.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -1,20 +1,3 @@
-
-/***************************************************************
- *
- * MODULE:       v.net
- * 
- * AUTHOR(S):    Radim Blazek
- *               
- * PURPOSE:      Network maintenance
- *               
- * COPYRIGHT:    (C) 2001 by the GRASS Development Team
- *
- *               This program is free software under the 
- *               GNU General Public License (>=v2). 
- *               Read the file COPYING that comes with GRASS
- *               for details.
- *
- **************************************************************/
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/Vect.h>
@@ -25,8 +8,10 @@
 {
     int i, node, nnodes, line, nlines, count, type, found;
     double x, y, z;
+
     struct line_pnts *Points, *Pout;
     struct line_cats *Cats;
+
     int cat;
 
     Points = Vect_new_line_struct();
@@ -82,11 +67,9 @@
 	}
     }
 
-    G_message(_("%d new points written to output"), count);
-
     Vect_destroy_line_struct(Points);
     Vect_destroy_line_struct(Pout);
     Vect_destroy_cats_struct(Cats);
 
-    return 0;
+    return count;
 }

Modified: grass/trunk/vector/v.net/proto.h
===================================================================
--- grass/trunk/vector/v.net/proto.h	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/proto.h	2009-01-19 22:31:57 UTC (rev 35490)
@@ -2,14 +2,34 @@
 #define TOOL_CONNECT 1
 #define TOOL_REPORT  2
 #define TOOL_NREPORT 3
+#define TOOL_ARCS    4
 
+struct opt {
+    struct Option *input, *points;
+    struct Option *output;
+    struct Option *action;
+    struct Option *afield_opt, *nfield_opt, *thresh_opt;
+    struct Option *file;
+    struct Flag *cats_flag;
+};
+
+/* arcs.c */
+int create_arcs(FILE *, struct Map_info *,
+		struct Map_info *, int, int);
+
+/* argc.c */
+void define_options(struct opt *);
+void parse_arguments(const struct opt *,
+		     int *, int *, double *, int *);
+
 /* connect.c */
-int connect_arcs(struct Map_info *In, struct Map_info *Pnts,
-		 struct Map_info *Out, int nfield, double thresh);
+int connect_arcs(struct Map_info *, struct Map_info *,
+		 struct Map_info *, int, double);
 
 /* nodes.c */
-int nodes(struct Map_info *In, struct Map_info *Out, int add_cats,
-	  int nfield);
+int nodes(struct Map_info *, struct Map_info *, int,
+	  int);
 
 /* report.c */
-int report(struct Map_info *In, int afield, int nfield, int action);
+int report(struct Map_info *, int, int,
+	   int);

Modified: grass/trunk/vector/v.net/report.c
===================================================================
--- grass/trunk/vector/v.net/report.c	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/report.c	2009-01-19 22:31:57 UTC (rev 35490)
@@ -1,20 +1,3 @@
-
-/***************************************************************
- *
- * MODULE:       v.net
- * 
- * AUTHOR(S):    Radim Blazek
- *               
- * PURPOSE:      Network maintenance 
- *               
- * COPYRIGHT:    (C) 2001 by the GRASS Development Team
- *
- *               This program is free software under the 
- *               GNU General Public License (>=v2). 
- *               Read the file COPYING that comes with GRASS
- *               for details.
- *
- **************************************************************/
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/Vect.h>
@@ -25,7 +8,9 @@
 {
     int i, j, k, line, ltype, nnodes;
     int cat_line, cat_node[2];
+
     struct line_cats *Cats, *Cats2;
+
     int node;
     double x, y, z;
 

Modified: grass/trunk/vector/v.net/v.net.html
===================================================================
--- grass/trunk/vector/v.net/v.net.html	2009-01-19 21:06:38 UTC (rev 35489)
+++ grass/trunk/vector/v.net/v.net.html	2009-01-19 22:31:57 UTC (rev 35490)
@@ -1,9 +1,9 @@
 <h2>DESCRIPTION</h2>
 
-<em>v.net</em> is used for vector network maps maintenance.
-It reports about the current network graph status.
-It also permits to globally insert missing nodes and to connect
-unconnected nodes to the graph within a given distance threshold.
+<em>v.net</em> is used for vector network maps maintenance.  It
+reports the current network graph status. It also permits to globally
+insert missing nodes or arcs and to connect unconnected nodes to the
+graph within a given distance threshold.
 
 <h3>NOTES</h3>
 
@@ -11,37 +11,45 @@
 graph, <em><a href="wxGUI.Vector_Digitizing_Tool.html">wxGUI vector
 digitizer</a></em> or <em><a href="v.edit.html">v.edit</a></em> can be
 used. Separately,
-<a HREF="lrs.html">Linear Referencing System</a> is available
-in GRASS.
+<a href="lrs.html">Linear Referencing System</a> is available in
+GRASS.
 
 <h3>EXAMPLES</h3>
 
-Spearfish based examples:<P>
+<a href="http://www.grassbook.org/data_menu3rd.php">NC dataset</a> based examples.
 
+<p>
 Create nodes globally for all line ends and intersections:
-<br>
+
 <div class="code"><pre>
-v.net in=streams out=streams_node
+v.net input=streams output=streams_node operation=nodes
 </pre></div>
 
-<P>
 Merge in nodes from a separate map within given threshold:
-<br>
+
 <div class="code"><pre>
-echo "1|601653.5|4922869.2|start
-2|593330.8|4924096.6|end" | v.in.ascii cat=1 x=2 y=3 out=startend col="cat integer, \
-                         east double precision, north double precision, label varchar(43)"
+v.net input=streams points=firestations out=streems_net operation=connect thresh=500
+</pre></div>
 
-#create lines map connecting points to network (on layer 2)
-v.net myroads points=startend out=myroads_net op=connect thresh=200
+For generating network for given vector point map is required input file in format
+
+<div class="code"><pre>
+[category of edge] [category of start node] [category of end node]
 </pre></div>
 
+<div class="code"><pre>
+v.net points=geodetic_swwake_pts output=geodetic_swwake_pts_net operation=arcs file=- << EOF
+> 1 28000 28005
+> 2 27945 27958
+> 3 27886 27897
+> EOF
+</pre></div>
 
 <h2>SEE ALSO</h2>
 
 <em>
   <a href="wxGUI.Vector_Digitizing_Tool.html">wxGUI vector digitizer</a>,
-  <a HREF="v.edit.html">v.edit</a>,
+  <a HREF="v.edit.html">v.edit</a><br>
   <a HREF="v.net.iso.html">v.net.iso</a>,
   <a HREF="v.net.path.html">v.net.path</a>,
   <a HREF="v.net.steiner.html">v.net.steiner</a>,
@@ -50,7 +58,10 @@
 
 <h2>AUTHORS</h2>
 
-Radim Blazek, ITC-Irst, Trento, Italy<BR>
-Martin Landa, FBK-Irst, Trento, Italy
+Radim Blazek, ITC-irst, Trento, Italy<br>
 
-<p><i>Last changed: $Date$</i>
+Martin Landa, FBK-irst (formerly ITC-irst), Trento, Italy and CTU in
+Prague, Czech Republic (operation 'connect' and 'arcs')
+
+<p>
+<i>Last changed: $Date$</i>



More information about the grass-commit mailing list