PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ test_gserialized_peek_gbox_p_gets_correct_box()

void test_gserialized_peek_gbox_p_gets_correct_box ( void  )

Definition at line 1123 of file cu_libgeom.c.

References gbox_float_round(), gbox_init(), gbox_same(), gserialized_from_lwgeom(), gserialized_has_bbox(), gserialized_peek_gbox_p(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_calculate_gbox(), lwgeom_free(), lwgeom_from_wkt(), and test_gserialized_peek_gbox_p_fails_for_unsupported_cases().

Referenced by libgeom_suite_setup(), and test_gserialized_peek_gbox_p_no_box_when_empty().

1124 {
1125  uint32_t i;
1126 
1127  char *ewkt[] =
1128  {
1129  "POINT (2.2945672355 48.85822923236)",
1130  "POINTZ (2.2945672355 48.85822923236 15)",
1131  "POINTM (2.2945672355 48.85822923236 12)",
1132  "POINT ZM (2.2945672355 48.85822923236 12 2)",
1133  "MULTIPOINT ((-76.45402132523 44.225406213532))",
1134  "MULTIPOINT Z ((-76.45402132523 44.225406213532 112))",
1135  "MULTIPOINT ZM ((-76.45402132523 44.225406213532 112 44))",
1136  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532)",
1137  "LINESTRING Z (2.2945672355 48.85822923236 6, -76.45402132523 44.225406213532 8)",
1138  "LINESTRING ZM (2.2945672355 48.85822923236 3 2, -76.45402132523 44.225406213532 9 4)",
1139  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532))",
1140  "MULTILINESTRING Z ((2.2945672355 48.85822923236 4, -76.45402132523 44.225406213532 3))"
1141  };
1142 
1143  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1144  {
1145  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1146  GBOX box_from_peek;
1147  GBOX box_from_lwgeom;
1148  gbox_init(&box_from_peek);
1149  gbox_init(&box_from_lwgeom);
1150 
1151  GSERIALIZED* gser = gserialized_from_lwgeom(geom, NULL);
1152 
1153  CU_ASSERT_FALSE(gserialized_has_bbox(gser));
1154 
1155  lwgeom_calculate_gbox(geom, &box_from_lwgeom);
1156  gserialized_peek_gbox_p(gser, &box_from_peek);
1157 
1158  gbox_float_round(&box_from_lwgeom);
1159 
1160  CU_ASSERT_TRUE(gbox_same(&box_from_peek, &box_from_lwgeom));
1161 
1162  lwgeom_free(geom);
1163  lwfree(gser);
1164  }
1165 }
void lwfree(void *mem)
Definition: lwutil.c:244
static int gserialized_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: g_serialized.c:460
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
int gserialized_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: g_serialized.c:40
unsigned int uint32_t
Definition: uthash.h:78
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:746
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
void gbox_float_round(GBOX *gbox)
Round given GBOX to float boundaries.
Definition: g_box.c:712
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: g_box.c:47
GSERIALIZED * gserialized_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
int gbox_same(const GBOX *g1, const GBOX *g2)
Check if 2 given Gbox are the same.
Definition: g_box.c:171
Here is the call graph for this function:
Here is the caller graph for this function: