PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ _lwt_InitEdgeEndByLine()

static int _lwt_InitEdgeEndByLine ( edgeend fee,
edgeend lee,
LWLINE edge,
POINT2D fp,
POINT2D lp 
)
static

Definition at line 1449 of file lwgeom_topo.c.

References _lwt_FirstDistinctVertex2D(), azimuth_pt_pt(), edgeend_t::ccwFace, edgeend_t::cwFace, LWDEBUG, LWDEBUGF, lwerror(), edgeend_t::myaz, edgeend_t::nextCCW, edgeend_t::nextCW, POINTARRAY::npoints, LWLINE::points, POINT2D::x, and POINT2D::y.

Referenced by lwt_ChangeEdgeGeom().

1451 {
1452  POINTARRAY *pa = edge->points;
1453  POINT2D pt;
1454 
1455  fee->nextCW = fee->nextCCW =
1456  lee->nextCW = lee->nextCCW = 0;
1457  fee->cwFace = fee->ccwFace =
1458  lee->cwFace = lee->ccwFace = -1;
1459 
1460  /* Compute azimuth of first edge end */
1461  LWDEBUG(1, "computing azimuth of first edge end");
1462  if ( ! _lwt_FirstDistinctVertex2D(pa, fp, 0, 1, &pt) )
1463  {
1464  lwerror("Invalid edge (no two distinct vertices exist)");
1465  return -1;
1466  }
1467  if ( ! azimuth_pt_pt(fp, &pt, &(fee->myaz)) ) {
1468  lwerror("error computing azimuth of first edgeend [%.15g %.15g,%.15g %.15g]",
1469  fp->x, fp->y, pt.x, pt.y);
1470  return -2;
1471  }
1472  LWDEBUGF(1, "azimuth of first edge end [%.15g %.15g,%.15g %.15g] is %g",
1473  fp->x, fp->y, pt.x, pt.y, fee->myaz);
1474 
1475  /* Compute azimuth of second edge end */
1476  LWDEBUG(1, "computing azimuth of second edge end");
1477  if ( ! _lwt_FirstDistinctVertex2D(pa, lp, pa->npoints-1, -1, &pt) )
1478  {
1479  lwerror("Invalid edge (no two distinct vertices exist)");
1480  return -1;
1481  }
1482  if ( ! azimuth_pt_pt(lp, &pt, &(lee->myaz)) ) {
1483  lwerror("error computing azimuth of last edgeend [%.15g %.15g,%.15g %.15g]",
1484  lp->x, lp->y, pt.x, pt.y);
1485  return -2;
1486  }
1487  LWDEBUGF(1, "azimuth of last edge end [%.15g %.15g,%.15g %.15g] is %g",
1488  lp->x, lp->y, pt.x, pt.y, lee->myaz);
1489 
1490  return 0;
1491 }
int npoints
Definition: liblwgeom.h:371
static int _lwt_FirstDistinctVertex2D(const POINTARRAY *pa, POINT2D *ref, int from, int dir, POINT2D *op)
Definition: lwgeom_topo.c:1410
LWT_ELEMID cwFace
Definition: lwgeom_topo.c:1391
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
LWT_ELEMID nextCCW
Definition: lwgeom_topo.c:1393
double x
Definition: liblwgeom.h:328
double myaz
Definition: lwgeom_topo.c:1397
double y
Definition: liblwgeom.h:328
LWT_ELEMID ccwFace
Definition: lwgeom_topo.c:1395
LWT_ELEMID nextCW
Definition: lwgeom_topo.c:1389
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
Definition: measures.c:2427
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
POINTARRAY * points
Definition: liblwgeom.h:422
Here is the call graph for this function:
Here is the caller graph for this function: