PostGIS  3.2.2dev-r@@SVN_REVISION@@

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1749 of file lwgeom_topo.c.

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

References getPoint2d_p(), POINTARRAY::npoints, p2d_same(), 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: