Browse Source

v.to.points allow to use llayer -1 to convert features without category (i.e. boundaries)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53273 15284696-431f-4ddb-bdfa-cd5b030d7da7
Maris Nartiss 12 years ago
parent
commit
0699b95f62
2 changed files with 31 additions and 18 deletions
  1. 11 3
      vector/v.to.points/main.c
  2. 20 15
      vector/v.to.points/v.to.points.html

+ 11 - 3
vector/v.to.points/main.c

@@ -48,8 +48,13 @@ void write_point(struct Map_info *Out, double x, double y, double z,
 
     /* Write point */
     Vect_append_point(PPoints, x, y, z);
-    Vect_cat_set(PCats, 1, line_cat);
-    Vect_cat_set(PCats, 2, point_cat);
+    if (line_cat > 0) {
+        Vect_cat_set(PCats, 1, line_cat);
+        Vect_cat_set(PCats, 2, point_cat);
+    }
+    else {
+        Vect_cat_set(PCats, 1, point_cat);
+    }
     Vect_write_line(Out, GV_POINT, PPoints, PCats);
 
     /* Attributes */
@@ -319,8 +324,11 @@ int main(int argc, char **argv)
 	    ltype = Vect_read_line(&In, LPoints, LCats, line);
 	    if (!(ltype & type))
 		continue;
-	    if (!Vect_cat_get(LCats, field, &cat))
+            if (!Vect_cat_get(LCats, field, &cat) && field != -1)
 		continue;
+            // Assign CAT for layer 0 objects (i.e. boundaries)
+            if (field == -1)
+                cat = -1;
 
 	    if (LPoints->n_points <= 1) {
 		write_point(&Out, LPoints->x[0], LPoints->y[0], LPoints->z[0],

+ 20 - 15
vector/v.to.points/v.to.points.html

@@ -1,17 +1,21 @@
 <h2>DESCRIPTION</h2>
 
-<em>v.to.points</em> creates points along input lines. The output is a vector with 2 layers.
+<p><em>v.to.points</em> creates points along input lines. The output is a vector with 2 layers.
 Layer 1 holds the category and attributes of the input lines; all points created along the
 same line have the same category, equal to the category of that line. In layer 2 each point
 has it's unique category; other attributes stored in layer 2 are <em>lcat</em> - the
-category of the input line and <em>along</em> - the distance from line's start.
+category of the input line and <em>along</em> - the distance from line's start.</p>
 
 <h2>NOTES</h2>
 
-The <em>dmax</em> parameter is the maximum limit but not an exact
+<p>The <em>dmax</em> parameter is the maximum limit but not an exact
 distance. To place points with exact distance from the beginning
 of the vector line the user should use
-<a href="v.segment.html">v.segment</a>.
+<a href="v.segment.html">v.segment</a>.</p>
+
+<p>Set llayer to -1 to ignore object category values. Objects will be assigned 
+new unique categories at layer 1. llayer -1 should be used to convert boundaries,
+as in most of cases boundaries lack category values.</p>
 
 <p>The <em>type</em> parameter is used to control which input vector
 geometry types to convert into points. 
@@ -43,30 +47,31 @@ converted to points twice. The centroid is not converted to a point in
 the output vector for <em>type=area</em>.</li>
 </ul>
 
-The -v flag is used to digitize points that fall on the line's vertices <em>only</em>.
-<em>dmax</em> is ignored in this case. 
+<p>The -v flag is used to digitize points that fall on the line's vertices <em>only</em>.
+<em>dmax</em> is ignored in this case.</p>
 <p>If the -i flag is used in conjunction with the -v flag,
 <em>v.to.points</em> will digitize points on the line vertices, as
 well as interpolate points between line vertices using <em>dmax</em>
-as the maximum allowable spacing.
+as the maximum allowable spacing.</p>
 <p>To get points created for the beginning, middle and end only, use
-the -i switch and set <em>dmax</em> so that:
-<p>&nbsp;&nbsp;&nbsp; (length of input line / 2) &lt;= <em>dmax</em> &lt;= length of input line
-<p>So if <em>dmax</em> is between 0.5x and 1.0x the line length, you
+the -i switch and set <em>dmax</em> so that: <br>
+&nbsp;&nbsp;&nbsp; (length of input line / 2) &lt;= <em>dmax</em> &lt;= length of input line
+So if <em>dmax</em> is between 0.5x and 1.0x the line length, you
 will always get points created at exactly the beginning, middle and
-end of the input line.
+end of the input line.</p>
 
 <h2>EXAMPLE</h2>
 
-In this example, the 't_powerlines' vector lines map in the
+<p>In this example, the 't_powerlines' vector lines map in the
 <a href="http://grass.osgeo.org/download/data6.php">Spearfish 6</a>
-location is used to create points along the input lines:
+location is used to create points along the input lines:</p>
 
 <div class="code"><pre>
 v.to.points in=t_powerlines out=t_powerlines_points dmax=120
 d.vect t_powerlines_points
 </pre></div>
- 
+
+
 <h2>SEE ALSO</h2>
 
 <em>
@@ -78,4 +83,4 @@ d.vect t_powerlines_points
 
 Radim Blazek
 
-<p><i>Last changed: $Date$</i>
+<p><i>Last changed: $Date$</i></p>