33 #include "../postgis_revision.h"
35 #define xstr(s) str(s)
41 static char *ptr = NULL;
57 if (d > (
double)FLT_MAX)
59 if (d <= (
double)-FLT_MAX)
63 if ( ((
double)result) <=d )
66 return nextafterf(result, -1*FLT_MAX);
78 if (d >= (
double)FLT_MAX)
80 if (d < (
double)-FLT_MAX)
84 if ( ((
double)result) >=d )
87 return nextafterf(result, FLT_MAX);
132 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
138 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
142 LWDEBUG(4,
"getPoint4d_p called.");
148 LWDEBUGF(4,
"ptr %p, zmflag %d", ptr, zmflag);
153 memcpy(op, ptr,
sizeof(
POINT2D));
159 memcpy(op, ptr,
sizeof(
POINT4D));
221 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
228 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
232 LWDEBUGF(2,
"getPoint3dz_p called on array of %d-dimensions / %u pts",
253 memcpy(op, ptr,
sizeof(
POINT2D));
275 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
281 lwerror(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
285 LWDEBUGF(2,
"getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
307 memcpy(op, ptr,
sizeof(
POINT2D));
317 memcpy(&(op->
m), ptr,
sizeof(
double));
353 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
359 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
379 assert(n < pa->npoints);
384 memcpy(ptr, p4d,
sizeof(
POINT4D));
390 memcpy(ptr, p4d,
sizeof(
POINT2D));
392 memcpy(ptr, &(p4d->
m),
sizeof(
double));
395 memcpy(ptr, p4d,
sizeof(
POINT2D));
429 lwerror(
"%s: unsupported number of dimensions - %d", __func__, ndims);
464 lwnotice(
" PTARRAY is null pointer!");
469 for (t = 0; t < pa->
npoints; t++)
475 lwnotice(
" %i : %lf,%lf,%lf", t, pt.
x, pt.
y, pt.
z);
477 lwnotice(
" %i : %lf,%lf,%lf,%lf", t, pt.
x, pt.
y, pt.
z, pt.
m);
493 uint8_t result_high = 0;
494 uint8_t result_low = 0;
610 return (uint8_t) ((result_high<<4) + result_low);
628 static char outchr[]=
633 input_high = (
str>>4);
634 input_low = (
str & 0x0F);
636 result[0] = outchr[input_high];
637 result[1] = outchr[input_low];
658 #if PARANOIA_LEVEL > 0
659 if (F < 0 || F > 1)
lwerror(
"interpolate_point4d: invalid F (%g)", F);
661 I->
x=A->
x+((B->
x-A->
x)*F);
662 I->
y=A->
y+((B->
y-A->
y)*F);
663 I->
z=A->
z+((B->
z-A->
z)*F);
664 I->
m=A->
m+((B->
m-A->
m)*F);
#define LIBLWGEOM_VERSION
liblwgeom versions
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
#define FLAGS_GET_Z(flags)
#define FLAGS_NDIMS(flags)
#define FLAGS_GET_M(flags)
#define FLAGS_GET_ZM(flags)
void deparse_hex(uint8_t str, char *result)
Given one byte, populate result with two byte representing the hex number.
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
lwinterrupt_callback * _lwgeom_interrupt_callback
const char * lwgeom_version()
Return lwgeom version string (not to be freed)
void lwgeom_cancel_interrupt()
Cancel any interruption request.
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...
POINT3DM getPoint3dm(const POINTARRAY *pa, uint32_t n)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *op)
int _lwgeom_interrupt_requested
void printPA(POINTARRAY *pa)
int getPoint2d_p(const POINTARRAY *pa, uint32_t n, POINT2D *point)
void printBOX3D(BOX3D *box)
void lwgeom_request_interrupt()
Request interruption of any running code.
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *cb)
POINT3DZ getPoint3dz(const POINTARRAY *pa, uint32_t n)
POINT2D getPoint2d(const POINTARRAY *pa, uint32_t n)
uint8_t parse_hex(char *str)
Given a string with at least 2 chars in it, convert them to a byte value.
float next_float_up(double d)
int getPoint3dm_p(const POINTARRAY *pa, uint32_t n, POINT3DM *op)
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void ptarray_copy_point(POINTARRAY *pa, uint32_t from, uint32_t to)
float next_float_down(double d)
int getPoint3dz_p(const POINTARRAY *pa, uint32_t n, POINT3DZ *op)
#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 size_t ptarray_point_size(const POINTARRAY *pa)
static uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)