Split a line by a point and push components to the provided multiline.
If the point doesn't split the line, push nothing to the container. Returns 0 if the point is off the line. Returns 1 if the point is on the line boundary (endpoints). Return 2 if the point is on the interior of the line (only case in which a split happens).
NOTE: the components pushed to the output vector have their SRID stripped
Definition at line 209 of file lwgeom_geos_split.c.
236 if ( ipa->
npoints < 1 )
return 0;
239 for ( i = 0; i < nsegs; i++ )
244 LWDEBUGF(4,
" Distance of point %g %g to segment %g %g, %g %g: %g", pt.
x, pt.
y, p1.
x, p1.
y, p2.
x, p2.
y, dist);
245 if (i==0 || dist < mindist )
249 if ( mindist == 0.0 )
break;
254 LWDEBUGF(3,
"Closest segment: %d", seg);
255 LWDEBUGF(3,
"mindist: %g", mindist);
258 if ( mindist > 0 )
return 0;
275 pt_projected.
x = pt.
x;
276 pt_projected.
y = pt.
y;
278 LWDEBUGF(3,
"Projected point:(%g %g), seg:%d, p1:(%g %g), p2:(%g %g)", pt_projected.
x, pt_projected.
y, seg, p1.
x, p1.
y, p2.
x, p2.
y);
281 if ( ( (seg == nsegs-1) &&
p4d_same(&pt_projected, &p2) ) ||
282 ( (seg == 0) &&
p4d_same(&pt_projected, &p1) ) )
291 for (i=0; i<=seg; ++i)
301 for (i=seg+1; i<ipa->
npoints; ++i)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
#define FLAGS_GET_M(flags)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
void ptarray_free(POINTARRAY *pa)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
#define SRID_UNKNOWN
Unknown SRID value.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
int p4d_same(const POINT4D *p1, const POINT4D *p2)
void closest_point_on_segment(const POINT4D *R, const POINT4D *A, const POINT4D *B, POINT4D *ret)
#define LWDEBUGF(level, msg,...)
References closest_point_on_segment(), distance2d_pt_seg(), POINTARRAY::flags, FLAGS_GET_M, FLAGS_GET_Z, getPoint4d_p(), LW_FALSE, LWDEBUGF, lwline_construct(), lwmline_add_lwline(), POINTARRAY::npoints, p4d_same(), LWPOINT::point, LWLINE::points, ptarray_append_point(), ptarray_construct_empty(), ptarray_free(), SRID_UNKNOWN, UINT32_MAX, POINT2D::x, POINT4D::x, POINT2D::y, and POINT4D::y.
Referenced by lwgeom_node(), lwline_split_by_mpoint(), lwline_split_by_point(), and test_lwline_split_by_point_to().