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.
212 double mindist_sqr = -1;
236 if ( ipa->
npoints < 1 )
return 0;
239 for ( i = 0; i < nsegs; i++ )
243 LWDEBUGF(4,
"Distance (squared) of point %g %g to segment %g %g, %g %g: %g",
248 if (i == 0 || dist_sqr < mindist_sqr)
250 mindist_sqr = dist_sqr;
252 if (mindist_sqr == 0.0)
258 LWDEBUGF(3,
"Closest segment: %d", seg);
259 LWDEBUGF(3,
"mindist: %g", mindist_sqr);
280 pt_projected.
x = pt.
x;
281 pt_projected.
y = pt.
y;
283 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);
286 if ( ( (seg == nsegs-1) &&
p4d_same(&pt_projected, &p2) ) ||
287 ( (seg == 0) &&
p4d_same(&pt_projected, &p1) ) )
296 for (i=0; i<=seg; ++i)
306 for (i=seg+1; i<ipa->
npoints; ++i)
LWMLINE * lwmline_add_lwline(LWMLINE *mobj, const LWLINE *obj)
#define FLAGS_GET_Z(flags)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
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)
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
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.
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_sqr_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().