Clean up strtree::Interval interface
[geos.git] / src / index / strtree / Interval.cpp
blob3605ee4d19ad5e321055b67e96baa18bd9dbcaa1
1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2006 Refractions Research Inc.
7 * Copyright (C) 2001-2002 Vivid Solutions Inc.
9 * This is free software; you can redistribute and/or modify it under
10 * the terms of the GNU Lesser General Public Licence as published
11 * by the Free Software Foundation.
12 * See the COPYING file for more information.
14 **********************************************************************/
16 #include <geos/index/strtree/Interval.h>
17 //#include <geos/util.h>
19 #include <algorithm>
20 #include <typeinfo>
21 #include <cassert>
23 using namespace std;
25 namespace geos {
26 namespace index { // geos.index
27 namespace strtree { // geos.index.strtree
29 Interval::Interval(double newMin,double newMax)
31 assert(newMin<=newMax);
32 imin=newMin;
33 imax=newMax;
36 double
37 Interval::getCentre()
39 return (imin+imax)/2;
42 Interval*
43 Interval::expandToInclude(const Interval *other)
45 imax=max(imax,other->imax);
46 imin=min(imin,other->imin);
47 return this;
50 bool
51 Interval::intersects(const Interval *other) const
53 return !(other->imin>imax || other->imax<imin);
56 bool
57 Interval::equals(const Interval *other) const {
58 return imin==other->imin && imax==other->imax;
61 } // namespace geos.index.strtree
62 } // namespace geos.index
63 } // namespace geos