[geos-commits] r2381 - in trunk: source/algorithm
source/headers/geos/algorithm tests/unit/algorithm
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Apr 17 09:59:27 EDT 2009
Author: strk
Date: 2009-04-17 09:59:27 -0400 (Fri, 17 Apr 2009)
New Revision: 2381
Modified:
trunk/source/algorithm/LineIntersector.cpp
trunk/source/headers/geos/algorithm/LineIntersector.h
trunk/tests/unit/algorithm/RobustLineIntersectorTest.cpp
Log:
renamed intersection constants
Modified: trunk/source/algorithm/LineIntersector.cpp
===================================================================
--- trunk/source/algorithm/LineIntersector.cpp 2009-04-17 09:56:10 UTC (rev 2380)
+++ trunk/source/algorithm/LineIntersector.cpp 2009-04-17 13:59:27 UTC (rev 2381)
@@ -14,7 +14,7 @@
*
**********************************************************************
*
- * Last port: algorithm/RobustLineIntersector.java rev. 1.37 (JTS-1.9)
+ * Last port: algorithm/RobustLineIntersector.java rev. 1.38 (JTS-1.10)
*
**********************************************************************/
@@ -309,11 +309,11 @@
intPt[0].z = (intPt[0].z+z)/2;
}
#endif // COMPUTE_Z
- result=DO_INTERSECT;
+ result=POINT_INTERSECTION;
return;
}
}
- result = DONT_INTERSECT;
+ result = NO_INTERSECTION;
}
/* public static */
@@ -344,9 +344,9 @@
if (!Envelope::intersects(p1,p2,q1,q2))
{
#if GEOS_DEBUG
- cerr<<" DONT_INTERSECT"<<endl;
+ cerr<<" NO_INTERSECTION"<<endl;
#endif
- return DONT_INTERSECT;
+ return NO_INTERSECTION;
}
// for each endpoint, compute which side of the other segment it lies
@@ -358,9 +358,9 @@
if ((Pq1>0 && Pq2>0) || (Pq1<0 && Pq2<0))
{
#if GEOS_DEBUG
- cerr<<" DONT_INTERSECT"<<endl;
+ cerr<<" NO_INTERSECTION"<<endl;
#endif
- return DONT_INTERSECT;
+ return NO_INTERSECTION;
}
int Qp1=CGAlgorithms::orientationIndex(q1,q2,p1);
@@ -368,9 +368,9 @@
if ((Qp1>0 && Qp2>0)||(Qp1<0 && Qp2<0)) {
#if GEOS_DEBUG
- cerr<<" DONT_INTERSECT"<<endl;
+ cerr<<" NO_INTERSECTION"<<endl;
#endif
- return DONT_INTERSECT;
+ return NO_INTERSECTION;
}
bool collinear=Pq1==0 && Pq2==0 && Qp1==0 && Qp2==0;
@@ -495,9 +495,9 @@
intersection(p1, p2, q1, q2, intPt[0]);
}
#if GEOS_DEBUG
- cerr<<" DO_INTERSECT; intPt[0]:"<<intPt[0].toString()<<endl;
+ cerr<<" POINT_INTERSECTION; intPt[0]:"<<intPt[0].toString()<<endl;
#endif // GEOS_DEBUG
- return DO_INTERSECT;
+ return POINT_INTERSECTION;
}
/*private*/
@@ -549,7 +549,7 @@
cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
#endif
- return COLLINEAR;
+ return COLLINEAR_INTERSECTION;
}
if (q1p1q2 && q1p2q2) {
#if GEOS_DEBUG
@@ -573,7 +573,7 @@
if (!ISNAN(p2.z)) { ztot+=p2.z; hits++; }
if ( hits ) intPt[1].z = ztot/hits;
#endif
- return COLLINEAR;
+ return COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p1q2) {
#if GEOS_DEBUG
@@ -601,7 +601,7 @@
cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
#endif
- return (q1==p1) && !p1q2p2 && !q1p2q2 ? DO_INTERSECT : COLLINEAR;
+ return (q1==p1) && !p1q2p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q1p2 && q1p2q2) {
#if GEOS_DEBUG
@@ -629,7 +629,7 @@
cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
#endif
- return (q1==p2) && !p1q2p2 && !q1p1q2 ? DO_INTERSECT : COLLINEAR;
+ return (q1==p2) && !p1q2p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p1q2) {
#if GEOS_DEBUG
@@ -657,7 +657,7 @@
cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
#endif
- return (q2==p1) && !p1q1p2 && !q1p2q2 ? DO_INTERSECT : COLLINEAR;
+ return (q2==p1) && !p1q1p2 && !q1p2q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
if (p1q2p2 && q1p2q2) {
#if GEOS_DEBUG
@@ -685,9 +685,9 @@
cerr<<" intPt[0]: "<<intPt[0].toString()<<endl;
cerr<<" intPt[1]: "<<intPt[1].toString()<<endl;
#endif
- return (q2==p2) && !p1q1p2 && !q1p1q2 ? DO_INTERSECT : COLLINEAR;
+ return (q2==p2) && !p1q1p2 && !q1p1q2 ? POINT_INTERSECTION : COLLINEAR_INTERSECTION;
}
- return DONT_INTERSECT;
+ return NO_INTERSECTION;
}
/*private*/
Modified: trunk/source/headers/geos/algorithm/LineIntersector.h
===================================================================
--- trunk/source/headers/geos/algorithm/LineIntersector.h 2009-04-17 09:56:10 UTC (rev 2380)
+++ trunk/source/headers/geos/algorithm/LineIntersector.h 2009-04-17 13:59:27 UTC (rev 2381)
@@ -14,7 +14,7 @@
*
**********************************************************************
*
- * Last port: algorithm/RobustLineIntersector.java rev. 1.37 (JTS-1.9)
+ * Last port: algorithm/RobustLineIntersector.java rev. 1.38 (JTS-1.10)
*
**********************************************************************/
@@ -124,12 +124,24 @@
/// Same as above but doen's compute intersection point. Faster.
static bool hasIntersection(const geom::Coordinate& p,const geom::Coordinate& p1,const geom::Coordinate& p2);
+ // These are deprecated, due to ambiguous naming
enum {
DONT_INTERSECT=0,
DO_INTERSECT=1,
COLLINEAR=2
};
+ enum {
+ /// Indicates that line segments do not intersect
+ NO_INTERSECTION=0,
+
+ /// Indicates that line segments intersect in a single point
+ POINT_INTERSECTION=1,
+
+ /// Indicates that line segments intersect in a line segment
+ COLLINEAR_INTERSECTION=2
+ };
+
/// Computes the intersection of the lines p1-p2 and p3-p4
void computeIntersection(const geom::Coordinate& p1, const geom::Coordinate& p2,
const geom::Coordinate& p3, const geom::Coordinate& p4);
@@ -141,7 +153,7 @@
*
* @return true if the input geometries intersect
*/
- bool hasIntersection() const { return result!=DONT_INTERSECT; }
+ bool hasIntersection() const { return result!=NO_INTERSECTION; }
/// Returns the number of intersection points found.
//
@@ -264,7 +276,7 @@
//Coordinate &pa;
//Coordinate &pb;
- bool isCollinear() const { return result==COLLINEAR; }
+ bool isCollinear() const { return result==COLLINEAR_INTERSECTION; }
int computeIntersect(const geom::Coordinate& p1,const geom::Coordinate& p2,const geom::Coordinate& q1,const geom::Coordinate& q2);
Modified: trunk/tests/unit/algorithm/RobustLineIntersectorTest.cpp
===================================================================
--- trunk/tests/unit/algorithm/RobustLineIntersectorTest.cpp 2009-04-17 09:56:10 UTC (rev 2380)
+++ trunk/tests/unit/algorithm/RobustLineIntersectorTest.cpp 2009-04-17 13:59:27 UTC (rev 2381)
@@ -66,7 +66,7 @@
Coordinate x(15, 15);
i.computeIntersection(p1, p2, q1, q2);
- ensure_equals(i.getIntersectionNum(), (int)LineIntersector::DO_INTERSECT);
+ ensure_equals(i.getIntersectionNum(), (int)LineIntersector::POINT_INTERSECTION);
ensure_equals(i.getIntersectionNum(), 1);
ensure_equals(i.getIntersection(0), x);
ensure("isProper", i.isProper());
@@ -85,7 +85,7 @@
Coordinate q2(30, 10);
i.computeIntersection(p1, p2, q1, q2);
- ensure_equals(i.getIntersectionNum(), (int)LineIntersector::DONT_INTERSECT);
+ ensure_equals(i.getIntersectionNum(), (int)LineIntersector::NO_INTERSECTION);
ensure_equals(i.getIntersectionNum(), 0);
ensure("!isProper", !i.isProper());
ensure("!hasIntersection", !i.hasIntersection());
@@ -103,7 +103,7 @@
Coordinate q2(30, 10);
i.computeIntersection(p1, p2, q1, q2);
- ensure_equals(i.getIntersectionNum(), (int)LineIntersector::DO_INTERSECT);
+ ensure_equals(i.getIntersectionNum(), (int)LineIntersector::POINT_INTERSECTION);
ensure_equals(i.getIntersectionNum(), 1);
ensure("!isProper", !i.isProper());
ensure("hasIntersection", i.hasIntersection());
@@ -121,7 +121,7 @@
Coordinate q2(30, 10);
i.computeIntersection(p1, p2, q1, q2);
- ensure_equals(i.getIntersectionNum(), (int)LineIntersector::COLLINEAR);
+ ensure_equals(i.getIntersectionNum(), (int)LineIntersector::COLLINEAR_INTERSECTION);
ensure_equals(i.getIntersectionNum(), 2);
ensure("!isProper", !i.isProper());
ensure("hasIntersection", i.hasIntersection());
@@ -139,7 +139,7 @@
Coordinate q2(30, 10);
i.computeIntersection(p1, p2, q1, q2);
- ensure_equals(i.getIntersectionNum(), (int)LineIntersector::COLLINEAR);
+ ensure_equals(i.getIntersectionNum(), (int)LineIntersector::COLLINEAR_INTERSECTION);
ensure_equals(i.getIntersectionNum(), 2);
ensure("!isProper", !i.isProper());
ensure("hasIntersection", i.hasIntersection());
More information about the geos-commits
mailing list