PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ RTreeCreateLeafNode()

static RTREE_NODE * RTreeCreateLeafNode ( POINTARRAY pa,
uint32_t  startPoint 
)
static

Creates a leaf node given the pointer to the start point of the segment.

Definition at line 169 of file lwgeom_rtree.c.

170{
171 RTREE_NODE *parent;
172 LWLINE *line;
173 double value1;
174 double value2;
175 POINT4D tmp;
176 POINTARRAY *npa;
177
178 POSTGIS_DEBUGF(2, "RTreeCreateLeafNode called for point %d of %p", startPoint, pa);
179
180 if (pa->npoints < startPoint + 2)
181 {
182 lwpgerror("RTreeCreateLeafNode: npoints = %d, startPoint = %d", pa->npoints, startPoint);
183 }
184
185 /*
186 * The given point array will be part of a geometry that will be freed
187 * independently of the index. Since we may want to cache the index,
188 * we must create independent arrays.
189 */
190 npa = ptarray_construct_empty(0,0,2);
191
192 getPoint4d_p(pa, startPoint, &tmp);
193 value1 = tmp.y;
195
196 getPoint4d_p(pa, startPoint+1, &tmp);
197 value2 = tmp.y;
199
200 line = lwline_construct(SRID_UNKNOWN, NULL, npa);
201
202 parent = lwalloc(sizeof(RTREE_NODE));
203 parent->interval = RTreeCreateInterval(value1, value2);
204 parent->segment = line;
205 parent->leftNode = NULL;
206 parent->rightNode = NULL;
207
208 POSTGIS_DEBUGF(3, "RTreeCreateLeafNode returning %p", parent);
209
210 return parent;
211}
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
void * lwalloc(size_t size)
Definition lwutil.c:227
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
Definition lwline.c:42
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
Definition ptarray.c:147
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:107
#define SRID_UNKNOWN
Unknown SRID value.
Definition liblwgeom.h:229
static RTREE_INTERVAL * RTreeCreateInterval(double value1, double value2)
Creates an interval given the min and max values, in arbitrary order.
double y
Definition liblwgeom.h:400
uint32_t npoints
Definition liblwgeom.h:413
struct rtree_node * leftNode
struct rtree_node * rightNode
LWLINE * segment
RTREE_INTERVAL * interval
The following struct and methods are used for a 1D RTree implementation, described at: http://lin-ear...

References getPoint4d_p(), rtree_node::interval, rtree_node::leftNode, LW_TRUE, lwalloc(), lwline_construct(), POINTARRAY::npoints, ptarray_append_point(), ptarray_construct_empty(), rtree_node::rightNode, RTreeCreateInterval(), rtree_node::segment, SRID_UNKNOWN, and POINT4D::y.

Referenced by RTreeCreate().

Here is the call graph for this function:
Here is the caller graph for this function: