7126 uint64_t num, numedges = 0, numnodes = 0;
7130 int input_was_closed = 0;
7141 input_was_closed = 1;
7143 LWDEBUGF(1,
"Input line is closed, original point is %g,%g", originalStartPoint.
x, originalStartPoint.
y);
7150 LWDEBUGF(1,
"Working tolerance:%.15g", tol);
7158 LWDEBUGG(1, tmp,
"Repeated-point removed");
7159 }}
else tmp=(
LWGEOM*)line;
7164 if ( ! noded )
return NULL;
7171 LWDEBUGF(1,
"BOX expanded by %g is %.15g %.15g, %.15g %.15g",
7175 int nearbyindex = 0;
7176 int nearbycount = 0;
7180 if (numedges == UINT64_MAX)
7186 LWDEBUGF(1,
"Line has %u points, its bbox intersects %llu edges bboxes",
7187 line->points->npoints, numedges);
7193 nearbycount += numedges;
7195 for (i=0; i<numedges; ++i)
7203 if ( 0 == GEOSDistanceIndexed(edge_g, noded_g, &dist) ) {
7204 GEOSGeom_destroy(edge_g);
7205 GEOSGeom_destroy(noded_g);
7210 GEOSGeom_destroy(edge_g);
7211 if ( dist && dist >= tol )
continue;
7212 nearby[nearbyindex++] = g;
7214 LWDEBUGF(1,
"Found %d edges closer than tolerance (%g)", nearbyindex, tol);
7215 GEOSGeom_destroy(noded_g);
7217 int nearbyedgecount = nearbyindex;
7224 if (numnodes == UINT64_MAX)
7230 LWDEBUGF(1,
"Line bbox intersects %llu nodes bboxes", numnodes);
7234 nearbycount = nearbyedgecount + numnodes;
7241 for (i=0; i<numnodes; ++i)
7248 if ( dist && dist >= tol )
7253 nearby[nearbyindex++] = g;
7256 LWDEBUGF(1,
"Found %d isolated nodes closer than tolerance (%g)", nn, tol);
7258 int nearbynodecount = nearbyindex - nearbyedgecount;
7259 nearbycount = nearbyindex;
7261 LWDEBUGF(1,
"Number of nearby elements is %d", nearbycount);
7270 NULL, nearbycount, nearby);
7273 LWDEBUGG(1, elems,
"Collected nearby elements");
7278 LWDEBUGG(1, noded,
"Elements-snapped");
7279 if ( input_was_closed )
7286 LWDEBUGF(1,
"Closed input line start point after snap %g,%g", originalStartPoint.
x, originalStartPoint.
y);
7301 LWDEBUGG(1, noded,
"Unary-unioned");
7305 if ( nearbyedgecount )
7311 LWDEBUGF(1,
"Line intersects %d edges", nearbyedgecount);
7314 NULL, nearbyedgecount, nearby);
7316 LWDEBUGG(1, iedges,
"Collected edges");
7318 LWDEBUGF(1,
"Diffing noded, with srid=%d "
7319 "and intersecting edges, with srid=%d",
7324 LWDEBUGF(1,
"Intersecting noded, with srid=%d "
7325 "and intersecting edges, with srid=%d",
7345 LWDEBUG(1,
"Linemerging intersection");
7355 LWDEBUG(1,
"Unioning difference and (linemerged) intersection");
7357 LWDEBUGG(1, noded,
"Diff-Xset Unioned");
7364 if ( input_was_closed )
7376 LWDEBUGG(1, noded,
"Diff-Xset Unioned cannot be scrolled");
7389 if ( nearbyedgecount )
7391 nearbycount += nearbyedgecount * 2;
7393 for (
int i=0; i<nearbyedgecount; i++)
7405 if ( nearbynodecount )
7408 NULL, nearbynodecount,
7409 nearby + nearbyedgecount);
7421 LWDEBUG(1,
"Freeing up nearby elements");
7424 if ( nearby )
lwfree(nearby);
7428 LWDEBUGG(2, noded,
"Finally-noded");
7434 LWDEBUG(1,
"Noded line was a collection");
7440 LWDEBUG(1,
"Noded line was a single geom");
7441 geomsbuf[0] = noded;
7446 LWDEBUGF(1,
"Line was split into %d edges", ngeoms);
7454 for ( i=0; i<ngeoms; ++i )
7460 #if POSTGIS_DEBUG_LEVEL > 0
7464 LWDEBUGF(1,
"Component %llu of split line is: %s", i, wkt1);
7479 LWDEBUGF(1,
"Component %llu of split line collapsed", i);
7484 i, forward ?
"forward" :
"backward",
id);
7485 ids[num++] = forward ? id : -id;
7488 LWDEBUGG(2, noded,
"Noded before free");
void gbox_expand(GBOX *g, double d)
Move the box minimums down and the maximums up by the distance provided.
char lwgeom_geos_errmsg[LWGEOM_GEOS_ERRMSG_MAXSIZE]
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, uint8_t autofix)
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)
int lwline_is_empty(const LWLINE *line)
#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 PGTOPO_BE_ERROR()
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
#define LWDEBUGG(level, geom, msg)
static LWGEOM * _lwt_split_by_nodes(const LWGEOM *g, const LWGEOM *nodes)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
LWT_ISO_EDGE * lwt_be_getEdgeWithinBox2D(const LWT_TOPOLOGY *topo, const GBOX *box, uint64_t *numelems, int fields, uint64_t limit)
void _lwt_release_edges(LWT_ISO_EDGE *edges, int num_edges)
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_ELEMID _lwt_AddLineEdge(LWT_TOPOLOGY *topo, LWLINE *edge, double tol, int handleFaceSplit, int *forward)
static LWGEOM * _lwt_toposnap(LWGEOM *src, LWGEOM *tgt, double tol)
LWT_ELEMID containing_face