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

◆ _lwt_GetInteriorEdgePoint()

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

Definition at line 1863 of file lwgeom_topo.c.

1864{
1865 uint32_t i;
1866 POINT2D fp, lp, tp;
1867 POINTARRAY *pa = edge->points;
1868
1869 if ( pa->npoints < 2 ) return 0; /* empty or structurally collapsed */
1870
1871 getPoint2d_p(pa, 0, &fp); /* save first point */
1872 getPoint2d_p(pa, pa->npoints-1, &lp); /* save last point */
1873 for (i=1; i<pa->npoints-1; ++i)
1874 {
1875 getPoint2d_p(pa, i, &tp); /* pick next point */
1876 if ( P2D_SAME_STRICT(&tp, &fp) ) continue; /* equal to startpoint */
1877 if ( P2D_SAME_STRICT(&tp, &lp) ) continue; /* equal to endpoint */
1878 /* this is a good one, neither same of start nor of end point */
1879 *ip = tp;
1880 return 1; /* found */
1881 }
1882
1883 /* no distinct vertex found */
1884
1885 /* interpolate if start point != end point */
1886
1887 if ( P2D_SAME_STRICT(&fp, &lp) ) return 0; /* no distinct points in edge */
1888
1889 ip->x = fp.x + ( (lp.x - fp.x) * 0.5 );
1890 ip->y = fp.y + ( (lp.y - fp.y) * 0.5 );
1891
1892 return 1;
1893}
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:342
#define P2D_SAME_STRICT(a, b)
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_ChangeEdgeGeom().

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