File: lwtree.h

package info (click to toggle)
postgis 3.5.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 70,052 kB
  • sloc: ansic: 162,204; sql: 93,950; xml: 53,121; cpp: 12,646; perl: 5,658; sh: 5,369; makefile: 3,434; python: 1,205; yacc: 447; lex: 151; pascal: 58
file content (114 lines) | stat: -rw-r--r-- 2,774 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/**********************************************************************
 *
 * PostGIS - Spatial Types for PostgreSQL
 * http://postgis.net
 *
 * PostGIS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * PostGIS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with PostGIS.  If not, see <http://www.gnu.org/licenses/>.
 *
 **********************************************************************
 *
 * Copyright (C) 2009-2012 Paul Ramsey <pramsey@cleverelephant.ca>
 *
 **********************************************************************/

#define RECT_NODE_SIZE 8

typedef enum
{
	RECT_NODE_INTERNAL_TYPE,
	RECT_NODE_LEAF_TYPE
} RECT_NODE_TYPE;

typedef enum
{
	RECT_NODE_RING_NONE = 0,
	RECT_NODE_RING_EXTERIOR,
	RECT_NODE_RING_INTERIOR
} RECT_NODE_RING_TYPE;

typedef enum
{
	RECT_NODE_SEG_UNKNOWN = 0,
	RECT_NODE_SEG_POINT,
	RECT_NODE_SEG_LINEAR,
	RECT_NODE_SEG_CIRCULAR
} RECT_NODE_SEG_TYPE;

typedef struct
{
	const POINTARRAY *pa;
	RECT_NODE_SEG_TYPE seg_type;
	int seg_num;
} RECT_NODE_LEAF;

struct rect_node;

typedef struct
{
	int num_nodes;
	RECT_NODE_RING_TYPE ring_type;
	struct rect_node *nodes[RECT_NODE_SIZE];
	int sorted;
} RECT_NODE_INTERNAL;

typedef struct rect_node
{
	RECT_NODE_TYPE type;
	unsigned char geom_type;
	double xmin;
	double xmax;
	double ymin;
	double ymax;
	double d;
	union {
		RECT_NODE_INTERNAL i;
		RECT_NODE_LEAF l;
	};
} RECT_NODE;

typedef struct rect_tree_distance_state
{
	double threshold;
	double min_dist;
	double max_dist;
	POINT2D p1;
	POINT2D p2;
} RECT_TREE_DISTANCE_STATE;

/**
* Create a tree index on top an LWGEOM. Do not free the LWGEOM
* until the tree is freed.
*/
RECT_NODE * rect_tree_from_lwgeom(const LWGEOM *geom);

/**
* Test if two RECT_NODE trees intersect one another.
*/
int rect_tree_intersects_tree(RECT_NODE *tree1, RECT_NODE *tree2);

/**
* Return the distance between two RECT_NODE trees.
*/
double rect_tree_distance_tree(RECT_NODE *n1, RECT_NODE *n2, double threshold);

/**
* Free the rect-tree memory
*/
void rect_tree_free(RECT_NODE *node);

int rect_tree_contains_point(RECT_NODE *tree, const POINT2D *pt);
RECT_NODE * rect_tree_from_ptarray(const POINTARRAY *pa, int geom_type);
LWGEOM * rect_tree_to_lwgeom(const RECT_NODE *tree);
char * rect_tree_to_wkt(const RECT_NODE *node);
void rect_tree_printf(const RECT_NODE *node, int depth);