AbstractNode.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 <cassert>
#include <cstddef>
#include <geos/export.h>
#include <geos/index/strtree/Boundable.h> // for inheritance
#include <vector>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
#endif
namespace geos {
namespace index { // geos::index
namespace strtree { // geos::index::strtree
class GEOS_DLL AbstractNode: public Boundable {
private:
std::vector<Boundable*> childBoundables;
int level;
public:
/*
* Constructs an AbstractNode at the given level in the tree
* @param level 0 if this node is a leaf, 1 if a parent of a leaf, and so on;
* the root node will have the highest level
*/
AbstractNode(int newLevel, std::size_t capacity = 10) : level(newLevel), bounds(nullptr) {
childBoundables.reserve(capacity);
}
~AbstractNode() override = default;
// TODO: change signature to return by ref,
// document ownership of the return
inline std::vector<Boundable*>*
getChildBoundables()
{
return &childBoundables;
}
// TODO: change signature to return by ref,
// document ownership of the return
inline const std::vector<Boundable*>*
getChildBoundables() const
{
return &childBoundables;
}
const void* getBounds() const override {
if(bounds == nullptr) {
bounds = computeBounds();
}
return bounds;
}
int getLevel() {
return level;
}
void addChildBoundable(Boundable* childBoundable) {
assert(bounds == nullptr);
childBoundables.push_back(childBoundable);
}
bool isLeaf() const override {
return false;
}
protected:
virtual void* computeBounds() const = 0;
mutable void* bounds;
};
} // namespace geos::index::strtree
} // namespace geos::index
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::index::strtree::AbstractNode::getLevel
int getLevel()
Definition AbstractNode.h:99
geos::index::strtree::AbstractNode::addChildBoundable
void addChildBoundable(Boundable *childBoundable)
Definition AbstractNode.h:107
geos::index::strtree::AbstractNode::getBounds
const void * getBounds() const override
Definition AbstractNode.h:88
geos::index::strtree::Boundable
A spatial object in an AbstractSTRtree.
Definition Boundable.h:24
geos::index::strtree
Contains 2-D and 1-D versions of the Sort-Tile-Recursive (STR) tree, a query-only R-tree.
Definition AbstractNode.h:31
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