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

◆ gbox_to_gml3()

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

Definition at line 130 of file lwout_gml.c.

131{
132 int size;
133 POINT4D pt;
134 POINTARRAY *pa;
135 char *ptr, *output;
136 size_t prefixlen = strlen(prefix);
137 int dimension = 2;
138
139 if ( ! bbox )
140 {
141 size = ( sizeof("<Envelope>/") + (prefixlen*2) ) * 2;
142 if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
143
144 ptr = output = lwalloc(size);
145
146 ptr += sprintf(ptr, "<%sEnvelope", prefix);
147 if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
148
149 ptr += sprintf(ptr, "/>");
150
151 return output;
152 }
153
154 if (FLAGS_GET_Z(bbox->flags)) dimension = 3;
155
156 pa = ptarray_construct_empty(FLAGS_GET_Z(bbox->flags), 0, 1);
157
158 pt.x = bbox->xmin;
159 pt.y = bbox->ymin;
160 if (FLAGS_GET_Z(bbox->flags)) pt.z = bbox->zmin;
162
163 size = pointArray_GMLsize(pa, precision) * 2;
164 size += ( sizeof("<Envelope><lowerCorner><upperCorner>//") + (prefixlen*3) ) * 2;
165 if ( srs ) size += strlen(srs) + sizeof(" srsName=..");
166 if ( IS_DIMS(opts) ) size += sizeof(" srsDimension=. .");
167
168 ptr = output = lwalloc(size);
169
170 ptr += sprintf(ptr, "<%sEnvelope", prefix);
171 if ( srs ) ptr += sprintf(ptr, " srsName=\"%s\"", srs);
172 if ( IS_DIMS(opts) ) ptr += sprintf(ptr, " srsDimension=\"%d\"", dimension);
173 ptr += sprintf(ptr, ">");
174
175 ptr += sprintf(ptr, "<%slowerCorner>", prefix);
176 ptr += pointArray_toGML3(pa, ptr, precision, opts);
177 ptr += sprintf(ptr, "</%slowerCorner>", prefix);
178
180 pt.x = bbox->xmax;
181 pt.y = bbox->ymax;
182 if (FLAGS_GET_Z(bbox->flags)) pt.z = bbox->zmax;
184
185 ptr += sprintf(ptr, "<%supperCorner>", prefix);
186 ptr += pointArray_toGML3(pa, ptr, precision, opts);
187 ptr += sprintf(ptr, "</%supperCorner>", prefix);
188
189 ptr += sprintf(ptr, "</%sEnvelope>", prefix);
190
191 ptarray_free(pa);
192
193 return output;
194}
static uint8_t precision
Definition cu_in_twkb.c:25
int ptarray_remove_point(POINTARRAY *pa, uint32_t where)
Remove a point from an existing POINTARRAY.
Definition ptarray.c:259
#define IS_DIMS(x)
Definition liblwgeom.h:1657
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_toGML3(POINTARRAY *pa, char *buf, int precision, int opts)
Definition lwout_gml.c:1889
static size_t pointArray_GMLsize(POINTARRAY *pa, int precision)
Definition lwout_gml.c:1947
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, IS_DIMS, LW_TRUE, lwalloc(), pointArray_GMLsize(), pointArray_toGML3(), precision, ptarray_append_point(), ptarray_construct_empty(), ptarray_free(), ptarray_remove_point(), POINT4D::x, GBOX::xmax, GBOX::xmin, POINT4D::y, GBOX::ymax, GBOX::ymin, POINT4D::z, GBOX::zmax, and GBOX::zmin.

Referenced by lwgeom_extent_to_gml3().

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