5594 uint64_t num, numedges = 0, numnodes = 0;
5608 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
5616 LWDEBUGG(1, tmp,
"Repeated-point removed");
5617 }}
else tmp=(
LWGEOM*)line;
5622 if ( ! noded )
return NULL;
5629 LWDEBUGF(1,
"BOX expanded by %g is %.15g %.15g, %.15g %.15g",
5633 int nearbyindex = 0;
5634 int nearbycount = 0;
5638 if (numedges == UINT64_MAX)
5644 LWDEBUGF(1,
"Line has %d points, its bbox intersects %d edges bboxes",
5645 line->points->npoints, numedges);
5649 nearbycount += numedges;
5651 for (i=0; i<numedges; ++i)
5659 if ( dist && dist >= tol )
continue;
5660 nearby[nearbyindex++] = g;
5662 LWDEBUGF(1,
"Found %d edges closer than tolerance (%g)", nearbyindex, tol);
5664 int nearbyedgecount = nearbyindex;
5671 if (numnodes == UINT64_MAX)
5677 LWDEBUGF(1,
"Line bbox intersects %d nodes bboxes", numnodes);
5681 nearbycount = nearbyedgecount + numnodes;
5689 for (i=0; i<numnodes; ++i)
5696 if ( dist && dist >= tol )
5698 LWDEBUGF(1,
"Node %d is %g units away, we tolerate only %g", n->
node_id, dist, tol);
5701 nearby[nearbyindex++] = g;
5704 LWDEBUGF(1,
"Found %d isolated nodes closer than tolerance (%g)", nn, tol);
5706 int nearbynodecount = nearbyindex - nearbyedgecount;
5707 nearbycount = nearbyindex;
5709 LWDEBUGF(1,
"Number of nearby elements is %d", nearbycount);
5718 NULL, nearbycount, nearby);
5721 LWDEBUGG(1, elems,
"Collected nearby elements");
5726 LWDEBUGG(1, noded,
"Elements-snapped");
5739 LWDEBUGG(1, noded,
"Unary-unioned");
5743 if ( nearbyedgecount )
5749 LWDEBUGF(1,
"Line intersects %d edges", nearbyedgecount);
5752 NULL, nearbyedgecount, nearby);
5754 LWDEBUGG(1, iedges,
"Collected edges");
5756 LWDEBUGF(1,
"Diffing noded, with srid=%d "
5757 "and interesecting edges, with srid=%d",
5762 LWDEBUGF(1,
"Intersecting noded, with srid=%d "
5763 "and interesecting edges, with srid=%d",
5783 LWDEBUG(1,
"Linemerging intersection");
5793 LWDEBUG(1,
"Unioning difference and (linemerged) intersection");
5795 LWDEBUGG(1, noded,
"Diff-Xset Unioned");
5809 if ( nearbyedgecount )
5811 nearbycount += nearbyedgecount * 2;
5813 for (
int i=0; i<nearbyedgecount; i++)
5825 if ( nearbynodecount )
5828 NULL, nearbynodecount,
5829 nearby + nearbyedgecount);
5841 LWDEBUG(1,
"Freeing up nearby elements");
5844 if ( nearby )
lwfree(nearby);
5848 LWDEBUGG(1, noded,
"Finally-noded");
5854 LWDEBUG(1,
"Noded line was a collection");
5860 LWDEBUG(1,
"Noded line was a single geom");
5861 geomsbuf[0] = noded;
5866 LWDEBUGF(1,
"Line was split into %d edges", ngeoms);
5874 for ( i=0; i<ngeoms; ++i )
5880 #if POSTGIS_DEBUG_LEVEL > 0
5884 LWDEBUGF(1,
"Component %d of split line is: %s", i, wkt1);
5899 LWDEBUGF(1,
"Component %d of split line collapsed", i);
5908 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.
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)
int lwline_is_empty(const LWLINE *line)
#define LW_ON_INTERRUPT(x)
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_ELEMID _lwt_AddLineEdge(LWT_TOPOLOGY *topo, LWLINE *edge, double tol, int handleFaceSplit)
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 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