33 #include "../postgis_svn_revision.h" 38 static char *ptr = NULL;
54 if (d > (
double)FLT_MAX)
56 if (d <= (
double)-FLT_MAX)
60 if ( ((
double)result) <=d )
63 return nextafterf(result, -1*FLT_MAX);
75 if (d >= (
double)FLT_MAX)
77 if (d < (
double)-FLT_MAX)
81 if ( ((
double)result) >=d )
84 return nextafterf(result, FLT_MAX);
129 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
133 if ( (n<0) || (n>=pa->
npoints))
135 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
139 LWDEBUG(4,
"getPoint4d_p called.");
145 LWDEBUGF(4,
"ptr %p, zmflag %d", ptr, zmflag);
150 memcpy(op, ptr,
sizeof(
POINT2D));
156 memcpy(op, ptr,
sizeof(
POINT4D));
220 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
224 if ( (n<0) || (n>=pa->
npoints))
226 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
230 LWDEBUGF(2,
"getPoint3dz_p called on array of %d-dimensions / %u pts",
251 memcpy(op, ptr,
sizeof(
POINT2D));
273 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
277 if ( (n<0) || (n>=pa->
npoints))
279 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
283 LWDEBUGF(2,
"getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
305 memcpy(op, ptr,
sizeof(
POINT2D));
315 memcpy(&(op->
m), ptr,
sizeof(
double));
351 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
355 if ( (n<0) || (n>=pa->
npoints))
357 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
375 if ( ! pa )
return 0;
377 if ( (n<0) || (n>=pa->
npoints))
379 lwerror(
"getPoint2D_const_p: point offset out of range");
389 if ( ! pa )
return 0;
393 lwerror(
"getPoint3dz_cp: no Z coordinates in point array");
397 if ( (n<0) || (n>=pa->
npoints))
399 lwerror(
"getPoint3dz_cp: point offset out of range");
410 if ( ! pa )
return 0;
414 lwerror(
"getPoint3dz_cp: no Z and M coordinates in point array");
418 if ( (n<0) || (n>=pa->
npoints))
420 lwerror(
"getPoint3dz_cp: point offset out of range");
440 assert(n >= 0 && n < pa->npoints);
445 memcpy(ptr, p4d,
sizeof(
POINT4D));
451 memcpy(ptr, p4d,
sizeof(
POINT2D));
453 memcpy(ptr, &(p4d->
m),
sizeof(
double));
456 memcpy(ptr, p4d,
sizeof(
POINT2D));
500 lwnotice(
" %i : %lf,%lf,%lf,%lf",t,pt.
x,pt.
y,pt.
z,pt.
m);
634 return (
uint8_t) ((result_high<<4) + result_low);
652 static char outchr[]=
657 input_high = (str>>4);
658 input_low = (str & 0x0F);
660 result[0] = outchr[input_high];
661 result[1] = outchr[input_low];
682 #if PARANOIA_LEVEL > 0 684 if ( absF < 0 || absF > 1 )
686 lwerror(
"interpolate_point4d: invalid F (%g)", F);
689 I->
x=A->
x+((B->
x-A->
x)*F);
690 I->
y=A->
y+((B->
y-A->
y)*F);
691 I->
z=A->
z+((B->
z-A->
z)*F);
692 I->
m=A->
m+((B->
m-A->
m)*F);
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
void lwgeom_request_interrupt()
Request interruption of any running code.
int _lwgeom_interrupt_requested
void lwnotice(const char *fmt,...)
Write a notice out to the notice handler.
int getPoint2d_p(const POINTARRAY *pa, int n, POINT2D *point)
const POINT4D * getPoint4d_cp(const POINTARRAY *pa, int n)
Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
void() lwinterrupt_callback()
Install a callback to be called periodically during algorithm execution.
float next_float_down(double d)
#define FLAGS_GET_ZM(flags)
#define LWDEBUG(level, msg)
#define LIBLWGEOM_VERSION
liblwgeom versions
void lwgeom_cancel_interrupt()
Cancel any interruption request.
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, int n)
Returns a pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
const char * lwgeom_version()
Return lwgeom version string (not to be freed)
uint8_t parse_hex(char *str)
Given a string with at least 2 chars in it, convert them to a byte value.
void printBOX3D(BOX3D *box)
uint8_t * getPoint_internal(const POINTARRAY *pa, int n)
int ptarray_point_size(const POINTARRAY *pa)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
POINT3DM getPoint3dm(const POINTARRAY *pa, int n)
lwinterrupt_callback * lwgeom_register_interrupt_callback(lwinterrupt_callback *cb)
int getPoint3dz_p(const POINTARRAY *pa, int n, POINT3DZ *op)
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, int n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from...
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *op)
POINT4D getPoint4d(const POINTARRAY *pa, int n)
#define FLAGS_GET_M(flags)
int getPoint3dm_p(const POINTARRAY *pa, int n, POINT3DM *op)
void interpolate_point4d(POINT4D *A, 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...
void deparse_hex(uint8_t str, char *result)
Given one byte, populate result with two byte representing the hex number.
float next_float_up(double d)
void printPA(POINTARRAY *pa)
#define LWDEBUGF(level, msg,...)
#define FLAGS_NDIMS(flags)
POINT2D getPoint2d(const POINTARRAY *pa, int n)
lwinterrupt_callback * _lwgeom_interrupt_callback
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
POINT3DZ getPoint3dz(const POINTARRAY *pa, int n)