[GRASS-SVN] r52525 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 4 12:22:00 PDT 2012
Author: mmetz
Date: 2012-08-04 12:22:00 -0700 (Sat, 04 Aug 2012)
New Revision: 52525
Modified:
grass/trunk/lib/vector/Vlib/intersect.c
Log:
Vlib inersect.c: print debug only on required debug level
Modified: grass/trunk/lib/vector/Vlib/intersect.c
===================================================================
--- grass/trunk/lib/vector/Vlib/intersect.c 2012-08-04 19:02:51 UTC (rev 52524)
+++ grass/trunk/lib/vector/Vlib/intersect.c 2012-08-04 19:22:00 UTC (rev 52525)
@@ -78,6 +78,8 @@
double bdistance, double x, double y);
static double dist2(double x1, double y1, double x2, double y2);
+static int debug_level = -1;
+
#if 0
static int ident(double x1, double y1, double x2, double y2, double thresh);
#endif
@@ -257,8 +259,8 @@
*z2 = 0;
if (!switched)
return 3;
- else
- return 4;
+
+ return 4;
}
/* b contains a */
if (ay1 >= by1 && ay2 <= by2) {
@@ -271,8 +273,8 @@
*z2 = 0;
if (!switched)
return 4;
- else
- return 3;
+
+ return 3;
}
/* general overlap, 2 intersection points */
@@ -383,8 +385,8 @@
*z2 = 0;
if (!switched)
return 3;
- else
- return 4;
+
+ return 4;
}
/* b contains a */
if (ax1 >= bx1 && ax2 <= bx2) {
@@ -397,8 +399,8 @@
*z2 = 0;
if (!switched)
return 4;
- else
- return 3;
+
+ return 3;
}
/* general overlap, 2 intersection points (lines are not vertical) */
@@ -613,6 +615,15 @@
static struct RTree_Rect rect;
static int rect_init = 0;
+ if (debug_level == -1) {
+ const char *dstr = G__getenv("DEBUG");
+
+ if (dstr != NULL)
+ debug_level = atoi(dstr);
+ else
+ debug_level = 0;
+ }
+
if (!rect_init) {
rect.boundary = G_malloc(6 * sizeof(RectReal));
rect_init = 6;
@@ -835,13 +846,16 @@
cmp_cross);
/* Print all (raw) breaks */
- for (i = 0; i < n_cross; i++) {
- G_debug(3,
- " cross = %d seg1/dist1 = %d/%f seg2/dist2 = %d/%f x = %f y = %f",
- i, cross[i].segment[current],
- sqrt(cross[i].distance[current]),
- cross[i].segment[second], sqrt(cross[i].distance[second]),
- cross[i].x, cross[i].y);
+ /* avoid loop when not debugging */
+ if (debug_level > 2) {
+ for (i = 0; i < n_cross; i++) {
+ G_debug(3,
+ " cross = %d seg1/dist1 = %d/%f seg2/dist2 = %d/%f x = %f y = %f",
+ i, cross[i].segment[current],
+ sqrt(cross[i].distance[current]),
+ cross[i].segment[second], sqrt(cross[i].distance[second]),
+ cross[i].x, cross[i].y);
+ }
}
/* Remove breaks on first/last line vertices */
More information about the grass-commit
mailing list