31 #include "../postgis_config.h"
90 LWDEBUGF(5,
"pa = %p; p = %p; where = %d", pa, p, where);
95 lwerror(
"ptarray_insert_point: called on read-only point array");
102 lwerror(
"ptarray_insert_point: offset out of range (%d)", where);
129 if( where < pa->npoints )
131 size_t copy_size = point_size * (pa->
npoints - where);
133 LWDEBUGF(5,
"copying %d bytes to start vertex %d from start vertex %d", copy_size, where+1, where);
141 LWDEBUGF(5,
"copying new point to start vertex %d", point_size, where);
152 lwerror(
"ptarray_append_point: null input");
161 LWDEBUGF(4,
"checking for duplicate end point (pt = POINT(%g %g) pa->npoints-q = POINT(%g %g))",pt->
x,pt->
y,tmp.
x,tmp.
y);
164 if ( (pt->
x == tmp.
x) && (pt->
y == tmp.
y) &&
179 unsigned int poff = 0;
180 unsigned int npoints;
187 lwerror(
"ptarray_append_ptarray: null input");
197 lwerror(
"ptarray_append_ptarray: target pointarray is read-only");
203 lwerror(
"ptarray_append_ptarray: appending mixed dimensionality is not allowed");
221 else if ( gap_tolerance == 0 || ( gap_tolerance > 0 &&
224 lwerror(
"Second line start point too far from first line end point");
256 lwerror(
"ptarray_remove_point: null input");
263 lwerror(
"ptarray_remove_point: offset out of range (%d)", where);
268 if (where < pa->npoints - 1)
286 LWDEBUGF(5,
"hasz = %d, hasm = %d, npoints = %d, ptlist = %p", hasz, hasm, npoints, ptlist);
336 uint32_t last = pa->
npoints - 1;
337 uint32_t mid = pa->
npoints / 2;
342 for (i = 0; i < mid; i++)
344 for (j = 0; j < ndims; j++)
348 d[i*ndims+j] = d[(last-i)*ndims+j];
349 d[(last-i)*ndims+j] = buf;
366 for (i=0 ; i < pa->
npoints ; i++)
382 double d, *dp1, *dp2;
385 dp1 = ((
double*)&p)+(unsigned)o1;
386 dp2 = ((
double*)&p)+(unsigned)o2;
387 for (i=0 ; i < pa->
npoints ; i++)
415 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0;
425 for (i = 1; i < ipa->
npoints; i++)
436 POINT4D *p1ptr=&p1, *p2ptr=&p2;
443 segments = ceil(segdist / dist);
448 lwnotice(
"%s:%d - %s: Too many segments required (%e)",
449 __FILE__, __LINE__,__func__, segments);
455 for (j = 1; j < nseg; j++)
457 pbuf.
x = p1.
x + (p2.
x - p1.
x) * j / nseg;
458 pbuf.
y = p1.
y + (p2.
y - p1.
y) * j / nseg;
460 pbuf.
z = p1.
z + (p2.
z - p1.
z) * j / nseg;
462 pbuf.
m = p1.
m + (p2.
m - p1.
m) * j / nseg;
482 LWDEBUG(5,
"dimensions are the same");
485 LWDEBUG(5,
"npoints are the same");
494 LWDEBUGF(5,
"point #%d is the same",i);
507 LWDEBUGF(3,
"pa %x p %x size %d where %d",
508 pa, p, pdims, where);
510 if ( pdims < 2 || pdims > 4 )
512 lwerror(
"ptarray_addPoint: point dimension out of range (%d)",
519 lwerror(
"ptarray_addPoint: offset out of range (%d)",
524 LWDEBUG(3,
"called with a %dD point");
526 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0.0;
527 memcpy((uint8_t *)&pbuf, p, pdims*
sizeof(
double));
529 LWDEBUG(3,
"initialized point buffer");
558 LWDEBUGF(3,
"pa %x which %d", pa, which);
560 #if PARANOIA_LEVEL > 0
563 lwerror(
"%s [%d] offset (%d) out of range (%d..%d)", __FILE__, __LINE__,
570 lwerror(
"%s [%d] can't remove a point from a 2-vertex POINTARRAY", __FILE__, __LINE__);
585 if ( which < pa->npoints-1 )
601 lwerror(
"ptarray_cat: Mixed dimension");
630 LWDEBUG(3,
"ptarray_clone_deep called.");
661 LWDEBUG(3,
"ptarray_clone called.");
683 lwerror(
"ptarray_is_closed: called with null point array");
697 lwerror(
"ptarray_is_closed_2d: called with null point array");
710 lwerror(
"ptarray_is_closed_3d: called with null point array");
749 if ( check_closed && !
p2d_same(seg1, seg2) )
750 lwerror(
"ptarray_contains_point called on unclosed ring");
752 for ( i=1; i < pa->
npoints; i++ )
757 if ( seg1->
x == seg2->
x && seg1->
y == seg2->
y )
767 if ( pt->
y > ymax || pt->
y < ymin )
789 if ( (side < 0) && (seg1->
y <= pt->
y) && (pt->
y < seg2->
y) )
799 else if ( (side > 0) && (seg2->
y <= pt->
y) && (pt->
y < seg1->
y) )
808 if ( winding_number )
809 *winding_number = wn;
850 lwerror(
"ptarrayarc_contains_point called with even number of points");
857 lwerror(
"ptarrayarc_contains_point called too-short pointarray");
864 if ( check_closed && !
p2d_same(seg1, seg3) )
866 lwerror(
"ptarrayarc_contains_point called on unclosed ring");
885 else if ( d < radius )
897 for ( i=1; i < pa->
npoints; i += 2 )
922 if ( (pt->
x > gbox.
xmax || pt->
x < gbox.
xmin) &&
932 if ( (side == 0) &&
lw_pt_in_arc(pt, seg1, seg2, seg3) )
938 if ( side < 0 && (seg1->
y <= pt->
y) && (pt->
y < seg3->
y) )
944 if ( side > 0 && (seg3->
y <= pt->
y) && (pt->
y < seg1->
y) )
950 if ( pt->
x <= gbox.
xmax && pt->
x >= gbox.
xmin )
976 if ( winding_number )
977 *winding_number = wn;
1001 double x0,
x, y1, y2;
1010 for ( i = 2; i < pa->
npoints; i++ )
1044 for( i = 0; i < pa->
npoints; i++ )
1047 if( hasz && ! in_hasz )
1049 if( hasm && ! in_hasm )
1066 double length, slength, tlength;
1079 LWDEBUGF(3,
"Total length: %g", length);
1087 LWDEBUGF(3,
"From/To: %g/%g", from, to);
1093 for ( i = 0; i < nsegs; i++ )
1100 LWDEBUGF(3 ,
"Segment %d: (%g,%g,%g,%g)-(%g,%g,%g,%g)",
1101 i, p1.
x, p1.
y, p1.
z, p1.
m, p2.
x, p2.
y, p2.
z, p2.
m);
1115 if ( fabs ( from - ( tlength + slength ) ) <= tolerance )
1118 LWDEBUG(3,
" Second point is our start");
1128 else if ( fabs(from - tlength) <= tolerance )
1131 LWDEBUG(3,
" First point is our start");
1149 else if ( from > tlength + slength )
goto END;
1154 LWDEBUG(3,
" Seg contains first point");
1160 dseg = (from - tlength) / slength;
1182 if ( fabs(to - ( tlength + slength ) ) <= tolerance )
1185 LWDEBUG(3,
" Second point is our end");
1195 else if ( fabs(to - tlength) <= tolerance )
1198 LWDEBUG(3,
" First point is our end");
1209 else if ( to > tlength + slength )
1219 else if ( to < tlength + slength )
1222 LWDEBUG(3,
" Seg contains our end");
1224 dseg = (to - tlength) / slength;
1242 memcpy(&p1, &p2,
sizeof(
POINT4D));
1279 r = ( (p->
x-A->
x) * (B->
x-A->
x) + (p->
y-A->
y) * (B->
y-A->
y) )/( (B->
x-A->
x)*(B->
x-A->
x) +(B->
y-A->
y)*(B->
y-A->
y) );
1292 ret->
x = A->
x + ( (B->
x - A->
x) *
r );
1293 ret->
y = A->
y + ( (B->
y - A->
y) *
r );
1294 ret->
z = A->
z + ( (B->
z - A->
z) *
r );
1295 ret->
m = A->
m + ( (B->
m - A->
m) *
r );
1305 double mindist=DBL_MAX;
1308 POINT4D start4d, end4d, projtmp;
1310 const POINT2D *start = NULL, *end = NULL;
1316 if ( ! proj4d ) proj4d = &projtmp;
1338 if (dist_sqr < mindist)
1344 LWDEBUG(3,
"Breaking on mindist=0");
1351 mindist = sqrt(mindist);
1353 if ( mindistout ) *mindistout = mindist;
1355 LWDEBUGF(3,
"Closest segment: %d", seg);
1356 LWDEBUGF(3,
"mindist: %g", mindist);
1378 LWDEBUGF(3,
"Closest point on segment: %g,%g", proj.
x, proj.
y);
1386 if ( tlen == 0 )
return 0;
1390 for (t=0; t<seg; t++, start=end)
1395 LWDEBUGF(4,
"Segment %d made plen %g", t, plen);
1400 LWDEBUGF(3,
"plen %g, tlen %g", plen, tlen);
1423 if (
x < 0 )
x+= 360;
1424 else if (
x > 180 )
x -= 360;
1455 double tolsq = tolerance * tolerance;
1458 uint32_t n_points = pa->
npoints;
1459 uint32_t n_points_out = 1;
1462 double dsq = FLT_MAX;
1465 if ( n_points <= min_points )
return;
1468 void *p_to = ((
char *)last) + pt_size;
1469 for (i = 1; i < n_points; i++)
1471 int last_point = (i == n_points - 1);
1477 if (n_points + n_points_out > min_points + i)
1479 if (tolerance > 0.0)
1484 if (!last_point && dsq <= tolsq)
1492 if (memcmp((
char*)pt, (
char*)last, pt_size) == 0)
1500 if (last_point && n_points_out > 1 && tolerance > 0.0 && dsq <= tolsq)
1508 memcpy(p_to, pt, pt_size);
1525 uint32_t split = it_first;
1526 if ((it_first - it_last) < 2)
1535 for (uint32_t itk = it_first + 1; itk < it_last; itk++)
1539 if (distance_sqr > max_distance_sqr)
1542 max_distance_sqr = distance_sqr;
1549 double ba_x = (B->
x - A->
x);
1550 double ba_y = (B->
y - A->
y);
1551 double ab_length_sqr = (ba_x * ba_x + ba_y * ba_y);
1554 max_distance_sqr *= ab_length_sqr;
1555 for (uint32_t itk = it_first + 1; itk < it_last; itk++)
1558 double distance_sqr;
1559 double ca_x = (C->
x - A->
x);
1560 double ca_y = (C->
y - A->
y);
1561 double dot_ac_ab = (ca_x * ba_x + ca_y * ba_y);
1563 if (dot_ac_ab <= 0.0)
1567 else if (dot_ac_ab >= ab_length_sqr)
1573 double s_numerator = ca_x * ba_y - ca_y * ba_x;
1574 distance_sqr = s_numerator * s_numerator;
1577 if (distance_sqr > max_distance_sqr)
1580 max_distance_sqr = distance_sqr;
1605 uint32_t *iterator_stack =
lwalloc(
sizeof(uint32_t) * pa->
npoints);
1606 iterator_stack[0] = 0;
1607 uint32_t iterator_stack_size = 1;
1609 uint32_t it_first = 0;
1610 uint32_t it_last = pa->
npoints - 1;
1612 const double tolerance_sqr = tolerance * tolerance;
1614 double it_tol = keptn >= minpts ? tolerance_sqr : -1.0;
1616 while (iterator_stack_size)
1619 if (split == it_first)
1622 it_last = iterator_stack[--iterator_stack_size];
1629 iterator_stack[iterator_stack_size++] = it_last;
1631 it_tol = keptn >= minpts ? tolerance_sqr : -1.0;
1648 for (uint32_t i = 1; i < pa->
npoints; i++)
1682 lwerror(
"arc point array with even number of points");
1686 for ( i=2; i < pts->
npoints; i += 2 )
1707 if ( pts->
npoints < 2 )
return 0.0;
1711 for ( i=1; i < pts->
npoints; i++ )
1715 dist += sqrt( ((frm->
x - to->
x)*(frm->
x - to->
x)) +
1716 ((frm->
y - to->
y)*(frm->
y - to->
y)) );
1735 if ( pts->
npoints < 2 )
return 0.0;
1741 for ( i=1; i < pts->
npoints; i++ )
1744 dist += sqrt( ((frm.
x - to.
x)*(frm.
x - to.
x)) +
1745 ((frm.
y - to.
y)*(frm.
y - to.
y)) +
1746 ((frm.
z - to.
z)*(frm.
z - to.
z)) );
1764 LWDEBUG(2,
"lwgeom_affine_ptarray start");
1781 LWDEBUGF(3,
" POINT %g %g %g => %g %g %g",
x,
y, z, p4d.
x, p4d.
y, p4d.
z);
1786 LWDEBUG(3,
" doesn't have z");
1797 LWDEBUGF(3,
" POINT %g %g => %g %g",
x,
y, p4d.
x, p4d.
y);
1801 LWDEBUG(3,
"lwgeom_affine_ptarray end");
1810 static int gluInvertMatrix(
const double *m,
double *invOut)
1812 double inv[16],
det;
1815 inv[0] = m[5] * m[10] * m[15] -
1816 m[5] * m[11] * m[14] -
1817 m[9] * m[6] * m[15] +
1818 m[9] * m[7] * m[14] +
1819 m[13] * m[6] * m[11] -
1820 m[13] * m[7] * m[10];
1822 inv[4] = -m[4] * m[10] * m[15] +
1823 m[4] * m[11] * m[14] +
1824 m[8] * m[6] * m[15] -
1825 m[8] * m[7] * m[14] -
1826 m[12] * m[6] * m[11] +
1827 m[12] * m[7] * m[10];
1829 inv[8] = m[4] * m[9] * m[15] -
1830 m[4] * m[11] * m[13] -
1831 m[8] * m[5] * m[15] +
1832 m[8] * m[7] * m[13] +
1833 m[12] * m[5] * m[11] -
1834 m[12] * m[7] * m[9];
1836 inv[12] = -m[4] * m[9] * m[14] +
1837 m[4] * m[10] * m[13] +
1838 m[8] * m[5] * m[14] -
1839 m[8] * m[6] * m[13] -
1840 m[12] * m[5] * m[10] +
1841 m[12] * m[6] * m[9];
1843 inv[1] = -m[1] * m[10] * m[15] +
1844 m[1] * m[11] * m[14] +
1845 m[9] * m[2] * m[15] -
1846 m[9] * m[3] * m[14] -
1847 m[13] * m[2] * m[11] +
1848 m[13] * m[3] * m[10];
1850 inv[5] = m[0] * m[10] * m[15] -
1851 m[0] * m[11] * m[14] -
1852 m[8] * m[2] * m[15] +
1853 m[8] * m[3] * m[14] +
1854 m[12] * m[2] * m[11] -
1855 m[12] * m[3] * m[10];
1857 inv[9] = -m[0] * m[9] * m[15] +
1858 m[0] * m[11] * m[13] +
1859 m[8] * m[1] * m[15] -
1860 m[8] * m[3] * m[13] -
1861 m[12] * m[1] * m[11] +
1862 m[12] * m[3] * m[9];
1864 inv[13] = m[0] * m[9] * m[14] -
1865 m[0] * m[10] * m[13] -
1866 m[8] * m[1] * m[14] +
1867 m[8] * m[2] * m[13] +
1868 m[12] * m[1] * m[10] -
1869 m[12] * m[2] * m[9];
1871 inv[2] = m[1] * m[6] * m[15] -
1872 m[1] * m[7] * m[14] -
1873 m[5] * m[2] * m[15] +
1874 m[5] * m[3] * m[14] +
1875 m[13] * m[2] * m[7] -
1876 m[13] * m[3] * m[6];
1878 inv[6] = -m[0] * m[6] * m[15] +
1879 m[0] * m[7] * m[14] +
1880 m[4] * m[2] * m[15] -
1881 m[4] * m[3] * m[14] -
1882 m[12] * m[2] * m[7] +
1883 m[12] * m[3] * m[6];
1885 inv[10] = m[0] * m[5] * m[15] -
1886 m[0] * m[7] * m[13] -
1887 m[4] * m[1] * m[15] +
1888 m[4] * m[3] * m[13] +
1889 m[12] * m[1] * m[7] -
1890 m[12] * m[3] * m[5];
1892 inv[14] = -m[0] * m[5] * m[14] +
1893 m[0] * m[6] * m[13] +
1894 m[4] * m[1] * m[14] -
1895 m[4] * m[2] * m[13] -
1896 m[12] * m[1] * m[6] +
1897 m[12] * m[2] * m[5];
1899 inv[3] = -m[1] * m[6] * m[11] +
1900 m[1] * m[7] * m[10] +
1901 m[5] * m[2] * m[11] -
1902 m[5] * m[3] * m[10] -
1903 m[9] * m[2] * m[7] +
1906 inv[7] = m[0] * m[6] * m[11] -
1907 m[0] * m[7] * m[10] -
1908 m[4] * m[2] * m[11] +
1909 m[4] * m[3] * m[10] +
1910 m[8] * m[2] * m[7] -
1913 inv[11] = -m[0] * m[5] * m[11] +
1914 m[0] * m[7] * m[9] +
1915 m[4] * m[1] * m[11] -
1916 m[4] * m[3] * m[9] -
1917 m[8] * m[1] * m[7] +
1920 inv[15] = m[0] * m[5] * m[10] -
1921 m[0] * m[6] * m[9] -
1922 m[4] * m[1] * m[10] +
1923 m[4] * m[2] * m[9] +
1924 m[8] * m[1] * m[6] -
1927 det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
1934 for (i = 0; i < 16; i++)
1935 invOut[i] = inv[i] *
det;
1949 LWDEBUG(3,
"ptarray_scale start");
1959 LWDEBUG(3,
"ptarray_scale end");
1986 LWDEBUGF(2,
"%s called on %p", __func__, pa);
1988 for (i = 0; i < pa->
npoints; i++)
1993 if (grid->
xsize > 0)
1998 if (grid->
ysize > 0)
2007 if (grid->
zsize > 0)
2014 if (grid->
msize > 0 && !has_z)
2017 if (grid->
msize > 0 && has_z)
2051 for ( i = 0; i < pa->
npoints; i++ )
int gbox_contains_point2d(const GBOX *g, const POINT2D *p)
int lw_arc_calculate_gbox_cartesian_2d(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, GBOX *gbox)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
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...
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
#define FLAGS_GET_READONLY(flags)
#define FLAGS_GET_Z(flags)
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *point)
void * lwrealloc(void *mem, size_t size)
#define FLAGS_NDIMS(flags)
#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)
#define FLAGS_GET_ZM(flags)
void * lwalloc(size_t size)
#define FLAGS_SET_READONLY(flags, value)
lwflags_t lwflags(int hasz, int hasm, int geodetic)
Construct a new flags bitmask.
#define LW_TRUE
Return types for functions with status returns.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
enum LWORD_T LWORD
Ordinate names.
#define LW_INSIDE
Constants for point-in-polygon return values.
double lw_arc_length(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns the length of a circular arc segment.
#define LW_ON_INTERRUPT(x)
double lw_arc_center(const POINT2D *p1, const POINT2D *p2, const POINT2D *p3, POINT2D *result)
Determines the center of the circle defined by the three given points.
int lw_arc_side(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3, const POINT2D *Q)
int lw_pt_in_seg(const POINT2D *P, const POINT2D *A1, const POINT2D *A2)
Returns true if P is between A1/A2.
int lw_segment_side(const POINT2D *p1, const POINT2D *p2, const POINT2D *q)
lw_segment_side()
int lw_arc_is_pt(const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if arc A is actually a point (all vertices are the same) .
int lw_pt_in_arc(const POINT2D *P, const POINT2D *A1, const POINT2D *A2, const POINT2D *A3)
Returns true if P is on the same side of the plane partition defined by A1/A3 as A2 is.
int p2d_same(const POINT2D *p1, const POINT2D *p2)
static double det(double m00, double m01, double m10, double m11)
#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.
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static double distance2d_sqr_pt_pt(const POINT2D *p1, const POINT2D *p2)
static size_t ptarray_point_size(const POINTARRAY *pa)
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
static uint32_t ptarray_dp_findsplit_in_place(const POINTARRAY *pts, uint32_t it_first, uint32_t it_last, double max_distance_sqr)
POINTARRAY * ptarray_construct_reference_data(char hasz, char hasm, uint32_t npoints, uint8_t *ptlist)
Build a new POINTARRAY, but on top of someone else's ordinate array.
int ptarray_remove_point(POINTARRAY *pa, uint32_t where)
Remove a point from an existing POINTARRAY.
void ptarray_longitude_shift(POINTARRAY *pa)
Longitude shift for a pointarray.
POINTARRAY * ptarray_construct_copy_data(char hasz, char hasm, uint32_t npoints, const uint8_t *ptlist)
Construct a new POINTARRAY, copying in the data from ptlist.
POINTARRAY * ptarray_clone(const POINTARRAY *in)
Clone a POINTARRAY object.
int ptarray_append_ptarray(POINTARRAY *pa1, POINTARRAY *pa2, double gap_tolerance)
Append a POINTARRAY, pa2 to the end of an existing POINTARRAY, pa1.
void ptarray_reverse_in_place(POINTARRAY *pa)
int ptarrayarc_contains_point(const POINTARRAY *pa, const POINT2D *pt)
For POINTARRAYs representing CIRCULARSTRINGS.
int ptarray_is_closed_2d(const POINTARRAY *in)
int ptarray_is_closed_z(const POINTARRAY *in)
double ptarray_length(const POINTARRAY *pts)
Find the 3d/2d length of the given POINTARRAY (depending on its dimensionality)
double ptarray_signed_area(const POINTARRAY *pa)
Returns the area in cartesian units.
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
void closest_point_on_segment(const POINT4D *p, const POINT4D *A, const POINT4D *B, POINT4D *ret)
int ptarray_startpoint(const POINTARRAY *pa, POINT4D *pt)
int ptarray_is_closed(const POINTARRAY *in)
Check for ring closure using whatever dimensionality is declared on the pointarray.
POINTARRAY * ptarray_clone_deep(const POINTARRAY *in)
Deep clone a pointarray (also clones serialized pointlist)
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...
void ptarray_grid_in_place(POINTARRAY *pa, const gridspec *grid)
Snap to grid.
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
char ptarray_same(const POINTARRAY *pa1, const POINTARRAY *pa2)
int ptarray_is_closed_3d(const POINTARRAY *in)
void ptarray_remove_repeated_points_in_place(POINTARRAY *pa, double tolerance, uint32_t min_points)
POINTARRAY * ptarray_removePoint(POINTARRAY *pa, uint32_t which)
Remove a point from a pointarray.
void ptarray_simplify_in_place(POINTARRAY *pa, double tolerance, uint32_t minpts)
int ptarray_insert_point(POINTARRAY *pa, const POINT4D *p, uint32_t where)
Insert a point into an existing POINTARRAY.
double ptarray_arc_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY, using circular arc interpolation between each coordinate ...
POINTARRAY * ptarray_remove_repeated_points(const POINTARRAY *in, double tolerance)
void ptarray_affine(POINTARRAY *pa, const AFFINE *a)
Affine transform a pointarray.
int ptarray_contains_point(const POINTARRAY *pa, const POINT2D *pt)
Return 1 if the point is inside the POINTARRAY, -1 if it is outside, and 0 if it is on the boundary.
int ptarrayarc_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
void ptarray_free(POINTARRAY *pa)
int ptarray_isccw(const POINTARRAY *pa)
int ptarray_has_z(const POINTARRAY *pa)
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int repeated_points)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
void ptarray_scale(POINTARRAY *pa, const POINT4D *fact)
WARNING, make sure you send in only 16-member double arrays or obviously things will go pear-shaped f...
static POINTARRAY * ptarray_remove_repeated_points_minpoints(const POINTARRAY *in, double tolerance, int minpoints)
void ptarray_swap_ordinates(POINTARRAY *pa, LWORD o1, LWORD o2)
Swap ordinate values o1 and o2 on a given POINTARRAY.
int ptarray_npoints_in_rect(const POINTARRAY *pa, const GBOX *gbox)
POINTARRAY * ptarray_substring(POINTARRAY *ipa, double from, double to, double tolerance)
@d1 start location (distance from start / total distance) @d2 end location (distance from start / tot...
POINTARRAY * ptarray_merge(POINTARRAY *pa1, POINTARRAY *pa2)
Merge two given POINTARRAY and returns a pointer on the new aggregate one.
POINTARRAY * ptarray_force_dims(const POINTARRAY *pa, int hasz, int hasm)
POINTARRAY * ptarray_flip_coordinates(POINTARRAY *pa)
Reverse X and Y axis on a given POINTARRAY.
int ptarray_has_m(const POINTARRAY *pa)
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...
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *p4d, double *mindistout, POINT4D *proj4d)
uint8_t * serialized_pointlist