SimpleSTRnode.h
/**********************************************************************
*
* GEOS - Geometry Engine Open Source
* http://geos.osgeo.org
*
* Copyright (C) 2020 Paul Ramsey
*
* 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 <geos/export.h>
#include <geos/geom/Envelope.h>
#include <geos/index/strtree/ItemBoundable.h>
#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 SimpleSTRnode : public ItemBoundable {
private:
std::vector<SimpleSTRnode*> childNodes;
void *item;
geom::Envelope bounds;
std::size_t level;
public:
/*
* Constructs an AbstractNode at the given level in the tree
*/
SimpleSTRnode(std::size_t newLevel, const geom::Envelope *p_env, void* p_item, std::size_t capacity = 10)
: ItemBoundable(p_env, p_item)
, item(p_item)
, bounds()
, level(newLevel)
{
childNodes.reserve(capacity);
if (p_env) {
bounds = *p_env;
}
}
SimpleSTRnode(std::size_t newLevel)
: SimpleSTRnode(newLevel, nullptr, nullptr)
{}
void toString(std::ostream& os, int indentLevel) const;
std::size_t getNumNodes() const;
std::size_t getNumLeafNodes() const;
const std::vector<SimpleSTRnode*>&
getChildNodes() const
{
return childNodes;
}
void* getItem() const {
return item;
}
bool removeItem(void *item);
bool removeChild(SimpleSTRnode *child);
const inline geom::Envelope& getEnvelope() const {
return bounds;
}
const void* getBounds() const override {
return &bounds;
}
std::size_t getLevel() const {
return level;
}
std::size_t size() const {
return childNodes.size();
}
void addChildNode(SimpleSTRnode* childNode);
bool isLeaf() const override
{
return level == 0;
}
bool isComposite() const
{
return ! isLeaf();
}
double area() const
{
return bounds.getArea();
}
};
} // namespace geos::index::strtree
} // namespace geos::index
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::geom::Envelope::getArea
double getArea() const
Gets the area of this envelope.
Definition Envelope.h:290
geos::index::strtree::SimpleSTRnode::getEnvelope
const geom::Envelope & getEnvelope() const
Definition SimpleSTRnode.h:89
geos::index::strtree::SimpleSTRnode::addChildNode
void addChildNode(SimpleSTRnode *childNode)
geos::index::strtree::SimpleSTRnode::getBounds
const void * getBounds() const override
Definition SimpleSTRnode.h:93
geos::index::strtree::SimpleSTRnode::getLevel
std::size_t getLevel() const
Definition SimpleSTRnode.h:101
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