PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ test_gserialized1_peek_gbox_p_gets_correct_box()

static void test_gserialized1_peek_gbox_p_gets_correct_box ( void  )
static

Definition at line 1117 of file cu_gserialized1.c.

1118 {
1119  uint32_t i;
1120 
1121  char *ewkt[] =
1122  {
1123  "POINT (2.2945672355 48.85822923236)",
1124  "POINTZ (2.2945672355 48.85822923236 15)",
1125  "POINTM (2.2945672355 48.85822923236 12)",
1126  "POINT ZM (2.2945672355 48.85822923236 12 2)",
1127  "MULTIPOINT ((-76.45402132523 44.225406213532))",
1128  "MULTIPOINT Z ((-76.45402132523 44.225406213532 112))",
1129  "MULTIPOINT ZM ((-76.45402132523 44.225406213532 112 44))",
1130  "LINESTRING (2.2945672355 48.85822923236, -76.45402132523 44.225406213532)",
1131  "LINESTRING Z (2.2945672355 48.85822923236 6, -76.45402132523 44.225406213532 8)",
1132  "LINESTRING ZM (2.2945672355 48.85822923236 3 2, -76.45402132523 44.225406213532 9 4)",
1133  "MULTILINESTRING ((2.2945672355 48.85822923236, -76.45402132523 44.225406213532))",
1134  "MULTILINESTRING Z ((2.2945672355 48.85822923236 4, -76.45402132523 44.225406213532 3))"
1135  };
1136 
1137  for ( i = 0; i < (sizeof ewkt/sizeof(char*)); i++ )
1138  {
1139  LWGEOM* geom = lwgeom_from_wkt(ewkt[i], LW_PARSER_CHECK_NONE);
1140  GBOX box_from_peek;
1141  GBOX box_from_lwgeom;
1142  gbox_init(&box_from_peek);
1143  gbox_init(&box_from_lwgeom);
1144 
1145  GSERIALIZED* gser = gserialized1_from_lwgeom(geom, NULL);
1146 
1147  CU_ASSERT_FALSE(gserialized1_has_bbox(gser));
1148 
1149  lwgeom_calculate_gbox(geom, &box_from_lwgeom);
1150  gserialized1_peek_gbox_p(gser, &box_from_peek);
1151 
1152  gbox_float_round(&box_from_lwgeom);
1153 
1154  CU_ASSERT_TRUE(gbox_same(&box_from_peek, &box_from_lwgeom));
1155 
1156  lwgeom_free(geom);
1157  lwfree(gser);
1158  }
1159 }
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:774
void gbox_init(GBOX *gbox)
Zero out all the entries in the GBOX.
Definition: gbox.c:40
int gserialized1_peek_gbox_p(const GSERIALIZED *g, GBOX *gbox)
Definition: gserialized1.c:298
int gserialized1_has_bbox(const GSERIALIZED *gser)
Check if a GSERIALIZED has a bounding box without deserializing first.
Definition: gserialized1.c:89
GSERIALIZED * gserialized1_from_lwgeom(LWGEOM *geom, size_t *size)
Allocate a new GSERIALIZED from an LWGEOM.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1138
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2060
void lwfree(void *mem)
Definition: lwutil.c:242
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:737
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:905

References gbox_float_round(), gbox_init(), gbox_same(), gserialized1_from_lwgeom(), gserialized1_has_bbox(), gserialized1_peek_gbox_p(), LW_PARSER_CHECK_NONE, lwfree(), lwgeom_calculate_gbox(), lwgeom_free(), and lwgeom_from_wkt().

Referenced by gserialized1_suite_setup().

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