36template<
typename T>
class PalRtree :
public RTree<T *, float, 2, float>
44 : mXMin( maxBounds.xMinimum() )
45 , mYMin( maxBounds.yMinimum() )
46 , mXRes( ( std::numeric_limits< float >::max() - 1 ) / ( maxBounds.xMaximum() - maxBounds.xMinimum() ) )
47 , mYRes( ( std::numeric_limits< float >::max() - 1 ) / ( maxBounds.yMaximum() - maxBounds.yMinimum() ) )
48 , mMaxBounds( maxBounds )
59 std::array< float, 4 > scaledBounds = scaleBounds( bounds );
60 const float aMin[2] { scaledBounds[0], scaledBounds[1] };
61 const float aMax[2] { scaledBounds[2], scaledBounds[3] };
62 this->Insert( aMin, aMax, data );
73 std::array< float, 4 > scaledBounds = scaleBounds( bounds );
74 const float aMin[2] { scaledBounds[0], scaledBounds[1] };
75 const float aMax[2] { scaledBounds[2], scaledBounds[3] };
76 this->Remove( aMin, aMax, data );
86 std::array< float, 4 > scaledBounds = scaleBounds( bounds );
87 const float aMin[2] { scaledBounds[0], scaledBounds[1] };
88 const float aMax[2] { scaledBounds[2], scaledBounds[3] };
89 this->Search( aMin, aMax, callback );
100 std::array<float, 4> scaleBounds(
const QgsRectangle &bounds )
const
103 static_cast< float >( ( std::max( bounds.
xMinimum(), mMaxBounds.
xMinimum() ) - mXMin ) / mXRes ),
104 static_cast< float >( ( std::max( bounds.
yMinimum(), mMaxBounds.
yMinimum() ) - mYMin ) / mYRes ),
105 static_cast< float >( ( std::min( bounds.
xMaximum(), mMaxBounds.
xMaximum() ) - mXMin ) / mXRes ),
106 static_cast< float >( ( std::min( bounds.
yMaximum(), mMaxBounds.
yMaximum() ) - mYMin ) / mYRes )
void insert(T *data, const QgsRectangle &bounds)
Inserts new data into the spatial index, with the specified bounds.
void remove(T *data, const QgsRectangle &bounds)
Removes existing data from the spatial index, with the specified bounds.
PalRtree(const QgsRectangle &maxBounds)
Constructor for PalRtree.
bool intersects(const QgsRectangle &bounds, const std::function< bool(T *data)> &callback) const
Performs an intersection check against the index, for data intersecting the specified bounds.
A rectangle specified with double values.