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);
112 lwerror(
"%s [%d] error returned by getPoint4d_p", __FILE__, __LINE__);
133 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
139 lwerror(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
143 LWDEBUG(4,
"getPoint4d_p called.");
149 LWDEBUGF(4,
"ptr %p, zmflag %d", ptr, zmflag);
154 memcpy(op, ptr,
sizeof(
POINT2D));
160 memcpy(op, ptr,
sizeof(
POINT4D));
222 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
229 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
233 LWDEBUGF(2,
"getPoint3dz_p called on array of %d-dimensions / %u pts",
254 memcpy(op, ptr,
sizeof(
POINT2D));
276 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
282 lwerror(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
304 memcpy(op, ptr,
sizeof(
POINT2D));
314 memcpy(&(op->
m), ptr,
sizeof(
double));
347 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
353 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
373 assert(n < pa->npoints);
378 memcpy(ptr, p4d,
sizeof(
POINT4D));
384 memcpy(ptr, p4d,
sizeof(
POINT2D));
386 memcpy(ptr, &(p4d->
m),
sizeof(
double));
389 memcpy(ptr, p4d,
sizeof(
POINT2D));
423 lwerror(
"%s: unsupported number of dimensions - %d", __func__, ndims);
458 lwnotice(
" PTARRAY is null pointer!");
463 for (t = 0; t < pa->
npoints; t++)
469 lwnotice(
" %i : %lf,%lf,%lf", t, pt.
x, pt.
y, pt.
z);
471 lwnotice(
" %i : %lf,%lf,%lf,%lf", t, pt.
x, pt.
y, pt.
z, pt.
m);
487 uint8_t result_high = 0;
488 uint8_t result_low = 0;
604 return (uint8_t) ((result_high<<4) + result_low);
622 static char outchr[]=
627 input_high = (
str>>4);
628 input_low = (
str & 0x0F);
630 result[0] = outchr[input_high];
631 result[1] = outchr[input_low];
652 #if PARANOIA_LEVEL > 0
653 if (F < 0 || F > 1)
lwerror(
"interpolate_point4d: invalid F (%g)", F);
655 I->
x=A->
x+((B->
x-A->
x)*F);
656 I->
y=A->
y+((B->
y-A->
y)*F);
657 I->
z=A->
z+((B->
z-A->
z)*F);
658 I->
m=A->
m+((B->
m-A->
m)*F);
char result[OUT_DOUBLE_BUFFER_SIZE]
#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)
#define LW_TRUE
Return types for functions with status returns.
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)