PostGIS  2.5.0dev-r@@SVN_REVISION@@
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 1079 of file measures.c.

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().

1080 {
1081  uint32_t t;
1082  const POINT2D *A1;
1083  const POINT2D *A2;
1084  const POINT2D *A3;
1085  int twist = dl->twisted;
1086 
1087  LWDEBUG(2, "lw_dist2d_pt_ptarrayarc is called");
1088 
1089  if ( pa->npoints % 2 == 0 || pa->npoints < 3 )
1090  {
1091  lwerror("lw_dist2d_pt_ptarrayarc called with non-arc input");
1092  return LW_FALSE;
1093  }
1094 
1095  if (dl->mode == DIST_MAX)
1096  {
1097  lwerror("lw_dist2d_pt_ptarrayarc does not currently support DIST_MAX mode");
1098  return LW_FALSE;
1099  }
1100 
1101  A1 = getPoint2d_cp(pa, 0);
1102 
1103  if ( ! lw_dist2d_pt_pt(p, A1, dl) )
1104  return LW_FALSE;
1105 
1106  for ( t=1; t<pa->npoints; t += 2 )
1107  {
1108  dl->twisted = twist;
1109  A2 = getPoint2d_cp(pa, t);
1110  A3 = getPoint2d_cp(pa, t+1);
1111 
1112  if ( lw_dist2d_pt_arc(p, A1, A2, A3, dl) == LW_FALSE )
1113  return LW_FALSE;
1114 
1115  if ( dl->distance <= dl->tolerance && dl->mode == DIST_MIN )
1116  return LW_TRUE; /*just a check if the answer is already given*/
1117 
1118  A1 = A3;
1119  }
1120 
1121  return LW_TRUE;
1122 }
int mode
Definition: measures.h:51
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
unsigned int uint32_t
Definition: uthash.h:78
double tolerance
Definition: measures.h:53
#define DIST_MIN
Definition: measures.h:41
#define LW_FALSE
Definition: liblwgeom.h:76
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:75
int lw_dist2d_pt_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, DISTPTS *dl)
Definition: measures.c:1435
int twisted
Definition: measures.h:52
double distance
Definition: measures.h:48
#define DIST_MAX
Definition: measures.h:40
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
int lw_dist2d_pt_pt(const POINT2D *thep1, const POINT2D *thep2, DISTPTS *dl)
Compares incomming points and stores the points closest to each other or most far away from each othe...
Definition: measures.c:2276
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:364
uint32_t npoints
Definition: liblwgeom.h:370

Here is the call graph for this function:

Here is the caller graph for this function: