PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum BOX2D_in ( PG_FUNCTION_ARGS  )

Definition at line 45 of file lwgeom_box.c.

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

46 {
47  char *str = PG_GETARG_CSTRING(0);
48  int nitems;
49  double tmp;
50  GBOX box;
51  int i;
52 
53  gbox_init(&box);
54 
55  for(i = 0; str[i]; i++) {
56  str[i] = tolower(str[i]);
57  }
58 
59  nitems = sscanf(str,"box(%lf %lf,%lf %lf)", &box.xmin, &box.ymin, &box.xmax, &box.ymax);
60  if (nitems != 4)
61  {
62  elog(ERROR,"box2d parser - couldnt parse. It should look like: BOX(xmin ymin,xmax ymax)");
63  PG_RETURN_NULL();
64  }
65 
66  if (box.xmin > box.xmax)
67  {
68  tmp = box.xmin;
69  box.xmin = box.xmax;
70  box.xmax = tmp;
71  }
72  if (box.ymin > box.ymax)
73  {
74  tmp = box.ymin;
75  box.ymin = box.ymax;
76  box.ymax = tmp;
77  }
78  PG_RETURN_POINTER(gbox_copy(&box));
79 }
GBOX * gbox_copy(const GBOX *box)
Return a copy of the GBOX, based on dimensionality of flags.
Definition: g_box.c:362
double xmax
Definition: liblwgeom.h:249
double ymin
Definition: liblwgeom.h:250
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:34
double xmin
Definition: liblwgeom.h:248
double ymax
Definition: liblwgeom.h:251

Here is the call graph for this function: