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

◆ lw_dist2d_pt_ptarrayarc()

int lw_dist2d_pt_ptarrayarc ( const POINT2D p,
const POINTARRAY pa,
DISTPTS dl 
)

Search all the arcs of pointarray to see which one is closest to p1 Returns minimum distance between point and arc pointarray.

Definition at line 1159 of file measures.c.

1160{
1161 uint32_t t;
1162 const POINT2D *A1;
1163 const POINT2D *A2;
1164 const POINT2D *A3;
1165 int twist = dl->twisted;
1166
1167 LWDEBUG(2, "lw_dist2d_pt_ptarrayarc is called");
1168
1169 if (pa->npoints % 2 == 0 || pa->npoints < 3)
1170 {
1171 lwerror("lw_dist2d_pt_ptarrayarc called with non-arc input");
1172 return LW_FALSE;
1173 }
1174
1175 if (dl->mode == DIST_MAX)
1176 {
1177 lwerror("lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1178 return LW_FALSE;
1179 }
1180
1181 A1 = getPoint2d_cp(pa, 0);
1182
1183 if (!lw_dist2d_pt_pt(p, A1, dl))
1184 return LW_FALSE;
1185
1186 for (t = 1; t < pa->npoints; t += 2)
1187 {
1188 dl->twisted = twist;
1189 A2 = getPoint2d_cp(pa, t);
1190 A3 = getPoint2d_cp(pa, t + 1);
1191
1192 if (lw_dist2d_pt_arc(p, A1, A2, A3, dl) == LW_FALSE)
1193 return LW_FALSE;
1194
1195 if (dl->distance <= dl->tolerance && dl->mode == DIST_MIN)
1196 return LW_TRUE; /*just a check if the answer is already given*/
1197
1198 A1 = A3;
1199 }
1200
1201 return LW_TRUE;
1202}
#define LW_FALSE
Definition liblwgeom.h:108
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:107
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:83
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition lwutil.c:190
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:91
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
Definition measures.c:1512
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:2365
#define DIST_MIN
Definition measures.h:44
#define DIST_MAX
Definition measures.h:43
int twisted
Definition measures.h:55
double tolerance
Definition measures.h:56
int mode
Definition measures.h:54
double distance
Definition measures.h:51
uint32_t npoints
Definition liblwgeom.h:413

References DIST_MAX, DIST_MIN, DISTPTS::distance, getPoint2d_cp(), lw_dist2d_pt_arc(), lw_dist2d_pt_pt(), LW_FALSE, LW_TRUE, LWDEBUG, lwerror(), DISTPTS::mode, POINTARRAY::npoints, DISTPTS::tolerance, and DISTPTS::twisted.

Referenced by lw_dist2d_point_circstring(), and test_lw_dist2d_pt_ptarrayarc().

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