[geos-commits] r3986 - in trunk: include/geos/index/strtree src/index/strtree

svn_geos at osgeo.org svn_geos at osgeo.org
Fri Jun 20 00:28:27 PDT 2014


Author: strk
Date: 2014-06-20 00:28:27 -0700 (Fri, 20 Jun 2014)
New Revision: 3986

Modified:
   trunk/include/geos/index/strtree/Interval.h
   trunk/src/index/strtree/Interval.cpp
   trunk/src/index/strtree/SIRtree.cpp
Log:
Clean up strtree::Interval interface

Set const-correctness, drop useless copy-ctor-like method

Modified: trunk/include/geos/index/strtree/Interval.h
===================================================================
--- trunk/include/geos/index/strtree/Interval.h	2014-05-21 16:08:38 UTC (rev 3985)
+++ trunk/include/geos/index/strtree/Interval.h	2014-06-20 07:28:27 UTC (rev 3986)
@@ -27,12 +27,11 @@
 ///
 class GEOS_DLL Interval {
 public:
-	Interval(Interval *other);
 	Interval(double newMin, double newMax);
 	double getCentre();
-	Interval* expandToInclude(Interval *other);
-	bool intersects(Interval *other);
-	bool equals(void *o);
+	Interval* expandToInclude(const Interval *other);
+	bool intersects(const Interval *other) const;
+	bool equals(const Interval *o) const;
 private:
 	double imin;
 	double imax;

Modified: trunk/src/index/strtree/Interval.cpp
===================================================================
--- trunk/src/index/strtree/Interval.cpp	2014-05-21 16:08:38 UTC (rev 3985)
+++ trunk/src/index/strtree/Interval.cpp	2014-06-20 07:28:27 UTC (rev 3986)
@@ -26,11 +26,6 @@
 namespace index { // geos.index
 namespace strtree { // geos.index.strtree
 
-Interval::Interval(Interval *other)
-{
-	Interval(other->imin,other->imax);
-}
-
 Interval::Interval(double newMin,double newMax)
 {
 	assert(newMin<=newMax);
@@ -45,7 +40,7 @@
 }
 
 Interval*
-Interval::expandToInclude(Interval *other)
+Interval::expandToInclude(const Interval *other)
 {
 	imax=max(imax,other->imax);
 	imin=min(imin,other->imin);
@@ -53,17 +48,13 @@
 }
 
 bool
-Interval::intersects(Interval *other)
+Interval::intersects(const Interval *other) const
 {
 	return !(other->imin>imax || other->imax<imin);
 }
 
 bool
-Interval::equals(void *o) {
-	if (typeid(o)!=typeid(Interval)) {
-		return false;
-	}
-	Interval *other=(Interval*) o;
+Interval::equals(const Interval *other) const {
 	return imin==other->imin && imax==other->imax;
 }
 

Modified: trunk/src/index/strtree/SIRtree.cpp
===================================================================
--- trunk/src/index/strtree/SIRtree.cpp	2014-05-21 16:08:38 UTC (rev 3985)
+++ trunk/src/index/strtree/SIRtree.cpp	2014-06-20 07:28:27 UTC (rev 3986)
@@ -106,7 +106,7 @@
 		{
 			const Boundable* childBoundable=b[i];
 			if (bounds==NULL) {
-				bounds=new Interval((Interval*)childBoundable->getBounds());
+				bounds=new Interval(*((Interval*)childBoundable->getBounds()));
 			} else {
 				bounds->expandToInclude((Interval*)childBoundable->getBounds());
 			}



More information about the geos-commits mailing list