[geos-commits] r2070 - in trunk/source/headers/geos/index: .
intervalrtree
svn_geos at osgeo.org
svn_geos at osgeo.org
Fri Dec 21 15:47:42 EST 2007
Author: benjubb
Date: 2007-12-21 15:47:42 -0500 (Fri, 21 Dec 2007)
New Revision: 2070
Added:
trunk/source/headers/geos/index/intervalrtree/
trunk/source/headers/geos/index/intervalrtree/IntervalRTreeBranchNode.h
trunk/source/headers/geos/index/intervalrtree/IntervalRTreeLeafNode.h
trunk/source/headers/geos/index/intervalrtree/IntervalRTreeNode.h
trunk/source/headers/geos/index/intervalrtree/SortedPackedIntervalRTree.h
Log:
Added from JTS 1.9 to support prepared geometry
Added: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeBranchNode.h
===================================================================
--- trunk/source/headers/geos/index/intervalrtree/IntervalRTreeBranchNode.h (rev 0)
+++ trunk/source/headers/geos/index/intervalrtree/IntervalRTreeBranchNode.h 2007-12-21 20:47:42 UTC (rev 2070)
@@ -0,0 +1,74 @@
+/**********************************************************************
+ * $Id
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ *
+ **********************************************************************/
+
+#ifndef GEOS_INDEX_INTERVALRTREE_INTERVALRTREEBRANCHNODE_H
+#define GEOS_INDEX_INTERVALRTREE_INTERVALRTREEBRANCHNODE_H
+
+#include <geos/index/intervalrtree/IntervalRTreeNode.h> // inherited
+
+#include <algorithm>
+
+// forward declarations
+namespace geos {
+ namespace index {
+ class ItemVisitor;
+ }
+}
+
+
+namespace geos {
+namespace index {
+namespace intervalrtree {
+
+class IntervalRTreeBranchNode : public IntervalRTreeNode
+{
+private:
+ const IntervalRTreeNode * node1;
+ const IntervalRTreeNode * node2;
+
+ //void buildExtent( IntervalRTreeNode * n1, IntervalRTreeNode * n2)
+ //{
+ // min = std::min( n1->min, n2->min);
+ // max = std::max( n1->max, n2->max);
+ //}
+
+protected:
+public:
+ IntervalRTreeBranchNode( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
+ : IntervalRTreeNode( std::min( n1->getMin(), n2->getMin()), std::max( n1->getMax(), n2->getMax())),
+ node1( n1),
+ node2( n2)
+ { }
+
+ ~IntervalRTreeBranchNode()
+ {
+ delete node1;
+ delete node2;
+ }
+
+
+ void query(double queryMin, double queryMax, index::ItemVisitor * visitor) const;
+};
+
+} // geos::intervalrtree
+} // geos::index
+} // geos
+
+#endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREEBRANCHNODE_H
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+
Property changes on: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeBranchNode.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeLeafNode.h
===================================================================
--- trunk/source/headers/geos/index/intervalrtree/IntervalRTreeLeafNode.h (rev 0)
+++ trunk/source/headers/geos/index/intervalrtree/IntervalRTreeLeafNode.h 2007-12-21 20:47:42 UTC (rev 2070)
@@ -0,0 +1,65 @@
+/**********************************************************************
+ * $Id
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ *
+ **********************************************************************/
+
+#ifndef GEOS_INDEX_INTERVALRTREE_INTERVALRTREELEAFNODE_H
+#define GEOS_INDEX_INTERVALRTREE_INTERVALRTREELEAFNODE_H
+
+
+#include <geos/index/intervalrtree/IntervalRTreeNode.h> // inherited
+
+
+// forward declarations
+namespace geos {
+ namespace index {
+ class ItemVisitor;
+ }
+}
+
+
+namespace geos {
+namespace index {
+namespace intervalrtree {
+
+class IntervalRTreeLeafNode : public IntervalRTreeNode
+{
+private:
+ void * item;
+
+protected:
+public:
+ IntervalRTreeLeafNode( double min, double max, void * item)
+ : IntervalRTreeNode( min, max),
+ item( item)
+ { }
+
+ ~IntervalRTreeLeafNode()
+ {
+ delete item;
+ }
+
+ void query( double queryMin, double queryMax, index::ItemVisitor * visitor) const;
+
+};
+
+} // geos::intervalrtree
+} // geos::index
+} // geos
+
+#endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREELEAFNODE_H
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+
Property changes on: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeLeafNode.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeNode.h
===================================================================
--- trunk/source/headers/geos/index/intervalrtree/IntervalRTreeNode.h (rev 0)
+++ trunk/source/headers/geos/index/intervalrtree/IntervalRTreeNode.h 2007-12-21 20:47:42 UTC (rev 2070)
@@ -0,0 +1,113 @@
+/**********************************************************************
+ * $Id
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ *
+ **********************************************************************/
+
+#ifndef GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
+#define GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
+
+#include <vector>
+#include <limits>
+
+// forward declarations
+namespace geos {
+ namespace index {
+ class ItemVisitor;
+ }
+}
+
+
+namespace geos {
+namespace index {
+namespace intervalrtree {
+
+class IntervalRTreeNode
+{
+private:
+protected:
+ double min;
+ double max;
+
+ bool intersects( double queryMin, double queryMax) const
+ {
+ if (min > queryMax || max < queryMin)
+ return false;
+
+ return true;
+ }
+
+public:
+ typedef std::vector<const IntervalRTreeNode *> ConstVect;
+
+ IntervalRTreeNode()
+ : min( std::numeric_limits<double>::min() ),
+ max( std::numeric_limits<double>::max() )
+ { }
+
+ IntervalRTreeNode( double min, double max)
+ : min( min ),
+ max( max )
+ { }
+
+ virtual ~IntervalRTreeNode()
+ { }
+
+ double getMin() const
+ {
+ return min;
+ }
+
+ double getMax() const
+ {
+ return max;
+ }
+
+ virtual void query( double queryMin, double queryMax, ItemVisitor * visitor) const =0;
+
+ //std::string toString()
+ //{
+ // return WKTWriter.toLineString(new Coordinate(min, 0), new Coordinate(max, 0));
+ //}
+
+
+ //class NodeComparator
+ //{
+ //public:
+ static bool compare( const IntervalRTreeNode * n1, const IntervalRTreeNode * n2)
+ {
+ //IntervalRTreeNode * n1 = dynamic_cast<IntervalRTreeNode *>( o1);
+ //IntervalRTreeNode * n2 = dynamic_cast<IntervalRTreeNode *>( o2);
+
+ double mid1 = (n1->getMin() + n1->getMax()) / 2;
+ double mid2 = (n2->getMin() + n2->getMax()) / 2;
+
+ //if (mid1 < mid2) return -1;
+ //if (mid1 > mid2) return 1;
+ //return 0;
+
+ return mid1 > mid2;
+ }
+ //};
+
+};
+
+} // geos::index::intervalrtree
+} // geos::index
+} // geos
+
+#endif // GEOS_INDEX_INTERVALRTREE_INTERVALRTREENODE_H
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+
Property changes on: trunk/source/headers/geos/index/intervalrtree/IntervalRTreeNode.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/source/headers/geos/index/intervalrtree/SortedPackedIntervalRTree.h
===================================================================
--- trunk/source/headers/geos/index/intervalrtree/SortedPackedIntervalRTree.h (rev 0)
+++ trunk/source/headers/geos/index/intervalrtree/SortedPackedIntervalRTree.h 2007-12-21 20:47:42 UTC (rev 2070)
@@ -0,0 +1,81 @@
+/**********************************************************************
+ * $Id
+ *
+ * GEOS - Geometry Engine Open Source
+ * http://geos.refractions.net
+ *
+ * Copyright (C) 2006 Refractions Research Inc.
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU Lesser General Public Licence as published
+ * by the Free Software Foundation.
+ * See the COPYING file for more information.
+ *
+ *
+ **********************************************************************/
+
+#ifndef GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
+#define GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
+
+#include <geos/index/intervalrtree/IntervalRTreeNode.h>
+
+// forward declarations
+namespace geos {
+ namespace index {
+ class ItemVisitor;
+ }
+}
+
+namespace geos {
+namespace index {
+namespace intervalrtree {
+
+class SortedPackedIntervalRTree
+{
+private:
+ IntervalRTreeNode::ConstVect * leaves;
+ const IntervalRTreeNode * root;
+ int level;
+
+ void init();
+ void buildLevel( IntervalRTreeNode::ConstVect * src, IntervalRTreeNode::ConstVect * dest);
+ const IntervalRTreeNode * buildTree();
+
+protected:
+public:
+ SortedPackedIntervalRTree();
+
+ ~SortedPackedIntervalRTree();
+
+ /**
+ * Adds an item to the index which is associated with the given interval
+ *
+ * @param min the lower bound of the item interval
+ * @param max the upper bound of the item interval
+ * @param item the item to insert
+ *
+ * @throw IllegalStateException if the index has already been queried
+ */
+ void insert( double min, double max, void * item);
+
+ /**
+ * Search for intervals in the index which intersect the given closed interval
+ * and apply the visitor to them.
+ *
+ * @param min the lower bound of the query interval
+ * @param max the upper bound of the query interval
+ * @param visitor the visitor to pass any matched items to
+ */
+ void query( double min, double max, index::ItemVisitor * visitor);
+
+};
+
+} // geos::intervalrtree
+} // geos::index
+} // geos
+
+#endif // GEOS_INDEX_INTERVALRTREE_SORTEDPACKEDINTERVALRTREE_H
+/**********************************************************************
+ * $Log$
+ **********************************************************************/
+
Property changes on: trunk/source/headers/geos/index/intervalrtree/SortedPackedIntervalRTree.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the geos-commits
mailing list