PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1725 of file lwgeom_topo.c.

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

Referenced by _lwt_AddFaceSplit(), and lwt_ChangeEdgeGeom().

1726 {
1727  int i;
1728  POINT2D fp, lp, tp;
1729  POINTARRAY *pa = edge->points;
1730 
1731  if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1732 
1733  getPoint2d_p(pa, 0, &fp); /* save first point */
1734  getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1735  for (i=1; i<pa->npoints-1; ++i)
1736  {
1737  getPoint2d_p(pa, i, &tp); /* pick next point */
1738  if ( p2d_same(&tp, &fp) ) continue; /* equal to startpoint */
1739  if ( p2d_same(&tp, &lp) ) continue; /* equal to endpoint */
1740  /* this is a good one, neither same of start nor of end point */
1741  *ip = tp;
1742  return 1; /* found */
1743  }
1744 
1745  /* no distinct vertex found */
1746 
1747  /* interpolate if start point != end point */
1748 
1749  if ( p2d_same(&fp, &lp) ) return 0; /* no distinct points in edge */
1750 
1751  ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1752  ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1753 
1754  return 1;
1755 }
int npoints
Definition: liblwgeom.h:371
double x
Definition: liblwgeom.h:328
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition: lwalgorithm.c:49
double y
Definition: liblwgeom.h:328
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:347
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: