PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ RTreeMergeMultiLines()

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

Merges two multilinestrings into a single multilinestring.

Definition at line 268 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().

269 {
270  LWGEOM **geoms;
271  LWCOLLECTION *col;
272  int i, j, ngeoms;
273 
274  POSTGIS_DEBUGF(2, "RTreeMergeMultiLines called on %p, %d, %d; %p, %d, %d", line1, line1->ngeoms, line1->type, line2, line2->ngeoms, line2->type);
275 
276  ngeoms = line1->ngeoms + line2->ngeoms;
277  geoms = lwalloc(sizeof(LWGEOM *) * ngeoms);
278 
279  j = 0;
280  for (i = 0; i < line1->ngeoms; i++, j++)
281  {
282  geoms[j] = lwgeom_clone((LWGEOM *)line1->geoms[i]);
283  }
284  for (i = 0; i < line2->ngeoms; i++, j++)
285  {
286  geoms[j] = lwgeom_clone((LWGEOM *)line2->geoms[i]);
287  }
288  col = lwcollection_construct(MULTILINETYPE, SRID_UNKNOWN, NULL, ngeoms, geoms);
289 
290  POSTGIS_DEBUGF(3, "RTreeMergeMultiLines returning %p, %d, %d", col, col->ngeoms, col->type);
291 
292  return (LWMLINE *)col;
293 }
uint8_t type
Definition: liblwgeom.h:461
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwcollection.c:30
uint8_t type
Definition: liblwgeom.h:487
int ngeoms
Definition: liblwgeom.h:465
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
LWGEOM * lwgeom_clone(const LWGEOM *lwgeom)
Clone LWGEOM object.
Definition: lwgeom.c:395
LWLINE ** geoms
Definition: liblwgeom.h:467
void * lwalloc(size_t size)
Definition: lwutil.c:199
#define MULTILINETYPE
Definition: liblwgeom.h:74
Here is the call graph for this function:
Here is the caller graph for this function: