Adds a point to the topology.
The given point will snap to existing nodes or edges within given tolerance. An existing edge may be split by the point.
5024 double mindist = FLT_MAX;
5051 LWDEBUGF(1,
"New point is within %.15g units of %d nodes", tol, num);
5056 for (i=0; i<num; ++i)
5058 sorted[i].
ptr = nodes+i;
5061 ((
LWT_ISO_NODE*)(sorted[i].ptr))->node_id, sorted[i].score);
5065 for (i=0; i<num; ++i)
5074 for ( i=0; i<num; ++i )
5080 if ( dist >= tol )
continue;
5081 if ( !
id || dist < mindist )
5111 LWDEBUGF(1,
"New point is within %.15g units of %d edges", tol, num);
5118 for (i=0; i<num; ++i)
5120 sorted[i].
ptr = edges+i;
5123 ((
LWT_ISO_EDGE*)(sorted[i].ptr))->edge_id, sorted[i].score);
5127 for (j=0, i=0; i<num; ++i)
5129 if ( sorted[i].score == sorted[0].score )
5144 for (i=0; i<num; ++i)
5151 GEOSGeometry *prjg, *gg;
5190 GEOSGeom_destroy(prjg);
5194 contains = GEOSContains(gg, prjg);
5195 GEOSGeom_destroy(prjg);
5196 GEOSGeom_destroy(gg);
5197 if ( contains == 2 )
5212 " does not contain projected point to it",
5219 LWDEBUG(1,
"But there's another to check");
5234 LWDEBUGF(1,
"Edge snapped with tolerance %g", snaptol);
5237 #if POSTGIS_DEBUG_LEVEL > 0 5242 LWDEBUGF(1,
"Edge %s snapped became %s", wkt1, wkt2);
5255 LWDEBUGF(1,
"Edge first point is %g %g, " 5256 "snapline first point is %g %g",
5257 p1.
x, p1.
y, p2.
x, p2.
y);
5258 if ( p1.
x != p2.
x || p1.
y != p2.
y )
5260 LWDEBUG(1,
"Snapping moved first point, re-adding it");
5269 #if POSTGIS_DEBUG_LEVEL > 0 5273 LWDEBUGF(1,
"Tweaked snapline became %s", wkt1);
5278 #if POSTGIS_DEBUG_LEVEL > 0 5280 LWDEBUG(1,
"Snapping did not move first point");
5290 lwerror(
"lwt_ChangeEdgeGeom failed");
5295 #if POSTGIS_DEBUG_LEVEL > 0 5301 LWDEBUGF(1,
"Edge %s contains projected point %s", wkt1, wkt2);
5314 lwerror(
"lwt_ModEdgeSplit failed");
5345 lwerror(
"lwt_AddIsoNode failed");
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
int lwt_ChangeEdgeGeom(LWT_TOPOLOGY *topo, LWT_ELEMID edge_id, LWLINE *geom)
Changes the shape of an edge without affecting the topology structure.
LWGEOM * lwgeom_closest_point(const LWGEOM *lw1, const LWGEOM *lw2)
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
LWGEOM * lwgeom_force_3dz(const LWGEOM *geom)
void lwgeom_free(LWGEOM *geom)
static int compare_scored_pointer(const void *si1, const void *si2)
LWT_ISO_NODE * lwt_be_getNodeWithinDistance2D(LWT_TOPOLOGY *topo, LWPOINT *pt, double dist, int *numelems, int fields, int limit)
void lwline_free(LWLINE *line)
Datum contains(PG_FUNCTION_ARGS)
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
#define LWDEBUG(level, msg)
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
#define _LWT_MINTOLERANCE(topo, geom)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
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.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
void lwgeom_geos_error(const char *fmt,...)
const LWT_BE_IFACE * be_iface
static double _lwt_minTolerance(LWGEOM *g)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWT_ELEMID lwt_AddIsoNode(LWT_TOPOLOGY *topo, LWT_ELEMID face, LWPOINT *pt, int skipISOChecks)
Add an isolated node.
#define LWDEBUGG(level, geom, msg)
#define LWT_COL_EDGE_EDGE_ID
Edge fields.
#define LWT_COL_NODE_NODE_ID
Node fields.
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
double lwgeom_mindistance2d(const LWGEOM *lw1, const LWGEOM *lw2)
Function initialazing min distance calculation.
LWT_ISO_EDGE * lwt_be_getEdgeWithinDistance2D(LWT_TOPOLOGY *topo, LWPOINT *pt, double dist, int *numelems, int fields, int limit)
#define LWT_COL_NODE_GEOM
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_GEOM
void * lwalloc(size_t size)
static LWGEOM * _lwt_toposnap(LWGEOM *src, LWGEOM *tgt, double tol)
#define LWDEBUGF(level, msg,...)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)