@@ -15,22 +15,10 @@ class generic_reprojection_t : public reprojection
1515{
1616public:
1717 explicit generic_reprojection_t (int srs)
18- : m_target_srs(srs), m_context(proj_context_create())
19- {
20- assert (m_context);
21-
22- m_transformation = create_transformation (PROJ_LATLONG, srs);
23-
24- m_transformation.reset (proj_normalize_for_visualization (
25- m_context.get (), m_transformation.get ()));
26-
27- if (!m_transformation) {
28- throw std::runtime_error{
29- " Invalid projection '{}': {}" _format (srs, errormsg ())};
30- }
31-
32- m_transformation_tile = create_transformation (PROJ_SPHERE_MERC, srs);
33- }
18+ : m_target_srs(srs), m_context(proj_context_create()),
19+ m_transformation(create_transformation(PROJ_LATLONG, srs)),
20+ m_transformation_tile(create_transformation(srs, PROJ_SPHERE_MERC))
21+ {}
3422
3523 osmium::geom::Coordinates reproject (osmium::Location loc) const override
3624 {
@@ -71,6 +59,8 @@ class generic_reprojection_t : public reprojection
7159 std::unique_ptr<PJ, pj_deleter_t > create_transformation (int from,
7260 int to) const
7361 {
62+ assert (m_context);
63+
7464 std::string const source = " epsg:{}" _format (from);
7565 std::string const target = " epsg:{}" _format (to);
7666
@@ -82,7 +72,17 @@ class generic_reprojection_t : public reprojection
8272 " Invalid projection from {} to {}: {}" _format (from, to,
8373 errormsg ())};
8474 }
85- return trans;
75+
76+ std::unique_ptr<PJ, pj_deleter_t > trans_vis{
77+ proj_normalize_for_visualization (m_context.get (), trans.get ())};
78+
79+ if (!trans_vis) {
80+ throw std::runtime_error{
81+ " Invalid projection from {} to {}: {}" _format (from, to,
82+ errormsg ())};
83+ }
84+
85+ return trans_vis;
8686 }
8787
8888 osmium::geom::Coordinates transform (PJ *transformation,
@@ -92,8 +92,8 @@ class generic_reprojection_t : public reprojection
9292 PJ_COORD c_in;
9393 c_in.lpzt .z = 0.0 ;
9494 c_in.lpzt .t = HUGE_VAL;
95- c_in.lpzt .lam = osmium::geom::deg_to_rad ( coords.x ) ;
96- c_in.lpzt .phi = osmium::geom::deg_to_rad ( coords.y ) ;
95+ c_in.lpzt .lam = coords.x ;
96+ c_in.lpzt .phi = coords.y ;
9797
9898 auto const c_out = proj_trans (transformation, PJ_FWD, c_in);
9999
0 commit comments