PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ gbox_to_gml2()

static char * gbox_to_gml2 ( const GBOX bbox,
const char *  srs,
int  precision,
const char *  prefix 
)
static

Definition at line 75 of file lwout_gml.c.

76{
77 int size;
78 POINT4D pt;
79 POINTARRAY *pa;
80 char *ptr, *output;
81 size_t prefixlen = strlen(prefix);
82
83 if ( ! bbox )
84 {
85 size = ( sizeof("<Box>/") + (prefixlen*2) ) * 2;
86 if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
87
88 ptr = output = lwalloc(size);
89
90 ptr += sprintf(ptr, "<%sBox", prefix);
91
92 if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
93
94 ptr += sprintf(ptr, "/>");
95
96 return output;
97 }
98
99 pa = ptarray_construct_empty(FLAGS_GET_Z(bbox->flags), 0, 2);
100
101 pt.x = bbox->xmin;
102 pt.y = bbox->ymin;
103 if (FLAGS_GET_Z(bbox->flags)) pt.z = bbox->zmin;
105
106 pt.x = bbox->xmax;
107 pt.y = bbox->ymax;
108 if (FLAGS_GET_Z(bbox->flags)) pt.z = bbox->zmax;
110
111 size = pointArray_GMLsize(pa, precision);
112 size += ( sizeof("<Box><coordinates>/") + (prefixlen*2) ) * 2;
113 if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
114
115 ptr = output = lwalloc(size);
116
117 if ( srs ) ptr += sprintf(ptr, "<%sBox srsName=\"%s\">", prefix, srs);
118 else ptr += sprintf(ptr, "<%sBox>", prefix);
119
120 ptr += sprintf(ptr, "<%scoordinates>", prefix);
121 ptr += pointArray_toGML2(pa, ptr, precision);
122 ptr += sprintf(ptr, "</%scoordinates></%sBox>", prefix, prefix);
123
124 ptarray_free(pa);
125
126 return output;
127}
static uint8_t precision
Definition cu_in_twkb.c:25
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
Definition ptarray.c:59
#define FLAGS_GET_Z(flags)
Definition liblwgeom.h:179
void * lwalloc(size_t size)
Definition lwutil.c:227
void ptarray_free(POINTARRAY *pa)
Definition ptarray.c:327
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
Definition ptarray.c:147
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:107
static size_t pointArray_GMLsize(POINTARRAY *pa, int precision)
Definition lwout_gml.c:1947
static size_t pointArray_toGML2(POINTARRAY *pa, char *buf, int precision)
Definition lwout_gml.c:662
double ymax
Definition liblwgeom.h:343
double zmax
Definition liblwgeom.h:345
double xmax
Definition liblwgeom.h:341
double zmin
Definition liblwgeom.h:344
double ymin
Definition liblwgeom.h:342
double xmin
Definition liblwgeom.h:340
lwflags_t flags
Definition liblwgeom.h:339
double x
Definition liblwgeom.h:400
double z
Definition liblwgeom.h:400
double y
Definition liblwgeom.h:400

References GBOX::flags, FLAGS_GET_Z, LW_TRUE, lwalloc(), pointArray_GMLsize(), pointArray_toGML2(), precision, ptarray_append_point(), ptarray_construct_empty(), ptarray_free(), POINT4D::x, GBOX::xmax, GBOX::xmin, POINT4D::y, GBOX::ymax, GBOX::ymin, POINT4D::z, GBOX::zmax, and GBOX::zmin.

Referenced by lwgeom_extent_to_gml2().

Here is the call graph for this function:
Here is the caller graph for this function: