PostGIS  2.2.7dev-r@@SVN_REVISION@@
static int _lwt_GetInteriorEdgePoint ( const LWLINE edge,
POINT2D ip 
)
static

Definition at line 1719 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().

1720 {
1721  int i;
1722  POINT2D fp, lp, tp;
1723  POINTARRAY *pa = edge->points;
1724 
1725  if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1726 
1727  getPoint2d_p(pa, 0, &fp); /* save first point */
1728  getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1729  for (i=1; i<pa->npoints-1; ++i)
1730  {
1731  getPoint2d_p(pa, i, &tp); /* pick next point */
1732  if ( p2d_same(&tp, &fp) ) continue; /* equal to startpoint */
1733  if ( p2d_same(&tp, &lp) ) continue; /* equal to endpoint */
1734  /* this is a good one, neither same of start nor of end point */
1735  *ip = tp;
1736  return 1; /* found */
1737  }
1738 
1739  /* no distinct vertex found */
1740 
1741  /* interpolate if start point != end point */
1742 
1743  if ( p2d_same(&fp, &lp) ) return 0; /* no distinct points in edge */
1744 
1745  ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1746  ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1747 
1748  return 1;
1749 }
int npoints
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:312
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition: lwalgorithm.c:35
double y
Definition: liblwgeom.h:312
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
Definition: lwgeom_api.c:448
POINTARRAY * points
Definition: liblwgeom.h:406

Here is the call graph for this function:

Here is the caller graph for this function: