47 LWDEBUG(2,
"lwline_construct called.");
106 LWDEBUGF(2,
"lwline_clone called with %p", g);
108 memcpy(ret, g,
sizeof(
LWLINE));
122 LWDEBUGF(2,
"lwline_clone_deep called with %p", g);
123 memcpy(ret, g,
sizeof(
LWLINE));
144 if ( ! segmentized )
return NULL;
173 for (i=0; i<ngeoms; i++)
177 if ( hasz && hasm )
break;
185 for ( i=0; i < ngeoms; i++ )
249 for (i=0; i<npoints; i++)
258 if ( hasz && hasm )
break;
263 for ( i=0; i < npoints; i++ )
302 for (i=0; i < npoints; i++)
308 LWDEBUGF(3,
"lwline_from_lwmpoint: constructed pointarray for %d points", mpoint->
ngeoms);
391 int hasm = 0, hasz = 0;
394 double length_so_far = 0.0;
395 double m_range = m_end - m_start;
402 lwerror(
"lwline_construct_from_lwline: only line types supported");
419 for ( i = 0; i < npoints; i++ )
430 m = m_start + m_range * length_so_far / length;
432 else if ( length == 0.0 && npoints > 1 )
433 m = m_start + m_range * i / (npoints-1);
467 double m = -1 * FLT_MAX;
470 lwnotice(
"Line does not have M dimension");
477 for (i=0; i<n; ++i) {
480 lwnotice(
"Measure of vertex %d (%g) not bigger than measure of vertex %d (%g)",
548 double length_fraction_increment = length_fraction;
549 double length_fraction_consumed = 0;
564 if ( length_fraction == 0.0 || length_fraction == 1.0 )
566 if ( length_fraction == 0.0 )
579 points_to_interpolate = repeat ? (
uint32_t) floor(1 / length_fraction) : 1;
583 for ( i = 0; i < ipa->
npoints - 1 && points_found < points_to_interpolate; i++ )
592 while ( length_fraction < length_fraction_consumed + segment_length_frac && points_found < points_to_interpolate )
597 double segment_fraction = (length_fraction - length_fraction_consumed) / segment_length_frac;
600 length_fraction += length_fraction_increment;
603 length_fraction_consumed += segment_length_frac;
610 if (points_found < points_to_interpolate) {
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
void lwgeom_refresh_bbox(LWGEOM *lwgeom)
Drop current bbox and calculate a fresh one.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
int ptarray_is_closed_3d(const POINTARRAY *pa)
int lwpointiterator_next(LWPOINTITERATOR *s, POINT4D *p)
Attempts to assign the next point in the iterator to p, and advances the iterator to the next point.
void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F)
Find interpolation point I between point A and point B so that the len(AI) == len(AB)*F and I falls o...
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
#define FLAGS_SET_BBOX(flags, value)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
void printPA(POINTARRAY *pa)
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
LWGEOM * lwgeom_remove_repeated_points(const LWGEOM *in, double tolerance)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
#define FLAGS_NDIMS(flags)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
#define FLAGS_GET_M(flags)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
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,...
void * lwalloc(size_t size)
#define FLAGS_SET_READONLY(flags, value)
int ptarray_is_closed_2d(const POINTARRAY *pa)
#define LW_TRUE
Return types for functions with status returns.
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *point)
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
POINTARRAY * ptarray_segmentize2d(const POINTARRAY *ipa, double dist)
Returns a modified POINTARRAY so that no segment is longer than the given distance (computed using 2d...
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
POINTARRAY * ptarray_clone(const POINTARRAY *ptarray)
Clone a POINTARRAY object.
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
int lwpoint_is_empty(const LWPOINT *point)
POINTARRAY * ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
LWLINE * lwline_removepoint(LWLINE *line, uint32_t index)
double lwline_length_2d(const LWLINE *line)
LWLINE * lwline_force_dims(const LWLINE *line, int hasz, int hasm)
LWLINE * lwline_segmentize2d(const LWLINE *line, double dist)
int lwline_is_empty(const LWLINE *line)
int lwline_is_closed(const LWLINE *line)
void lwline_release(LWLINE *lwline)
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
void lwline_setPoint4d(LWLINE *line, uint32_t index, POINT4D *newpoint)
LWGEOM * lwline_remove_repeated_points(const LWLINE *lwline, double tolerance)
POINTARRAY * lwline_interpolate_points(const LWLINE *line, double length_fraction, char repeat)
Interpolate one or more points along a line.
LWLINE * lwline_clone(const LWLINE *g)
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
void printLWLINE(LWLINE *line)
double lwline_length(const LWLINE *line)
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
LWLINE * lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure betwe...
char lwline_same(const LWLINE *l1, const LWLINE *l2)
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
LWLINE * lwline_clone_deep(const LWLINE *g)
int lwline_is_trajectory(const LWLINE *line)
void lwline_free(LWLINE *line)
uint32_t lwline_count_vertices(LWLINE *line)
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, uint32_t where)
Add a LWPOINT to an LWLINE.
LWPOINT * lwline_get_lwpoint(const LWLINE *line, uint32_t where)
Returns freshly allocated LWPOINT that corresponds to the index where.