[GRASS-SVN] r41978 - grass/branches/releasebranch_6_4/vector/v.split
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 22 12:37:07 EDT 2010
Author: mmetz
Date: 2010-04-22 12:37:07 -0400 (Thu, 22 Apr 2010)
New Revision: 41978
Modified:
grass/branches/releasebranch_6_4/vector/v.split/main.c
Log:
v.split: full 3D support
Modified: grass/branches/releasebranch_6_4/vector/v.split/main.c
===================================================================
--- grass/branches/releasebranch_6_4/vector/v.split/main.c 2010-04-22 16:36:51 UTC (rev 41977)
+++ grass/branches/releasebranch_6_4/vector/v.split/main.c 2010-04-22 16:37:07 UTC (rev 41978)
@@ -33,8 +33,8 @@
/* int layer; */
int line, nlines;
- double length;
- int vertices;
+ double length = -1;
+ int vertices = 0;
G_gisinit(argv[0]);
@@ -69,8 +69,11 @@
!(length_opt->answer || vertices_opt->answer))
G_fatal_error("Use either length or vertices");
- if (length_opt->answer)
+ if (length_opt->answer) {
length = atof(length_opt->answer);
+ if (length <= 0)
+ G_fatal_error("Length must be positive but is %g", length);
+ }
if (vertices_opt->answer) {
vertices = atoi(vertices_opt->answer);
@@ -80,7 +83,7 @@
Vect_set_open_level(2);
Vect_open_old(&In, in_opt->answer, "");
- Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In) ? WITH_Z : WITHOUT_Z);
+ Vect_open_new(&Out, out_opt->answer, Vect_is_3d(&In));
Vect_copy_head_data(&In, &Out);
Vect_hist_copy(&In, &Out);
Vect_hist_command(&Out);
@@ -100,7 +103,7 @@
ltype = Vect_read_line(&In, Points, Cats, line);
if (ltype & GV_LINES) {
- if (length_opt->answer) {
+ if (length > 0) {
double l, from, to, step;
l = Vect_line_length(Points);
@@ -117,7 +120,7 @@
for (i = 0; i < n; i++) {
int ret;
- double x, y;
+ double x, y, z;
if (i == n - 1) {
to = l; /* to be sure that it goes to end */
@@ -138,12 +141,15 @@
if (i > 0) {
Points2->x[0] = x;
Points2->y[0] = y;
+ Points2->z[0] = z;
}
if (i == n - 1) {
Points2->x[Points2->n_points - 1] =
Points->x[Points->n_points - 1];
Points2->y[Points2->n_points - 1] =
Points->y[Points->n_points - 1];
+ Points2->z[Points2->n_points - 1] =
+ Points->z[Points->n_points - 1];
}
Vect_write_line(&Out, ltype, Points2, Cats);
@@ -151,6 +157,7 @@
/* last point */
x = Points2->x[Points2->n_points - 1];
y = Points2->y[Points2->n_points - 1];
+ z = Points2->z[Points2->n_points - 1];
from += step;
}
More information about the grass-commit
mailing list