[GRASS-SVN] r61857 - grass/trunk/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Sep 10 23:50:16 PDT 2014
Author: mmetz
Date: 2014-09-10 23:50:16 -0700 (Wed, 10 Sep 2014)
New Revision: 61857
Modified:
grass/trunk/lib/gis/intersect.c
Log:
libgis: restore return codes for G_intersect_line_segments()
Modified: grass/trunk/lib/gis/intersect.c
===================================================================
--- grass/trunk/lib/gis/intersect.c 2014-09-11 06:25:06 UTC (rev 61856)
+++ grass/trunk/lib/gis/intersect.c 2014-09-11 06:50:16 UTC (rev 61857)
@@ -106,17 +106,23 @@
/* lines are parallel */
if (D1 || D2) {
- return 0;
+ return -1;
}
/* segments are colinear. check for overlap */
/* Collinear vertical */
if (ax1 == ax2) {
- if (ay1 > by2)
- return 0;
- if (ay2 < by1)
- return 0;
+ if (ay1 > by2) {
+ *x = ax1;
+ *y = ay1;
+ return 0; /* extensions overlap */
+ }
+ if (ay2 < by1) {
+ *x = ax2;
+ *y = ay2;
+ return 0; /* extensions overlap */
+ }
/* there is overlap */
@@ -140,13 +146,19 @@
*x = ax2;
*y = ay2;
}
- return -1;
+ return 2;
}
else {
- if (ax1 > bx2)
- return 0;
- if (ax2 < bx1)
- return 0;
+ if (ax1 > bx2) {
+ *x = ax1;
+ *y = ay1;
+ return 0; /* extensions overlap */
+ }
+ if (ax2 < bx1) {
+ *x = ax2;
+ *y = ay2;
+ return 0; /* extensions overlap */
+ }
/* there is overlap */
@@ -170,7 +182,7 @@
*x = ax2;
*y = ay2;
}
- return -1;
+ return 2;
}
return 0; /* should not be reached */
More information about the grass-commit
mailing list