[GRASS-SVN] r41976 - grass/trunk/vector/v.split
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 22 12:36:03 EDT 2010
Author: mmetz
Date: 2010-04-22 12:36:02 -0400 (Thu, 22 Apr 2010)
New Revision: 41976
Modified:
grass/trunk/vector/v.split/main.c
Log:
v.split: full 3D support
Modified: grass/trunk/vector/v.split/main.c
===================================================================
--- grass/trunk/vector/v.split/main.c 2010-04-22 10:54:30 UTC (rev 41975)
+++ grass/trunk/vector/v.split/main.c 2010-04-22 16:36:02 UTC (rev 41976)
@@ -33,8 +33,8 @@
struct line_cats *Cats;
int line, nlines, layer;
- double length;
- int vertices;
+ double length = -1;
+ int vertices = 0;
G_gisinit(argv[0]);
@@ -70,8 +70,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);
@@ -83,7 +86,7 @@
Vect_open_old2(&In, in_opt->answer, "", layer_opt->answer);
layer = Vect_get_field_number(&In, layer_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);
@@ -107,7 +110,7 @@
continue;
if (ltype & GV_LINES) {
- if (length_opt->answer) {
+ if (length > 0) {
double l, from, to, step;
l = Vect_line_length(Points);
@@ -124,7 +127,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 */
@@ -144,12 +147,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);
@@ -157,6 +163,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