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

◆ test_gserialized2_peek_gbox_p_gets_correct_box()

static void test_gserialized2_peek_gbox_p_gets_correct_box ( void  )
static

Definition at line 369 of file cu_gserialized2.c.

370{
371 uint32_t i;
372
373 char *ewkt[] =
374 {
375 "POINT (2.2945672355 48.85822923236)",
376 "POINTZ (2.2945672355 48.85822923236 15)",
377 "POINTM (2.2945672355 48.85822923236 12)",
378 "POINT ZM (2.2945672355 48.85822923236 12 2)",
379 "MULTIPOINT ((-76.45402132523 44.225406213532))",
380 "MULTIPOINT Z ((-76.45402132523 44.225406213532 112))",
381 "MULTIPOINT ZM ((-76.45402132523 44.225406213532 112 44))",
382 "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532)",
383 "LINESTRING Z (2.2945672355 48.85822923236 6, -76.45402132523 44.225406213532 8)",
384 "LINESTRING ZM (2.2945672355 48.85822923236 3 2, -76.45402132523 44.225406213532 9 4)",
385 "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532))",
386 "MULTILINESTRING Z ((2.2945672355 48.85822923236 4, -76.45402132523 44.225406213532 3))"
387 };
388
389 for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
390 {
392 GBOX box_from_peek;
393 GBOX box_from_lwgeom;
394 gbox_init(&box_from_peek);
395 gbox_init(&box_from_lwgeom);
396
397 GSERIALIZED* gser = gserialized2_from_lwgeom(geom, NULL);
398
399 CU_ASSERT_FALSE(gserialized2_has_bbox(gser));
400
401 lwgeom_calculate_gbox(geom, &box_from_lwgeom);
402 gserialized2_peek_gbox_p(gser, &box_from_peek);
403
404 gbox_float_round(&box_from_lwgeom);
405
406 CU_ASSERT_TRUE(gbox_same(&box_from_peek, &box_from_lwgeom));
407
408 lwgeom_free(geom);
409 lwfree(gser);
410 }
411}
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition gbox.c:164
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition gbox.c:786
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition gbox.c:40
GSERIALIZED * gserialized2_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
int gserialized2_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
int gserialized2_has_bbox(const GSERIALIZED *g)
Check if a GSERIALIZED has a bounding box without deserializing first.
void lwgeom_free(LWGEOM *geom)
Definition lwgeom.c:1246
#define LW_PARSER_CHECK_NONE
Definition liblwgeom.h:2149
void lwfree(void *mem)
Definition lwutil.c:248
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
Definition lwgeom.c:783
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition lwin_wkt.c:940

References gbox_float_round(), gbox_init(), gbox_same(), gserialized2_from_lwgeom(), gserialized2_has_bbox(), gserialized2_peek_gbox_p(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_calculate_gbox(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by gserialized2_suite_setup().

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