PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ BOX3D_in()

Datum BOX3D_in ( PG_FUNCTION_ARGS  )

Definition at line 55 of file lwgeom_box3d.c.

References BOX3D_out(), PG_FUNCTION_INFO_V1(), BOX3D::srid, SRID_UNKNOWN, BOX3D::xmax, BOX3D::xmin, BOX3D::ymax, BOX3D::ymin, BOX3D::zmax, and BOX3D::zmin.

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