PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ rect_leaf_node_segment_side()

static int rect_leaf_node_segment_side ( RECT_NODE_LEAF node,
const POINT2D q,
int *  on_boundary 
)
inlinestatic

Definition at line 199 of file lwtree.c.

200{
201 const POINT2D *p1, *p2, *p3;
202 switch (node->seg_type)
203 {
205 {
206 int side;
207 p1 = getPoint2d_cp(node->pa, node->seg_num);
208 p2 = getPoint2d_cp(node->pa, node->seg_num+1);
209
210 side = lw_segment_side(p1, p2, q);
211
212 /* Always note case where we're on boundary */
213 if (side == 0 && lw_pt_in_seg(q, p1, p2))
214 {
215 *on_boundary = LW_TRUE;
216 return 0;
217 }
218
219 /* Segment points up and point is on left */
220 if (p1->y < p2->y && side == -1 && q->y != p2->y)
221 {
222 return 1;
223 }
224
225 /* Segment points down and point is on right */
226 if (p1->y > p2->y && side == 1 && q->y != p2->y)
227 {
228 return 1;
229 }
230
231 /* Segment is horizontal, do we cross first point? */
232 if (p1->y == p2->y && q->x < p1->x)
233 {
234 return 1;
235 }
236
237 return 0;
238 }
240 {
241 int arc_side, seg_side;
242
243 p1 = getPoint2d_cp(node->pa, node->seg_num*2);
244 p2 = getPoint2d_cp(node->pa, node->seg_num*2+1);
245 p3 = getPoint2d_cp(node->pa, node->seg_num*2+2);
246
247 /* Always note case where we're on boundary */
248 arc_side = lw_arc_side(p1, p2, p3, q);
249 if (arc_side == 0)
250 {
251 *on_boundary = LW_TRUE;
252 return 0;
253 }
254
255 seg_side = lw_segment_side(p1, p3, q);
256 if (seg_side == arc_side)
257 {
258 /* Segment points up and point is on left */
259 if (p1->y < p3->y && seg_side == -1 && q->y != p3->y)
260 {
261 return 1;
262 }
263
264 /* Segment points down and point is on right */
265 if (p1->y > p3->y && seg_side == 1 && q->y != p3->y)
266 {
267 return 1;
268 }
269 }
270 else
271 {
272 /* Segment points up and point is on left */
273 if (p1->y < p3->y && seg_side == 1 && q->y != p3->y)
274 {
275 return 1;
276 }
277
278 /* Segment points down and point is on right */
279 if (p1->y > p3->y && seg_side == -1 && q->y != p3->y)
280 {
281 return 1;
282 }
283
284 /* Segment is horizontal, do we cross first point? */
285 if (p1->y == p3->y)
286 {
287 return 1;
288 }
289 }
290
291 return 0;
292
293 }
294 default:
295 {
296 lwerror("%s: unsupported seg_type - %d", __func__, node->seg_type);
297 return 0;
298 }
299 }
300
301 return 0;
302}
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:93
int lw_arc_side(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q)
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
Definition lwalgorithm.c:70
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
Definition lwinline.h:97
@ RECT_NODE_SEG_LINEAR
Definition lwtree.h:44
@ RECT_NODE_SEG_CIRCULAR
Definition lwtree.h:45
double y
Definition liblwgeom.h:390
double x
Definition liblwgeom.h:390
const POINTARRAY * pa
Definition lwtree.h:50
RECT_NODE_SEG_TYPE seg_type
Definition lwtree.h:51

References getPoint2d_cp(), lw_arc_side(), lw_pt_in_seg(), lw_segment_side(), LW_TRUE, lwerror(), RECT_NODE_LEAF::pa, RECT_NODE_SEG_CIRCULAR, RECT_NODE_SEG_LINEAR, RECT_NODE_LEAF::seg_num, RECT_NODE_LEAF::seg_type, POINT2D::x, and POINT2D::y.

Referenced by rect_tree_ring_contains_point().

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