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

◆ lwcompound_add_lwgeom()

int lwcompound_add_lwgeom ( LWCOMPOUND comp,
LWGEOM geom 
)

Add a component, allocating extra space if necessary.

The compoundcurve takes ownership of the passed geometry.

Definition at line 131 of file lwcompound.c.

132{
133 LWCOLLECTION *col = (LWCOLLECTION*)comp;
134
135 /* Empty things can't continuously join up with other things */
136 if ( lwgeom_is_empty(geom) )
137 {
138 LWDEBUG(4, "Got an empty component for a compound curve!");
139 return LW_FAILURE;
140 }
141
142 if( col->ngeoms > 0 )
143 {
144 POINT4D last, first;
145 /* First point of the component we are adding */
146 LWLINE *newline = (LWLINE*)geom;
147 /* Last point of the previous component */
148 LWLINE *prevline = (LWLINE*)(col->geoms[col->ngeoms-1]);
149
150 getPoint4d_p(newline->points, 0, &first);
151 getPoint4d_p(prevline->points, prevline->points->npoints-1, &last);
152
153 if ( !(FP_EQUALS(first.x,last.x) && FP_EQUALS(first.y,last.y)) )
154 {
155 LWDEBUG(4, "Components don't join up end-to-end!");
156 LWDEBUGF(4, "first pt (%g %g %g %g) last pt (%g %g %g %g)", first.x, first.y, first.z, first.m, last.x, last.y, last.z, last.m);
157 return LW_FAILURE;
158 }
159 }
160
161 col = lwcollection_add_lwgeom(col, geom);
162 return LW_SUCCESS;
163}
#define LW_FAILURE
Definition liblwgeom.h:96
#define LW_SUCCESS
Definition liblwgeom.h:97
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition lwgeom_api.c:125
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
#define FP_EQUALS(A, B)
#define LWDEBUG(level, msg)
Definition lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition lwgeom_log.h:106
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
uint32_t ngeoms
Definition liblwgeom.h:580
LWGEOM ** geoms
Definition liblwgeom.h:575
POINTARRAY * points
Definition liblwgeom.h:483
double m
Definition liblwgeom.h:414
double x
Definition liblwgeom.h:414
double z
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414
uint32_t npoints
Definition liblwgeom.h:427

References FP_EQUALS, LWCOLLECTION::geoms, getPoint4d_p(), LW_FAILURE, LW_SUCCESS, lwcollection_add_lwgeom(), LWDEBUG, LWDEBUGF, lwgeom_is_empty(), POINT4D::m, LWCOLLECTION::ngeoms, POINTARRAY::npoints, LWLINE::points, POINT4D::x, POINT4D::y, and POINT4D::z.

Referenced by lwcompound_construct_from_lwline(), and wkt_parser_compound_add_geom().

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