PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ BOX2D_in()

Datum BOX2D_in ( PG_FUNCTION_ARGS  )

Definition at line 58 of file lwgeom_box.c.

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

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

Here is the call graph for this function: