PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ rect_node_leaf_new()

RECT_NODE* rect_node_leaf_new ( const POINTARRAY pa,
int  i 
)

Create a new leaf node, calculating a measure value for each point on the edge and storing pointers back to the end points for later.

Definition at line 128 of file lwtree.c.

References FP_EQUALS, FP_MAX, FP_MIN, getPoint_internal(), rect_node::left_node, lwalloc(), rect_node::p1, rect_node::p2, rect_node::right_node, POINT2D::x, rect_node::xmax, rect_node::xmin, POINT2D::y, rect_node::ymax, and rect_node::ymin.

Referenced by rect_tree_new().

129 {
130  POINT2D *p1, *p2;
131  RECT_NODE *node;
132 
133  p1 = (POINT2D*)getPoint_internal(pa, i);
134  p2 = (POINT2D*)getPoint_internal(pa, i+1);
135 
136  /* Zero length edge, doesn't get a node */
137  if ( FP_EQUALS(p1->x, p2->x) && FP_EQUALS(p1->y, p2->y) )
138  return NULL;
139 
140  node = lwalloc(sizeof(RECT_NODE));
141  node->p1 = p1;
142  node->p2 = p2;
143  node->xmin = FP_MIN(p1->x,p2->x);
144  node->xmax = FP_MAX(p1->x,p2->x);
145  node->ymin = FP_MIN(p1->y,p2->y);
146  node->ymax = FP_MAX(p1->y,p2->y);
147  node->left_node = NULL;
148  node->right_node = NULL;
149  return node;
150 }
struct rect_node * right_node
Definition: lwtree.h:32
POINT2D * p1
Definition: lwtree.h:33
#define FP_MIN(A, B)
POINT2D * p2
Definition: lwtree.h:34
double xmax
Definition: lwtree.h:28
double x
Definition: liblwgeom.h:328
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1753
double ymax
Definition: lwtree.h:30
double y
Definition: liblwgeom.h:328
double xmin
Definition: lwtree.h:27
double ymin
Definition: lwtree.h:29
#define FP_EQUALS(A, B)
void * lwalloc(size_t size)
Definition: lwutil.c:229
struct rect_node * left_node
Definition: lwtree.h:31
#define FP_MAX(A, B)
Here is the call graph for this function:
Here is the caller graph for this function: