[GRASS-SVN] r56603 - in grass-addons/grass7/vector: . v.net.alloc2

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 5 04:21:44 PDT 2013


Author: turek
Date: 2013-06-05 04:21:44 -0700 (Wed, 05 Jun 2013)
New Revision: 56603

Added:
   grass-addons/grass7/vector/v.net.alloc2/
   grass-addons/grass7/vector/v.net.alloc2/Makefile
   grass-addons/grass7/vector/v.net.alloc2/main.c
   grass-addons/grass7/vector/v.net.alloc2/v.net.alloc.html
   grass-addons/grass7/vector/v.net.alloc2/v_net_alloc.png
   grass-addons/grass7/vector/v.net.alloc2/v_net_alloc_time.png
Log:
v.net.alloc2: dev version of v.net.alloc module with turns support

Added: grass-addons/grass7/vector/v.net.alloc2/Makefile
===================================================================
--- grass-addons/grass7/vector/v.net.alloc2/Makefile	                        (rev 0)
+++ grass-addons/grass7/vector/v.net.alloc2/Makefile	2013-06-05 11:21:44 UTC (rev 56603)
@@ -0,0 +1,17 @@
+
+MODULE_TOPDIR = ../..
+
+PGM = v.net.alloc2
+
+LIBES = $(VECTORLIB) $(GISLIB)
+DEPENDENCIES = $(VECTORDEP) $(GISDEP)
+EXTRA_INC = $(VECT_INC)
+EXTRA_CFLAGS = $(VECT_CFLAGS)
+
+include $(MODULE_TOPDIR)/include/Make/Module.make
+
+default: cmd
+
+
+
+

Added: grass-addons/grass7/vector/v.net.alloc2/main.c
===================================================================
--- grass-addons/grass7/vector/v.net.alloc2/main.c	                        (rev 0)
+++ grass-addons/grass7/vector/v.net.alloc2/main.c	2013-06-05 11:21:44 UTC (rev 56603)
@@ -0,0 +1,473 @@
+
+/****************************************************************
+ * 
+ *  MODULE:       v.net.alloc2
+ *  
+ *  AUTHOR(S):    Radim Blazek
+ *                
+ *  PURPOSE:      Allocate subnets for nearest centers.
+ *                
+ *  COPYRIGHT:    (C) 2001, 2013 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 <string.h>
+#include <time.h>
+#include <grass/gis.h>
+#include <grass/vector.h>
+#include <grass/dbmi.h>
+#include <grass/glocale.h>
+
+typedef struct
+{
+    int cat;			/* category number */
+    int node;			/* node number */
+} CENTER;
+
+typedef struct
+{
+    int center;			/* neares center, initially -1 */
+    double cost;		/* costs from this center, initially not undefined */
+} NODE;
+
+int main(int argc, char **argv)
+{
+    int i, j, ret, center, line, center1, center2;
+    int nlines, nnodes, type, ltype, afield, nfield, geo, cat, tfield,
+	tucfield;
+    int node1, node2;
+    double cost, e1cost, e2cost, n1cost, n2cost, s1cost, s2cost, l, l1, l2;
+    struct Option *map, *output;
+    struct Option *afield_opt, *nfield_opt, *afcol, *abcol, *ncol, *type_opt,
+	*term_opt, *tfield_opt, *tucfield_opt;
+    struct Flag *geo_f, *turntable_f;
+    struct GModule *module;
+    struct Map_info Map, Out;
+    struct cat_list *catlist;
+    CENTER *Centers = NULL;
+    int acenters = 0, ncenters = 0;
+    NODE *Nodes;
+    struct line_cats *Cats;
+    struct line_pnts *Points, *SPoints;
+
+    G_gisinit(argv[0]);
+
+    module = G_define_module();
+    G_add_keyword(_("vector"));
+    G_add_keyword(_("network"));
+    G_add_keyword(_("allocation"));
+    module->label =
+	_("Allocate subnets for nearest centers (direction from center).");
+    module->description =
+	_("center node must be opened (costs >= 0). "
+	  "Costs of center node are used in calculation");
+
+
+    map = G_define_standard_option(G_OPT_V_INPUT);
+    output = G_define_standard_option(G_OPT_V_OUTPUT);
+
+    type_opt = G_define_standard_option(G_OPT_V_TYPE);
+    type_opt->options = "line,boundary";
+    type_opt->answer = "line,boundary";
+    type_opt->description = _("Arc type");
+
+    afield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    afield_opt->key = "alayer";
+    afield_opt->answer = "1";
+    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->label = _("Node layer");
+
+    tfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    tfield_opt->key = "tlayer";
+    tfield_opt->answer = "3";
+    tfield_opt->label = _("Turntable layer");
+
+    tucfield_opt = G_define_standard_option(G_OPT_V_FIELD);
+    tucfield_opt->key = "tuclayer";
+    tucfield_opt->answer = "4";
+    tucfield_opt->label = _("Unique categories layer for turntable");
+
+    afcol = G_define_option();
+    afcol->key = "afcolumn";
+    afcol->type = TYPE_STRING;
+    afcol->required = NO;
+    afcol->description =
+	_("Arc forward/both direction(s) cost column (number)");
+
+    abcol = G_define_option();
+    abcol->key = "abcolumn";
+    abcol->type = TYPE_STRING;
+    abcol->required = NO;
+    abcol->description = _("Arc backward direction cost column (number)");
+
+    ncol = G_define_option();
+    ncol->key = "ncolumn";
+    ncol->type = TYPE_STRING;
+    ncol->required = NO;
+    ncol->description = _("Node cost column (number)");
+
+    term_opt = G_define_standard_option(G_OPT_V_CATS);
+    term_opt->key = "ccats";
+    term_opt->required = YES;
+    term_opt->description =
+	_("Categories of centers (points on nodes) to which net "
+	  "will be allocated, "
+	  "layer for this categories is given by nlayer option");
+
+    geo_f = G_define_flag();
+    geo_f->key = 'g';
+    geo_f->description =
+	_("Use geodesic calculation for longitude-latitude locations");
+
+    turntable_f = G_define_flag();
+    turntable_f->key = 't';
+    turntable_f->description = _("Use turntable"
+				 "(otherwise tuclayer and tlayer are ignored)");
+
+    if (G_parser(argc, argv))
+	exit(EXIT_FAILURE);
+
+    Vect_check_input_output_name(map->answer, output->answer, G_FATAL_EXIT);
+
+    Cats = Vect_new_cats_struct();
+    Points = Vect_new_line_struct();
+    SPoints = Vect_new_line_struct();
+
+    type = Vect_option_to_types(type_opt);
+
+    catlist = Vect_new_cat_list();
+    Vect_str_to_cat_list(term_opt->answer, catlist);
+
+    if (geo_f->answer)
+	geo = 1;
+    else
+	geo = 0;
+
+    Vect_set_open_level(2);
+    Vect_open_old(&Map, map->answer, "");
+
+    afield = Vect_get_field_number(&Map, afield_opt->answer);
+    nfield = Vect_get_field_number(&Map, nfield_opt->answer);
+    tfield = Vect_get_field_number(&Map, tfield_opt->answer);
+    tucfield = Vect_get_field_number(&Map, tucfield_opt->answer);
+
+    /* Build graph */
+    if (turntable_f->answer)
+	Vect_net_ttb_build_graph(&Map, type, afield, nfield, tfield, tucfield,
+				 afcol->answer, abcol->answer, ncol->answer,
+				 geo, 0);
+    else
+	Vect_net_build_graph(&Map, type, afield, nfield, afcol->answer,
+			     abcol->answer, ncol->answer, geo, 0);
+
+
+    nnodes = Vect_get_num_nodes(&Map);
+    nlines = Vect_get_num_lines(&Map);
+
+    /* Create list of centers based on list of categories */
+    for (i = 1; i <= nlines; i++) {
+	int node;
+
+	ltype = Vect_get_line_type(&Map, i);
+	if (!(ltype & GV_POINT))
+	    continue;
+
+	Vect_read_line(&Map, Points, Cats, i);
+	node =
+	    Vect_find_node(&Map, Points->x[0], Points->y[0], Points->z[0], 0,
+			   0);
+	if (!node) {
+	    G_warning(_("Point is not connected to the network"));
+	    continue;
+	}
+	if (!(Vect_cat_get(Cats, nfield, &cat)))
+	    continue;
+	if (Vect_cat_in_cat_list(cat, catlist)) {
+	    Vect_net_get_node_cost(&Map, node, &n1cost);
+	    if (n1cost == -1) {	/* closed */
+		G_warning("Centre at closed node (costs = -1) ignored");
+	    }
+	    else {
+		if (acenters == ncenters) {
+		    acenters += 1;
+		    Centers =
+			(CENTER *) G_realloc(Centers,
+					     acenters * sizeof(CENTER));
+		}
+		Centers[ncenters].cat = cat;
+		Centers[ncenters].node = node;
+		G_debug(2, "centre = %d node = %d cat = %d", ncenters,
+			node, cat);
+		ncenters++;
+	    }
+	}
+    }
+
+    G_message(_("Number of centers: [%d] (nlayer: [%d])"), ncenters, nfield);
+
+    if (ncenters == 0)
+	G_warning(_("Not enough centers for selected nlayer. "
+		    "Nothing will be allocated."));
+
+    /* alloc and reset space for all lines */
+    if (turntable_f->answer) {
+
+	/* if turntable is used we are looking for lines as destinations, not the intersections (nodes) */
+	Nodes = (NODE *) G_calloc((nlines * 2 + 2), sizeof(NODE));
+	for (i = 2; i <= (nlines * 2 + 2); i++) {
+	    Nodes[i].center = -1;
+	}
+
+    }
+    else {
+	Nodes = (NODE *) G_calloc((nnodes + 1), sizeof(NODE));
+	for (i = 1; i <= nnodes; i++) {
+	    Nodes[i].center = -1;
+	}
+    }
+
+    /* Fill Nodes by nearest center and costs from that center */
+    G_message(_("Calculating costs from centers ..."));
+
+    for (center = 0; center < ncenters; center++) {
+	G_percent(center, ncenters, 1);
+	node1 = Centers[center].node;
+	Vect_net_get_node_cost(&Map, node1, &n1cost);
+	G_debug(2, "center = %d node = %d cat = %d", center, node1,
+		Centers[center].cat);
+
+	if (turntable_f->answer)
+	    for (line = 1; line <= nlines; line++) {
+		G_debug(5, "  node1 = %d line = %d", node1, line);
+		Vect_net_get_node_cost(&Map, line, &n2cost);
+		/* closed, left it as not attached */
+
+		if (Vect_read_line(&Map, Points, Cats, line) < 0)
+		    continue;
+		if (Vect_get_line_type(&Map, line) != GV_LINE)
+		    continue;
+		if (!Vect_cat_get(Cats, tucfield, &cat))
+		    continue;
+
+		for (j = 0; j < 2; j++) {
+		    if (j == 1)
+			cat *= -1;
+
+		    ret =
+			Vect_net_ttb_shortest_path(&Map, node1, 0, cat, 1,
+						   tfield, tucfield, NULL,
+						   &cost);
+		    if (ret == -1) {
+			continue;
+		    }		/* node unreachable */
+
+		    /* We must add center node costs (not calculated by Vect_net_shortest_path() ), but
+		     *  only if center and node are not identical, because at the end node cost is add later */
+		    if (ret != 1)
+			cost += n1cost;
+
+		    G_debug(5,
+			    "Arc nodes: %d %d cost: %f (x old cent: %d old cost %f",
+			    node1, line, cost, Nodes[line * 2 + j].center,
+			    Nodes[line * 2 + j].cost);
+		    if (Nodes[line * 2 + j].center == -1 ||
+			cost < Nodes[line * 2 + j].cost) {
+			Nodes[line * 2 + j].cost = cost;
+			Nodes[line * 2 + j].center = center;
+		    }
+		}
+	    }
+	else
+	    for (node2 = 1; node2 <= nnodes; node2++) {
+		G_debug(5, "  node1 = %d node2 = %d", node1, node2);
+		Vect_net_get_node_cost(&Map, node2, &n2cost);
+		if (n2cost == -1) {
+		    continue;
+		}		/* closed, left it as not attached */
+
+		ret = Vect_net_shortest_path(&Map, node1, node2, NULL, &cost);
+		if (ret == -1) {
+		    continue;
+		}		/* node unreachable */
+
+		/* We must add center node costs (not calculated by Vect_net_shortest_path() ), but
+		 *  only if center and node are not identical, because at the end node cost is add later */
+		if (node1 != node2)
+		    cost += n1cost;
+
+		G_debug(5,
+			"Arc nodes: %d %d cost: %f (x old cent: %d old cost %f",
+			node1, node2, cost, Nodes[node2].center,
+			Nodes[node2].cost);
+		if (Nodes[node2].center == -1 || cost < Nodes[node2].cost) {
+		    Nodes[node2].cost = cost;
+		    Nodes[node2].center = center;
+		}
+	    }
+    }
+    G_percent(1, 1, 1);
+
+    /* Write arcs to new map */
+    Vect_open_new(&Out, output->answer, Vect_is_3d(&Map));
+    Vect_hist_command(&Out);
+
+    nlines = Vect_get_num_lines(&Map);
+    for (line = 1; line <= nlines; line++) {
+	ltype = Vect_read_line(&Map, Points, NULL, line);
+	if (!(ltype & type)) {
+	    continue;
+	}
+
+	if (turntable_f->answer) {
+	    center1 = Nodes[line * 2].center;
+	    center2 = Nodes[line * 2 + 1].center;
+	    s1cost = Nodes[line * 2].cost;
+	    s2cost = Nodes[line * 2 + 1].cost;
+	    n1cost = n2cost = 0;
+	}
+	else {
+	    Vect_get_line_nodes(&Map, line, &node1, &node2);
+	    center1 = Nodes[node1].center;
+	    center2 = Nodes[node2].center;
+	    s1cost = Nodes[node1].cost;
+	    s2cost = Nodes[node2].cost;
+
+	    Vect_net_get_node_cost(&Map, node1, &n1cost);
+	    Vect_net_get_node_cost(&Map, node2, &n2cost);
+	}
+
+	Vect_net_get_line_cost(&Map, line, GV_FORWARD, &e1cost);
+	Vect_net_get_line_cost(&Map, line, GV_BACKWARD, &e2cost);
+
+	G_debug(3, "Line %d:", line);
+	G_debug(3, "Arc centers: %d %d (nodes: %d %d)", center1, center2,
+		node1, node2);
+
+	G_debug(3, "  s1cost = %f n1cost = %f e1cost = %f", s1cost, n1cost,
+		e1cost);
+	G_debug(3, "  s2cost = %f n2cost = %f e2cost = %f", s2cost, n2cost,
+		e2cost);
+
+	Vect_reset_cats(Cats);
+
+	/* First check if arc is reachable from at least one side */
+	if ((center1 != -1 && n1cost != -1 && e1cost != -1) ||
+	    (center2 != -1 && n2cost != -1 && e2cost != -1)) {
+	    /* Line is reachable at least from one side */
+	    G_debug(3, "  -> arc is reachable");
+
+	    if (center1 == center2) {	/* both nodes in one area -> whole arc in one area */
+		if (center1 != -1)
+		    cat = Centers[center1].cat;	/* line reachable */
+		else
+		    cat = Centers[center2].cat;
+		Vect_cat_set(Cats, 1, cat);
+		Vect_write_line(&Out, ltype, Points, Cats);
+	    }
+	    else {		/* each node in different area */
+		/* Check if direction is reachable */
+		if (center1 == -1 || n1cost == -1 || e1cost == -1) {	/* closed from first node */
+		    G_debug(3,
+			    "    -> arc is not reachable from 1. node -> alloc to 2. node");
+		    cat = Centers[center2].cat;
+		    Vect_cat_set(Cats, 1, cat);
+		    Vect_write_line(&Out, ltype, Points, Cats);
+		    continue;
+		}
+		else if (center2 == -1 || n2cost == -1 || e2cost == -1) {	/* closed from second node */
+		    G_debug(3,
+			    "    -> arc is not reachable from 2. node -> alloc to 1. node");
+		    cat = Centers[center1].cat;
+		    Vect_cat_set(Cats, 1, cat);
+		    Vect_write_line(&Out, ltype, Points, Cats);
+		    continue;
+		}
+
+		/* Now we know that arc is reachable from both sides */
+
+		/* Add costs of node to starting costs */
+		s1cost += n1cost;
+		s2cost += n2cost;
+
+		/* Check if s1cost + e1cost <= s2cost or s2cost + e2cost <= s1cost !
+		 * Note this check also possibility of (e1cost + e2cost) = 0 */
+		if (s1cost + e1cost <= s2cost) {	/* whole arc reachable from node1 */
+		    cat = Centers[center1].cat;
+		    Vect_cat_set(Cats, 1, cat);
+		    Vect_write_line(&Out, ltype, Points, Cats);
+		}
+		else if (s2cost + e2cost <= s1cost) {	/* whole arc reachable from node2 */
+		    cat = Centers[center2].cat;
+		    Vect_cat_set(Cats, 1, cat);
+		    Vect_write_line(&Out, ltype, Points, Cats);
+		}
+		else {		/* split */
+		    /* Calculate relative costs - we expect that costs along the line do not change */
+		    l = Vect_line_length(Points);
+		    e1cost /= l;
+		    e2cost /= l;
+
+		    G_debug(3, "  -> s1cost = %f e1cost = %f", s1cost,
+			    e1cost);
+		    G_debug(3, "  -> s2cost = %f e2cost = %f", s2cost,
+			    e2cost);
+
+		    /* Costs from both centers to the splitting point must be equal:
+		     * s1cost + l1 * e1cost = s2cost + l2 * e2cost */
+		    l1 = (l * e2cost - s1cost + s2cost) / (e1cost + e2cost);
+		    l2 = l - l1;
+		    G_debug(3, "l = %f l1 = %f l2 = %f", l, l1, l2);
+
+		    /* First segment */
+		    ret = Vect_line_segment(Points, 0, l1, SPoints);
+		    if (ret == 0) {
+			G_warning(_
+				  ("Cannot get line segment, segment out of line"));
+		    }
+		    else {
+			cat = Centers[center1].cat;
+			Vect_cat_set(Cats, 1, cat);
+			Vect_write_line(&Out, ltype, SPoints, Cats);
+		    }
+
+		    /* Second segment */
+		    ret = Vect_line_segment(Points, l1, l, SPoints);
+		    if (ret == 0) {
+			G_warning(_
+				  ("Cannot get line segment, segment out of line"));
+		    }
+		    else {
+			Vect_reset_cats(Cats);
+			cat = Centers[center2].cat;
+			Vect_cat_set(Cats, 1, cat);
+			Vect_write_line(&Out, ltype, SPoints, Cats);
+		    }
+		}
+	    }
+	}
+	else {
+	    /* arc is not reachable */
+	    G_debug(3, "  -> arc is not reachable");
+	    Vect_write_line(&Out, ltype, Points, Cats);
+	}
+    }
+
+    Vect_build(&Out);
+
+    /* Free, ... */
+    G_free(Nodes);
+    G_free(Centers);
+    Vect_close(&Map);
+    Vect_close(&Out);
+
+    exit(EXIT_SUCCESS);
+}

Added: grass-addons/grass7/vector/v.net.alloc2/v.net.alloc.html
===================================================================
--- grass-addons/grass7/vector/v.net.alloc2/v.net.alloc.html	                        (rev 0)
+++ grass-addons/grass7/vector/v.net.alloc2/v.net.alloc.html	2013-06-05 11:21:44 UTC (rev 56603)
@@ -0,0 +1,157 @@
+<h2>DESCRIPTION</h2>
+
+<em>v.net.alloc</em> allocates subnets for nearest centers 
+(direction from center). center nodes must be opened (costs >= 0).
+Costs of center nodes are used in the calculation. 
+<p>
+Costs may be either line lengths, or attributes saved in a 
+database table. These attribute values are taken as costs of whole 
+segments, not as costs to traverse a length unit (e.g. meter) of the 
+segment. For example, if the speed limit is 100 km / h, the cost to 
+traverse a 10 km long road segment must be calculated as
+<br>
+length / speed = 10 km / (100 km/h) = 0.1 h.
+<br>
+Supported are cost assignments for both arcs and nodes, 
+and also different costs for both directions of a vector line. 
+For areas, costs will be calculated along boundary lines.
+<p>
+The input vector needs to be prepared with <em>v.net operation=connect</em> 
+in order to connect points representing center nodes to the network.
+<p>There is the option of applying the <a href="v.net.turntable.html">v.net.turntable</a> module on the input layer first. This means the input layer is expanded by turntable with costs of every possible turn on any possible node (intersection) in both directions. Note that after this expansion it is required to apply the -t flag. This flag enables additional parameters tlayer and tuclayer that are otherwise ignored.
+
+<h2>NOTES</h2>
+
+Nodes and arcs can be closed using cost = -1. 
+<p>
+Center nodes can also be assigned to vector nodes using 
+<em><a href="wxGUI.Vector_Digitizer.html">wxGUI vector digitizer</a></em>. 
+
+<h2>EXAMPLES</h2>
+
+<p>1. Subnetwork allocation using distance:
+<p><img src="v_net_alloc.png" alt="v.net.alloc example using distance" border="1">
+<br>
+<p>2. Subnetwork allocation using traveling time:
+<p><img src="v_net_alloc_time.png" alt="v.net.alloc example using time" border="1">
+<br>
+
+<p>Example 1: <em>Calculating subnets for 3 center nodes using distances</em>
+<div class="code"><pre>
+# Spearfish
+
+# center nodes:
+echo "591235.5|4926306.62|1
+596591.8|4917042.5|2
+602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
+
+g.copy vect=roads,myroads
+
+# connect points to network
+v.net myroads points=centernodes out=myroads_net op=connect thresh=200
+
+# allocate, specifying range of center cats (easier to catch all):
+v.net.alloc myroads_net out=myroads_net_alloc ccats=1-100000 nlayer=2
+
+# report categories
+v.category myroads_net_alloc option=report
+</pre></div>
+
+To display the result, run for example:
+
+<div class="code"><pre>
+# show result
+g.region vect=myroads_net
+d.mon x0
+d.vect myroads_net layer=1
+
+# the result has to be selected by category number of the relevant node:
+d.vect myroads_net_alloc cat=1 col=red layer=1
+d.vect myroads_net_alloc cat=2 col=green layer=1
+d.vect myroads_net_alloc cat=3 col=yellow layer=1
+
+# center nodes
+d.vect myroads_net col=red icon=basic/triangle fcol=green size=12 layer=2
+</pre></div>
+
+<p>Example 2: <em>Calculating subnets for 3 center nodes using traveling time</em><br>
+
+<div class="code"><pre>
+# Spearfish
+
+# center nodes:
+echo "591235.5|4926306.62|1
+596591.8|4917042.5|2
+602722.9|4923544.2|3" | v.in.ascii in=- out=centernodes
+
+g.copy vect=roads,myroads
+
+# create lines map connecting points to network
+v.net myroads points=centernodes out=myroads_net op=connect thresh=500 alayer=1 nlayer=2
+
+# set up costs
+
+# create unique categories for each road in layer 3
+v.category in=myroads_net out=myroads_net_time opt=add cat=1 layer=3 type=line
+
+# add new table for layer 3
+v.db.addtable myroads_net_time layer=3 col="cat integer,label varchar(43),length double precision,speed double precision,cost double precision,bcost double precision"
+
+# copy road type to layer 3
+v.to.db myroads_net_time layer=3 qlayer=1 opt=query qcolumn=label columns=label
+
+# upload road length in miles
+v.to.db myroads_net_time layer=3 type=line option=length col=length unit=miles
+
+# set speed limits in miles / hour
+v.db.update myroads_net_time layer=3 col=speed val="5.0"
+v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='interstate'"
+v.db.update myroads_net_time layer=3 col=speed val="75.0" where="label='primary highway, hard surface'"
+v.db.update myroads_net_time layer=3 col=speed val="50.0" where="label='secondary highway, hard surface'"
+v.db.update myroads_net_time layer=3 col=speed val="25.0" where="label='light-duty road, improved surface'"
+v.db.update myroads_net_time layer=3 col=speed val="5.0" where="label='unimproved road'"
+
+# define traveling costs as traveling time in minutes:
+
+# set forward costs
+v.db.update myroads_net_time layer=3 col=cost val="length / speed * 60"
+# set backward costs
+v.db.update myroads_net_time layer=3 col=bcost val="length / speed * 60"
+
+# subnetwork allocation with fastest paths
+v.net.alloc in=myroads_net_time alayer=3 nlayer=2 afcol=cost abcol=bcost out=myroads_net_alloc_time ccats=1-3
+</pre></div>
+
+To display the result, run for example:
+
+<div class="code"><pre>
+# show result
+g.region vect=myroads_net
+d.mon x0
+d.vect myroads_net type=line layer=1
+
+# the result has to be selected by category number of the relevant node:
+d.vect myroads_net_alloc_time cat=1 col=red layer=1
+d.vect myroads_net_alloc_time cat=2 col=green layer=1
+d.vect myroads_net_alloc_time cat=3 col=yellow layer=1
+
+# center nodes
+d.vect myroads_net_time col=red icon=basic/triangle fcol=green size=12 type=point layer=2
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em><a href="d.path.html">d.path</a></em>,
+<em><a href="v.net.html">v.net</a></em>,
+<em><a href="v.net.iso.html">v.net.iso</a></em>,
+<em><a href="v.net.path.html">v.net.path</a></em>,
+<em><a href="v.net.steiner.html">v.net.steiner</a></em>,
+<em><a href="v.net.salesman.html">v.net.salesman</a></em>
+
+<h2>AUTHOR</h2>
+
+Radim Blazek, ITC-Irst, Trento, Italy<br>
+Documentation: Markus Neteler, Markus Metz
+
+
+<p><i>Last changed: $Date: 2013-05-23 21:59:24 +0200 (Thu, 23 May 2013) $</i>

Added: grass-addons/grass7/vector/v.net.alloc2/v_net_alloc.png
===================================================================
(Binary files differ)


Property changes on: grass-addons/grass7/vector/v.net.alloc2/v_net_alloc.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: grass-addons/grass7/vector/v.net.alloc2/v_net_alloc_time.png
===================================================================
(Binary files differ)


Property changes on: grass-addons/grass7/vector/v.net.alloc2/v_net_alloc_time.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream



More information about the grass-commit mailing list