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

◆ lwt_GetNodeByPoint()

LWT_ELEMID lwt_GetNodeByPoint ( LWT_TOPOLOGY topo,
LWPOINT pt,
double  tol 
)

Retrieve the id of a node at a point location.

Parameters
topothe topology to operate on
pointthe point to use for query
tolmax distance around the given point to look for a node
Returns
a node identifier if one is found, 0 if none is found, -1 on error (multiple nodes within distance). The liblwgeom error handler will be invoked in case of error.

Definition at line 4945 of file lwgeom_topo.c.

4946{
4947 LWT_ISO_NODE *elem;
4948 uint64_t num;
4949 int flds = LWT_COL_NODE_NODE_ID|LWT_COL_NODE_GEOM; /* geom not needed */
4950 LWT_ELEMID id = 0;
4951 POINT2D qp; /* query point */
4952
4953 if ( ! getPoint2d_p(pt->point, 0, &qp) )
4954 {
4955 lwerror("Empty query point");
4956 return -1;
4957 }
4958 elem = lwt_be_getNodeWithinDistance2D(topo, pt, tol, &num, flds, 0);
4959 if (num == UINT64_MAX)
4960 {
4962 return -1;
4963 }
4964 else if ( num )
4965 {
4966 if ( num > 1 )
4967 {
4968 _lwt_release_nodes(elem, num);
4969 lwerror("Two or more nodes found");
4970 return -1;
4971 }
4972 id = elem[0].node_id;
4973 _lwt_release_nodes(elem, num);
4974 }
4975
4976 return id;
4977}
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
Definition lwgeom_api.c:342
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_NODE_GEOM
#define LWT_COL_NODE_NODE_ID
Node fields.
#define PGTOPO_BE_ERROR()
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_ISO_NODE * lwt_be_getNodeWithinDistance2D(LWT_TOPOLOGY *topo, const LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
POINTARRAY * point
Definition liblwgeom.h:471
LWT_ELEMID node_id

References _lwt_release_nodes(), getPoint2d_p(), lwerror(), lwt_be_getNodeWithinDistance2D(), LWT_COL_NODE_GEOM, LWT_COL_NODE_NODE_ID, LWT_ISO_NODE::node_id, PGTOPO_BE_ERROR, and LWPOINT::point.

Here is the call graph for this function: