[GRASS-SVN] r45856 - grass/branches/develbranch_6/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 6 13:06:46 EDT 2011
Author: mmetz
Date: 2011-04-06 10:06:46 -0700 (Wed, 06 Apr 2011)
New Revision: 45856
Modified:
grass/branches/develbranch_6/lib/vector/Vlib/buffer2.c
Log:
buffer2 bug workaround
Modified: grass/branches/develbranch_6/lib/vector/Vlib/buffer2.c
===================================================================
--- grass/branches/develbranch_6/lib/vector/Vlib/buffer2.c 2011-04-06 07:00:06 UTC (rev 45855)
+++ grass/branches/develbranch_6/lib/vector/Vlib/buffer2.c 2011-04-06 17:06:46 UTC (rev 45856)
@@ -625,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;
@@ -890,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);
@@ -919,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