Find the face-id of a face containing a given point.
5037{
5040 uint64_t num, i;
5046
5048 if ( id == -1 ) {
5050 return -1;
5051 }
5052
5053 if ( id > 0 )
5054 {
5055 return id;
5056 }
5057
5058 if ( tol == 0 )
5059 {
5060 return id;
5061 }
5062
5063 LWDEBUG(1,
"No face properly contains query point,"
5064 " looking for edges");
5065
5066
5067
5068
5069
5071 if (num == UINT64_MAX)
5072 {
5074 return -1;
5075 }
5076 for (i=0; i<num; ++i)
5077 {
5081 double dist;
5082
5084 {
5087 " has null geometry", e->
edge_id);
5088 continue;
5089 }
5090
5091
5093 {
5095 " is dangling, won't consider it", e->
edge_id);
5096 continue;
5097 }
5098
5101
5103 " is %g (tol=%g)", e->
edge_id, dist, tol);
5104
5105
5106 if ( dist > tol ) continue;
5109 }
5112 }
5113 else {
5115 lwerror(
"Two or more faces found");
5116 return -1;
5117 }
5118
5119 if ( id && id != eface )
5120 {
5122 lwerror(
"Two or more faces found"
5123#if 0
5126#endif
5127 );
5128 return -1;
5129 }
5130 else id = eface;
5131 }
5133
5134 return id;
5135}
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
double lwgeom_mindistance2d_tolerance(const LWGEOM *lw1, const LWGEOM *lw2, double tolerance)
Function handling min distance calculations and dwithin calculations.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
#define LWT_COL_EDGE_FACE_RIGHT
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_FACE_LEFT
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_EDGE_GEOM
#define PGTOPO_BE_ERROR()
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_ISO_EDGE * lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo, const LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
LWT_ELEMID lwt_GetFaceContainingPoint(LWT_TOPOLOGY *topo, const LWPOINT *pt)
Find the face-id of the face properly containing a given point.
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)