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