PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ lwline_split_by_mpoint()

static LWGEOM * lwline_split_by_mpoint ( const LWLINE lwgeom_in,
const LWMPOINT blade_in 
)
static

Definition at line 172 of file lwgeom_geos_split.c.

References COLLECTIONTYPE, LWLINE::flags, FLAGS_GET_M, FLAGS_GET_Z, LWMPOINT::geoms, LWMLINE::geoms, lwline_clone_deep(), lwline_free(), lwline_split_by_point_to(), lwmline_add_lwline(), lwmline_construct_empty(), LWMPOINT::ngeoms, LWMLINE::ngeoms, LWLINE::srid, and LWMLINE::type.

Referenced by lwline_split().

173 {
174  LWMLINE* out;
175  uint32_t i, j;
176 
177  out = lwmline_construct_empty(lwline_in->srid,
178  FLAGS_GET_Z(lwline_in->flags),
179  FLAGS_GET_M(lwline_in->flags));
180  lwmline_add_lwline(out, lwline_clone_deep(lwline_in));
181 
182  for (i=0; i<mp->ngeoms; ++i)
183  {
184  for (j=0; j<out->ngeoms; ++j)
185  {
186  lwline_in = out->geoms[j];
187  LWPOINT *blade_in = mp->geoms[i];
188  int ret = lwline_split_by_point_to(lwline_in, blade_in, out);
189  if ( 2 == ret )
190  {
191  /* the point splits this line,
192  * 2 splits were added to collection.
193  * We'll move the latest added into
194  * the slot of the current one.
195  */
196  lwline_free(out->geoms[j]);
197  out->geoms[j] = out->geoms[--out->ngeoms];
198  }
199  }
200  }
201 
202  /* Turn multiline into collection */
203  out->type = COLLECTIONTYPE;
204 
205  return (LWGEOM*)out;
206 }
uint8_t type
Definition: liblwgeom.h:479
void lwline_free(LWLINE *line)
Definition: lwline.c:76
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
Definition: lwmline.c:46
LWMLINE * lwmline_construct_empty(int srid, char hasz, char hasm)
Definition: lwmline.c:38
unsigned int uint32_t
Definition: uthash.h:78
LWPOINT ** geoms
Definition: liblwgeom.h:472
#define FLAGS_GET_Z(flags)
Macros for manipulating the &#39;flags&#39; byte.
Definition: liblwgeom.h:139
int lwline_split_by_point_to(const LWLINE *lwline_in, const LWPOINT *blade_in, LWMLINE *v)
Split a line by a point and push components to the provided multiline.
uint32_t ngeoms
Definition: liblwgeom.h:483
LWLINE ** geoms
Definition: liblwgeom.h:485
#define FLAGS_GET_M(flags)
Definition: liblwgeom.h:140
LWLINE * lwline_clone_deep(const LWLINE *lwgeom)
Definition: lwline.c:118
#define COLLECTIONTYPE
Definition: liblwgeom.h:90
Here is the call graph for this function:
Here is the caller graph for this function: