PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ BOX3D_in()

Datum BOX3D_in ( PG_FUNCTION_ARGS  )

Definition at line 52 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.

53 {
54  char *str = PG_GETARG_CSTRING(0);
55  int nitems;
56  BOX3D *box = (BOX3D *) palloc(sizeof(BOX3D));
57  box->zmin = 0;
58  box->zmax = 0;
59 
60 
61  /*printf( "box3d_in gets '%s'\n",str); */
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,"BOX3D(%le %le %le ,%le %le %le)",
71  &box->xmin, &box->ymin, &box->zmin,
72  &box->xmax, &box->ymax, &box->zmax);
73  if (nitems != 6 )
74  {
75  nitems = sscanf(str,"BOX3D(%le %le ,%le %le)",
76  &box->xmin, &box->ymin, &box->xmax, &box->ymax);
77  if (nitems != 4)
78  {
79  pfree(box);
80  elog(ERROR,"BOX3D parser - couldnt parse. It should look like: BOX3D(xmin ymin zmin,xmax ymax zmax) or BOX3D(xmin ymin,xmax ymax)");
81  PG_RETURN_NULL();
82  }
83  }
84 
85  if (box->xmin > box->xmax)
86  {
87  float tmp = box->xmin;
88  box->xmin = box->xmax;
89  box->xmax = tmp;
90  }
91  if (box->ymin > box->ymax)
92  {
93  float tmp = box->ymin;
94  box->ymin = box->ymax;
95  box->ymax = tmp;
96  }
97  if (box->zmin > box->zmax)
98  {
99  float tmp = box->zmin;
100  box->zmin = box->zmax;
101  box->zmax = tmp;
102  }
103  box->srid = SRID_UNKNOWN;
104  PG_RETURN_POINTER(box);
105 }
int32_t srid
Definition: liblwgeom.h:263
double ymin
Definition: liblwgeom.h:261
double xmin
Definition: liblwgeom.h:261
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:172
double xmax
Definition: liblwgeom.h:262
double ymax
Definition: liblwgeom.h:262
double zmax
Definition: liblwgeom.h:262
double zmin
Definition: liblwgeom.h:261
Here is the call graph for this function: