PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ BOX3D_in()

Datum BOX3D_in ( PG_FUNCTION_ARGS  )

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

73 {
74  char *str = PG_GETARG_CSTRING(0);
75  int nitems;
76  BOX3D *box = (BOX3D *) palloc(sizeof(BOX3D));
77  box->zmin = 0;
78  box->zmax = 0;
79 
80 
81  /*printf( "box3d_in gets '%s'\n",str); */
82 
83  if (strstr(str,"BOX3D(") != str )
84  {
85  pfree(box);
86  elog(ERROR,"BOX3D parser - doesn't start with BOX3D(");
87  PG_RETURN_NULL();
88  }
89 
90  nitems = sscanf(str,"BOX3D(%le %le %le ,%le %le %le)",
91  &box->xmin, &box->ymin, &box->zmin,
92  &box->xmax, &box->ymax, &box->zmax);
93  if (nitems != 6 )
94  {
95  nitems = sscanf(str,"BOX3D(%le %le ,%le %le)",
96  &box->xmin, &box->ymin, &box->xmax, &box->ymax);
97  if (nitems != 4)
98  {
99  pfree(box);
100  elog(ERROR,"BOX3D parser - couldnt parse. It should look like: BOX3D(xmin ymin zmin,xmax ymax zmax) or BOX3D(xmin ymin,xmax ymax)");
101  PG_RETURN_NULL();
102  }
103  }
104 
105  if (box->xmin > box->xmax)
106  {
107  float tmp = box->xmin;
108  box->xmin = box->xmax;
109  box->xmax = tmp;
110  }
111  if (box->ymin > box->ymax)
112  {
113  float tmp = box->ymin;
114  box->ymin = box->ymax;
115  box->ymax = tmp;
116  }
117  if (box->zmin > box->zmax)
118  {
119  float tmp = box->zmin;
120  box->zmin = box->zmax;
121  box->zmax = tmp;
122  }
123  box->srid = SRID_UNKNOWN;
124  PG_RETURN_POINTER(box);
125 }
int32_t srid
Definition: liblwgeom.h:279
double ymin
Definition: liblwgeom.h:277
double xmin
Definition: liblwgeom.h:277
#define SRID_UNKNOWN
Unknown SRID value.
Definition: liblwgeom.h:188
double xmax
Definition: liblwgeom.h:278
double ymax
Definition: liblwgeom.h:278
double zmax
Definition: liblwgeom.h:278
double zmin
Definition: liblwgeom.h:277
Here is the call graph for this function: