PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ BOX3D_in()

Datum BOX3D_in ( PG_FUNCTION_ARGS  )

Definition at line 56 of file lwgeom_box3d.c.

57 {
58  char *str = PG_GETARG_CSTRING(0);
59  int nitems;
60  BOX3D *box = (BOX3D *)palloc(sizeof(BOX3D));
61  box->zmin = 0;
62  box->zmax = 0;
63 
64  if (strstr(str, "BOX3D(") != str)
65  {
66  pfree(box);
67  elog(ERROR, "BOX3D parser - doesn't start with BOX3D(");
68  PG_RETURN_NULL();
69  }
70 
71  nitems = sscanf(str,
72  "BOX3D(%le %le %le ,%le %le %le)",
73  &box->xmin,
74  &box->ymin,
75  &box->zmin,
76  &box->xmax,
77  &box->ymax,
78  &box->zmax);
79  if (nitems != 6)
80  {
81  nitems = sscanf(str, "BOX3D(%le %le ,%le %le)", &box->xmin, &box->ymin, &box->xmax, &box->ymax);
82  if (nitems != 4)
83  {
84  pfree(box);
85  elog(
86  ERROR,
87  "BOX3D parser - couldn't parse. It should look like: BOX3D(xmin ymin zmin,xmax ymax zmax) or BOX3D(xmin ymin,xmax ymax)");
88  PG_RETURN_NULL();
89  }
90  }
91 
92  if (box->xmin > box->xmax)
93  {
94  float tmp = box->xmin;
95  box->xmin = box->xmax;
96  box->xmax = tmp;
97  }
98  if (box->ymin > box->ymax)
99  {
100  float tmp = box->ymin;
101  box->ymin = box->ymax;
102  box->ymax = tmp;
103  }
104  if (box->zmin > box->zmax)
105  {
106  float tmp = box->zmin;
107  box->zmin = box->zmax;
108  box->zmax = tmp;
109  }
110  box->srid = SRID_UNKNOWN;
111  PG_RETURN_POINTER(box);
112 }
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
double xmax
Definition: liblwgeom.h:281
double zmin
Definition: liblwgeom.h:280
double ymax
Definition: liblwgeom.h:281
double ymin
Definition: liblwgeom.h:280
double zmax
Definition: liblwgeom.h:281
double xmin
Definition: liblwgeom.h:280
int32_t srid
Definition: liblwgeom.h:282

References BOX3D::srid, SRID_UNKNOWN, BOX3D::xmax, BOX3D::xmin, BOX3D::ymax, BOX3D::ymin, BOX3D::zmax, and BOX3D::zmin.