index/quadtree/Node.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.
*
**********************************************************************
*
* Last port: index/quadtree/Node.java rev 1.8 (JTS-1.10)
*
**********************************************************************/
#pragma once
#include <geos/export.h>
#include <geos/index/quadtree/NodeBase.h> // for inheritance
#include <geos/geom/Coordinate.h> // for composition
#include <geos/geom/Envelope.h> // for inline
#include <string>
#include <memory>
#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
// Forward declarations
namespace geos {
namespace geom {
//class Coordinate;
class Envelope;
}
}
namespace geos {
namespace index { // geos::index
namespace quadtree { // geos::index::quadtree
class GEOS_DLL Node: public NodeBase {
private:
std::unique_ptr<geom::Envelope> env;
geom::Coordinate centre;
int level;
Node* getSubnode(int index);
std::unique_ptr<Node> createSubnode(int index);
protected:
bool
isSearchMatch(const geom::Envelope& searchEnv) const override
{
return env->intersects(searchEnv);
}
public:
// Create a node computing level from given envelope
static std::unique_ptr<Node> createNode(const geom::Envelope& env);
//
static std::unique_ptr<Node> createExpanded(std::unique_ptr<Node> node,
const geom::Envelope& addEnv);
Node(std::unique_ptr<geom::Envelope> nenv, int nlevel)
:
env(std::move(nenv)),
centre((env->getMinX() + env->getMaxX()) / 2,
(env->getMinY() + env->getMaxY()) / 2),
level(nlevel)
{
}
~Node() override {}
geom::Envelope*
getEnvelope()
{
return env.get();
}
Node* getNode(const geom::Envelope* searchEnv);
NodeBase* find(const geom::Envelope* searchEnv);
void insertNode(std::unique_ptr<Node> node);
std::string toString() const override;
};
} // namespace geos::index::quadtree
} // namespace geos::index
} // namespace geos
#ifdef _MSC_VER
#pragma warning(pop)
#endif
geos::geom::Coordinate
Coordinate is the lightweight class used to store coordinates.
Definition Coordinate.h:217
geos::geom::Envelope
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
geos::index::quadtree::Node
Represents a node of a Quadtree.
Definition index/quadtree/Node.h:54
geos::index::quadtree::Node::find
NodeBase * find(const geom::Envelope *searchEnv)
Returns the smallest existing node containing the envelope.
geos::index::quadtree::Node::createExpanded
static std::unique_ptr< Node > createExpanded(std::unique_ptr< Node > node, const geom::Envelope &addEnv)
Create a node containing the given node and envelope.
geos::index::quadtree::Node::getNode
Node * getNode(const geom::Envelope *searchEnv)
Returns the subquad containing the envelope. Creates the subquad if it does not already exist.
geos::index::quadtree::Node::getEnvelope
geom::Envelope * getEnvelope()
Definition index/quadtree/Node.h:110
geos::geom
Definition Angle.h:26
geos::index::quadtree
Contains classes that implement a Quadtree spatial index.
Definition CleanCoverage.h:40
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