PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ RTreeMergeMultiLines()

static LWMLINE* RTreeMergeMultiLines ( LWMLINE line1,
LWMLINE line2 
)
static

Merges two multilinestrings into a single multilinestring.

Definition at line 282 of file lwgeom_rtree.c.

References LWMLINE::geoms, lwalloc(), lwcollection_construct(), lwgeom_clone(), MULTILINETYPE, LWMLINE::ngeoms, LWCOLLECTION::ngeoms, SRID_UNKNOWN, LWMLINE::type, and LWCOLLECTION::type.

Referenced by RTreeFindLineSegments().

283 {
284  LWGEOM **geoms;
285  LWCOLLECTION *col;
286  int i, j, ngeoms;
287 
288  POSTGIS_DEBUGF(2, "RTreeMergeMultiLines called on %p, %d, %d; %p, %d, %d", line1, line1->ngeoms, line1->type, line2, line2->ngeoms, line2->type);
289 
290  ngeoms = line1->ngeoms + line2->ngeoms;
291  geoms = lwalloc(sizeof(LWGEOM *) * ngeoms);
292 
293  j = 0;
294  for (i = 0; i < line1->ngeoms; i++, j++)
295  {
296  geoms[j] = lwgeom_clone((LWGEOM *)line1->geoms[i]);
297  }
298  for (i = 0; i < line2->ngeoms; i++, j++)
299  {
300  geoms[j] = lwgeom_clone((LWGEOM *)line2->geoms[i]);
301  }
302  col = lwcollection_construct(MULTILINETYPE, SRID_UNKNOWN, NULL, ngeoms, geoms);
303 
304  POSTGIS_DEBUGF(3, "RTreeMergeMultiLines returning %p, %d, %d", col, col->ngeoms, col->type);
305 
306  return (LWMLINE *)col;
307 }
uint8_t type
Definition: liblwgeom.h:477
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:43
uint8_t type
Definition: liblwgeom.h:503
int ngeoms
Definition: liblwgeom.h:481
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:444
LWLINE ** geoms
Definition: liblwgeom.h:483
void * lwalloc(size_t size)
Definition: lwutil.c:229
#define MULTILINETYPE
Definition: liblwgeom.h:89
Here is the call graph for this function:
Here is the caller graph for this function: