5319{
5321 LWPOINT *start_point, *end_point;
5327 uint64_t nn, i;
5328 int moved=0, mm;
5329
5331 LWDEBUGF(1,
"_lwtAddLineEdge with tolerance %g", tol);
5332
5334 if ( ! start_point )
5335 {
5336 lwnotice(
"Empty component of noded line");
5337 return 0;
5338 }
5341 handleFaceSplit, &mm );
5343 if ( nid[0] == -1 ) return -1;
5344 moved += mm;
5345
5346
5348 if ( ! end_point )
5349 {
5350 lwerror(
"could not get last point of line "
5351 "after successfully getting first point !?");
5352 return -1;
5353 }
5356 handleFaceSplit, &mm );
5357 moved += mm;
5359 if ( nid[1] == -1 ) return -1;
5360
5361
5362
5363
5364
5365 if ( moved )
5366 {
5367
5368 nn = nid[0] == nid[1] ? 1 : 2;
5371 if (nn == UINT64_MAX)
5372 {
5374 return -1;
5375 }
5376 start_point = NULL; end_point = NULL;
5377 for (i=0; i<nn; ++i)
5378 {
5379 if ( node[i].node_id == nid[0] ) start_point = node[i].
geom;
5380 if ( node[i].node_id == nid[1] ) end_point = node[i].
geom;
5381 }
5382 if ( ! start_point || ! end_point )
5383 {
5387 return -1;
5388 }
5389
5390
5391
5394
5397
5399
5400
5402
5404 if ( col )
5405 {{
5406
5408
5409
5411 {
5414 LWDEBUG(1,
"Made-valid snapped edge collapsed");
5415 return 0;
5416 }
5417
5420 tmp = tmp2;
5423 if ( ! edge )
5424 {
5425
5426 lwerror(
"lwcollection_extract(LINETYPE) returned a non-line?");
5427 return -1;
5428 }
5429 }}
5430 else
5431 {
5433 if ( ! edge )
5434 {
5435 LWDEBUGF(1,
"Made-valid snapped edge collapsed to %s",
5438 return 0;
5439 }
5440 }
5441 }
5442
5443
5446 if ( id == -1 )
5447 {
5449 return -1;
5450 }
5451 if ( id )
5452 {
5454 return id;
5455 }
5456
5457
5458
5459
5460
5461 if ( tol )
5462 {{
5464 LWDEBUGG(1, tmp2,
"Repeated-point removed");
5467 tmp = tmp2;
5468
5469
5471 {
5473 LWDEBUG(1,
"Repeated-point removed edge collapsed");
5474 return 0;
5475 }
5476
5477
5480 if ( id == -1 )
5481 {
5483 return -1;
5484 }
5485 if ( id )
5486 {
5488 return id;
5489 }
5490 }}
5491
5492
5493
5494 id =
_lwt_AddEdge( topo, nid[0], nid[1], edge, 0, handleFaceSplit ? 1 : -1 );
5496 if ( id == -1 )
5497 {
5499 return -1;
5500 }
5502
5503 return id;
5504}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWCOLLECTION * lwcollection_extract(LWCOLLECTION *col, int type)
Takes a potentially heterogeneous collection and returns a homogeneous collection consisting only of ...
void lwpoint_free(LWPOINT *pt)
void lwgeom_free(LWGEOM *geom)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.
LWCOLLECTION * lwgeom_as_lwcollection(const LWGEOM *lwgeom)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
void lwcollection_free(LWCOLLECTION *col)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
void lwline_setPoint4d(LWLINE *line, uint32_t which, POINT4D *newpoint)
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
LWGEOM * lwline_remove_repeated_points(const LWLINE *in, double tolerance)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_NODE_GEOM
#define LWT_COL_NODE_NODE_ID
Node fields.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
#define LWDEBUGG(level, geom, msg)
static LWT_ELEMID _lwt_AddEdge(LWT_TOPOLOGY *topo, LWT_ELEMID start_node, LWT_ELEMID end_node, LWLINE *geom, int skipChecks, int modFace)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
static double _lwt_minTolerance(LWGEOM *g)
static LWT_ELEMID _lwt_GetEqualEdge(LWT_TOPOLOGY *topo, LWLINE *edge)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
static LWT_ELEMID _lwt_AddPoint(LWT_TOPOLOGY *topo, LWPOINT *point, double tol, int findFace, int *moved)
LWT_ISO_NODE * lwt_be_getNodeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
static uint32_t lwgeom_get_type(const LWGEOM *geom)
Return LWTYPE number.
const LWT_BE_IFACE * be_iface