[GRASS-SVN] r45176 - grass/branches/develbranch_6/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jan 25 04:48:12 EST 2011
Author: mmetz
Date: 2011-01-25 01:48:12 -0800 (Tue, 25 Jan 2011)
New Revision: 45176
Modified:
grass/branches/develbranch_6/lib/vector/Vlib/break_polygons.c
Log:
break polygons: write to Err only used points, no duplicates
Modified: grass/branches/develbranch_6/lib/vector/Vlib/break_polygons.c
===================================================================
--- grass/branches/develbranch_6/lib/vector/Vlib/break_polygons.c 2011-01-25 09:37:42 UTC (rev 45175)
+++ grass/branches/develbranch_6/lib/vector/Vlib/break_polygons.c 2011-01-25 09:48:12 UTC (rev 45176)
@@ -52,6 +52,7 @@
typedef struct
{
+ double x, y;
double a1, a2; /* angles */
char cross; /* 0 - do not break, 1 - break */
char used; /* 0 - was not used to break line, 1 - was used to break line
@@ -88,7 +89,7 @@
Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
{
struct line_pnts *BPoints, *Points;
- struct line_cats *Cats, *ErrCats;
+ struct line_cats *Cats;
int i, j, k, ret, ltype, broken, last, nlines;
int nbreaks;
struct Node *RTree;
@@ -103,7 +104,6 @@
BPoints = Vect_new_line_struct();
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
- ErrCats = Vect_new_cats_struct();
nlines = Vect_get_num_lines(Map);
@@ -217,6 +217,8 @@
(XPNT *) G_realloc(XPnts,
(apoints + 1) * sizeof(XPNT));
}
+ XPnts[npoints].x = Points->x[j];
+ XPnts[npoints].y = Points->y[j];
XPnts[npoints].used = 0;
if (j == 0 || j == (Points->n_points - 1) ||
Points->n_points < 3) {
@@ -287,6 +289,10 @@
RTreeSearch(RTree, &rect, (void *)srch, 0);
G_debug(3, "fpoint = %d", fpoint);
+ if (XPnts[fpoint].cross) { /* realy use to break line */
+ XPnts[fpoint].used = 1;
+ }
+
/* break or write last segment of broken line */
if ((j == (Points->n_points - 1) && broken) ||
XPnts[fpoint].cross) {
@@ -308,16 +314,6 @@
if (!broken)
Vect_delete_line(Map, i); /* not yet deleted */
- /* Write points on breaks */
- if (Err) {
- if (XPnts[fpoint].cross && !XPnts[fpoint].used) {
- Vect_reset_line(BPoints);
- Vect_append_point(BPoints, Points->x[j], Points->y[j], 0);
- Vect_write_line(Err, GV_POINT, BPoints, ErrCats);
- }
- XPnts[fpoint].used = 1;
- }
-
last = j;
broken = 1;
nbreaks++;
@@ -339,6 +335,18 @@
}
}
+ /* Write points on breaks */
+ if (Err) {
+ Vect_reset_cats(Cats);
+ for (i = 1; i < npoints; i++) {
+ if (XPnts[i].used) {
+ Vect_reset_line(Points);
+ Vect_append_point(Points, XPnts[i].x, XPnts[i].y, 0);
+ Vect_write_line(Err, GV_POINT, Points, Cats);
+ }
+ }
+ }
+
G_free(XPnts);
RTreeDestroyNode(RTree);
}
More information about the grass-commit
mailing list