6873{
6874 uint64_t num, i;
6875 double mindist = FLT_MAX;
6880 int flds;
6882
6883
6884 if ( tol == -1 )
6886
6888
6889
6890
6891
6892
6893
6896 if (num == UINT64_MAX)
6897 {
6899 return -1;
6900 }
6901
6902 if ( numSplitEdges ) *numSplitEdges = 0;
6903
6904 if ( num )
6905 {
6906 LWDEBUGF(1,
"New point is within %.15g units of %llu nodes", tol, num);
6907
6908 if ( num > 1 )
6909 {{
6911 for (i=0; i<num; ++i)
6912 {
6913 sorted[i].
ptr = nodes+i;
6916 ((
LWT_ISO_NODE*)(sorted[i].ptr))->node_id, sorted[i].score);
6917 }
6920 for (i=0; i<num; ++i)
6921 {
6923 }
6926 nodes = nodes2;
6927 }}
6928
6929 for ( i=0; i<num; ++i )
6930 {
6934
6935
6936 if ( dist && dist >= tol ) continue;
6937 if ( ! id || dist < mindist )
6938 {
6940 mindist = dist;
6941 }
6942 }
6943 if ( id )
6944 {
6945
6947 if ( moved ) *moved = mindist == 0 ? 0 : 1;
6948 return id;
6949 }
6950 }
6951
6953
6954
6955
6956
6957
6958
6961 if (num == UINT64_MAX)
6962 {
6964 return -1;
6965 }
6966 LWDEBUGF(1,
"New point is within %.15g units of %llu edges", tol, num);
6967 if ( num )
6968 {
6971 if ( numSplitEdges ) *numSplitEdges = num;
6972 }
6973
6974 if ( id == 0 )
6975 {
6976
6977
6979 if ( moved ) *moved = 0;
6980 if ( -1 == id )
6981 {
6982
6984 lwerror(
"lwt_AddIsoNode failed");
6985 return -1;
6986 }
6987 }
6988
6989 return id;
6990}
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)