6754{
6755 uint64_t num, i;
6756 double mindist = FLT_MAX;
6761 int flds;
6763
6764
6765 if (!tol)
6767
6769
6770
6771
6772
6773
6774
6777 if (num == UINT64_MAX)
6778 {
6780 return -1;
6781 }
6782 if ( num )
6783 {
6784 LWDEBUGF(1,
"New point is within %.15g units of %llu nodes", tol, num);
6785
6786 if ( num > 1 )
6787 {{
6789 for (i=0; i<num; ++i)
6790 {
6791 sorted[i].
ptr = nodes+i;
6794 ((
LWT_ISO_NODE*)(sorted[i].ptr))->node_id, sorted[i].score);
6795 }
6798 for (i=0; i<num; ++i)
6799 {
6801 }
6804 nodes = nodes2;
6805 }}
6806
6807 for ( i=0; i<num; ++i )
6808 {
6812
6813
6814 if ( dist && dist >= tol ) continue;
6815 if ( ! id || dist < mindist )
6816 {
6818 mindist = dist;
6819 }
6820 }
6821 if ( id )
6822 {
6823
6825 if ( moved ) *moved = mindist == 0 ? 0 : 1;
6826 return id;
6827 }
6828 }
6829
6831
6832
6833
6834
6835
6836
6839 if (num == UINT64_MAX)
6840 {
6842 return -1;
6843 }
6844 LWDEBUGF(1,
"New point is within %.15g units of %llu edges", tol, num);
6845 if ( num )
6846 {
6849 }
6850
6851 if ( id == 0 )
6852 {
6853
6854
6856 if ( moved ) *moved = 0;
6857 if ( -1 == id )
6858 {
6859
6861 lwerror(
"lwt_AddIsoNode failed");
6862 return -1;
6863 }
6864 }
6865
6866 return id;
6867}
void lwgeom_geos_error(const char *fmt,...)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
void * lwalloc(size_t size)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
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()
#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.
#define LWDEBUGG(level, geom, msg)
LWT_ISO_EDGE * lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo, const LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
static LWT_ELEMID _lwt_AddIsoNode(LWT_TOPOLOGY *topo, LWT_ELEMID face, LWPOINT *pt, int skipISOChecks, int checkFace)
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)
static int compare_scored_pointer(const void *si1, const void *si2)
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
#define _LWT_MINTOLERANCE(topo, geom)
static LWT_ELEMID _lwt_SplitAllEdgesToNewNode(LWT_TOPOLOGY *topo, LWT_ISO_EDGE *edges, uint64_t num, LWPOINT *point, double tol, int *moved)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)