34 #include "../postgis_svn_revision.h"
39 static char *ptr = NULL;
55 if (d > (
double)FLT_MAX)
57 if (d <= (
double)-FLT_MAX)
61 if ( ((
double)result) <=d )
64 return nextafterf(result, -1*FLT_MAX);
76 if (d >= (
double)FLT_MAX)
78 if (d < (
double)-FLT_MAX)
82 if ( ((
double)result) >=d )
85 return nextafterf(result, FLT_MAX);
130 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
136 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
140 LWDEBUG(4,
"getPoint4d_p called.");
146 LWDEBUGF(4,
"ptr %p, zmflag %d", ptr, zmflag);
151 memcpy(op, ptr,
sizeof(
POINT2D));
157 memcpy(op, ptr,
sizeof(
POINT4D));
221 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
227 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
231 LWDEBUGF(2,
"getPoint3dz_p called on array of %d-dimensions / %u pts",
252 memcpy(op, ptr,
sizeof(
POINT2D));
274 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
280 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
284 LWDEBUGF(2,
"getPoint3dm_p(%d) called on array of %d-dimensions / %u pts",
306 memcpy(op, ptr,
sizeof(
POINT2D));
316 memcpy(&(op->
m), ptr,
sizeof(
double));
352 lwerror(
"%s [%d] NULL POINTARRAY input", __FILE__, __LINE__);
358 lwnotice(
"%s [%d] called with n=%d and npoints=%d", __FILE__, __LINE__, n, pa->
npoints);
376 if ( ! pa )
return 0;
380 lwerror(
"getPoint2d_cp: point offset out of range");
390 if ( ! pa )
return 0;
394 lwerror(
"getPoint3dz_cp: no Z coordinates in point array");
400 lwerror(
"getPoint3dz_cp: point offset out of range");
414 lwerror(
"getPoint4d_cp: no Z and M coordinates in point array");
420 lwerror(
"getPoint4d_cp: point offset out of range");
438 assert(n < pa->npoints);
443 memcpy(ptr, p4d,
sizeof(
POINT4D));
449 memcpy(ptr, p4d,
sizeof(
POINT2D));
451 memcpy(ptr, &(p4d->
m),
sizeof(
double));
454 memcpy(ptr, p4d,
sizeof(
POINT2D));
488 lwerror(
"%s: unsupported number of dimensions - %d", __func__, ndims);
534 lwnotice(
" %i : %lf,%lf,%lf,%lf",t,pt.
x,pt.
y,pt.
z,pt.
m);
668 return (
uint8_t) ((result_high<<4) + result_low);
686 static char outchr[]=
691 input_high = (str>>4);
692 input_low = (str & 0x0F);
694 result[0] = outchr[input_high];
695 result[1] = outchr[input_low];
716 #if PARANOIA_LEVEL > 0
717 if (F < 0 || F > 1)
lwerror(
"interpolate_point4d: invalid F (%g)", F);
719 I->
x=A->
x+((B->
x-A->
x)*F);
720 I->
y=A->
y+((B->
y-A->
y)*F);
721 I->
z=A->
z+((B->
z-A->
z)*F);
722 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.
uint8_t * getPoint_internal(const POINTARRAY *pa, uint32_t n)
#define FLAGS_GET_Z(flags)
Macros for manipulating the 'flags' byte.
#define FLAGS_NDIMS(flags)
size_t ptarray_point_size(const POINTARRAY *pa)
#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)
const POINT4D * getPoint4d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT4D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
int _lwgeom_interrupt_requested
void printPA(POINTARRAY *pa)
const POINT3DZ * getPoint3dz_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT3DZ pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
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)
const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
#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.