[test][srs] Fix memory leak in projection_selftest when TEST_WITH_PROJ4 is defined.

This commit is contained in:
Adam Wulkiewicz 2018-03-07 11:26:16 +01:00
parent 5ac66e34ca
commit d9670e4da0

View File

@ -50,14 +50,17 @@ void test_projection(std::string const& id, std::string const& parameters,
<< bg::wkt(fwd_expected[i]) << "}"); << bg::wkt(fwd_expected[i]) << "}");
#ifdef TEST_WITH_PROJ4 #ifdef TEST_WITH_PROJ4
projUV pj_ll = {bg::get_as_radian<0>(fwd_in[i]), bg::get_as_radian<1>(fwd_in[i])}; if (pj_par)
projUV pj_xy = pj_fwd(pj_ll, pj_par); {
bool same_as_pj = bg::get<0>(fwd_out) == pj_xy.u projUV pj_ll = {bg::get_as_radian<0>(fwd_in[i]), bg::get_as_radian<1>(fwd_in[i])};
&& bg::get<1>(fwd_out) == pj_xy.v; projUV pj_xy = pj_fwd(pj_ll, pj_par);
BOOST_CHECK_MESSAGE((same_as_pj), bool same_as_pj = bg::get<0>(fwd_out) == pj_xy.u
std::setprecision(16) << "Result of " << id << " forward projection {" && bg::get<1>(fwd_out) == pj_xy.v;
<< bg::wkt(fwd_out) << "} different than Proj4 {POINT(" BOOST_CHECK_MESSAGE((same_as_pj),
<< pj_xy.u << " " << pj_xy.v << ")}"); std::setprecision(16) << "Result of " << id << " forward projection {"
<< bg::wkt(fwd_out) << "} different than Proj4 {POINT("
<< pj_xy.u << " " << pj_xy.v << ")}");
}
#endif #endif
} }
@ -77,19 +80,29 @@ void test_projection(std::string const& id, std::string const& parameters,
<< bg::wkt(inv_expected[i]) << "}"); << bg::wkt(inv_expected[i]) << "}");
#ifdef TEST_WITH_PROJ4 #ifdef TEST_WITH_PROJ4
projUV pj_xy = {bg::get<0>(inv_in[i]), bg::get<1>(inv_in[i])}; if (pj_par)
projUV pj_ll = pj_inv(pj_xy, pj_par); {
pj_ll.u *= RAD_TO_DEG; projUV pj_xy = {bg::get<0>(inv_in[i]), bg::get<1>(inv_in[i])};
pj_ll.v *= RAD_TO_DEG; projUV pj_ll = pj_inv(pj_xy, pj_par);
bool same_as_pj = bg::get<0>(inv_out) == pj_ll.u pj_ll.u *= RAD_TO_DEG;
&& bg::get<1>(inv_out) == pj_ll.v; pj_ll.v *= RAD_TO_DEG;
BOOST_CHECK_MESSAGE((same_as_pj), bool same_as_pj = bg::get<0>(inv_out) == pj_ll.u
std::setprecision(16) << "Result of " << id << " inverse projection {" && bg::get<1>(inv_out) == pj_ll.v;
<< bg::wkt(inv_out) << "} different than Proj4 {POINT(" BOOST_CHECK_MESSAGE((same_as_pj),
<< pj_ll.u << " " << pj_ll.v << ")}"); std::setprecision(16) << "Result of " << id << " inverse projection {"
<< bg::wkt(inv_out) << "} different than Proj4 {POINT("
<< pj_ll.u << " " << pj_ll.v << ")}");
}
#endif #endif
} }
} }
#ifdef TEST_WITH_PROJ4
if (pj_par)
{
pj_free(pj_par);
}
#endif
} }
void test_projections(const projection_case * cases, std::size_t n) void test_projections(const projection_case * cases, std::size_t n)