30 #include "../postgis_config.h"
99 LWDEBUGF(5,
"pa = %p; p = %p; where = %d", pa, p, where);
104 lwerror(
"ptarray_insert_point: called on read-only point array");
111 lwerror(
"ptarray_insert_point: offset out of range (%d)", where);
138 if( where < pa->npoints )
140 size_t copy_size = point_size * (pa->
npoints - where);
142 LWDEBUGF(5,
"copying %d bytes to start vertex %d from start vertex %d", copy_size, where+1, where);
150 LWDEBUGF(5,
"copying new point to start vertex %d", point_size, where);
162 lwerror(
"ptarray_append_point: null input");
171 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);
174 if ( (pt->
x == tmp.
x) && (pt->
y == tmp.
y) &&
189 unsigned int poff = 0;
190 unsigned int npoints;
197 lwerror(
"ptarray_append_ptarray: null input");
207 lwerror(
"ptarray_append_ptarray: target pointarray is read-only");
213 lwerror(
"ptarray_append_ptarray: appending mixed dimensionality is not allowed");
231 else if ( gap_tolerance == 0 || ( gap_tolerance > 0 &&
234 lwerror(
"Second line start point too far from first line end point");
266 lwerror(
"ptarray_remove_point: null input");
273 lwerror(
"ptarray_remove_point: offset out of range (%d)", where);
278 if (where < pa->npoints - 1)
296 LWDEBUGF(5,
"hasz = %d, hasm = %d, npoints = %d, ptlist = %p", hasz, hasm, npoints, ptlist);
335 LWDEBUG(5,
"Freeing a PointArray");
350 for (i = 0; i < mid; i++)
352 for (j = 0; j < ndims; j++)
356 d[i*ndims+j] = d[(last-i)*ndims+j];
357 d[(last-i)*ndims+j] = buf;
374 for (i=0 ; i < pa->
npoints ; i++)
390 double d, *dp1, *dp2;
393 dp1 = ((
double*)&p)+(unsigned)o1;
394 dp2 = ((
double*)&p)+(unsigned)o2;
395 for (i=0 ; i < pa->
npoints ; i++)
424 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0;
435 while (ipoff<ipa->npoints)
447 POINT4D *p1ptr=&p1, *p2ptr=&p2;
455 pbuf.
x = p1.
x + (p2.
x-p1.
x)/segdist * dist;
456 pbuf.
y = p1.
y + (p2.
y-p1.
y)/segdist * dist;
458 pbuf.
z = p1.
z + (p2.
z-p1.
z)/segdist * dist;
460 pbuf.
m = p1.
m + (p2.
m-p1.
m)/segdist * dist;
484 LWDEBUG(5,
"dimensions are the same");
487 LWDEBUG(5,
"npoints are the same");
496 LWDEBUGF(5,
"point #%d is the same",i);
509 LWDEBUGF(3,
"pa %x p %x size %d where %d",
510 pa, p, pdims, where);
512 if ( pdims < 2 || pdims > 4 )
514 lwerror(
"ptarray_addPoint: point dimension out of range (%d)",
521 lwerror(
"ptarray_addPoint: offset out of range (%d)",
526 LWDEBUG(3,
"called with a %dD point");
528 pbuf.
x = pbuf.
y = pbuf.
z = pbuf.
m = 0.0;
529 memcpy((
uint8_t *)&pbuf, p, pdims*
sizeof(
double));
531 LWDEBUG(3,
"initialized point buffer");
560 LWDEBUGF(3,
"pa %x which %d", pa, which);
562 #if PARANOIA_LEVEL > 0
565 lwerror(
"%s [%d] offset (%d) out of range (%d..%d)", __FILE__, __LINE__,
572 lwerror(
"%s [%d] can't remove a point from a 2-vertex POINTARRAY", __FILE__, __LINE__);
587 if ( which < pa->npoints-1 )
603 lwerror(
"ptarray_cat: Mixed dimension");
632 LWDEBUG(3,
"ptarray_clone_deep called.");
663 LWDEBUG(3,
"ptarray_clone called.");
685 lwerror(
"ptarray_is_closed: called with null point array");
699 lwerror(
"ptarray_is_closed_2d: called with null point array");
712 lwerror(
"ptarray_is_closed_3d: called with null point array");
751 if ( check_closed && !
p2d_same(seg1, seg2) )
752 lwerror(
"ptarray_contains_point called on unclosed ring");
754 for ( i=1; i < pa->
npoints; i++ )
759 if ( seg1->
x == seg2->
x && seg1->
y == seg2->
y )
769 if ( pt->
y > ymax || pt->
y < ymin )
791 if ( (side < 0) && (seg1->
y <= pt->
y) && (pt->
y < seg2->
y) )
801 else if ( (side > 0) && (seg2->
y <= pt->
y) && (pt->
y < seg1->
y) )
810 if ( winding_number )
811 *winding_number = wn;
852 lwerror(
"ptarrayarc_contains_point called with even number of points");
859 lwerror(
"ptarrayarc_contains_point called too-short pointarray");
866 if ( check_closed && !
p2d_same(seg1, seg3) )
868 lwerror(
"ptarrayarc_contains_point called on unclosed ring");
887 else if ( d < radius )
899 for ( i=1; i < pa->
npoints; i += 2 )
924 if ( (pt->
x > gbox.
xmax || pt->
x < gbox.
xmin) &&
934 if ( (side == 0) &&
lw_pt_in_arc(pt, seg1, seg2, seg3) )
940 if ( side < 0 && (seg1->
y <= pt->
y) && (pt->
y < seg3->
y) )
946 if ( side > 0 && (seg3->
y <= pt->
y) && (pt->
y < seg1->
y) )
952 if ( pt->
x <= gbox.
xmax && pt->
x >= gbox.
xmin )
978 if ( winding_number )
979 *winding_number = wn;
1003 double x0,
x, y1, y2;
1012 for ( i = 2; i < pa->
npoints; i++ )
1046 for( i = 0; i < pa->
npoints; i++ )
1049 if( hasz && ! in_hasz )
1051 if( hasm && ! in_hasm )
1068 double length, slength, tlength;
1081 LWDEBUGF(3,
"Total length: %g", length);
1089 LWDEBUGF(3,
"From/To: %g/%g", from, to);
1095 for ( i = 0; i < nsegs; i++ )
1102 LWDEBUGF(3 ,
"Segment %d: (%g,%g,%g,%g)-(%g,%g,%g,%g)",
1103 i, p1.
x, p1.
y, p1.
z, p1.
m, p2.
x, p2.
y, p2.
z, p2.
m);
1117 if ( fabs ( from - ( tlength + slength ) ) <= tolerance )
1120 LWDEBUG(3,
" Second point is our start");
1130 else if ( fabs(from - tlength) <= tolerance )
1133 LWDEBUG(3,
" First point is our start");
1151 else if ( from > tlength + slength )
goto END;
1156 LWDEBUG(3,
" Seg contains first point");
1162 dseg = (from - tlength) / slength;
1184 if ( fabs(to - ( tlength + slength ) ) <= tolerance )
1187 LWDEBUG(3,
" Second point is our end");
1197 else if ( fabs(to - tlength) <= tolerance )
1200 LWDEBUG(3,
" First point is our end");
1211 else if ( to > tlength + slength )
1221 else if ( to < tlength + slength )
1224 LWDEBUG(3,
" Seg contains our end");
1226 dseg = (to - tlength) / slength;
1244 memcpy(&p1, &p2,
sizeof(
POINT4D));
1281 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) );
1294 ret->
x = A->
x + ( (B->
x - A->
x) *
r );
1295 ret->
y = A->
y + ( (B->
y - A->
y) *
r );
1296 ret->
z = A->
z + ( (B->
z - A->
z) *
r );
1297 ret->
m = A->
m + ( (B->
m - A->
m) *
r );
1307 double mindist=DBL_MAX;
1310 POINT4D start4d, end4d, projtmp;
1312 const POINT2D *start = NULL, *end = NULL;
1318 if ( ! proj4d ) proj4d = &projtmp;
1340 if ( dist < mindist )
1346 LWDEBUG(3,
"Breaking on mindist=0");
1354 if ( mindistout ) *mindistout = mindist;
1356 LWDEBUGF(3,
"Closest segment: %d", seg);
1357 LWDEBUGF(3,
"mindist: %g", mindist);
1379 LWDEBUGF(3,
"Closest point on segment: %g,%g", proj.
x, proj.
y);
1387 if ( tlen == 0 )
return 0;
1391 for (t=0; t<seg; t++, start=end)
1396 LWDEBUGF(4,
"Segment %d made plen %g", t, plen);
1401 LWDEBUGF(3,
"plen %g, tlen %g", plen, tlen);
1424 if (
x < 0 )
x+= 360;
1425 else if (
x > 180 )
x -= 360;
1456 double tolsq = tolerance * tolerance;
1463 double dsq = FLT_MAX;
1466 if ( n_points <= min_points )
return;
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)
1525 LWDEBUG(4,
"function called");
1536 LWDEBUGF(4,
"P%d(%f,%f) to P%d(%f,%f)",
1537 p1, pa->
x, pa->
y, p2, pb->
x, pb->
y);
1539 for (k=p1+1; k<p2; k++)
1553 LWDEBUGF(4,
"P%d is farthest (%g)", k, d);
1560 LWDEBUG(3,
"segment too short, no split/no dist");
1569 const int *ia = (
const int *)a;
1570 const int *ib = (
const int *)b;
1578 static size_t stack_size = 256;
1579 int *stack, *outlist;
1580 int stack_static[stack_size];
1581 int outlist_static[stack_size];
1588 double eps_sqr = epsilon * epsilon;
1601 stack = stack_static;
1602 outlist = outlist_static;
1609 outlist[outn++] = 0;
1614 if ((dist > eps_sqr) || ((outn + sp+1 < minpts) && (dist >= 0)))
1616 stack[++sp] = split;
1620 outlist[outn++] = stack[sp];
1627 qsort(outlist, outn,
sizeof(
int),
int_cmp);
1629 for (i = 0; i < outn; i++)
1646 if (stack != stack_static)
1648 if (outlist != outlist_static)
1671 lwerror(
"arc point array with even number of points");
1675 for ( i=2; i < pts->
npoints; i += 2 )
1696 if ( pts->
npoints < 2 )
return 0.0;
1700 for ( i=1; i < pts->
npoints; i++ )
1704 dist += sqrt( ((frm->
x - to->
x)*(frm->
x - to->
x)) +
1705 ((frm->
y - to->
y)*(frm->
y - to->
y)) );
1724 if ( pts->
npoints < 2 )
return 0.0;
1730 for ( i=1; i < pts->
npoints; i++ )
1733 dist += sqrt( ((frm.
x - to.
x)*(frm.
x - to.
x)) +
1734 ((frm.
y - to.
y)*(frm.
y - to.
y)) +
1735 ((frm.
z - to.
z)*(frm.
z - to.
z)) );
1755 #if PARANOIA_LEVEL > 0
1758 lwerror(
"%s [%d] got NULL pointarray", __FILE__, __LINE__);
1767 lwerror(
"%s [%d] called outside of ptarray range (n=%d, pa.npoints=%d, pa.maxpoints=%d)", __FILE__, __LINE__, n, pa->
npoints, pa->
maxpoints);
1777 LWDEBUGF(5,
"point = %g %g", *((
double*)(ptr)), *((
double*)(ptr+8)));
1781 LWDEBUGF(5,
"point = %g %g %g", *((
double*)(ptr)), *((
double*)(ptr+8)), *((
double*)(ptr+16)));
1785 LWDEBUGF(5,
"point = %g %g %g %g", *((
double*)(ptr)), *((
double*)(ptr+8)), *((
double*)(ptr+16)), *((
double*)(ptr+24)));
1802 LWDEBUG(2,
"lwgeom_affine_ptarray start");
1819 LWDEBUGF(3,
" POINT %g %g %g => %g %g %g",
x,
y, z, p4d.
x, p4d.
y, p4d.
z);
1824 LWDEBUG(3,
" doesn't have z");
1835 LWDEBUGF(3,
" POINT %g %g => %g %g",
x,
y, p4d.
x, p4d.
y);
1839 LWDEBUG(3,
"lwgeom_affine_ptarray end");
1848 static int gluInvertMatrix(
const double *m,
double *invOut)
1850 double inv[16],
det;
1853 inv[0] = m[5] * m[10] * m[15] -
1854 m[5] * m[11] * m[14] -
1855 m[9] * m[6] * m[15] +
1856 m[9] * m[7] * m[14] +
1857 m[13] * m[6] * m[11] -
1858 m[13] * m[7] * m[10];
1860 inv[4] = -m[4] * m[10] * m[15] +
1861 m[4] * m[11] * m[14] +
1862 m[8] * m[6] * m[15] -
1863 m[8] * m[7] * m[14] -
1864 m[12] * m[6] * m[11] +
1865 m[12] * m[7] * m[10];
1867 inv[8] = m[4] * m[9] * m[15] -
1868 m[4] * m[11] * m[13] -
1869 m[8] * m[5] * m[15] +
1870 m[8] * m[7] * m[13] +
1871 m[12] * m[5] * m[11] -
1872 m[12] * m[7] * m[9];
1874 inv[12] = -m[4] * m[9] * m[14] +
1875 m[4] * m[10] * m[13] +
1876 m[8] * m[5] * m[14] -
1877 m[8] * m[6] * m[13] -
1878 m[12] * m[5] * m[10] +
1879 m[12] * m[6] * m[9];
1881 inv[1] = -m[1] * m[10] * m[15] +
1882 m[1] * m[11] * m[14] +
1883 m[9] * m[2] * m[15] -
1884 m[9] * m[3] * m[14] -
1885 m[13] * m[2] * m[11] +
1886 m[13] * m[3] * m[10];
1888 inv[5] = m[0] * m[10] * m[15] -
1889 m[0] * m[11] * m[14] -
1890 m[8] * m[2] * m[15] +
1891 m[8] * m[3] * m[14] +
1892 m[12] * m[2] * m[11] -
1893 m[12] * m[3] * m[10];
1895 inv[9] = -m[0] * m[9] * m[15] +
1896 m[0] * m[11] * m[13] +
1897 m[8] * m[1] * m[15] -
1898 m[8] * m[3] * m[13] -
1899 m[12] * m[1] * m[11] +
1900 m[12] * m[3] * m[9];
1902 inv[13] = m[0] * m[9] * m[14] -
1903 m[0] * m[10] * m[13] -
1904 m[8] * m[1] * m[14] +
1905 m[8] * m[2] * m[13] +
1906 m[12] * m[1] * m[10] -
1907 m[12] * m[2] * m[9];
1909 inv[2] = m[1] * m[6] * m[15] -
1910 m[1] * m[7] * m[14] -
1911 m[5] * m[2] * m[15] +
1912 m[5] * m[3] * m[14] +
1913 m[13] * m[2] * m[7] -
1914 m[13] * m[3] * m[6];
1916 inv[6] = -m[0] * m[6] * m[15] +
1917 m[0] * m[7] * m[14] +
1918 m[4] * m[2] * m[15] -
1919 m[4] * m[3] * m[14] -
1920 m[12] * m[2] * m[7] +
1921 m[12] * m[3] * m[6];
1923 inv[10] = m[0] * m[5] * m[15] -
1924 m[0] * m[7] * m[13] -
1925 m[4] * m[1] * m[15] +
1926 m[4] * m[3] * m[13] +
1927 m[12] * m[1] * m[7] -
1928 m[12] * m[3] * m[5];
1930 inv[14] = -m[0] * m[5] * m[14] +
1931 m[0] * m[6] * m[13] +
1932 m[4] * m[1] * m[14] -
1933 m[4] * m[2] * m[13] -
1934 m[12] * m[1] * m[6] +
1935 m[12] * m[2] * m[5];
1937 inv[3] = -m[1] * m[6] * m[11] +
1938 m[1] * m[7] * m[10] +
1939 m[5] * m[2] * m[11] -
1940 m[5] * m[3] * m[10] -
1941 m[9] * m[2] * m[7] +
1944 inv[7] = m[0] * m[6] * m[11] -
1945 m[0] * m[7] * m[10] -
1946 m[4] * m[2] * m[11] +
1947 m[4] * m[3] * m[10] +
1948 m[8] * m[2] * m[7] -
1951 inv[11] = -m[0] * m[5] * m[11] +
1952 m[0] * m[7] * m[9] +
1953 m[4] * m[1] * m[11] -
1954 m[4] * m[3] * m[9] -
1955 m[8] * m[1] * m[7] +
1958 inv[15] = m[0] * m[5] * m[10] -
1959 m[0] * m[6] * m[9] -
1960 m[4] * m[1] * m[10] +
1961 m[4] * m[2] * m[9] +
1962 m[8] * m[1] * m[6] -
1965 det = m[0] * inv[0] + m[1] * inv[4] + m[2] * inv[8] + m[3] * inv[12];
1972 for (i = 0; i < 16; i++)
1973 invOut[i] = inv[i] *
det;
1987 LWDEBUG(3,
"ptarray_scale start");
1997 LWDEBUG(3,
"ptarray_scale end");
2024 LWDEBUGF(2,
"%s called on %p", __func__, pa);
2026 for (i = 0; i < pa->
npoints; i++)
2031 if (grid->
xsize > 0)
2036 if (grid->
ysize > 0)
2045 if (grid->
zsize > 0)
2052 if (grid->
msize > 0 && !has_z)
2055 if (grid->
msize > 0 && has_z)
2089 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)
uint8_t gflags(int hasz, int hasm, int geodetic)
Construct a new flags char.
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
double distance2d_sqr_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)
Macros for manipulating the 'flags' byte.
double distance2d_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
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)
#define LW_TRUE
Return types for functions with status returns.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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) .
void ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to)
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)
Datum area(PG_FUNCTION_ARGS)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
int ptarray_contains_point_partial(const POINTARRAY *pa, const POINT2D *pt, int check_closed, int *winding_number)
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.
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
POINTARRAY * ptarray_addPoint(const POINTARRAY *pa, uint8_t *p, size_t pdims, uint32_t where)
Add a point in a pointarray.
void ptarray_simplify_in_place(POINTARRAY *pa, double epsilon, uint32_t minpts)
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)
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.
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)
size_t ptarray_point_size(const POINTARRAY *pa)
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.
static void ptarray_dp_findsplit_in_place(const POINTARRAY *pts, int p1, int p2, int *split, double *dist)
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...
static int int_cmp(const void *a, const void *b)
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