node->num_nodes = 0;
node->nodes = NULL;
node->edge_num = i;
+
+ /* Zero out metadata */
+ node->pt_outside = NULL;
+ node->geom_type = 0;
return node;
}
tree->nodes = NULL;
tree->num_nodes = 0;
tree->edge_num = 0;
+ tree->geom_type = POINTTYPE;
+ tree->pt_outside = NULL;
return tree;
}
node->num_nodes = num_nodes;
node->nodes = c;
node->edge_num = -1;
+ node->geom_type = 0;
+ node->pt_outside = NULL;
return node;
}
/**
-* Build a tree of nodes from a point array, one node per edge, and each
-* with an associated measure range along a one-dimensional space. We
-* can then search that space as a range tree.
+* Build a tree of nodes from a point array, one node per edge.
*/
CIRC_NODE*
circ_tree_new(const POINTARRAY* pa)
}
+/**
+* Returns a #POINT2D that is a vertex of the input shape
+*/
+int circ_tree_get_point(const CIRC_NODE* node, POINT4D* pt)
+{
+ if ( circ_node_is_leaf(node) )
+ {
+ pt->x = node->p1->x;
+ pt->y = node->p1->y;
+ return LW_SUCCESS;
+ }
+ else
+ {
+ return circ_tree_get_point(node->nodes[0], pt);
+ }
+}
+
+
/**
* Walk the tree and count intersections between the stab line and the edges.
* odd => containment, even => no containment.
static CIRC_NODE*
lwpoint_calculate_circ_tree(const LWPOINT* lwpoint)
{
- return circ_tree_new(lwpoint->point);
+ CIRC_NODE* node;
+ node = circ_tree_new(lwpoint->point);
+ node->geom_type = lwgeom_get_type((LWGEOM*)lwpoint);;
+ return node;
}
static CIRC_NODE*
lwline_calculate_circ_tree(const LWLINE* lwline)
{
- return circ_tree_new(lwline->points);
+ CIRC_NODE* node;
+ node = circ_tree_new(lwline->points);
+ node->geom_type = lwgeom_get_type((LWGEOM*)lwline);
+ return node;
}
static CIRC_NODE*
node = circ_nodes_merge(nodes, j);
/* Don't need the working list any more */
lwfree(nodes);
+
+ node->geom_type = lwgeom_get_type((LWGEOM*)lwpoly);
return node;
}
/* Don't need the working list any more */
lwfree(nodes);
+ node->geom_type = lwgeom_get_type((LWGEOM*)lwcol);;
+
return node;
}
int num_nodes;
struct circ_node** nodes;
int edge_num;
+ int geom_type;
+ POINT2D* pt_outside;
POINT2D* p1;
POINT2D* p2;
} CIRC_NODE;
int circ_tree_contains_point(const CIRC_NODE* node, const POINT2D* pt, const POINT2D* pt_outside, int* on_boundary);
double circ_tree_distance_tree(const CIRC_NODE* n1, const CIRC_NODE* n2, const SPHEROID *spheroid, double threshold);
CIRC_NODE* lwgeom_calculate_circ_tree(const LWGEOM* lwgeom);
+int circ_tree_get_point(const CIRC_NODE* node, POINT4D* pt);
#endif /* _LWGEODETIC_TREE_H */