PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1708 of file lwgeom_topo.c.

1709{
1710 uint32_t i;
1711 POINT2D fp, lp, tp;
1712 POINTARRAY *pa = edge->points;
1713
1714 if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1715
1716 getPoint2d_p(pa, 0, &fp); /* save first point */
1717 getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1718 for (i=1; i<pa->npoints-1; ++i)
1719 {
1720 getPoint2d_p(pa, i, &tp); /* pick next point */
1721 if ( p2d_same(&tp, &fp) ) continue; /* equal to startpoint */
1722 if ( p2d_same(&tp, &lp) ) continue; /* equal to endpoint */
1723 /* this is a good one, neither same of start nor of end point */
1724 *ip = tp;
1725 return 1; /* found */
1726 }
1727
1728 /* no distinct vertex found */
1729
1730 /* interpolate if start point != end point */
1731
1732 if ( p2d_same(&fp, &lp) ) return 0; /* no distinct points in edge */
1733
1734 ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1735 ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1736
1737 return 1;
1738}
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:349
int p2d_same(const POINT2D *p1, const POINT2D *p2)
Definition lwalgorithm.c:50
POINTARRAY * points
Definition liblwgeom.h:469
double y
Definition liblwgeom.h:376
double x
Definition liblwgeom.h:376
uint32_t npoints
Definition liblwgeom.h:413

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: