1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * PostGIS is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * PostGIS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with PostGIS.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  **********************************************************************
20  *
21  * Copyright (C) 2012-2015 Paul Ramsey <pramsey@cleverelephant.ca>
22  *
23  **********************************************************************/
24 
25 
26 #ifndef _LWGEODETIC_TREE_H
27 #define _LWGEODETIC_TREE_H 1
28 
29 #include "lwgeodetic.h"
30 
31 #define CIRC_NODE_SIZE 8
32 
33 /**
34 * Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
35 */
36 typedef struct circ_node
37 {
38 	GEOGRAPHIC_POINT center;
39 	double radius;
40 	uint32_t num_nodes;
41 	struct circ_node** nodes;
42 	int edge_num;
43 	uint32_t geom_type;
44 	double d;
45 	POINT2D pt_outside;
46 	POINT2D* p1;
47 	POINT2D* p2;
48 } CIRC_NODE;
49 
50 void circ_tree_print(const CIRC_NODE* node, int depth);
51 CIRC_NODE* circ_tree_new(const POINTARRAY* pa);
52 void circ_tree_free(CIRC_NODE* node);
53 int circ_tree_contains_point(const CIRC_NODE* node, const POINT2D* pt, const POINT2D* pt_outside, int level, int* on_boundary);
54 double circ_tree_distance_tree(const CIRC_NODE* n1, const CIRC_NODE* n2, const SPHEROID *spheroid, double threshold);
55 CIRC_NODE* lwgeom_calculate_circ_tree(const LWGEOM* lwgeom);
56 int circ_tree_get_point(const CIRC_NODE* node, POINT2D* pt);
57 int circ_tree_get_point_outside(const CIRC_NODE* node, POINT2D* pt);
58 
59 #endif /* _LWGEODETIC_TREE_H */
60 
61 
62