PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ _lwt_GetEqualEdge()

static LWT_ELEMID _lwt_GetEqualEdge ( LWT_TOPOLOGY topo,
LWLINE edge 
)
static

Definition at line 5241 of file lwgeom_topo.c.

5242 {
5243  LWT_ELEMID id;
5244  LWT_ISO_EDGE *edges;
5245  uint64_t num, i;
5246  const GBOX *qbox = lwgeom_get_bbox( lwline_as_lwgeom(edge) );
5247  GEOSGeometry *edgeg;
5248  const int flds = LWT_COL_EDGE_EDGE_ID|LWT_COL_EDGE_GEOM;
5249 
5250  edges = lwt_be_getEdgeWithinBox2D( topo, qbox, &num, flds, 0 );
5251  if (num == UINT64_MAX)
5252  {
5253  lwerror("Backend error: %s", lwt_be_lastErrorMessage(topo->be_iface));
5254  return -1;
5255  }
5256  if ( num )
5257  {
5258  initGEOS(lwnotice, lwgeom_geos_error);
5259 
5260  edgeg = LWGEOM2GEOS( lwline_as_lwgeom(edge), 0 );
5261  if ( ! edgeg )
5262  {
5263  _lwt_release_edges(edges, num);
5264  lwerror("Could not convert edge geometry to GEOS: %s", lwgeom_geos_errmsg);
5265  return -1;
5266  }
5267  for (i=0; i<num; ++i)
5268  {
5269  LWT_ISO_EDGE *e = &(edges[i]);
5270  LWGEOM *g = lwline_as_lwgeom(e->geom);
5271  GEOSGeometry *gg;
5272  int equals;
5273  gg = LWGEOM2GEOS( g, 0 );
5274  if ( ! gg )
5275  {
5276  GEOSGeom_destroy(edgeg);
5277  _lwt_release_edges(edges, num);
5278  lwerror("Could not convert edge geometry to GEOS: %s", lwgeom_geos_errmsg);
5279  return -1;
5280  }
5281  equals = GEOSEquals(gg, edgeg);
5282  GEOSGeom_destroy(gg);
5283  if ( equals == 2 )
5284  {
5285  GEOSGeom_destroy(edgeg);
5286  _lwt_release_edges(edges, num);
5287  lwerror("GEOSEquals exception: %s", lwgeom_geos_errmsg);
5288  return -1;
5289  }
5290  if ( equals )
5291  {
5292  id = e->edge_id;
5293  GEOSGeom_destroy(edgeg);
5294  _lwt_release_edges(edges, num);
5295  return id;
5296  }
5297  }
5298  GEOSGeom_destroy(edgeg);
5299  _lwt_release_edges(edges, num);
5300  }
5301 
5302  return 0;
5303 }
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
void lwgeom_geos_error(const char *fmt,...)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:321
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
Definition: lwgeom.c:725
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_EDGE_GEOM
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
Definition: lwutil.c:177
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
Definition: lwgeom_topo.c:119
static LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
Definition: lwgeom_topo.c:178
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
Definition: lwgeom_topo.c:451
LWLINE * geom
LWT_ELEMID edge_id
const LWT_BE_IFACE * be_iface

References _lwt_release_edges(), LWT_TOPOLOGY_T::be_iface, LWT_ISO_EDGE::edge_id, LWT_ISO_EDGE::geom, lwerror(), LWGEOM2GEOS(), lwgeom_geos_errmsg, lwgeom_geos_error(), lwgeom_get_bbox(), lwline_as_lwgeom(), lwnotice(), lwt_be_getEdgeWithinBox2D(), lwt_be_lastErrorMessage(), LWT_COL_EDGE_EDGE_ID, and LWT_COL_EDGE_GEOM.

Referenced by _lwt_AddLineEdge().

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