PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ lwt_edgeEnd_fromEdge()

LWT_EDGEEND* lwt_edgeEnd_fromEdge ( const LWT_ISO_EDGE edge,
int  outgoing 
)

Definition at line 68 of file lwt_edgeend.c.

69 {
70  LWT_EDGEEND *ee = lwalloc(sizeof(LWT_EDGEEND));
71  ee->edge = edge;
72  ee->outgoing = outgoing;
73  const POINTARRAY *pa = edge->geom->points;
74 
75  int ret = _lwt_DistinctVertexes2D(
76  edge->geom->points,
77  outgoing ? 0 : pa->npoints-1, // from,
78  outgoing ? 1 : -1, // dir,
79  &(ee->p0),
80  &(ee->p1)
81  );
82  if (!ret)
83  {
84  lwerror("No distinct vertices found in edge %" LWTFMT_ELEMID, edge->edge_id);
85  return NULL;
86  }
87 
88  if ( ! azimuth_pt_pt(&(ee->p0), &(ee->p1), &(ee->azimuth)) ) {
89  lwerror("error computing azimuth of endpoint [%.15g %.15g,%.15g %.15g]",
90  ee->p0.x, ee->p0.y,
91  ee->p1.x, ee->p1.y
92  );
93  return NULL;
94  }
95 
96  LWDEBUGF(1, "Azimuth of segment [%.15g %.15g,%.15g %.15g] = %.15g",
97  ee->p0.x, ee->p0.y,
98  ee->p1.x, ee->p1.y,
99  ee->azimuth
100  );
101 
102  return ee;
103 }
int azimuth_pt_pt(const POINT2D *p1, const POINT2D *p2, double *ret)
Compute the azimuth of segment AB in radians.
Definition: measures.c:2509
void * lwalloc(size_t size)
Definition: lwutil.c:227
#define LWTFMT_ELEMID
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int _lwt_DistinctVertexes2D(const POINTARRAY *pa, int from, int dir, POINT2D *p0, POINT2D *p1)
Definition: lwt_edgeend.c:40
POINTARRAY * points
Definition: liblwgeom.h:483
double azimuth
Definition: lwt_edgeend.h:37
POINT2D p0
Definition: lwt_edgeend.h:34
POINT2D p1
Definition: lwt_edgeend.h:35
const LWT_ISO_EDGE * edge
Definition: lwt_edgeend.h:33
LWLINE * geom
LWT_ELEMID edge_id
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390
uint32_t npoints
Definition: liblwgeom.h:427

References _lwt_DistinctVertexes2D(), LWT_EDGEEND_t::azimuth, azimuth_pt_pt(), LWT_EDGEEND_t::edge, LWT_ISO_EDGE::edge_id, LWT_ISO_EDGE::geom, lwalloc(), LWDEBUGF, lwerror(), LWTFMT_ELEMID, POINTARRAY::npoints, LWT_EDGEEND_t::outgoing, LWT_EDGEEND_t::p0, LWT_EDGEEND_t::p1, LWLINE::points, POINT2D::x, and POINT2D::y.

Referenced by lwt_edgeEndStar_addEdge().

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