PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1728 of file lwgeom_topo.c.

1729 {
1730  uint32_t i;
1731  POINT2D fp, lp, tp;
1732  POINTARRAY *pa = edge->points;
1733 
1734  if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1735 
1736  getPoint2d_p(pa, 0, &fp); /* save first point */
1737  getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1738  for (i=1; i<pa->npoints-1; ++i)
1739  {
1740  getPoint2d_p(pa, i, &tp); /* pick next point */
1741  if ( P2D_SAME_STRICT(&tp, &fp) ) continue; /* equal to startpoint */
1742  if ( P2D_SAME_STRICT(&tp, &lp) ) continue; /* equal to endpoint */
1743  /* this is a good one, neither same of start nor of end point */
1744  *ip = tp;
1745  return 1; /* found */
1746  }
1747 
1748  /* no distinct vertex found */
1749 
1750  /* interpolate if start point != end point */
1751 
1752  if ( P2D_SAME_STRICT(&fp, &lp) ) return 0; /* no distinct points in edge */
1753 
1754  ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1755  ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1756 
1757  return 1;
1758 }
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition: lwgeom_api.c:342
#define P2D_SAME_STRICT(a, b)
Definition: lwgeom_topo.c:50
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_AddFaceSplit(), and lwt_ChangeEdgeGeom().

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