5542 uint64_t num, numedges = 0, numnodes = 0;
5556 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
5564 LWDEBUGG(1, tmp,
"Repeated-point removed");
5565 }}
else tmp=(
LWGEOM*)line;
5570 if ( ! noded )
return NULL;
5577 LWDEBUGF(1,
"BOX expanded by %g is %.15g %.15g, %.15g %.15g",
5581 int nearbyindex = 0;
5582 int nearbycount = 0;
5586 if (numedges == UINT64_MAX)
5592 LWDEBUGF(1,
"Line has %d points, its bbox intersects %d edges bboxes",
5593 line->points->npoints, numedges);
5597 nearbycount += numedges;
5599 for (i=0; i<numedges; ++i)
5607 if ( dist && dist >= tol )
continue;
5608 nearby[nearbyindex++] = g;
5610 LWDEBUGF(1,
"Found %d edges closer than tolerance (%g)", nearbyindex, tol);
5612 int nearbyedgecount = nearbyindex;
5617 if (numnodes == UINT64_MAX)
5623 LWDEBUGF(1,
"Line bbox intersects %d nodes bboxes", numnodes);
5627 nearbycount = nearbyedgecount + numnodes;
5634 for (i=0; i<numnodes; ++i)
5640 if ( dist && dist >= tol )
5642 LWDEBUGF(1,
"Node %d is %g units away, we tolerate only %g", n->
node_id, dist, tol);
5645 nearby[nearbyindex++] = g;
5648 LWDEBUGF(1,
"Found %d nodes closer than tolerance (%g)", nn, tol);
5650 int nearbynodecount = nearbyindex - nearbyedgecount;
5651 nearbycount = nearbyindex;
5653 LWDEBUGF(1,
"Number of nearby elements is %d", nearbycount);
5662 NULL, nearbycount, nearby);
5665 LWDEBUGG(1, elems,
"Collected nearby elements");
5670 LWDEBUGG(1, noded,
"Elements-snapped");
5683 LWDEBUGG(1, noded,
"Unary-unioned");
5687 if ( nearbyedgecount )
5693 LWDEBUGF(1,
"Line intersects %d edges", nearbyedgecount);
5696 NULL, nearbyedgecount, nearby);
5698 LWDEBUGG(1, iedges,
"Collected edges");
5700 LWDEBUGF(1,
"Diffing noded, with srid=%d "
5701 "and interesecting edges, with srid=%d",
5706 LWDEBUGF(1,
"Intersecting noded, with srid=%d "
5707 "and interesecting edges, with srid=%d",
5727 LWDEBUG(1,
"Linemerging intersection");
5737 LWDEBUG(1,
"Unioning difference and (linemerged) intersection");
5739 LWDEBUGG(1, noded,
"Diff-Xset Unioned");
5753 if ( nearbyedgecount )
5755 nearbycount += nearbyedgecount * 2;
5757 for (
int i=0; i<nearbyedgecount; i++)
5769 if ( nearbynodecount )
5772 NULL, nearbynodecount,
5773 nearby + nearbyedgecount);
5785 LWDEBUG(1,
"Freeing up nearby elements");
5788 if ( nearby )
lwfree(nearby);
5792 LWDEBUGG(1, noded,
"Finally-noded");
5798 LWDEBUG(1,
"Noded line was a collection");
5804 LWDEBUG(1,
"Noded line was a single geom");
5805 geomsbuf[0] = noded;
5810 LWDEBUGF(1,
"Line was split into %d edges", ngeoms);
5818 for ( i=0; i<ngeoms; ++i )
5824 #if POSTGIS_DEBUG_LEVEL > 0
5828 LWDEBUGF(1,
"Component %d of split line is: %s", i, wkt1);
5843 LWDEBUGF(1,
"Component %d of split line collapsed", i);
5852 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)
const LWT_BE_IFACE * be_iface