PostGIS  2.2.8dev-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 104 of file lwtree.c.

Referenced by rect_tree_new().

105 {
106  POINT2D *p1, *p2;
107  RECT_NODE *node;
108
109  p1 = (POINT2D*)getPoint_internal(pa, i);
110  p2 = (POINT2D*)getPoint_internal(pa, i+1);
111
112  /* Zero length edge, doesn't get a node */
113  if ( FP_EQUALS(p1->x, p2->x) && FP_EQUALS(p1->y, p2->y) )
114  return NULL;
115
116  node = lwalloc(sizeof(RECT_NODE));
117  node->p1 = p1;
118  node->p2 = p2;
119  node->xmin = FP_MIN(p1->x,p2->x);
120  node->xmax = FP_MAX(p1->x,p2->x);
121  node->ymin = FP_MIN(p1->y,p2->y);
122  node->ymax = FP_MAX(p1->y,p2->y);
123  node->left_node = NULL;
124  node->right_node = NULL;
125  return node;
126 }
struct rect_node * right_node
Definition: lwtree.h:11
POINT2D * p1
Definition: lwtree.h:12
#define FP_MIN(A, B)
POINT2D * p2
Definition: lwtree.h:13
double xmax
Definition: lwtree.h:7
double x
Definition: liblwgeom.h:312
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
Definition: ptarray.c:1706
double ymax
Definition: lwtree.h:9
double y
Definition: liblwgeom.h:312
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
Definition: lwtree.h:4
double xmin
Definition: lwtree.h:6
double ymin
Definition: lwtree.h:8
#define FP_EQUALS(A, B)
void * lwalloc(size_t size)
Definition: lwutil.c:199
struct rect_node * left_node
Definition: lwtree.h:10
#define FP_MAX(A, B)
Here is the call graph for this function:
Here is the caller graph for this function: