PostGIS  3.3.9dev-r@@SVN_REVISION@@

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1755 of file lwgeom_topo.c.

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

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: