5620 uint64_t num, numedges = 0, numnodes = 0;
5624 int input_was_closed = 0;
5629 input_was_closed = 1;
5631 LWDEBUGF(1,
"Input line is closed, original point is %g,%g", originalStartPoint.
x, originalStartPoint.
y);
5638 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
5646 LWDEBUGG(1, tmp,
"Repeated-point removed");
5647 }}
else tmp=(
LWGEOM*)line;
5652 if ( ! noded )
return NULL;
5659 LWDEBUGF(1,
"BOX expanded by %g is %.15g %.15g, %.15g %.15g",
5663 int nearbyindex = 0;
5664 int nearbycount = 0;
5668 if (numedges == UINT64_MAX)
5674 LWDEBUGF(1,
"Line has %d points, its bbox intersects %d edges bboxes",
5675 line->points->npoints, numedges);
5679 nearbycount += numedges;
5681 for (i=0; i<numedges; ++i)
5689 if ( dist && dist >= tol )
continue;
5690 nearby[nearbyindex++] = g;
5692 LWDEBUGF(1,
"Found %d edges closer than tolerance (%g)", nearbyindex, tol);
5694 int nearbyedgecount = nearbyindex;
5701 if (numnodes == UINT64_MAX)
5707 LWDEBUGF(1,
"Line bbox intersects %d nodes bboxes", numnodes);
5711 nearbycount = nearbyedgecount + numnodes;
5718 for (i=0; i<numnodes; ++i)
5725 if ( dist && dist >= tol )
5727 LWDEBUGF(1,
"Node %d is %g units away, we tolerate only %g", n->
node_id, dist, tol);
5730 nearby[nearbyindex++] = g;
5733 LWDEBUGF(1,
"Found %d isolated nodes closer than tolerance (%g)", nn, tol);
5735 int nearbynodecount = nearbyindex - nearbyedgecount;
5736 nearbycount = nearbyindex;
5738 LWDEBUGF(1,
"Number of nearby elements is %d", nearbycount);
5747 NULL, nearbycount, nearby);
5750 LWDEBUGG(1, elems,
"Collected nearby elements");
5755 LWDEBUGG(1, noded,
"Elements-snapped");
5756 if ( input_was_closed )
5763 LWDEBUGF(1,
"Closed input line start point after snap %g,%g", originalStartPoint.
x, originalStartPoint.
y);
5778 LWDEBUGG(1, noded,
"Unary-unioned");
5782 if ( nearbyedgecount )
5788 LWDEBUGF(1,
"Line intersects %d edges", nearbyedgecount);
5791 NULL, nearbyedgecount, nearby);
5793 LWDEBUGG(1, iedges,
"Collected edges");
5795 LWDEBUGF(1,
"Diffing noded, with srid=%d "
5796 "and interesecting edges, with srid=%d",
5801 LWDEBUGF(1,
"Intersecting noded, with srid=%d "
5802 "and interesecting edges, with srid=%d",
5822 LWDEBUG(1,
"Linemerging intersection");
5832 LWDEBUG(1,
"Unioning difference and (linemerged) intersection");
5834 LWDEBUGG(1, noded,
"Diff-Xset Unioned");
5841 if ( input_was_closed )
5853 LWDEBUGG(1, xset,
"Linemerged intersected input is not a line anymore");
5866 if ( nearbyedgecount )
5868 nearbycount += nearbyedgecount * 2;
5870 for (
int i=0; i<nearbyedgecount; i++)
5882 if ( nearbynodecount )
5885 NULL, nearbynodecount,
5886 nearby + nearbyedgecount);
5898 LWDEBUG(1,
"Freeing up nearby elements");
5901 if ( nearby )
lwfree(nearby);
5905 LWDEBUGG(1, noded,
"Finally-noded");
5911 LWDEBUG(1,
"Noded line was a collection");
5917 LWDEBUG(1,
"Noded line was a single geom");
5918 geomsbuf[0] = noded;
5923 LWDEBUGF(1,
"Line was split into %d edges", ngeoms);
5931 for ( i=0; i<ngeoms; ++i )
5937 #if POSTGIS_DEBUG_LEVEL > 0
5941 LWDEBUGF(1,
"Component %d of split line is: %s", i, wkt1);
5956 LWDEBUGF(1,
"Component %d of split line collapsed", i);
5961 i, forward ?
"forward" :
"backward",
id);
5962 ids[num++] = forward ? id : -id;
5965 LWDEBUGG(1, noded,
"Noded before free");
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwcollection_as_lwgeom(const LWCOLLECTION *obj)
LWGEOM * lwgeom_node(const LWGEOM *lwgeom_in)
void lwgeom_free(LWGEOM *geom)
LWGEOM * lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
LWGEOM * lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2)
void * lwrealloc(void *mem, size_t size)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWGEOM * lwgeom_unaryunion(const LWGEOM *geom1)
void lwcollection_release(LWCOLLECTION *lwcollection)
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.
const GBOX * lwgeom_get_bbox(const LWGEOM *lwgeom)
Get a non-empty geometry bounding box, computing and caching it if not already there.
LWGEOM * lwgeom_linemerge(const LWGEOM *geom1)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
LWGEOM * lwgeom_union(const LWGEOM *geom1, const LWGEOM *geom2)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
LWGEOM * lwline_remove_repeated_points(const LWLINE *in, double tolerance)
#define LW_ON_INTERRUPT(x)
int lwline_is_closed(const LWLINE *line)
int ptarray_scroll_in_place(POINTARRAY *pa, const POINT4D *newbase)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
#define LWDEBUGG(level, geom, msg)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
static LWGEOM * _lwt_split_by_nodes(const LWGEOM *g, const LWGEOM *nodes)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
static LWT_ISO_NODE * lwt_be_getNodeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
#define _LWT_MINTOLERANCE(topo, geom)
static LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
static LWT_ELEMID _lwt_AddLineEdge(LWT_TOPOLOGY *topo, LWLINE *edge, double tol, int handleFaceSplit, int *forward)
static LWGEOM * _lwt_toposnap(LWGEOM *src, LWGEOM *tgt, double tol)
static void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
LWT_ELEMID containing_face
const LWT_BE_IFACE * be_iface