1
#ifndef _LWGEOM_RTREE_H
2
#define _LWGEOM_RTREE_H
10
/* Returns 1 if min < value <= max, 0 otherwise */
11
uint32 isContained(INTERVAL *interval, double value);
12
/* Creates an interval given the min and max values, in whatever order. */
13
INTERVAL *createInterval(double value1, double value2);
14
/* Creates an interval with the total extents of the two given intervals. */
15
INTERVAL *mergeIntervals(INTERVAL *inter1, INTERVAL *inter2);
18
* The following struct and methods are used for a 1D RTree implementation,
20
* http://lin-ear-th-inking.blogspot.com/2007/06/packed-1-dimensional-r-tree.html
22
typedef struct rtree_node
25
struct rtree_node *leftNode;
26
struct rtree_node *rightNode;
30
/* Creates an interior node given the children. */
31
RTREE_NODE *createInteriorNode(RTREE_NODE *left, RTREE_NODE *right);
32
/* Creates a leaf node given the pointer to the start point of the segment. */
33
RTREE_NODE *createLeafNode(POINTARRAY *pa, int startPoint);
35
* Creates an rtree given a pointer to the point array.
36
* Must copy the point array.
38
RTREE_NODE *createTree(POINTARRAY *pointArray);
40
void freeTree(RTREE_NODE *root);
41
/* Retrieves a collection of line segments given the root and crossing value. */
42
LWMLINE *findLineSegments(RTREE_NODE *root, double value);
43
/* Merges two multilinestrings into a single multilinestring. */
44
LWMLINE *mergeMultiLines(LWMLINE *line1, LWMLINE *line2);
49
RTREE_NODE **ringIndices;
56
* Creates a new cachable index if needed, or returns the current cache if
57
* it is applicable to the current polygon.
59
RTREE_POLY_CACHE *retrieveCache(LWGEOM *lwgeom, uchar *serializedPoly, RTREE_POLY_CACHE *currentCache);
60
RTREE_POLY_CACHE *createCache(void);
61
/* Frees the cache. */
62
void populateCache(RTREE_POLY_CACHE *cache, LWGEOM *lwgeom, uchar *serializedPoly);
63
void clearCache(RTREE_POLY_CACHE *cache);
65
#endif /* !defined _LIBLWGEOM_H */