proj_transform test: also check that transform succeeded

This commit is contained in:
Mickey Rose 2018-07-18 19:31:12 +02:00
parent 69c317cd1f
commit f1d07d6718

View file

@ -25,20 +25,23 @@ SECTION("Test bounding box transforms - 4326 to 3857")
double maxy = 75.0; double maxy = 75.0;
mapnik::box2d<double> bbox(minx, miny, maxx, maxy); mapnik::box2d<double> bbox(minx, miny, maxx, maxy);
prj_trans.forward(bbox);
INFO(bbox.to_string()); INFO(bbox.to_string());
CHECKED_IF(prj_trans.forward(bbox))
{
CHECK(bbox.minx() == Approx(-5009377.085697311)); CHECK(bbox.minx() == Approx(-5009377.085697311));
CHECK(bbox.miny() == Approx(7361866.1130511891)); CHECK(bbox.miny() == Approx(7361866.1130511891));
CHECK(bbox.maxx() == Approx(-4452779.631730943)); CHECK(bbox.maxx() == Approx(-4452779.631730943));
CHECK(bbox.maxy() == Approx(12932243.1119920239)); CHECK(bbox.maxy() == Approx(12932243.1119920239));
}
prj_trans.backward(bbox); CHECKED_IF(prj_trans.backward(bbox))
{
CHECK(bbox.minx() == Approx(minx)); CHECK(bbox.minx() == Approx(minx));
CHECK(bbox.miny() == Approx(miny)); CHECK(bbox.miny() == Approx(miny));
CHECK(bbox.maxx() == Approx(maxx)); CHECK(bbox.maxx() == Approx(maxx));
CHECK(bbox.maxy() == Approx(maxy)); CHECK(bbox.maxy() == Approx(maxy));
}
} }
@ -145,22 +148,26 @@ SECTION("Test proj antimeridian bbox")
{ {
mapnik::box2d<double> ext(274000, 3087000, 3327000, 7173000); mapnik::box2d<double> ext(274000, 3087000, 3327000, 7173000);
prj_trans_fwd.forward(ext, PROJ_ENVELOPE_POINTS); CHECKED_IF(prj_trans_fwd.forward(ext, PROJ_ENVELOPE_POINTS))
{
CHECK(ext.minx() == Approx(better.minx())); CHECK(ext.minx() == Approx(better.minx()));
CHECK(ext.miny() == Approx(better.miny())); CHECK(ext.miny() == Approx(better.miny()));
CHECK(ext.maxx() == Approx(better.maxx())); CHECK(ext.maxx() == Approx(better.maxx()));
CHECK(ext.maxy() == Approx(better.maxy())); CHECK(ext.maxy() == Approx(better.maxy()));
} }
}
{ {
// check the same logic works for .backward() // check the same logic works for .backward()
mapnik::box2d<double> ext(274000, 3087000, 3327000, 7173000); mapnik::box2d<double> ext(274000, 3087000, 3327000, 7173000);
prj_trans_rev.backward(ext, PROJ_ENVELOPE_POINTS); CHECKED_IF(prj_trans_rev.backward(ext, PROJ_ENVELOPE_POINTS))
{
CHECK(ext.minx() == Approx(better.minx())); CHECK(ext.minx() == Approx(better.minx()));
CHECK(ext.miny() == Approx(better.miny())); CHECK(ext.miny() == Approx(better.miny()));
CHECK(ext.maxx() == Approx(better.maxx())); CHECK(ext.maxx() == Approx(better.maxx()));
CHECK(ext.maxy() == Approx(better.maxy())); CHECK(ext.maxy() == Approx(better.maxy()));
} }
}
// reference values taken from proj4 command line tool: // reference values taken from proj4 command line tool:
// //
@ -177,22 +184,26 @@ SECTION("Test proj antimeridian bbox")
{ {
// checks for not being snapped (ie. not antimeridian) // checks for not being snapped (ie. not antimeridian)
mapnik::box2d<double> ext(274000, 3087000, 276000, 7173000); mapnik::box2d<double> ext(274000, 3087000, 276000, 7173000);
prj_trans_fwd.forward(ext, PROJ_ENVELOPE_POINTS); CHECKED_IF(prj_trans_fwd.forward(ext, PROJ_ENVELOPE_POINTS))
{
CHECK(ext.minx() == Approx(normal.minx())); CHECK(ext.minx() == Approx(normal.minx()));
CHECK(ext.miny() == Approx(normal.miny())); CHECK(ext.miny() == Approx(normal.miny()));
CHECK(ext.maxx() == Approx(normal.maxx())); CHECK(ext.maxx() == Approx(normal.maxx()));
CHECK(ext.maxy() == Approx(normal.maxy())); CHECK(ext.maxy() == Approx(normal.maxy()));
} }
}
{ {
// check the same logic works for .backward() // check the same logic works for .backward()
mapnik::box2d<double> ext(274000, 3087000, 276000, 7173000); mapnik::box2d<double> ext(274000, 3087000, 276000, 7173000);
prj_trans_rev.backward(ext, PROJ_ENVELOPE_POINTS); CHECKED_IF(prj_trans_rev.backward(ext, PROJ_ENVELOPE_POINTS))
{
CHECK(ext.minx() == Approx(normal.minx())); CHECK(ext.minx() == Approx(normal.minx()));
CHECK(ext.miny() == Approx(normal.miny())); CHECK(ext.miny() == Approx(normal.miny()));
CHECK(ext.maxx() == Approx(normal.maxx())); CHECK(ext.maxx() == Approx(normal.maxx()));
CHECK(ext.maxy() == Approx(normal.maxy())); CHECK(ext.maxy() == Approx(normal.maxy()));
} }
} }
}
} }