PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ RTreeCreateLeafNode()

static RTREE_NODE* RTreeCreateLeafNode ( POINTARRAY pa,
uint32_t  startPoint 

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

Definition at line 169 of file lwgeom_rtree.c.

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().

170 {
171  RTREE_NODE *parent;
172  LWLINE *line;
173  double value1;
174  double value2;
175  POINT4D tmp;
176  POINTARRAY *npa;
178  POSTGIS_DEBUGF(2, "RTreeCreateLeafNode called for point %d of %p", startPoint, pa);
180  if (pa->npoints < startPoint + 2)
181  {
182  lwpgerror("RTreeCreateLeafNode: npoints = %d, startPoint = %d", pa->npoints, startPoint);
183  }
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);
192  getPoint4d_p(pa, startPoint, &tmp);
193  value1 = tmp.y;
194  ptarray_append_point(npa,&tmp,LW_TRUE);
196  getPoint4d_p(pa, startPoint+1, &tmp);
197  value2 = tmp.y;
198  ptarray_append_point(npa,&tmp,LW_TRUE);
200  line = lwline_construct(SRID_UNKNOWN, NULL, npa);
202  parent = lwalloc(sizeof(RTREE_NODE));
203  parent->interval = RTreeCreateInterval(value1, value2);
204  parent->segment = line;
205  parent->leftNode = NULL;
206  parent->rightNode = NULL;
208  POSTGIS_DEBUGF(3, "RTreeCreateLeafNode returning %p", parent);
210  return parent;
211 }
The following struct and methods are used for a 1D RTree implementation, described at: http://lin-ear...
Definition: lwgeom_rtree.h:46
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition: ptarray.c:70
struct rtree_node * leftNode
Definition: lwgeom_rtree.h:49
Definition: lwgeom_rtree.h:48
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, then a duplicate point will not be added.
Definition: ptarray.c:156
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:76
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
Definition: lwline.c:42
Unknown SRID value.
Definition: liblwgeom.h:188
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
LWLINE * segment
Definition: lwgeom_rtree.h:51
struct rtree_node * rightNode
Definition: lwgeom_rtree.h:50
static RTREE_INTERVAL * RTreeCreateInterval(double value1, double value2)
Creates an interval given the min and max values, in arbitrary order.
Definition: lwgeom_rtree.c:129
void * lwalloc(size_t size)
Definition: lwutil.c:229
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374
Here is the call graph for this function:
Here is the caller graph for this function: