[GRASS-SVN] r46078 -
grass/branches/releasebranch_6_4/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 22 02:58:47 EDT 2011
Author: mmetz
Date: 2011-04-21 23:58:47 -0700 (Thu, 21 Apr 2011)
New Revision: 46078
Modified:
grass/branches/releasebranch_6_4/lib/vector/Vlib/buffer2.c
Log:
backport r45856
Modified: grass/branches/releasebranch_6_4/lib/vector/Vlib/buffer2.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/vector/Vlib/buffer2.c 2011-04-22 06:57:59 UTC (rev 46077)
+++ grass/branches/releasebranch_6_4/lib/vector/Vlib/buffer2.c 2011-04-22 06:58:47 UTC (rev 46078)
@@ -485,7 +485,7 @@
/* close the output line */
Vect_append_point(nPoints, nPoints->x[0], nPoints->y[0], nPoints->z[0]);
- /* Vect_line_prune ( nPoints ); */
+ Vect_line_prune ( nPoints );
}
/*
@@ -533,7 +533,11 @@
eangle = atan2(vert->y - vert0->y, vert->x - vert0->x);
while (1) {
- Vect_append_point(nPoints, vert0->x, vert0->y, 0);
+ if (nPoints->n_points > 0 && (nPoints->x[nPoints->n_points - 1] != vert0->x ||
+ nPoints->y[nPoints->n_points - 1] != vert0->y))
+ Vect_append_point(nPoints, vert0->x, vert0->y, 0);
+ else
+ Vect_append_point(nPoints, vert0->x, vert0->y, 0);
G_debug(4, "ec: v0=%d, v=%d, eside=%d, edge->v1=%d, edge->v2=%d", v0,
v, eside, edge->v1, edge->v2);
G_debug(4, "ec: append point x=%.18f y=%.18f", vert0->x, vert0->y);
@@ -621,6 +625,7 @@
eangle = vert0->angles[opt_j];
}
Vect_append_point(nPoints, vert->x, vert->y, 0);
+ Vect_line_prune(nPoints);
G_debug(4, "ec: append point x=%.18f y=%.18f", vert->x, vert->y);
return;
@@ -886,14 +891,32 @@
res = extract_inner_contour(pg2, &winding, cPoints);
while (res != 0) {
if (winding == 0) {
- if (!Vect_point_in_poly(cPoints->x[0], cPoints->y[0], area_outer)) {
- if (Vect_get_point_in_poly(cPoints, &px, &py) != 0)
- G_fatal_error(_("Vect_get_point_in_poly() failed"));
- if (!point_in_buf(area_outer, px, py, da, db, dalpha)) {
- add_line_to_array(cPoints, &arrPoints, &count, &allocated,
- more);
- cPoints = Vect_new_line_struct();
+ int check_poly = 1;
+ double area_size;
+
+ dig_find_area_poly(cPoints, &area_size);
+ if (area_size == 0) {
+ G_warning(_("zero area size"));
+ check_poly = 0;
+ }
+ if (cPoints->x[0] != cPoints->x[cPoints->n_points - 1] ||
+ cPoints->y[0] != cPoints->y[cPoints->n_points - 1]) {
+
+ G_warning(_("Line was not closed"));
+ check_poly = 0;
+ }
+
+ if (check_poly && !Vect_point_in_poly(cPoints->x[0], cPoints->y[0], area_outer)) {
+ if (Vect_get_point_in_poly(cPoints, &px, &py) == 0) {
+ if (!point_in_buf(area_outer, px, py, da, db, dalpha)) {
+ add_line_to_array(cPoints, &arrPoints, &count, &allocated,
+ more);
+ cPoints = Vect_new_line_struct();
+ }
}
+ else {
+ G_warning(_("Vect_get_point_in_poly() failed"));
+ }
}
}
res = extract_inner_contour(pg2, &winding, cPoints);
@@ -915,18 +938,36 @@
res = extract_inner_contour(pg2, &winding, cPoints);
while (res != 0) {
if (winding == -1) {
+ int check_poly = 1;
+ double area_size;
+
+ dig_find_area_poly(cPoints, &area_size);
+ if (area_size == 0) {
+ G_warning(_("zero area size"));
+ check_poly = 0;
+ }
+ if (cPoints->x[0] != cPoints->x[cPoints->n_points - 1] ||
+ cPoints->y[0] != cPoints->y[cPoints->n_points - 1]) {
+
+ G_warning(_("Line was not closed"));
+ check_poly = 0;
+ }
+
/* we need to check if the area is in the buffer.
I've simplfied convolution_line(), so that it runs faster,
however that leads to ocasional problems */
- if (Vect_point_in_poly
+ if (check_poly && Vect_point_in_poly
(cPoints->x[0], cPoints->y[0], area_isles[i])) {
- if (Vect_get_point_in_poly(cPoints, &px, &py) != 0)
- G_fatal_error(_("Vect_get_point_in_poly() failed"));
- if (!point_in_buf(area_isles[i], px, py, da, db, dalpha)) {
- add_line_to_array(cPoints, &arrPoints, &count,
- &allocated, more);
- cPoints = Vect_new_line_struct();
+ if (Vect_get_point_in_poly(cPoints, &px, &py) == 0) {
+ if (!point_in_buf(area_isles[i], px, py, da, db, dalpha)) {
+ add_line_to_array(cPoints, &arrPoints, &count,
+ &allocated, more);
+ cPoints = Vect_new_line_struct();
+ }
}
+ else {
+ G_warning(_("Vect_get_point_in_poly() failed"));
+ }
}
}
res = extract_inner_contour(pg2, &winding, cPoints);
More information about the grass-commit
mailing list