Find the face-id of a face containing a given point.
4752{
4755 uint64_t num, i;
4761
4763 if ( id == -2 ) {
4765 return -1;
4766 }
4767
4768 if ( id > 0 )
4769 {
4770 return id;
4771 }
4772 id = 0;
4773
4774 LWDEBUG(1,
"No face properly contains query point,"
4775 " looking for edges");
4776
4777
4778
4779
4780
4782 if (num == UINT64_MAX)
4783 {
4785 return -1;
4786 }
4787 for (i=0; i<num; ++i)
4788 {
4792 double dist;
4793
4795 {
4798 " has null geometry", e->
edge_id);
4799 continue;
4800 }
4801
4802
4804 {
4806 " is dangling, won't consider it", e->
edge_id);
4807 continue;
4808 }
4809
4812
4814 " is %g (tol=%g)", e->
edge_id, dist, tol);
4815
4816
4817 if ( dist > tol ) continue;
4820 }
4823 }
4824 else {
4826 lwerror(
"Two or more faces found");
4827 return -1;
4828 }
4829
4830 if ( id && id != eface )
4831 {
4833 lwerror(
"Two or more faces found"
4834#if 0
4837#endif
4838 );
4839 return -1;
4840 }
4841 else id = eface;
4842 }
4844
4845 return id;
4846}
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 LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
LWT_ELEMID lwt_be_getFaceContainingPoint(LWT_TOPOLOGY *topo, LWPOINT *pt)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
LWT_ISO_EDGE * lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo, LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
const LWT_BE_IFACE * be_iface