678{
679 double max;
680 double d, d_min;
681 uint32_t i;
682
684
685
686
687
688
689
690
691 if( *min_dist < threshold || *min_dist == 0.0 )
692 return *min_dist;
693
694
696 {
697 LWDEBUGF(4,
"pruning pair %p, %p", n1, n2);
698 return FLT_MAX;
699 }
700
701
704 if( max < *max_dist )
705 *max_dist = max;
706
707
708
710 {
713 LWDEBUGF(4,
"n1 is polygon, testing if contains (%.5g,%.5g)", pt.
x, pt.
y);
715 {
717 *min_dist = 0.0;
720 return *min_dist;
721 }
722 }
723
724
726 {
729 LWDEBUGF(4,
"n2 is polygon, testing if contains (%.5g,%.5g)", pt.
x, pt.
y);
731 {
735 *min_dist = 0.0;
736 return *min_dist;
737 }
738 }
739
740
742 {
743 double d;
746
747 if ( n1->
p1 == n1->
p2 || n2->
p1 == n2->
p2 )
748 {
751
752
753 if ( n1->
p1 == n1->
p2 && n2->
p1 == n2->
p2 )
754 {
757 close1 = gp1; close2 = gp2;
759 }
760
761 else if ( n1->
p1 == n1->
p2 )
762 {
766 close1 = gp1;
768 }
769
770 else
771 {
775 close2 = gp2;
777 }
779 }
780
781 else
782 {
795 {
796 d = 0.0;
798 close1 = close2 = g;
799 }
800 else
801 {
803 }
804 LWDEBUGF(4,
"edge_distance_to_edge returned %g", d);
805 }
806 if ( d < *min_dist )
807 {
808 *min_dist = d;
809 *closest1 = close1;
810 *closest2 = close2;
811 }
812 return d;
813 }
814 else
815 {
816 d_min = FLT_MAX;
817
818
819
821 {
824 {
827 }
828 }
830 {
833 {
836 }
837 }
839 {
842 {
845 }
846 }
848 {
851 {
854 }
855 }
856 else
857 {
858
859 }
860
861 return d_min;
862 }
863}
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
int edge_intersection(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *g)
Returns true if an intersection can be calculated, and places it in *g.
uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Returns non-zero if edges A and B interact.
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
double edge_distance_to_edge(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
Calculate the distance between two edges.
int circ_tree_get_point(const CIRC_NODE *node, POINT2D *pt)
Returns a POINT2D that is a vertex of the input shape.
static double circ_node_max_distance(const CIRC_NODE *n1, const CIRC_NODE *n2)
static int circ_node_is_leaf(const CIRC_NODE *node)
Internal nodes have their point references set to NULL.
double circ_tree_distance_tree_internal(const CIRC_NODE *n1, const CIRC_NODE *n2, double threshold, double *min_dist, double *max_dist, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
static void circ_internal_nodes_sort(CIRC_NODE **nodes, uint32_t num_nodes, const CIRC_NODE *target_node)
static double circ_node_min_distance(const CIRC_NODE *n1, const CIRC_NODE *n2)
int circ_tree_contains_point(const CIRC_NODE *node, const POINT2D *pt, const POINT2D *pt_outside, int level, int *on_boundary)
Walk the tree and count intersections between the stab line and the edges.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
Two-point great circle segment from a to b.
Point in spherical coordinates on the world.
struct circ_node ** nodes