4921 double mindist = FLT_MAX;
4942 if (num == UINT64_MAX)
4949 LWDEBUGF(1,
"New point is within %.15g units of %d nodes", tol, num);
4954 for (i=0; i<num; ++i)
4956 sorted[i].
ptr = nodes+i;
4959 ((
LWT_ISO_NODE*)(sorted[i].ptr))->node_id, sorted[i].score);
4963 for (i=0; i<num; ++i)
4972 for ( i=0; i<num; ++i )
4979 if ( dist && dist >= tol )
continue;
4980 if ( !
id || dist < mindist )
4990 if ( moved ) *moved = mindist == 0 ? 0 : 1;
5004 if (num == UINT64_MAX)
5011 LWDEBUGF(1,
"New point is within %.15g units of %d edges", tol, num);
5018 for (i=0; i<num; ++i)
5020 sorted[i].
ptr = edges+i;
5023 ((
LWT_ISO_EDGE*)(sorted[i].ptr))->edge_id, sorted[i].score);
5027 for (j=0, i=0; i<num; ++i)
5029 if ( sorted[i].score == sorted[0].score )
5044 for (i=0; i<num; ++i)
5057 if ( moved ) *moved =
lwgeom_same(prj,pt) ? 0 : 1;
5089 " does not contain projected point to it",
5096 LWDEBUG(1,
"But there's another to check");
5111 LWDEBUGF(1,
"Edge snapped with tolerance %g", snaptol);
5114 #if POSTGIS_DEBUG_LEVEL > 0
5119 LWDEBUGF(1,
"Edge %s snapped became %s", wkt1, wkt2);
5132 LWDEBUGF(1,
"Edge first point is %g %g, "
5133 "snapline first point is %g %g",
5134 p1.
x, p1.
y, p2.
x, p2.
y);
5135 if ( p1.
x != p2.
x || p1.
y != p2.
y )
5137 LWDEBUG(1,
"Snapping moved first point, re-adding it");
5146 #if POSTGIS_DEBUG_LEVEL > 0
5150 LWDEBUGF(1,
"Tweaked snapline became %s", wkt1);
5155 #if POSTGIS_DEBUG_LEVEL > 0
5157 LWDEBUG(1,
"Snapping did not move first point");
5167 lwerror(
"lwt_ChangeEdgeGeom failed");
5172 #if POSTGIS_DEBUG_LEVEL > 0
5178 LWDEBUGF(1,
"Edge %s contains projected point %s", wkt1, wkt2);
5191 lwerror(
"lwt_ModEdgeSplit failed");
5219 if ( moved ) *moved = 0;
5223 lwerror(
"lwt_AddIsoNode failed");
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
void lwgeom_geos_error(const char *fmt,...)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
char lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2)
geom1 same as geom2 iff
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
void lwgeom_free(LWGEOM *geom)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initializing min distance calculation.
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
void * lwalloc(size_t size)
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void lwline_free(LWLINE *line)
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_NODE_GEOM
#define LWT_COL_NODE_NODE_ID
Node 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.
#define LWDEBUGG(level, geom, msg)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
LWT_ELEMID lwt_ModEdgeSplit(LWT_TOPOLOGY *topo, LWT_ELEMID edge, LWPOINT *pt, int skipISOChecks)
Split an edge by a node, modifying the original edge and adding a new one.
static LWT_ELEMID _lwt_AddIsoNode(LWT_TOPOLOGY *topo, LWT_ELEMID face, LWPOINT *pt, int skipISOChecks, int checkFace)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
static double _lwt_minTolerance(LWGEOM *g)
LWT_ISO_NODE * lwt_be_getNodeWithinDistance2D(LWT_TOPOLOGY *topo, LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
static int compare_scored_pointer(const void *si1, const void *si2)
LWT_ISO_EDGE * lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo, LWPOINT *pt, double dist, uint64_t *numelems, int fields, int64_t limit)
#define _LWT_MINTOLERANCE(topo, geom)
static LWGEOM * _lwt_toposnap(LWGEOM *src, LWGEOM *tgt, double tol)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
int lwt_ChangeEdgeGeom(LWT_TOPOLOGY *topo, LWT_ELEMID edge_id, LWLINE *geom)
Changes the shape of an edge without affecting the topology structure.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Datum contains(PG_FUNCTION_ARGS)
const LWT_BE_IFACE * be_iface