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

◆ BOX2D_in()

Datum BOX2D_in ( PG_FUNCTION_ARGS  )

Definition at line 56 of file lwgeom_box.c.

57{
58 char *str = PG_GETARG_CSTRING(0);
59 int nitems;
60 double tmp;
61 GBOX box;
62 int i;
63
64 gbox_init(&box);
65
66 for(i = 0; str[i]; i++) {
67 str[i] = tolower(str[i]);
68 }
69
70 nitems = sscanf(str,"box(%lf %lf,%lf %lf)", &box.xmin, &box.ymin, &box.xmax, &box.ymax);
71 if (nitems != 4)
72 {
73 elog(ERROR,"box2d parser - couldn't parse. It should look like: BOX(xmin ymin,xmax ymax)");
74 PG_RETURN_NULL();
75 }
76
77 if (box.xmin > box.xmax)
78 {
79 tmp = box.xmin;
80 box.xmin = box.xmax;
81 box.xmax = tmp;
82 }
83 if (box.ymin > box.ymax)
84 {
85 tmp = box.ymin;
86 box.ymin = box.ymax;
87 box.ymax = tmp;
88 }
89 PG_RETURN_POINTER(gbox_copy(&box));
90}
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:426
#define str(s)
double ymax
Definition liblwgeom.h:343
double xmax
Definition liblwgeom.h:341
double ymin
Definition liblwgeom.h:342
double xmin
Definition liblwgeom.h:340

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

Here is the call graph for this function: