PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ rect_leaf_node_intersects()

static int rect_leaf_node_intersects ( RECT_NODE_LEAF n1,
RECT_NODE_LEAF n2 
)
static

Definition at line 85 of file lwtree.c.

86 {
87  const POINT2D *p1, *p2, *p3, *q1, *q2, *q3;
88  DISTPTS dl;
89  lw_dist2d_distpts_init(&dl, 1);
90  switch (n1->seg_type)
91  {
93  {
94  p1 = getPoint2d_cp(n1->pa, n1->seg_num);
95 
96  switch (n2->seg_type)
97  {
99  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
100  lw_dist2d_pt_pt(q1, p1, &dl);
101  return dl.distance == 0.0;
102 
104  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
105  q2 = getPoint2d_cp(n2->pa, n2->seg_num+1);
106  lw_dist2d_pt_seg(p1, q1, q2, &dl);
107  return dl.distance == 0.0;
108 
110  q1 = getPoint2d_cp(n2->pa, n2->seg_num*2);
111  q2 = getPoint2d_cp(n2->pa, n2->seg_num*2+1);
112  q3 = getPoint2d_cp(n2->pa, n2->seg_num*2+2);
113  lw_dist2d_pt_arc(p1, q1, q2, q3, &dl);
114  return dl.distance == 0.0;
115 
116  default:
117  lwerror("%s: unsupported segment type", __func__);
118  break;
119  }
120 
121  break;
122  }
123 
125  {
126  p1 = getPoint2d_cp(n1->pa, n1->seg_num);
127  p2 = getPoint2d_cp(n1->pa, n1->seg_num+1);
128 
129  switch (n2->seg_type)
130  {
131  case RECT_NODE_SEG_POINT:
132  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
133  lw_dist2d_pt_seg(q1, p1, p2, &dl);
134  return dl.distance == 0.0;
135 
137  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
138  q2 = getPoint2d_cp(n2->pa, n2->seg_num+1);
139  return lw_segment_intersects(p1, p2, q1, q2) > 0;
140 
142  q1 = getPoint2d_cp(n2->pa, n2->seg_num*2);
143  q2 = getPoint2d_cp(n2->pa, n2->seg_num*2+1);
144  q3 = getPoint2d_cp(n2->pa, n2->seg_num*2+2);
145  lw_dist2d_seg_arc(p1, p2, q1, q2, q3, &dl);
146  return dl.distance == 0.0;
147 
148  default:
149  lwerror("%s: unsupported segment type", __func__);
150  break;
151  }
152 
153  break;
154  }
156  {
157  p1 = getPoint2d_cp(n1->pa, n1->seg_num*2);
158  p2 = getPoint2d_cp(n1->pa, n1->seg_num*2+1);
159  p3 = getPoint2d_cp(n1->pa, n1->seg_num*2+2);
160 
161  switch (n2->seg_type)
162  {
163  case RECT_NODE_SEG_POINT:
164  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
165  lw_dist2d_pt_arc(q1, p1, p2, p3, &dl);
166  return dl.distance == 0.0;
167 
169  q1 = getPoint2d_cp(n2->pa, n2->seg_num);
170  q2 = getPoint2d_cp(n2->pa, n2->seg_num+1);
171  lw_dist2d_seg_arc(q1, q2, p1, p2, p3, &dl);
172  return dl.distance == 0.0;
173 
175  q1 = getPoint2d_cp(n2->pa, n2->seg_num*2);
176  q2 = getPoint2d_cp(n2->pa, n2->seg_num*2+1);
177  q3 = getPoint2d_cp(n2->pa, n2->seg_num*2+2);
178  lw_dist2d_arc_arc(p1, p2, p3, q1, q2, q3, &dl);
179  return dl.distance == 0.0;
180 
181  default:
182  lwerror("%s: unsupported segment type", __func__);
183  break;
184  }
185 
186  break;
187  }
188  default:
189  return LW_FALSE;
190  }
191  return LW_FALSE;
192 }
#define LW_FALSE
Definition: liblwgeom.h:77
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition: lwgeom_api.c:374
int lw_segment_intersects(const POINT2D *p1, const POINT2D *p2, const POINT2D *q1, const POINT2D *q2)
returns the kind of CG_SEGMENT_INTERSECTION_TYPE behavior of lineseg 1 (constructed from p1 and p2) a...
Definition: lwalgorithm.c:372
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
@ RECT_NODE_SEG_POINT
Definition: lwtree.h:43
@ RECT_NODE_SEG_LINEAR
Definition: lwtree.h:44
@ RECT_NODE_SEG_CIRCULAR
Definition: lwtree.h:45
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
Definition: measures.c:1439
int lw_dist2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B, DISTPTS *dl)
lw_dist2d_comp from p to line A->B This one is now sending every occasion to lw_dist2d_pt_pt Before i...
Definition: measures.c:2206
int lw_dist2d_seg_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Calculate the shortest distance between an arc and an edge.
Definition: measures.c:1292
void lw_dist2d_distpts_init(DISTPTS *dl, int mode)
Definition: measures.c:67
int lw_dist2d_arc_arc(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *B1, const POINT2D *B2, const POINT2D *B3, DISTPTS *dl)
Definition: measures.c:1497
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incoming points and stores the points closest to each other or most far away from each other...
Definition: measures.c:2282
double distance
Definition: measures.h:51
Structure used in distance-calculations.
Definition: measures.h:50
const POINTARRAY * pa
Definition: lwtree.h:50
int seg_num
Definition: lwtree.h:52
RECT_NODE_SEG_TYPE seg_type
Definition: lwtree.h:51

References DISTPTS::distance, getPoint2d_cp(), lw_dist2d_arc_arc(), lw_dist2d_distpts_init(), lw_dist2d_pt_arc(), lw_dist2d_pt_pt(), lw_dist2d_pt_seg(), lw_dist2d_seg_arc(), LW_FALSE, lw_segment_intersects(), lwerror(), RECT_NODE_LEAF::pa, RECT_NODE_SEG_CIRCULAR, RECT_NODE_SEG_LINEAR, RECT_NODE_SEG_POINT, RECT_NODE_LEAF::seg_num, and RECT_NODE_LEAF::seg_type.

Referenced by rect_tree_intersects_tree_recursive().

Here is the call graph for this function:
Here is the caller graph for this function: