- #2026, improve performance of distance calculations
- #2057, Fixed linking issue for raster2psql to libpq
- #2077, Fixed incorrect values returning from ST_Hillshade()
+ - #2019, ST_FlipCoordinates does not update bbox
+
PostGIS 2.0.1
2012/06/22
static void do_lwgeom_flip_coordinates(char *in, char *out)
{
- LWGEOM *g,*h;
+ LWGEOM *g;
char * t;
+ double xmax, ymax;
+ int testbox;
g = lwgeom_from_wkt(in, LW_PARSER_CHECK_NONE);
- h = lwgeom_flip_coordinates(g);
+ lwgeom_add_bbox(g);
+
+ if ( testbox = (g->bbox != NULL) )
+ {
+ xmax = g->bbox->xmax;
+ ymax = g->bbox->ymax;
+ }
+
+ g = lwgeom_flip_coordinates(g);
+
+ if ( testbox )
+ {
+ CU_ASSERT_DOUBLE_EQUAL(g->bbox->xmax, ymax, 0.00001);
+ CU_ASSERT_DOUBLE_EQUAL(g->bbox->ymax, xmax, 0.00001);
+ }
t = lwgeom_to_wkt(g, WKT_EXTENDED, 8, NULL);
if (t == NULL) fprintf(stderr, "In:%s", in);
}
-
/*
** Used by test harness to register the tests in this file.
*/
PG_TEST(test_lwgeom_calculate_gbox),
PG_TEST(test_lwgeom_is_empty),
PG_TEST(test_lwgeom_same),
+ PG_TEST(test_lwgeom_flip_coordinates),
CU_TEST_INFO_NULL
};
CU_SuiteInfo libgeom_suite = {"libgeom", NULL, NULL, libgeom_tests};
LWPOLY *poly;
int i;
+ if ( (!in) || lwgeom_is_empty(in) )
+ return in;
+
LWDEBUGF(4, "lwgeom_flip_coordinates, got type: %s",
lwtype_name(in->type));
{
case POINTTYPE:
ptarray_flip_coordinates(lwgeom_as_lwpoint(in)->point);
- return in;
+ break;
case LINETYPE:
ptarray_flip_coordinates(lwgeom_as_lwline(in)->points);
- return in;
+ break;
case CIRCSTRINGTYPE:
ptarray_flip_coordinates(lwgeom_as_lwcircstring(in)->points);
- return in;
+ break;
case POLYGONTYPE:
poly = (LWPOLY *) in;
for (i=0; i<poly->nrings; i++)
+ {
ptarray_flip_coordinates(poly->rings[i]);
- return in;
+ }
+ break;
case TRIANGLETYPE:
ptarray_flip_coordinates(lwgeom_as_lwtriangle(in)->points);
- return in;
+ break;
case MULTIPOINTTYPE:
case MULTILINETYPE:
case TINTYPE:
col = (LWCOLLECTION *) in;
for (i=0; i<col->ngeoms; i++)
+ {
lwgeom_flip_coordinates(col->geoms[i]);
- return in;
+ }
+ break;
default:
lwerror("lwgeom_flip_coordinates: unsupported geometry type: %s",
lwtype_name(in->type));
+ return NULL;
}
- return NULL;
+
+ lwgeom_drop_bbox(in);
+ lwgeom_add_bbox(in);
+ return in;
}
void lwgeom_set_srid(LWGEOM *geom, int32_t srid)