21template<
typename ItemType,
typename BoundsTraits>
22class TemplateSTRNode {
24 using BoundsType =
typename BoundsTraits::BoundsType;
30 const TemplateSTRNode* childrenEnd;
32 explicit Body (ItemType&& p_item) : item(std::forward<ItemType>(p_item)) {}
34 explicit Body (
const ItemType& p_item) : item(p_item) {}
36 explicit Body (
const TemplateSTRNode<ItemType, BoundsTraits>* p_childrenEnd) : childrenEnd(p_childrenEnd) {}
40 const TemplateSTRNode* children;
45 data.item.~ItemType();
49 TemplateSTRNode(ItemType&& p_item,
const BoundsType& env) :
51 data(std::forward<ItemType>(p_item)),
55 TemplateSTRNode(
const ItemType& p_item,
const BoundsType& env) :
61 TemplateSTRNode(
const TemplateSTRNode* begin,
const TemplateSTRNode* end) :
62 bounds(boundsFromChildren(begin, end)),
67 const TemplateSTRNode* beginChildren()
const {
71 const TemplateSTRNode* endChildren()
const {
72 return data.childrenEnd;
75 bool isDeleted()
const {
76 return children ==
this;
80 return children ==
nullptr || children ==
this;
83 bool isComposite()
const {
87 bool boundsIntersect(
const BoundsType& queryBounds)
const {
88 return BoundsTraits::intersects(getBounds(), queryBounds);
91 double getSize()
const {
92 return BoundsTraits::size(getBounds());
95 static BoundsType boundsFromChildren(
const TemplateSTRNode* from,
const TemplateSTRNode* to) {
96 BoundsType bnds = from->getBounds();
98 for (
auto *child = from + 1; child < to; ++child) {
99 BoundsTraits::expandToInclude(bnds, child->getBounds());
105 BoundsType boundsFromChildren()
const {
106 return boundsFromChildren(children, data.childrenEnd);
109 const BoundsType& getBounds()
const {
113 std::size_t getNumNodes()
const
116 return isDeleted() ? 0 : 1;
119 std::size_t count = 1;
120 for (
const auto* child = beginChildren(); child != endChildren(); ++child) {
121 count += child->getNumNodes();
127 std::size_t getNumLeafNodes()
const
130 return isDeleted() ? 0 : 1;
133 std::size_t count = 0;
134 for (
const auto* child = beginChildren(); child != endChildren(); ++child) {
135 count += child->getNumNodes();
140 const ItemType& getItem()
const {
141 assert(!isDeleted());
Basic namespace for all GEOS functionalities.
Definition: geos.h:39