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));
150 if ( ! segmentized )
return NULL;
179 for (i=0; i<ngeoms; i++)
183 if ( hasz && hasm )
break;
191 for ( i=0; i < ngeoms; i++ )
255 for (i=0; i<npoints; i++)
264 if ( hasz && hasm )
break;
269 for ( i=0; i < npoints; i++ )
308 for (i=0; i < npoints; i++)
314 LWDEBUGF(3,
"lwline_from_lwmpoint: constructed pointarray for %d points", mpoint->
ngeoms);
399 int hasm = 0, hasz = 0;
402 double length_so_far = 0.0;
403 double m_range = m_end - m_start;
410 lwerror(
"lwline_construct_from_lwline: only line types supported");
427 for ( i = 0; i < npoints; i++ )
438 m = m_start + m_range * length_so_far / length;
440 else if ( length == 0.0 && npoints > 1 )
441 m = m_start + m_range * i / (npoints-1);
460 LWDEBUGF(3,
"%s: npts %p", __func__, npts);
481 double m = -1 * FLT_MAX;
484 lwnotice(
"Line does not have M dimension");
491 for (i=0; i<n; ++i) {
494 lwnotice(
"Measure of vertex %d (%g) not bigger than measure of vertex %d (%g)",
543 static const int minvertices = 2;
554 if ( ! pa )
return NULL;
560 if ( preserve_collapsed )
603 if ( opa->
npoints < 2 )
return NULL;
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
int lwline_is_trajectory(const LWLINE *line)
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
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...
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
POINTARRAY * ptarray_clone(const POINTARRAY *ptarray)
Clone a POINTARRAY object.
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...
LWGEOM * lwline_remove_repeated_points(const LWLINE *lwline, double tolerance)
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
int lwline_is_closed(const LWLINE *line)
void printLWLINE(LWLINE *line)
int ptarray_is_closed_3d(const POINTARRAY *pa)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void ptarray_free(POINTARRAY *pa)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
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...
#define LWDEBUG(level, msg)
LWLINE * lwline_construct_empty(int srid, char hasz, char hasm)
LWLINE * lwline_from_ptarray(int srid, uint32_t npoints, LWPOINT **points)
int lwline_is_empty(const LWLINE *line)
void lwline_setPoint4d(LWLINE *line, uint32_t index, POINT4D *newpoint)
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *point)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
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...
int ptarray_is_closed_2d(const POINTARRAY *pa)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWPOINTITERATOR * lwpointiterator_create(const LWGEOM *g)
Create a new LWPOINTITERATOR over supplied LWGEOM*.
void lwgeom_drop_bbox(LWGEOM *lwgeom)
Call this function to drop BBOX and SRID from LWGEOM.
void lwline_release(LWLINE *lwline)
void lwpointiterator_destroy(LWPOINTITERATOR *s)
Free all memory associated with the iterator.
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
POINT4D getPoint4d(const POINTARRAY *pa, int n)
double lwline_length(const LWLINE *line)
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *point)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
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, then a duplicate point will not be added.
LWLINE * lwline_grid(const LWLINE *line, const gridspec *grid)
char lwline_same(const LWLINE *l1, const LWLINE *l2)
#define LW_TRUE
Return types for functions with status returns.
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
LWLINE * lwline_clone(const LWLINE *g)
LWPOINT * lwline_get_lwpoint(const LWLINE *line, int where)
Returns freshly allocated LWPOINT that corresponds to the index where.
void lwline_reverse(LWLINE *line)
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
POINTARRAY * ptarray_clone_deep(const POINTARRAY *ptarray)
Deep clone a pointarray (also clones serialized pointlist)
POINTARRAY * ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
LWLINE * lwline_clone_deep(const LWLINE *g)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, int where)
Insert a point into an existing POINTARRAY.
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
int lwline_add_lwpoint(LWLINE *line, LWPOINT *point, int where)
Add a LWPOINT to an LWLINE.
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
POINTARRAY * ptarray_simplify(POINTARRAY *inpts, double epsilon, unsigned int minpts)
#define FLAGS_SET_BBOX(flags, value)
LWLINE * lwline_removepoint(LWLINE *line, uint32_t index)
void printPA(POINTARRAY *pa)
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
POINTARRAY * ptarray_remove_repeated_points_minpoints(const POINTARRAY *in, double tolerance, int minpoints)
int lwline_count_vertices(LWLINE *line)
POINTARRAY * ptarray_grid(const POINTARRAY *pa, const gridspec *grid)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
int lwpoint_is_empty(const LWPOINT *point)
void lwgeom_add_bbox(LWGEOM *lwgeom)
Compute a bbox if not already computed.
void ptarray_reverse(POINTARRAY *pa)
#define FLAGS_GET_M(flags)
LWLINE * lwline_segmentize2d(LWLINE *line, double dist)
void lwgeom_release(LWGEOM *lwgeom)
Free the containing LWGEOM and the associated BOX.
LWLINE * lwline_force_dims(const LWLINE *line, int hasz, int hasm)
void lwline_free(LWLINE *line)
double lwline_length_2d(const LWLINE *line)
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t where)
Remove a point from a pointarray.
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
#define LWDEBUGF(level, msg,...)
LWLINE * lwline_simplify(const LWLINE *iline, double dist, int preserve_collapsed)
#define FLAGS_NDIMS(flags)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)
#define FLAGS_SET_READONLY(flags, value)
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)