SIRtree.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/export.h>
#include <geos/index/strtree/AbstractSTRtree.h> // for inheritance
#include <geos/index/strtree/Interval.h> // for inline
#include <vector>
#include <memory>
namespace geos {
namespace index { // geos::index
namespace strtree { // geos::index::strtree
class GEOS_DLL SIRtree: public AbstractSTRtree {
using AbstractSTRtree::insert;
using AbstractSTRtree::query;
public:
SIRtree();
SIRtree(std::size_t nodeCapacity);
~SIRtree() override;
void insert(double x1, double x2, void* item);
std::vector<void*>*
query(double x1, double x2)
{
std::vector<void*>* results = new std::vector<void*>();
Interval interval(std::min(x1, x2), std::max(x1, x2));
AbstractSTRtree::query(&interval, *results);
return results;
}
std::vector<void*>*
query(double x)
{
return query(x, x);
}
SIRtree(const SIRtree&) = delete;
SIRtree& operator=(const SIRtree&) = delete;
protected:
class SIRIntersectsOp: public AbstractSTRtree::IntersectsOp {
public:
bool intersects(const void* aBounds, const void* bBounds) override;
};
std::unique_ptr<BoundableList> createParentBoundables(
BoundableList* childBoundables, int newLevel) override;
AbstractNode* createNode(int level) override;
IntersectsOp*
getIntersectsOp() override
{
return intersectsOp;
}
std::unique_ptr<BoundableList> sortBoundables(const BoundableList* input);
private:
IntersectsOp* intersectsOp;
std::vector<std::unique_ptr<Interval>> intervals;
};
} // namespace geos::index::strtree
} // namespace geos::index
} // namespace geos
geos::index::strtree::AbstractNode
A node of the STR tree.
Definition AbstractNode.h:43
geos::index::strtree::AbstractSTRtree::IntersectsOp
A test for intersection between two bounds, necessary because subclasses of AbstractSTRtree have diff...
Definition AbstractSTRtree.h:175
geos::index::strtree::AbstractSTRtree::insert
virtual void insert(const void *bounds, void *item)
Also builds the tree, if necessary.
geos::index::strtree::AbstractSTRtree::query
void query(const void *searchBounds, std::vector< void * > &foundItems)
Also builds the tree, if necessary.
geos::index::strtree::Interval
A contiguous portion of 1D-space. Used internally by SIRtree.
Definition strtree/Interval.h:30
geos::index::strtree::SIRtree::SIRtree
SIRtree()
Constructs an SIRtree with the default node capacity.
geos::index::strtree::SIRtree::SIRtree
SIRtree(std::size_t nodeCapacity)
Constructs an SIRtree with the given maximum number of child nodes that a node may have.
geos::index::strtree::SIRtree::query
std::vector< void * > * query(double x)
Definition SIRtree.h:79
geos::index::strtree::SIRtree::SIRtree
SIRtree(const SIRtree &)=delete
geos::index::strtree::SIRtree::createParentBoundables
std::unique_ptr< BoundableList > createParentBoundables(BoundableList *childBoundables, int newLevel) override
Sorts the childBoundables then divides them into groups of size M, where M is the node capacity.
geos::index::strtree::SIRtree::query
std::vector< void * > * query(double x1, double x2)
Definition SIRtree.h:67
geos::index::strtree::SIRtree::getIntersectsOp
IntersectsOp * getIntersectsOp() override
Definition SIRtree.h:108
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::strtree::BoundableList
std::vector< Boundable * > BoundableList
A list of boundables. TODO: use a list.
Definition AbstractSTRtree.h:43
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