PostGIS  2.5.0beta2dev-r@@SVN_REVISION@@

◆ test_lwgeom_calculate_gbox()

static void test_lwgeom_calculate_gbox ( void  )
static

Definition at line 201 of file cu_libgeom.c.

References LW_PARSER_CHECK_NONE, lwgeom_calculate_gbox_cartesian(), lwgeom_free(), lwgeom_from_hexwkb(), lwgeom_from_wkt(), GBOX::xmin, and GBOX::ymax.

Referenced by libgeom_suite_setup().

202 {
203  LWGEOM *g;
204  GBOX b;
205 
206  g = lwgeom_from_wkt("POINT(0 0)", LW_PARSER_CHECK_NONE);
208  CU_ASSERT_DOUBLE_EQUAL(b.xmin, 0.0, 0.0000001);
209  lwgeom_free(g);
210 
211  /* Inf = 0x7FF0000000000000 */
212  /* POINT(0 0) = 00 00000001 0000000000000000 0000000000000000 */
213  /* POINT(0 Inf) = 00 00000001 0000000000000000 7FF0000000000000 */
214  g = lwgeom_from_hexwkb("000000000100000000000000007FF0000000000000", LW_PARSER_CHECK_NONE);
216  CU_ASSERT_DOUBLE_EQUAL(b.xmin, 0.0, 0.0000001);
217  CU_ASSERT(isinf(b.ymax));
218  lwgeom_free(g);
219 
220  /* LINESTRING(0 0, 0 Inf) = 00 00000002 00000002 0000000000000000 7FF0000000000000 0000000000000000 0000000000000000 */
221  /* Inf should show up in bbox */
222  g = lwgeom_from_hexwkb("00000000020000000200000000000000007FF000000000000000000000000000000000000000000000", LW_PARSER_CHECK_NONE);
224  CU_ASSERT_DOUBLE_EQUAL(b.xmin, 0.0, 0.0000001);
225  CU_ASSERT(isinf(b.ymax));
226  lwgeom_free(g);
227 
228  /* Geometry with NaN 0101000020E8640000000000000000F8FF000000000000F8FF */
229  /* NaN should show up in bbox for "SRID=4326;POINT(0 NaN)" */
230  g = lwgeom_from_hexwkb("0101000020E86400000000000000000000000000000000F8FF", LW_PARSER_CHECK_NONE);
232  CU_ASSERT(isnan(b.ymax));
233  lwgeom_free(g);
234 
235 }
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
LWGEOM * lwgeom_from_wkt(const char *wkt, const char check)
Definition: lwin_wkt.c:904
#define LW_PARSER_CHECK_NONE
Definition: liblwgeom.h:2004
double xmin
Definition: liblwgeom.h:294
double ymax
Definition: liblwgeom.h:297
LWGEOM * lwgeom_from_hexwkb(const char *hexwkb, const char check)
Definition: lwin_wkb.c:789
int lwgeom_calculate_gbox_cartesian(const LWGEOM *lwgeom, GBOX *gbox)
Calculate the 2-4D bounding box of a geometry.
Definition: g_box.c:678
Here is the call graph for this function:
Here is the caller graph for this function: