static void mbc_test(LWGEOM* g) { LWBOUNDINGCIRCLE* result = lwgeom_calculate_mbc(g); CU_ASSERT_TRUE(result != NULL); LWPOINTITERATOR* it = lwpointiterator_create(g); POINT2D p; POINT4D p4; while (lwpointiterator_next(it, &p4)) { p.x = p4.x; p.y = p4.y; /* We need to store the distance in a variable before the assert so that * it is rounded from its 80-bit representation (on x86) down to 64 bits. * */ volatile double d = distance2d_pt_pt(result->center, &p); CU_ASSERT_TRUE(d <= result->radius); } lwboundingcircle_destroy(result); lwpointiterator_destroy(it); }
LWMPOINT* lwmpoint_from_lwgeom(const LWGEOM *g) { LWPOINTITERATOR* it = lwpointiterator_create(g); int has_z = lwgeom_has_z(g); int has_m = lwgeom_has_m(g); LWMPOINT* result = lwmpoint_construct_empty(g->srid, has_z, has_m); POINT4D p; while(lwpointiterator_next(it, &p)) { LWPOINT* lwp = lwpoint_make(g->srid, has_z, has_m, &p); lwmpoint_add_lwpoint(result, lwp); } lwpointiterator_destroy(it); return result; }