Changes the shape of an edge without affecting the topology structure.
3267 int leftRingIsCCW = -1;
3272 lwerror(
"SQL/MM Spatial exception - curve not simple");
3281 "lwt_be_getEdgeById returned NULL and set i=%llu", i);
3282 if (i == UINT64_MAX)
3289 lwerror(
"SQL/MM Spatial exception - non-existent edge %"
3295 lwerror(
"Backend coding error: getEdgeById callback returned NULL "
3296 "but numelements output parameter has value %" PRIu64
" "
3297 "(expected 0 or 1)", i);
3303 "old edge has %d points, new edge has %d points",
3314 lwerror(
"SQL/MM Spatial exception - "
3315 "start node not geometry start point.");
3326 " has less than 2 vertices", oldedge->
edge_id);
3330 if ( geom->points->npoints < 2 )
3333 lwerror(
"Invalid edge: less than 2 vertices");
3336 getPoint2d_p(geom->points, geom->points->npoints-1, &pt);
3340 lwerror(
"SQL/MM Spatial exception - "
3341 "end node not geometry end point.");
3357 lwerror(
"Invalid edge (no two distinct vertices exist)");
3366 lwerror(
"Edge twist at node POINT(%g %g)", p1.
x, p1.
y);
3372 oldedge->
end_node, geom, edge_id ) )
3379 LWDEBUG(1,
"lwt_ChangeEdgeGeom: "
3380 "edge crossing check passed ");
3398 LWDEBUGF(1,
"lwt_be_getNodeWithinBox2D returned %llu nodes", numnodes);
3399 if (numnodes == UINT64_MAX)
3406 if ( numnodes > ( 1 + isclosed ? 0 : 1 ) )
3409 for (i=0; i<numnodes; ++i)
3422 lwerror(
"Edge motion collision at %s", wkt);
3430 LWDEBUG(1,
"nodes containment check passed");
3443 isclosed ? &epan_pre : NULL, edge_id );
3445 isclosed ? &span_pre : NULL, edge_id );
3468 uint64_t num_signed_edge_ids;
3472 LWDEBUG(1,
"Twist check before");
3475 if (!signed_edge_ids)
3481 LWDEBUGF(1,
"getRingEdges returned %llu edges", num_signed_edge_ids);
3485 lwfree( signed_edge_ids );
3495 lwfree( signed_edge_ids );
3497 " is geometrically not-closed", edge_id);
3503 lwfree( signed_edge_ids );
3505 LWDEBUGF(1,
"Ring of edge %" LWTFMT_ELEMID " is %sclockwise", edge_id, leftRingIsCCW ?
"counter" :
"");
3511 newedge.
geom = geom;
3522 lwerror(
"Unexpected error: %" PRIu64
" edges updated when expecting 1", i);
3535 isclosed ? &epan_post : NULL, edge_id );
3537 isclosed ? &span_post : NULL, edge_id );
3552 lwerror(
"Edge changed disposition around start node %"
3563 lwerror(
"Edge changed disposition around end node %"
3569 if ( leftRingIsCCW != -1 )
3571 uint64_t num_signed_edge_ids;
3576 LWDEBUG(1,
"Twist check after");
3579 if (!signed_edge_ids)
3585 LWDEBUGF(1,
"getRingEdges returned %llu edges", num_signed_edge_ids);
3589 lwfree( signed_edge_ids );
3599 lwfree( signed_edge_ids );
3601 " is geometrically not-closed", edge_id);
3607 lwfree( signed_edge_ids );
3609 if ( isCCW != leftRingIsCCW )
3612 lwerror(
"Edge ring changes winding");
3634 uint64_t facestoupdate = 0;
3648 faces[facestoupdate++].
mbr = updatedBox;
3657 lwerror(
"Corrupted topology: face %"
3664 faces[facestoupdate++].
mbr = updatedBox;
3666 LWDEBUGF(1,
"%llu faces to update", facestoupdate);
3667 if ( facestoupdate )
3670 if (updatedFaces != facestoupdate)
3672 while ( facestoupdate-- )
lwfree(faces[facestoupdate].mbr);
3674 if (updatedFaces == UINT64_MAX)
3677 lwerror(
"Unexpected error: %" PRIu64
" faces updated when expecting 1", updatedFaces);
3681 while ( facestoupdate-- )
lwfree(faces[facestoupdate].mbr);
3685 LWDEBUG(1,
"BBOX of changed edge did not change");
3688 LWDEBUG(1,
"all done, cleaning up edges");
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
int gbox_union(const GBOX *g1, const GBOX *g2, GBOX *gout)
Update the output GBOX to be large enough to include both inputs.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
int lwgeom_is_simple(const LWGEOM *lwgeom)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
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.
int ptarray_is_closed_2d(const POINTARRAY *pa)
void lwpoly_free(LWPOLY *poly)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
#define LW_INSIDE
Constants for point-in-polygon return values.
int ptarray_isccw(const POINTARRAY *pa)
#define P2D_SAME_STRICT(a, b)
LWT_INT64 LWT_ELEMID
Identifier of topology element.
#define LWT_COL_EDGE_GEOM
#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.
static LWT_ELEMID * lwt_be_getRingEdges(LWT_TOPOLOGY *topo, LWT_ELEMID edge, uint64_t *numedges, uint64_t limit)
static uint64_t lwt_be_updateFacesById(LWT_TOPOLOGY *topo, const LWT_ISO_FACE *faces, uint64_t numfaces)
const char * lwt_be_lastErrorMessage(const LWT_BE_IFACE *be)
static int _lwt_InitEdgeEndByLine(edgeend *fee, edgeend *lee, LWLINE *edge, POINT2D *fp, POINT2D *lp)
LWT_ISO_EDGE * lwt_be_getEdgeById(LWT_TOPOLOGY *topo, const LWT_ELEMID *ids, uint64_t *numelems, int fields)
static int _lwt_GetInteriorEdgePoint(const LWLINE *edge, POINT2D *ip)
static LWPOLY * _lwt_MakeRingShell(LWT_TOPOLOGY *topo, LWT_ELEMID *signed_edge_ids, uint64_t num_signed_edge_ids)
static GBOX * lwt_be_computeFaceMBR(const LWT_TOPOLOGY *topo, LWT_ELEMID face)
static int _lwt_CheckEdgeCrossing(LWT_TOPOLOGY *topo, LWT_ELEMID start_node, LWT_ELEMID end_node, const LWLINE *geom, LWT_ELEMID myself)
static void _lwt_release_nodes(LWT_ISO_NODE *nodes, int num_nodes)
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)
int lwt_be_updateEdgesById(LWT_TOPOLOGY *topo, const LWT_ISO_EDGE *edges, int numedges, int upd_fields)
static int _lwt_FindAdjacentEdges(LWT_TOPOLOGY *topo, LWT_ELEMID node, edgeend *data, edgeend *other, LWT_ELEMID myedge_id)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
const LWT_BE_IFACE * be_iface