PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ _lwt_GetInteriorEdgePoint()

static int _lwt_GetInteriorEdgePoint ( const LWLINE edge,
POINT2D ip 
)
static

Definition at line 1746 of file lwgeom_topo.c.

1747 {
1748  uint32_t i;
1749  POINT2D fp, lp, tp;
1750  POINTARRAY *pa = edge->points;
1751 
1752  if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1753 
1754  getPoint2d_p(pa, 0, &fp); /* save first point */
1755  getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1756  for (i=1; i<pa->npoints-1; ++i)
1757  {
1758  getPoint2d_p(pa, i, &tp); /* pick next point */
1759  if ( P2D_SAME_STRICT(&tp, &fp) ) continue; /* equal to startpoint */
1760  if ( P2D_SAME_STRICT(&tp, &lp) ) continue; /* equal to endpoint */
1761  /* this is a good one, neither same of start nor of end point */
1762  *ip = tp;
1763  return 1; /* found */
1764  }
1765 
1766  /* no distinct vertex found */
1767 
1768  /* interpolate if start point != end point */
1769 
1770  if ( P2D_SAME_STRICT(&fp, &lp) ) return 0; /* no distinct points in edge */
1771 
1772  ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1773  ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1774 
1775  return 1;
1776 }
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:342
#define P2D_SAME_STRICT(a, b)
POINTARRAY * points
Definition: liblwgeom.h:483
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390
uint32_t npoints
Definition: liblwgeom.h:427

References getPoint2d_p(), POINTARRAY::npoints, P2D_SAME_STRICT, LWLINE::points, POINT2D::x, and POINT2D::y.

Referenced by lwt_ChangeEdgeGeom().

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