PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ lwt_edgeEndStar_addEdge()

void lwt_edgeEndStar_addEdge ( LWT_EDGEEND_STAR star,
const LWT_ISO_EDGE edge 
)

Definition at line 66 of file lwt_edgeend_star.c.

67{
68 int numEdgeEnds = 0;
69 LWT_EDGEEND *edgeEnds[2];
70 uint64_t newCapacity;
71
72 if ( edge->start_node == star->nodeID )
73 {
74 LWT_EDGEEND *ee = lwt_edgeEnd_fromEdge( edge, 1 );
75 if ( ! ee ) {
76 lwerror("Could not construct outgoing EdgeEnd for edge %"
77 LWTFMT_ELEMID, edge->edge_id);
78 return;
79 }
80 edgeEnds[numEdgeEnds++] = ee;
81 }
82 if ( edge->end_node == star->nodeID )
83 {
84 LWT_EDGEEND *ee = lwt_edgeEnd_fromEdge( edge, 0 );
85 if ( ! ee ) {
86 lwerror("Could not construct outgoing incoming for edge %"
87 LWTFMT_ELEMID, edge->edge_id);
88 return;
89 }
90 edgeEnds[numEdgeEnds++] = ee;
91 }
92
93 if ( ! numEdgeEnds )
94 {
95 lwerror("Edge %" LWTFMT_ELEMID
96 " doesn't start nor end on star node %" LWTFMT_ELEMID,
97 edge->edge_id, star->nodeID);
98 return;
99 }
100
101 LWDEBUGF(1, "Edge %" LWTFMT_ELEMID
102 " got %d" " ends incident to star node %" LWTFMT_ELEMID,
103 edge->edge_id, numEdgeEnds, star->nodeID );
104
105 newCapacity = star->numEdgeEnds + numEdgeEnds;
106 LWDEBUGF(3, "Current star capacity:%lld, required:%lld",
107 star->edgeEndsCapacity, newCapacity);
108 if ( newCapacity > star->edgeEndsCapacity )
109 {
110 LWDEBUGF(3, "Reallocating edgeEnds from %p to new size %lld", star->edgeEnds, newCapacity * sizeof(LWT_EDGEEND *));
111 if ( star->edgeEnds ) {
112 star->edgeEnds = lwrealloc(star->edgeEnds, newCapacity * sizeof(LWT_EDGEEND *));
113 } else {
114 star->edgeEnds = lwalloc(newCapacity * sizeof(LWT_EDGEEND *));
115 }
116 LWDEBUGF(3, "Reallocated edgeEnds are %p", star->edgeEnds);
117 star->edgeEndsCapacity = newCapacity;
118 LWDEBUGF(3, "New star capacity: %lld", newCapacity);
119 }
120
121 for (int i=0; i<numEdgeEnds; ++i)
122 {
123 star->edgeEnds[ star->numEdgeEnds++ ] = edgeEnds[i];
124 }
125 star->sorted = 0;
126}
void * lwrealloc(void *mem, size_t size)
Definition lwutil.c:242
void * lwalloc(size_t size)
Definition lwutil.c:227
#define LWTFMT_ELEMID
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
LWT_EDGEEND * lwt_edgeEnd_fromEdge(const LWT_ISO_EDGE *edge, int outgoing)
Definition lwt_edgeend.c:68
LWT_EDGEEND ** edgeEnds
LWT_ELEMID end_node
LWT_ELEMID edge_id
LWT_ELEMID start_node

References LWT_ISO_EDGE::edge_id, LWT_EDGEEND_STAR_t::edgeEnds, LWT_EDGEEND_STAR_t::edgeEndsCapacity, LWT_ISO_EDGE::end_node, lwalloc(), LWDEBUGF, lwerror(), lwrealloc(), lwt_edgeEnd_fromEdge(), LWTFMT_ELEMID, LWT_EDGEEND_STAR_t::nodeID, LWT_EDGEEND_STAR_t::numEdgeEnds, LWT_EDGEEND_STAR_t::sorted, and LWT_ISO_EDGE::start_node.

Referenced by _lwt_SnapEdgeToExistingNode().

Here is the call graph for this function:
Here is the caller graph for this function: