PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lwcompound_add_lwgeom()

int lwcompound_add_lwgeom ( LWCOMPOUND comp,
LWGEOM geom 
)

Add a component, allocating extra space if necessary.

The compoundcurve takes owership of the passed geometry.

Definition at line 88 of file lwcompound.c.

89 {
90  LWCOLLECTION *col = (LWCOLLECTION*)comp;
91 
92  /* Empty things can't continuously join up with other things */
93  if ( lwgeom_is_empty(geom) )
94  {
95  LWDEBUG(4, "Got an empty component for a compound curve!");
96  return LW_FAILURE;
97  }
98 
99  if( col->ngeoms > 0 )
100  {
101  POINT4D last, first;
102  /* First point of the component we are adding */
103  LWLINE *newline = (LWLINE*)geom;
104  /* Last point of the previous component */
105  LWLINE *prevline = (LWLINE*)(col->geoms[col->ngeoms-1]);
106 
107  getPoint4d_p(newline->points, 0, &first);
108  getPoint4d_p(prevline->points, prevline->points->npoints-1, &last);
109 
110  if ( !(FP_EQUALS(first.x,last.x) && FP_EQUALS(first.y,last.y)) )
111  {
112  LWDEBUG(4, "Components don't join up end-to-end!");
113  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);
114  return LW_FAILURE;
115  }
116  }
117 
118  col = lwcollection_add_lwgeom(col, geom);
119  return LW_SUCCESS;
120 }
#define LW_FAILURE
Definition: liblwgeom.h:79
#define LW_SUCCESS
Definition: liblwgeom.h:80
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwgeom.c:1393
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
Definition: lwgeom_api.c:123
LWCOLLECTION * lwcollection_add_lwgeom(LWCOLLECTION *col, const LWGEOM *geom)
Appends geom to the collection managed by col.
Definition: lwcollection.c:187
#define FP_EQUALS(A, B)
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
uint32_t ngeoms
Definition: liblwgeom.h:510
LWGEOM ** geoms
Definition: liblwgeom.h:512
POINTARRAY * points
Definition: liblwgeom.h:425
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
uint32_t npoints
Definition: liblwgeom.h:374

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: