5540 uint64_t num, numedges = 0, numnodes = 0;
5548 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
5556 LWDEBUGG(1, tmp,
"Repeated-point removed");
5557 }}
else tmp=(
LWGEOM*)line;
5562 if ( ! noded )
return NULL;
5569 LWDEBUGF(1,
"BOX expanded by %g is %.15g %.15g, %.15g %.15g",
5573 int nearbyindex = 0;
5574 int nearbycount = 0;
5578 if (numedges == UINT64_MAX)
5584 LWDEBUGF(1,
"Line has %d points, its bbox intersects %d edges bboxes",
5585 line->points->npoints, numedges);
5589 nearbycount += numedges;
5591 for (i=0; i<numedges; ++i)
5599 if ( dist && dist >= tol )
continue;
5600 nearby[nearbyindex++] = g;
5602 LWDEBUGF(1,
"Found %d edges closer than tolerance (%g)", nearbyindex, tol);
5604 int nearbyedgecount = nearbyindex;
5609 if (numnodes == UINT64_MAX)
5615 LWDEBUGF(1,
"Line bbox intersects %d nodes bboxes", numnodes);
5619 nearbycount = nearbyedgecount + numnodes;
5626 for (i=0; i<numnodes; ++i)
5632 if ( dist && dist >= tol )
5634 LWDEBUGF(1,
"Node %d is %g units away, we tolerate only %g", n->
node_id, dist, tol);
5637 nearby[nearbyindex++] = g;
5640 LWDEBUGF(1,
"Found %d nodes closer than tolerance (%g)", nn, tol);
5642 int nearbynodecount = nearbyindex - nearbyedgecount;
5643 nearbycount = nearbyindex;
5645 LWDEBUGF(1,
"Number of nearby elements is %d", nearbycount);
5654 NULL, nearbycount, nearby);
5657 LWDEBUGG(1, elems,
"Collected nearby elements");
5662 LWDEBUGG(1, noded,
"Elements-snapped");
5675 LWDEBUGG(1, noded,
"Unary-unioned");
5679 if ( nearbyedgecount )
5685 LWDEBUGF(1,
"Line intersects %d edges", nearbyedgecount);
5688 NULL, nearbyedgecount, nearby);
5690 LWDEBUGG(1, iedges,
"Collected edges");
5692 LWDEBUGF(1,
"Diffing noded, with srid=%d "
5693 "and interesecting edges, with srid=%d",
5698 LWDEBUGF(1,
"Intersecting noded, with srid=%d "
5699 "and interesecting edges, with srid=%d",
5719 LWDEBUG(1,
"Linemerging intersection");
5729 LWDEBUG(1,
"Unioning difference and (linemerged) intersection");
5731 LWDEBUGG(1, noded,
"Diff-Xset Unioned");
5745 if ( nearbyedgecount )
5747 nearbycount += nearbyedgecount * 2;
5749 for (
int i=0; i<nearbyedgecount; i++)
5761 if ( nearbynodecount )
5764 NULL, nearbynodecount,
5765 nearby + nearbyedgecount);
5777 LWDEBUG(1,
"Freeing up nearby elements");
5780 if ( nearby )
lwfree(nearby);
5784 LWDEBUGG(1, noded,
"Finally-noded");
5790 LWDEBUG(1,
"Noded line was a collection");
5796 LWDEBUG(1,
"Noded line was a single geom");
5797 geomsbuf[0] = noded;
5802 LWDEBUGF(1,
"Line was split into %d edges", ngeoms);
5810 for ( i=0; i<ngeoms; ++i )
5816 #if POSTGIS_DEBUG_LEVEL > 0
5820 LWDEBUGF(1,
"Component %d of split line is: %s", i, wkt1);
5835 LWDEBUGF(1,
"Component %d of split line collapsed", i);
5844 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)
#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