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

Definition at line 44 of file lwgeom_box.c.

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

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

Here is the call graph for this function: