PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ BOX2D_in()

Datum BOX2D_in ( PG_FUNCTION_ARGS  )

Definition at line 57 of file lwgeom_box.c.

58{
59 char *str = PG_GETARG_CSTRING(0);
60 int nitems;
61 double tmp;
62 GBOX box;
63 int i;
64
65 gbox_init(&box);
66
67 for(i = 0; str[i]; i++) {
68 str[i] = tolower(str[i]);
69 }
70
71 nitems = sscanf(str,"box(%lf %lf,%lf %lf)", &box.xmin, &box.ymin, &box.xmax, &box.ymax);
72 if (nitems != 4)
73 {
74 elog(ERROR,"box2d parser - couldn't parse. It should look like: BOX(xmin ymin,xmax ymax)");
75 PG_RETURN_NULL();
76 }
77
78 if (box.xmin > box.xmax)
79 {
80 tmp = box.xmin;
81 box.xmin = box.xmax;
82 box.xmax = tmp;
83 }
84 if (box.ymin > box.ymax)
85 {
86 tmp = box.ymin;
87 box.ymin = box.ymax;
88 box.ymax = tmp;
89 }
90 PG_RETURN_POINTER(gbox_copy(&box));
91}
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition gbox.c:40
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition gbox.c:438
#define str(s)
double ymax
Definition liblwgeom.h:357
double xmax
Definition liblwgeom.h:355
double ymin
Definition liblwgeom.h:356
double xmin
Definition liblwgeom.h:354

References gbox_copy(), gbox_init(), str, GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Here is the call graph for this function: