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

◆ gserialized2_is_empty_recurse()

static size_t gserialized2_is_empty_recurse ( const uint8_t *  p,
int *  isempty 
)
static

Definition at line 224 of file gserialized2.c.

225{
226 uint32_t type = 0, num = 0;
227
228 /* Short circuit if we found any non-empty component */
229 if (!*isempty) return 0;
230
231 memcpy(&type, p, 4);
232 memcpy(&num, p+4, 4);
233
234 if (lwtype_is_collection(type))
235 {
236 /* Recurse into collections */
237 size_t lz = 8;
238 for ( uint32_t i = 0; i < num; i++ )
239 {
240 lz += gserialized2_is_empty_recurse(p+lz, isempty);
241 if (!*isempty)
242 return lz;
243 }
244 *isempty = LW_TRUE;
245 return lz;
246 }
247 else
248 {
249 size_t lz = 8;
250 /* Any non-collection with zero elements is empty */
251 if ( num == 0 )
252 {
253 *isempty = LW_TRUE;
254 }
255 /*
256 * Special case to handle polygon with a non-zero
257 * set of empty rings
258 * https://trac.osgeo.org/postgis/ticket/6028
259 */
260 else if ( num > 0 && type == POLYGONTYPE )
261 {
262 for ( uint32_t i = 0; i < num; i++ )
263 {
264 uint32_t lrnum;
265 memcpy(&lrnum, p+lz, 4);
266 lz += 4;
267 if ( lrnum > 0 )
268 {
269 *isempty = LW_FALSE;
270 return lz;
271 }
272 }
273 *isempty = LW_TRUE;
274 }
275 /* Any other non-collection with more than zero elements is not empty */
276 else
277 {
278 *isempty = LW_FALSE;
279 }
280 return lz;
281 }
282}
static size_t gserialized2_is_empty_recurse(const uint8_t *p, int *isempty)
#define LW_FALSE
Definition liblwgeom.h:108
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
Definition lwgeom.c:1087
#define POLYGONTYPE
Definition liblwgeom.h:118
#define LW_TRUE
Return types for functions with status returns.
Definition liblwgeom.h:107

References gserialized2_is_empty_recurse(), LW_FALSE, LW_TRUE, lwtype_is_collection(), and POLYGONTYPE.

Referenced by gserialized2_is_empty(), and gserialized2_is_empty_recurse().

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