SortedPackedIntervalRTree.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* 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.
*
*
**********************************************************************/
#pragma once
#include <geos/index/intervalrtree/IntervalRTreeNode.h>
#include <geos/index/intervalrtree/IntervalRTreeBranchNode.h>
#include <geos/index/intervalrtree/IntervalRTreeLeafNode.h>
#include <geos/util/UnsupportedOperationException.h>
// forward declarations
namespace geos {
namespace index {
class ItemVisitor;
}
}
namespace geos {
namespace index {
namespace intervalrtree {
class SortedPackedIntervalRTree {
private:
std::vector<IntervalRTreeLeafNode> leaves;
std::vector<IntervalRTreeBranchNode> branches;
const IntervalRTreeNode* root = nullptr;
int level = 0;
void init();
void buildLevel(IntervalRTreeNode::ConstVect& src, IntervalRTreeNode::ConstVect& dest);
const IntervalRTreeNode* buildTree();
protected:
public:
SortedPackedIntervalRTree() {}
SortedPackedIntervalRTree(std::size_t initialCapacity)
{
leaves.reserve(initialCapacity);
}
void insert(double min, double max, void* item) {
if(root != nullptr) {
throw util::UnsupportedOperationException("Index cannot be added to once it has been queried");
}
leaves.emplace_back(min, max, item);
}
void query(double min, double max, index::ItemVisitor* visitor);
};
} // geos::intervalrtree
} // geos::index
} // geos
geos::index::ItemVisitor
A visitor for items in an index.
Definition ItemVisitor.h:28
geos::index::intervalrtree::SortedPackedIntervalRTree::query
void query(double min, double max, index::ItemVisitor *visitor)
geos::index::intervalrtree::SortedPackedIntervalRTree::insert
void insert(double min, double max, void *item)
Definition SortedPackedIntervalRTree.h:87
geos::util::UnsupportedOperationException
Indicates that the requested operation is unsupported.
Definition UnsupportedOperationException.h:35
geos::index::intervalrtree
Contains classes that implement a static index on a set of 1-dimensional intervals,...
Definition IntervalRTreeBranchNode.h:32
geos::index
Provides classes for various kinds of spatial indexes.
Definition CleanCoverage.h:39
geos
Basic namespace for all GEOS functionalities.
Definition geos.h:38