*** geo_ops.c Fri May 1 14:41:47 1998 --- geo_ops.c.last Fri May 1 13:43:36 1998 *************** *** 2354,2360 **** * * Some tricky code here, relying on boolean expressions * evaluating to only zero or one to use as an array index. - * bug fixes by gthaker@atl.lmco.com; May 1, 98 */ Point * close_ps(Point *pt, LSEG *lseg) --- 2354,2359 ---- *************** *** 2368,2374 **** result = NULL; xh = lseg->p[0].x < lseg->p[1].x; yh = lseg->p[0].y < lseg->p[1].y; ! /* !xh (or !yh) is the index of lower x( or y) end point of lseg */ /* vertical segment? */ if (lseg_vertical(lseg)) --- 2367,2382 ---- result = NULL; xh = lseg->p[0].x < lseg->p[1].x; yh = lseg->p[0].y < lseg->p[1].y; ! if (pt->x < lseg->p[!xh].x) ! result = point_copy(&lseg->p[!xh]); ! else if (pt->x > lseg->p[xh].x) ! result = point_copy(&lseg->p[xh]); ! else if (pt->y < lseg->p[!yh].y) ! result = point_copy(&lseg->p[!yh]); ! else if (pt->y > lseg->p[yh].y) ! result = point_copy(&lseg->p[yh]); ! if (result != NULL) ! return (result); /* vertical segment? */ if (lseg_vertical(lseg)) *************** *** 2376,2391 **** #ifdef GEODEBUG printf("close_ps- segment is vertical\n"); #endif - /* first check if point is below or above the entire lseg. */ - if (pt->y < lseg->p[!yh].y) - result = point_copy(&lseg->p[!yh]); /* below the lseg */ - else if (pt->y > lseg->p[yh].y) - result = point_copy(&lseg->p[yh]); /* above the lseg */ - if (result != NULL) - return (result); - - /* point lines along (to left or right) of the vertical lseg. */ - result = palloc(sizeof(*result)); result->x = lseg->p[0].x; result->y = pt->y; --- 2384,2389 ---- *************** *** 2396,2410 **** #ifdef GEODEBUG printf("close_ps- segment is horizontal\n"); #endif - /* first check if point is left or right of the entire lseg. */ - if (pt->x < lseg->p[!xh].x) - result = point_copy(&lseg->p[!xh]); /* left of the lseg */ - else if (pt->x > lseg->p[xh].x) - result = point_copy(&lseg->p[xh]); /* right of the lseg */ - if (result != NULL) - return (result); - - /* point lines along (at top or below) the horiz. lseg. */ result = palloc(sizeof(*result)); result->x = pt->x; result->y = lseg->p[0].y; --- 2394,2399 ----