[geos-commits] r2470 - in trunk/source: geom headers/geos/geom

svn_geos at osgeo.org svn_geos at osgeo.org
Tue May 5 10:28:27 EDT 2009


Author: strk
Date: 2009-05-05 10:28:27 -0400 (Tue, 05 May 2009)
New Revision: 2470

Modified:
   trunk/source/geom/Envelope.cpp
   trunk/source/headers/geos/geom/Envelope.h
   trunk/source/headers/geos/geom/Envelope.inl
Log:
Sync Envelope to JTS-1.10


Modified: trunk/source/geom/Envelope.cpp
===================================================================
--- trunk/source/geom/Envelope.cpp	2009-05-05 10:30:39 UTC (rev 2469)
+++ trunk/source/geom/Envelope.cpp	2009-05-05 14:28:27 UTC (rev 2470)
@@ -14,7 +14,7 @@
  *
  **********************************************************************
  *
- * Last port: geom/Envelope.java rev. 1.41 (JTS-1.7)
+ * Last port: geom/Envelope.java rev 1.46 (JTS-1.10)
  *
  **********************************************************************/
 
@@ -295,33 +295,33 @@
 }
 
 /*public*/
-bool
-Envelope::contains(const Coordinate& p) const
+bool 
+Envelope::covers(double x, double y) const
 {
-	return contains(p.x, p.y);
+	if (isNull()) return false;
+	return x >= minx &&
+		x <= maxx &&
+		y >= miny &&
+		y <= maxy;
 }
 
+
 /*public*/
-bool
-Envelope::contains(double x, double y) const
+bool 
+Envelope::covers(const Envelope& other) const
 {
-	return  x >= minx &&
-			x <= maxx &&
-			y >= miny &&
-			y <= maxy;
-}
+	if (isNull() || other.isNull()) return false;
 
-/*public*/
-bool
-Envelope::contains(const Envelope* other) const
-{
-	if (isNull() || other->isNull()) { return false; }
-	return  other->getMinX() >= minx &&
-			other->getMaxX() <= maxx &&
-			other->getMinY() >= miny &&
-			other->getMaxY() <= maxy;
+	return 
+		other.getMinX() >= minx &&
+		other.getMaxX() <= maxx &&
+		other.getMinY() >= miny &&
+		other.getMaxY() <= maxy;
 }
 
+
+
+
 /*public*/
 bool
 Envelope::equals(const Envelope* other) const

Modified: trunk/source/headers/geos/geom/Envelope.h
===================================================================
--- trunk/source/headers/geos/geom/Envelope.h	2009-05-05 10:30:39 UTC (rev 2469)
+++ trunk/source/headers/geos/geom/Envelope.h	2009-05-05 14:28:27 UTC (rev 2470)
@@ -13,7 +13,7 @@
  *
  **********************************************************************
  *
- * Last port: geom/Envelope.java rev. 1.41 (JTS-1.7)
+ * Last port: geom/Envelope.java rev 1.46 (JTS-1.10)
  *
  **********************************************************************/
 
@@ -21,6 +21,7 @@
 #define GEOS_GEOM_ENVELOPE_H
 
 #include <geos/inline.h>
+#include <geos/geom/Coordinate.h>
 
 #include <string>
 #include <vector>
@@ -193,6 +194,17 @@
 	double getHeight(void) const;
 
 	/**
+	 * Gets the area of this envelope.
+	 *
+	 * @return the area of the envelope
+	 * @return 0.0 if the envelope is null
+	 */
+	double getArea() const
+	{
+		return getWidth() * getHeight();
+	}
+
+	/**
 	 *  Returns the Envelope maximum y-value. min y > max y
 	 *  indicates that this is a null Envelope.
 	 */
@@ -295,6 +307,27 @@
 	void expandToInclude(const Envelope* other);
 
 	/** \brief
+	 * Tests if the <code>Envelope other</code> lies wholely
+	 * inside this <code>Envelope</code> (inclusive of the boundary).
+	 * 
+	 * Note that this is <b>not</b> the same definition as the SFS
+	 * <tt>contains</tt>, which would exclude the envelope boundary.
+	 *
+	 * @param  other the <code>Envelope</code> to check
+	 * @return true if <code>other</code> is contained in this
+	 *              <code>Envelope</code>
+	 *
+	 * @see covers(Envelope)
+	 */
+	bool contains(const Envelope& other) const {
+		return covers(other);
+	}
+
+	bool contains(const Envelope* other) const {
+		return contains(*other);
+	}
+
+	/** \brief
 	 * Returns <code>true</code> if the given point lies in
 	 * or on the envelope.
 	 *
@@ -303,7 +336,9 @@
 	 * @return    <code>true</code> if the point lies in the interior or
 	 *      on the boundary of this <code>Envelope</code>.
 	 */
-	bool contains(const Coordinate& p) const;
+	bool contains(const Coordinate& p) const {
+		return covers(p.x, p.y);
+	}
 
 	/** \brief
 	 * Returns <code>true</code> if the given point lies in
@@ -320,24 +355,10 @@
 	 *            the interior or on the boundary of this
 	 *            <code>Envelope</code>.
 	 */
-	bool contains(double x, double y) const;
+	bool contains(double x, double y) const {
+		return covers(x, y);
+	}
 
-	/** \brief
-	 * Returns <code>true</code> if the <code>Envelope other</code>
-	 * lies wholely inside this <code>Envelope</code> (inclusive of
-	 * the boundary).
-	 *
-	 * @param  other  the <code>Envelope</code> which this
-	 *                    <code>Envelope</code> is being checked
-	 *                    for containing
-	 *
-	 * @return        <code>true</code> if <code>other</code>
-	 *                is contained in this <code>Envelope</code>
-	 */
-	bool contains(const Envelope* other) const;
-
-	bool contains(const Envelope& other) const { return contains(&other); }
-
 	/**
 	 * Check if the point p
 	 * intersects (lies inside) the region of this Envelope.
@@ -393,16 +414,20 @@
 	bool covers(const Coordinate *p) const;
 
 	/**
-	* Tests if the <code>Envelope other</code>
-	* lies wholely inside this <code>Envelope</code> (inclusive of the boundary).
-	*
-	*@param  other the <code>Envelope</code> to check
-	*@return true if this <code>Envelope</code> covers the <code>other</code> 
-	*/
-	bool covers(const Envelope *other) const;
-	bool covers(const Envelope &other) const;
+	 * Tests if the <code>Envelope other</code> lies wholely inside
+	 * this <code>Envelope</code> (inclusive of the boundary).
+	 *
+	 * @param  other the <code>Envelope</code> to check
+	 * @return true if this <code>Envelope</code> covers the
+	 * <code>other</code> 
+	 */
+	bool covers(const Envelope& other) const;
 
+	bool covers(const Envelope* other) const {
+		return covers(*other);
+	}
 
+
 	/** \brief
 	 * Returns <code>true</code> if the <code>Envelope other</code>
 	 * spatially equals this <code>Envelope</code>.

Modified: trunk/source/headers/geos/geom/Envelope.inl
===================================================================
--- trunk/source/headers/geos/geom/Envelope.inl	2009-05-05 10:30:39 UTC (rev 2469)
+++ trunk/source/headers/geos/geom/Envelope.inl	2009-05-05 14:28:27 UTC (rev 2470)
@@ -11,6 +11,10 @@
  * by the Free Software Foundation. 
  * See the COPYING file for more information.
  *
+ **********************************************************************
+ *
+ * Last port: geom/Envelope.java rev 1.46 (JTS-1.10)
+ *
  **********************************************************************/
 
 #ifndef GEOS_GEOM_ENVELOPE_INL
@@ -83,43 +87,11 @@
 
 /*public*/
 INLINE bool 
-Envelope::covers(double x, double y) const
+Envelope::covers(const Coordinate *p) const
 {
-	if (isNull()) return false;
-	return x >= minx &&
-		x <= maxx &&
-		y >= miny &&
-		y <= maxy;
-}
-
-/*public*/
-INLINE bool 
-Envelope::covers( const Coordinate *p) const
-{
 	return covers(p->x, p->y);
 }
 
-/*public*/
-INLINE bool 
-Envelope::covers( const Envelope *other) const
-{
-	if (isNull() || other->isNull()) return false;
-
-	return 
-		other->getMinX() >= minx &&
-		other->getMaxX() <= maxx &&
-		other->getMinY() >= miny &&
-		other->getMaxY() <= maxy;
-}
-
-/*public*/
-INLINE bool 
-Envelope::covers( const Envelope &other) const 
-{ 
-	return covers( &other); 
-}
-
-
 } // namespace geos::geom
 } // namespace geos
 



More information about the geos-commits mailing list