update boost
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -33,16 +33,28 @@ namespace detail
|
||||
\tparam P parameters type
|
||||
*/
|
||||
template <typename CT, typename P>
|
||||
class base_v
|
||||
class dynamic_wrapper_b
|
||||
{
|
||||
public :
|
||||
dynamic_wrapper_b(P const& par)
|
||||
: m_par(par)
|
||||
{}
|
||||
|
||||
virtual ~dynamic_wrapper_b() {}
|
||||
|
||||
/// Forward projection using lon / lat and x / y separately
|
||||
virtual void fwd(P const& par, CT const& lp_lon, CT const& lp_lat, CT& xy_x, CT& xy_y) const = 0;
|
||||
|
||||
/// Inverse projection using x / y and lon / lat
|
||||
virtual void inv(P const& par, CT const& xy_x, CT const& xy_y, CT& lp_lon, CT& lp_lat) const = 0;
|
||||
|
||||
/// Forward projection, from Latitude-Longitude to Cartesian
|
||||
template <typename LL, typename XY>
|
||||
inline bool forward(LL const& lp, XY& xy) const
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_fwd(*this, this->params(), lp, xy);
|
||||
pj_fwd(*this, m_par, lp, xy);
|
||||
return true;
|
||||
}
|
||||
catch (...)
|
||||
@@ -57,7 +69,7 @@ public :
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_inv(*this, this->params(), xy, lp);
|
||||
pj_inv(*this, m_par, xy, lp);
|
||||
return true;
|
||||
}
|
||||
catch (projection_not_invertible_exception &)
|
||||
@@ -70,87 +82,74 @@ public :
|
||||
}
|
||||
}
|
||||
|
||||
/// Forward projection using lon / lat and x / y separately
|
||||
virtual void fwd(CT const& lp_lon, CT const& lp_lat, CT& xy_x, CT& xy_y) const = 0;
|
||||
|
||||
/// Inverse projection using x / y and lon / lat
|
||||
virtual void inv(CT const& xy_x, CT const& xy_y, CT& lp_lon, CT& lp_lat) const = 0;
|
||||
|
||||
/// Returns name of projection
|
||||
virtual std::string name() const = 0;
|
||||
std::string name() const { return m_par.id.name; }
|
||||
|
||||
/// Returns parameters of projection
|
||||
virtual P const& params() const = 0;
|
||||
P const& params() const { return m_par; }
|
||||
|
||||
/// Returns mutable parameters of projection
|
||||
virtual P& mutable_params() = 0;
|
||||
|
||||
virtual ~base_v() {}
|
||||
};
|
||||
|
||||
// Base-virtual-forward
|
||||
template <typename Prj, typename CT, typename P>
|
||||
class base_v_f : public base_v<CT, P>
|
||||
{
|
||||
public:
|
||||
explicit base_v_f(P const& p)
|
||||
: m_proj(p)
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
base_v_f(P1 const& p1, P2 const& p2)
|
||||
: m_proj(p1, p2)
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2, typename P3>
|
||||
base_v_f(P1 const& p1, P2 const& p2, P3 const& p3)
|
||||
: m_proj(p1, p2, p3)
|
||||
{}
|
||||
|
||||
virtual void fwd(CT const& lp_lon, CT const& lp_lat, CT& xy_x, CT& xy_y) const
|
||||
{
|
||||
m_proj.fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
}
|
||||
|
||||
virtual void inv(CT const& , CT const& , CT& , CT& ) const
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(projection_not_invertible_exception(params().id.name));
|
||||
}
|
||||
|
||||
virtual std::string name() const { return m_proj.name(); }
|
||||
|
||||
virtual P const& params() const { return m_proj.params(); }
|
||||
|
||||
virtual P& mutable_params() { return m_proj.mutable_params(); }
|
||||
P& mutable_params() { return m_par; }
|
||||
|
||||
protected:
|
||||
Prj m_proj;
|
||||
P m_par;
|
||||
};
|
||||
|
||||
// Base-virtual-forward/inverse
|
||||
// Forward
|
||||
template <typename Prj, typename CT, typename P>
|
||||
class base_v_fi : public base_v_f<Prj, CT, P>
|
||||
class dynamic_wrapper_f
|
||||
: public dynamic_wrapper_b<CT, P>
|
||||
, protected Prj
|
||||
{
|
||||
typedef base_v_f<Prj, CT, P> base_t;
|
||||
typedef dynamic_wrapper_b<CT, P> base_t;
|
||||
|
||||
public:
|
||||
explicit base_v_fi(P const& p)
|
||||
: base_t(p)
|
||||
template <typename Params>
|
||||
dynamic_wrapper_f(Params const& params, P const& par)
|
||||
: base_t(par)
|
||||
, Prj(params, this->m_par) // prj can modify parameters
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
base_v_fi(P1 const& p1, P2 const& p2)
|
||||
: base_t(p1, p2)
|
||||
template <typename Params, typename P3>
|
||||
dynamic_wrapper_f(Params const& params, P const& par, P3 const& p3)
|
||||
: base_t(par)
|
||||
, Prj(params, this->m_par, p3) // prj can modify parameters
|
||||
{}
|
||||
|
||||
template <typename P1, typename P2, typename P3>
|
||||
base_v_fi(P1 const& p1, P2 const& p2, P3 const& p3)
|
||||
: base_t(p1, p2, p3)
|
||||
{}
|
||||
|
||||
virtual void inv(CT const& xy_x, CT const& xy_y, CT& lp_lon, CT& lp_lat) const
|
||||
virtual void fwd(P const& par, CT const& lp_lon, CT const& lp_lat, CT& xy_x, CT& xy_y) const
|
||||
{
|
||||
this->m_proj.inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
prj().fwd(par, lp_lon, lp_lat, xy_x, xy_y);
|
||||
}
|
||||
|
||||
virtual void inv(P const& , CT const& , CT const& , CT& , CT& ) const
|
||||
{
|
||||
BOOST_THROW_EXCEPTION(projection_not_invertible_exception(this->name()));
|
||||
}
|
||||
|
||||
protected:
|
||||
Prj const& prj() const { return *this; }
|
||||
};
|
||||
|
||||
// Forward/inverse
|
||||
template <typename Prj, typename CT, typename P>
|
||||
class dynamic_wrapper_fi : public dynamic_wrapper_f<Prj, CT, P>
|
||||
{
|
||||
typedef dynamic_wrapper_f<Prj, CT, P> base_t;
|
||||
|
||||
public:
|
||||
template <typename Params>
|
||||
dynamic_wrapper_fi(Params const& params, P const& par)
|
||||
: base_t(params, par)
|
||||
{}
|
||||
|
||||
template <typename Params, typename P3>
|
||||
dynamic_wrapper_fi(Params const& params, P const& par, P3 const& p3)
|
||||
: base_t(params, par, p3)
|
||||
{}
|
||||
|
||||
virtual void inv(P const& par, CT const& xy_x, CT const& xy_y, CT& lp_lon, CT& lp_lat) const
|
||||
{
|
||||
this->prj().inv(par, xy_x, xy_y, lp_lon, lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -21,13 +21,13 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/impl/pj_fwd.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/pj_inv.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
@@ -40,78 +40,110 @@ namespace detail
|
||||
template <typename Prj, typename CSTag, typename SP, typename CT, typename P>
|
||||
struct static_projection_type
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG((false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_PROJECTION_OR_CSTAG,
|
||||
(Prj, CSTag));
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"Not implemented for this projection or coordinate system.",
|
||||
Prj, CSTag, SP, CT, P);
|
||||
};
|
||||
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION(PROJ, P_SPHERE, P_SPHEROID) \
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_F(PROJ, P_SPHXXX) \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef P_SPHERE<CT, P> type; \
|
||||
typedef projections::detail::static_wrapper_f<P_SPHXXX<CT, P>, P> type; \
|
||||
}; \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef P_SPHEROID<CT, P> type; \
|
||||
typedef projections::detail::static_wrapper_f<P_SPHXXX<CT, P>, P> type; \
|
||||
}; \
|
||||
|
||||
// Base-template-forward
|
||||
template <typename Prj, typename CT, typename P>
|
||||
struct base_t_f
|
||||
{
|
||||
public:
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI(PROJ, P_SPHXXX) \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef projections::detail::static_wrapper_fi<P_SPHXXX<CT, P>, P> type; \
|
||||
}; \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef projections::detail::static_wrapper_fi<P_SPHXXX<CT, P>, P> type; \
|
||||
}; \
|
||||
|
||||
inline base_t_f(Prj const& prj, P const& params)
|
||||
: m_par(params), m_prj(prj)
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_STATIC_PROJECTION_FI2(PROJ, P_SPHERE, P_SPHEROID) \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_sphere_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef projections::detail::static_wrapper_fi<P_SPHERE<CT, P>, P> type; \
|
||||
}; \
|
||||
template <typename SP, typename CT, typename P> \
|
||||
struct static_projection_type<PROJ, srs_spheroid_tag, SP, CT, P> \
|
||||
{ \
|
||||
typedef projections::detail::static_wrapper_fi<P_SPHEROID<CT, P>, P> type; \
|
||||
}; \
|
||||
|
||||
template <typename P>
|
||||
struct static_wrapper_b
|
||||
{
|
||||
inline explicit static_wrapper_b(P const& par)
|
||||
: m_par(par)
|
||||
{}
|
||||
|
||||
inline P const& params() const { return m_par; }
|
||||
std::string name() const { return m_par.id.name; }
|
||||
|
||||
inline P& mutable_params() { return m_par; }
|
||||
P const& params() const { return m_par; }
|
||||
|
||||
P& mutable_params() { return m_par; }
|
||||
|
||||
protected:
|
||||
P m_par;
|
||||
};
|
||||
|
||||
// Forward
|
||||
template <typename Prj, typename P>
|
||||
struct static_wrapper_f
|
||||
: public static_wrapper_b<P>
|
||||
, public Prj
|
||||
{
|
||||
public:
|
||||
template <typename Params>
|
||||
inline static_wrapper_f(Params const& params, P const& par)
|
||||
: static_wrapper_b<P>(par)
|
||||
, Prj(params, this->m_par) // prj can modify parameters
|
||||
{}
|
||||
|
||||
template <typename LL, typename XY>
|
||||
inline bool forward(LL const& lp, XY& xy) const
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_fwd(m_prj, m_par, lp, xy);
|
||||
pj_fwd(*this, this->m_par, lp, xy);
|
||||
return true;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename XY, typename LL>
|
||||
inline bool inverse(XY const& , LL& ) const
|
||||
inline bool inverse(XY const&, LL&) const
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG((false),
|
||||
PROJECTION_IS_NOT_INVERTABLE,
|
||||
(Prj));
|
||||
BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
|
||||
"This projection is not invertable.",
|
||||
Prj);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline std::string name() const
|
||||
{
|
||||
return this->m_par.id.name;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
P m_par;
|
||||
const Prj& m_prj;
|
||||
};
|
||||
|
||||
// Base-template-forward/inverse
|
||||
template <typename Prj, typename CT, typename P>
|
||||
struct base_t_fi : public base_t_f<Prj, CT, P>
|
||||
// Forward/inverse
|
||||
template <typename Prj, typename P>
|
||||
struct static_wrapper_fi
|
||||
: public static_wrapper_f<Prj, P>
|
||||
{
|
||||
public :
|
||||
inline base_t_fi(Prj const& prj, P const& params)
|
||||
: base_t_f<Prj, CT, P>(prj, params)
|
||||
public:
|
||||
template <typename Params>
|
||||
inline static_wrapper_fi(Params const& params, P const& par)
|
||||
: static_wrapper_f<Prj, P>(params, par)
|
||||
{}
|
||||
|
||||
template <typename XY, typename LL>
|
||||
@@ -119,10 +151,10 @@ public :
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_inv(this->m_prj, this->m_par, xy, lp);
|
||||
pj_inv(*this, this->m_par, xy, lp);
|
||||
return true;
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
@@ -39,9 +40,10 @@
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/core/config.hpp>
|
||||
@@ -123,16 +125,10 @@ struct dms_parser
|
||||
bool has_dms[3];
|
||||
|
||||
dms_value()
|
||||
#ifdef BOOST_GEOMETRY_CXX11_ARRAY_UNIFIED_INITIALIZATION
|
||||
: dms{0, 0, 0}
|
||||
, has_dms{false, false, false}
|
||||
{}
|
||||
#else
|
||||
{
|
||||
std::fill(dms, dms + 3, T(0));
|
||||
std::fill(has_dms, has_dms + 3, false);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017, 2018, 2019.
|
||||
// Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/geometry/srs/projections/factory_key.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/base_dynamic.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
@@ -32,7 +31,7 @@ template <typename Params, typename CT, typename Parameters>
|
||||
struct factory_entry
|
||||
{
|
||||
virtual ~factory_entry() {}
|
||||
virtual base_v<CT, Parameters>* create_new(Params const& , Parameters const& ) const = 0;
|
||||
virtual dynamic_wrapper_b<CT, Parameters>* create_new(Params const& , Parameters const& ) const = 0;
|
||||
};
|
||||
|
||||
// Macros for entries definition
|
||||
@@ -41,22 +40,22 @@ struct factory_entry
|
||||
template <typename Params, typename T, typename Parameters> \
|
||||
struct ENTRY : projections::detail::factory_entry<Params, T, Parameters> \
|
||||
{ \
|
||||
projections::detail::base_v<T, Parameters>* create_new(Params const& params, \
|
||||
Parameters const& parameters) const
|
||||
projections::detail::dynamic_wrapper_b<T, Parameters>* create_new(Params const& params, \
|
||||
Parameters const& parameters) const
|
||||
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END };
|
||||
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_F(ENTRY, PROJ) \
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ENTRY) \
|
||||
{ \
|
||||
return new projections::detail::base_v_f<PROJ<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
return new projections::detail::dynamic_wrapper_f<PROJ<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
} \
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
|
||||
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_FI(ENTRY, PROJ) \
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ENTRY) \
|
||||
{ \
|
||||
return new projections::detail::base_v_fi<PROJ<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
return new projections::detail::dynamic_wrapper_fi<PROJ<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
} \
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
|
||||
|
||||
@@ -64,9 +63,9 @@ BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_BEGIN(ENTRY) \
|
||||
{ \
|
||||
if (parameters.es != 0.0) \
|
||||
return new projections::detail::base_v_fi<PROJ_E<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
return new projections::detail::dynamic_wrapper_fi<PROJ_E<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
else \
|
||||
return new projections::detail::base_v_fi<PROJ_S<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
return new projections::detail::dynamic_wrapper_fi<PROJ_S<T, Parameters>, T, Parameters>(params, parameters); \
|
||||
} \
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_ENTRY_END
|
||||
|
||||
@@ -76,8 +75,8 @@ template <typename Params, typename T, typename Parameters> \
|
||||
inline void FUN_NAME(projections::detail::factory<Params, T, Parameters>& factory)
|
||||
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DETAIL_FACTORY_INIT_ENTRY(PROJ_NAME, ENTRY) \
|
||||
factory.add_to_factory(projections::detail::factory_key(#PROJ_NAME, \
|
||||
srs::dpar::proj_##PROJ_NAME), \
|
||||
factory.add_to_factory(#PROJ_NAME, \
|
||||
srs::dpar::proj_##PROJ_NAME, \
|
||||
new ENTRY<Params, T, Parameters>);
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* ERROR HANDLING
|
||||
*
|
||||
* This component checks parameters for valid values. If an invalid value
|
||||
* is found, the error code is combined with the current error code using
|
||||
* is found, the error code is combined with the current error code using
|
||||
* the bitwise or. This combining allows multiple error codes to be
|
||||
* returned. The possible error codes are:
|
||||
*
|
||||
@@ -47,13 +47,13 @@
|
||||
* GEOCENTRIC is intended for reuse by any application that performs
|
||||
* coordinate conversions between geodetic coordinates and geocentric
|
||||
* coordinates.
|
||||
*
|
||||
*
|
||||
*
|
||||
* REFERENCES
|
||||
*
|
||||
*
|
||||
* An Improved Algorithm for Geocentric to Geodetic Coordinate Conversion,
|
||||
* Ralph Toms, February 1996 UCRL-JC-123138.
|
||||
*
|
||||
*
|
||||
* Further information on GEOCENTRIC can be found in the Reuse Manual.
|
||||
*
|
||||
* GEOCENTRIC originated from : U.S. Army Topographic Engineering Center
|
||||
@@ -135,11 +135,11 @@ inline T AD_C()
|
||||
|
||||
/***************************************************************************/
|
||||
/*
|
||||
* FUNCTIONS
|
||||
* FUNCTIONS
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
inline long pj_Set_Geocentric_Parameters (GeocentricInfo<T> & gi, T const& a, T const& b)
|
||||
inline long pj_Set_Geocentric_Parameters (GeocentricInfo<T> & gi, T const& a, T const& b)
|
||||
|
||||
{ /* BEGIN Set_Geocentric_Parameters */
|
||||
/*
|
||||
@@ -172,7 +172,7 @@ inline long pj_Set_Geocentric_Parameters (GeocentricInfo<T> & gi, T const& a, T
|
||||
|
||||
template <typename T>
|
||||
inline void pj_Get_Geocentric_Parameters (GeocentricInfo<T> const& gi,
|
||||
T & a,
|
||||
T & a,
|
||||
T & b)
|
||||
{ /* BEGIN Get_Geocentric_Parameters */
|
||||
/*
|
||||
@@ -246,7 +246,7 @@ inline long pj_Convert_Geodetic_To_Geocentric (GeocentricInfo<T> const& gi,
|
||||
|
||||
/*
|
||||
* The function Convert_Geocentric_To_Geodetic converts geocentric
|
||||
* coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
|
||||
* coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
|
||||
* and height), according to the current ellipsoid parameters.
|
||||
*
|
||||
* X : Geocentric X coordinate, in meters. (input)
|
||||
@@ -326,7 +326,7 @@ inline void pj_Convert_Geocentric_To_Geodetic (GeocentricInfo<T> const& gi,
|
||||
Latitude = PI_OVER_2;
|
||||
Height = -Geocent_b;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
W2 = X*X + Y*Y;
|
||||
|
||||
@@ -329,14 +329,16 @@ inline bool load_grid(StreamPolicy const& stream_policy, pj_gi_load & gi)
|
||||
/* This is the real workhorse, given a gridlist. */
|
||||
/************************************************************************/
|
||||
|
||||
template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
|
||||
// Generic stream policy and standard grids
|
||||
template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range, typename Grids>
|
||||
inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
Range & range,
|
||||
srs::grids & grids,
|
||||
std::vector<std::size_t> const& gridindexes)
|
||||
Grids & grids,
|
||||
std::vector<std::size_t> const& gridindexes,
|
||||
grids_tag)
|
||||
{
|
||||
typedef typename boost::range_size<Range>::type size_type;
|
||||
|
||||
|
||||
// If the grids are empty the indexes are as well
|
||||
if (gridindexes.empty())
|
||||
{
|
||||
@@ -354,7 +356,7 @@ inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
|
||||
CalcT in_lon = geometry::get_as_radian<0>(point);
|
||||
CalcT in_lat = geometry::get_as_radian<1>(point);
|
||||
|
||||
|
||||
pj_gi * gip = find_grid(in_lon, in_lat, grids.gridinfo, gridindexes);
|
||||
|
||||
if ( gip != NULL )
|
||||
@@ -367,7 +369,7 @@ inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
CalcT out_lat = HUGE_VAL;
|
||||
|
||||
nad_cvt<Inverse>(in_lon, in_lat, out_lon, out_lat, *gip);
|
||||
|
||||
|
||||
// TODO: check differently
|
||||
if ( out_lon != HUGE_VAL )
|
||||
{
|
||||
@@ -381,6 +383,103 @@ inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Generic stream policy and shared grids
|
||||
template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range, typename SharedGrids>
|
||||
inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
Range & range,
|
||||
SharedGrids & grids,
|
||||
std::vector<std::size_t> const& gridindexes,
|
||||
shared_grids_tag)
|
||||
{
|
||||
typedef typename boost::range_size<Range>::type size_type;
|
||||
|
||||
// If the grids are empty the indexes are as well
|
||||
if (gridindexes.empty())
|
||||
{
|
||||
//pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID);
|
||||
//return PJD_ERR_FAILED_TO_LOAD_GRID;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_type point_count = boost::size(range);
|
||||
|
||||
// local storage
|
||||
pj_gi_load local_gi;
|
||||
|
||||
for (size_type i = 0 ; i < point_count ; )
|
||||
{
|
||||
bool load_needed = false;
|
||||
|
||||
CalcT in_lon = 0;
|
||||
CalcT in_lat = 0;
|
||||
|
||||
{
|
||||
typename SharedGrids::read_locked lck_grids(grids);
|
||||
|
||||
for ( ; i < point_count ; ++i )
|
||||
{
|
||||
typename boost::range_reference<Range>::type
|
||||
point = range::at(range, i);
|
||||
|
||||
in_lon = geometry::get_as_radian<0>(point);
|
||||
in_lat = geometry::get_as_radian<1>(point);
|
||||
|
||||
pj_gi * gip = find_grid(in_lon, in_lat, lck_grids.gridinfo, gridindexes);
|
||||
|
||||
if (gip == NULL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (! gip->ct.cvs.empty())
|
||||
{
|
||||
// TODO: use set_invalid_point() or similar mechanism
|
||||
CalcT out_lon = HUGE_VAL;
|
||||
CalcT out_lat = HUGE_VAL;
|
||||
|
||||
nad_cvt<Inverse>(in_lon, in_lat, out_lon, out_lat, *gip);
|
||||
|
||||
// TODO: check differently
|
||||
if (out_lon != HUGE_VAL)
|
||||
{
|
||||
geometry::set_from_radian<0>(point, out_lon);
|
||||
geometry::set_from_radian<1>(point, out_lat);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loading is needed
|
||||
local_gi = *gip;
|
||||
load_needed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (load_needed)
|
||||
{
|
||||
if (load_grid(stream_policy, local_gi))
|
||||
{
|
||||
typename SharedGrids::write_locked lck_grids(grids);
|
||||
|
||||
// check again in case other thread already loaded the grid.
|
||||
pj_gi * gip = find_grid(in_lon, in_lat, lck_grids.gridinfo, gridindexes);
|
||||
|
||||
if (gip != NULL && gip->ct.cvs.empty())
|
||||
{
|
||||
// swap loaded local storage with empty grid
|
||||
local_gi.swap(*gip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_apply_gridshift_2() */
|
||||
@@ -392,7 +491,7 @@ inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
/************************************************************************/
|
||||
|
||||
template <bool Inverse, typename Par, typename Range, typename ProjGrids>
|
||||
inline bool pj_apply_gridshift_2(Par const& /*defn*/, Range & range, ProjGrids const& grids)
|
||||
inline bool pj_apply_gridshift_2(Par const& /*defn*/, Range & range, ProjGrids const& proj_grids)
|
||||
{
|
||||
/*if( defn->catalog_name != NULL )
|
||||
return pj_gc_apply_gridshift( defn, inverse, point_count, point_offset,
|
||||
@@ -404,19 +503,18 @@ inline bool pj_apply_gridshift_2(Par const& /*defn*/, Range & range, ProjGrids c
|
||||
grids.storage_ptr->grids,
|
||||
gridindexes);*/
|
||||
|
||||
BOOST_GEOMETRY_ASSERT(grids.storage_ptr != NULL);
|
||||
|
||||
// At this point the grids should be initialized
|
||||
if (grids.hindexes.empty())
|
||||
if (proj_grids.hindexes.empty())
|
||||
return false;
|
||||
|
||||
return pj_apply_gridshift_3
|
||||
<
|
||||
Inverse, typename Par::type
|
||||
>(grids.storage_ptr->stream_policy,
|
||||
>(proj_grids.grids_storage().stream_policy,
|
||||
range,
|
||||
grids.storage_ptr->hgrids,
|
||||
grids.hindexes);
|
||||
proj_grids.grids_storage().hgrids,
|
||||
proj_grids.hindexes,
|
||||
typename ProjGrids::grids_storage_type::grids_type::tag());
|
||||
}
|
||||
|
||||
template <bool Inverse, typename Par, typename Range>
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
// Boost.Geometry
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// This file was modified by Oracle on 2018, 2019.
|
||||
// Modifications copyright (c) 2018-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// This file is converted from PROJ4, http://trac.osgeo.org/proj
|
||||
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
|
||||
// PROJ4 is maintained by Frank Warmerdam
|
||||
// This file was converted to Geometry Library by Adam Wulkiewicz
|
||||
|
||||
// Original copyright notice:
|
||||
// Author: Frank Warmerdam, warmerdam@pobox.com
|
||||
|
||||
// Copyright (c) 2000, Frank Warmerdam
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_APPLY_GRIDSHIFT_SHARED_HPP
|
||||
#define BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_APPLY_GRIDSHIFT_SHARED_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/impl/pj_apply_gridshift.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/pj_gridlist_shared.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <bool Inverse, typename CalcT, typename StreamPolicy, typename Range>
|
||||
inline bool pj_apply_gridshift_3(StreamPolicy const& stream_policy,
|
||||
Range & range,
|
||||
shared_grids & grids,
|
||||
std::vector<std::size_t> const& gridindexes)
|
||||
{
|
||||
typedef typename boost::range_size<Range>::type size_type;
|
||||
|
||||
// If the grids are empty the indexes are as well
|
||||
if (gridindexes.empty())
|
||||
{
|
||||
//pj_ctx_set_errno(ctx, PJD_ERR_FAILED_TO_LOAD_GRID);
|
||||
//return PJD_ERR_FAILED_TO_LOAD_GRID;
|
||||
return false;
|
||||
}
|
||||
|
||||
size_type point_count = boost::size(range);
|
||||
|
||||
// local storage
|
||||
pj_gi_load local_gi;
|
||||
|
||||
for (size_type i = 0 ; i < point_count ; )
|
||||
{
|
||||
bool load_needed = false;
|
||||
|
||||
CalcT in_lon = 0;
|
||||
CalcT in_lat = 0;
|
||||
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(grids.mutex);
|
||||
|
||||
for ( ; i < point_count ; ++i )
|
||||
{
|
||||
typename boost::range_reference<Range>::type
|
||||
point = range::at(range, i);
|
||||
|
||||
in_lon = geometry::get_as_radian<0>(point);
|
||||
in_lat = geometry::get_as_radian<1>(point);
|
||||
|
||||
pj_gi * gip = find_grid(in_lon, in_lat, grids.gridinfo, gridindexes);
|
||||
|
||||
if (gip == NULL)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
else if (! gip->ct.cvs.empty())
|
||||
{
|
||||
// TODO: use set_invalid_point() or similar mechanism
|
||||
CalcT out_lon = HUGE_VAL;
|
||||
CalcT out_lat = HUGE_VAL;
|
||||
|
||||
nad_cvt<Inverse>(in_lon, in_lat, out_lon, out_lat, *gip);
|
||||
|
||||
// TODO: check differently
|
||||
if (out_lon != HUGE_VAL)
|
||||
{
|
||||
geometry::set_from_radian<0>(point, out_lon);
|
||||
geometry::set_from_radian<1>(point, out_lat);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// loading is needed
|
||||
local_gi = *gip;
|
||||
load_needed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (load_needed)
|
||||
{
|
||||
if (load_grid(stream_policy, local_gi))
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(grids.mutex);
|
||||
|
||||
// check again in case other thread already loaded the grid.
|
||||
pj_gi * gip = find_grid(in_lon, in_lat, grids.gridinfo, gridindexes);
|
||||
|
||||
if (gip != NULL && gip->ct.cvs.empty())
|
||||
{
|
||||
// swap loaded local storage with empty grid
|
||||
local_gi.swap(*gip);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
}}} // namespace boost::geometry::projections
|
||||
|
||||
#endif // BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_APPLY_GRIDSHIFT_SHARED_HPP
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018, 2019.
|
||||
// Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -43,7 +44,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/dpar.hpp>
|
||||
#include <boost/geometry/srs/projections/exception.hpp>
|
||||
@@ -103,7 +105,7 @@ inline const pj_datums_type<T>* pj_datum_find_datum(srs::dpar::parameters<T> con
|
||||
{
|
||||
typename srs::dpar::parameters<T>::const_iterator
|
||||
it = pj_param_find(params, srs::dpar::datum);
|
||||
|
||||
|
||||
if (it != params.end())
|
||||
{
|
||||
const pj_datums_type<T>* pj_datums = pj_get_datums<T>().first;
|
||||
@@ -125,12 +127,12 @@ inline const pj_datums_type<T>* pj_datum_find_datum(srs::dpar::parameters<T> con
|
||||
template
|
||||
<
|
||||
typename Params,
|
||||
typename Param = typename srs::spar::detail::tuples_find_if
|
||||
typename Param = typename geometry::tuples::find_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::datum_traits>::pred
|
||||
>::type,
|
||||
bool IsFound = srs::spar::detail::tuples_is_found<Param>::value
|
||||
bool IsFound = geometry::tuples::is_found<Param>::value
|
||||
>
|
||||
struct pj_datum_find_datum_static
|
||||
{
|
||||
@@ -146,7 +148,7 @@ struct pj_datum_find_datum_static
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: Implemnt as MPL_ASSERT instead
|
||||
// TODO: Implemnt as BOOST_GEOMETRY_STATIC_ASSERT instead
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_unknown_ellp_param) );
|
||||
}
|
||||
}
|
||||
@@ -161,12 +163,12 @@ struct pj_datum_find_datum_static<Params, Param, false>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline const pj_datums_type<T>* pj_datum_find_datum(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params)
|
||||
template <typename T, typename ...Ps>
|
||||
inline const pj_datums_type<T>* pj_datum_find_datum(srs::spar::parameters<Ps...> const& params)
|
||||
{
|
||||
return pj_datum_find_datum_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
|
||||
srs::spar::parameters<Ps...>
|
||||
>::template apply<T>(params);
|
||||
}
|
||||
|
||||
@@ -184,7 +186,7 @@ inline bool pj_datum_find_nadgrids(srs::detail::proj4_parameters const& params,
|
||||
{
|
||||
std::string::size_type end = snadgrids.find(',', i);
|
||||
std::string name = snadgrids.substr(i, end - i);
|
||||
|
||||
|
||||
i = end;
|
||||
if (end != std::string::npos)
|
||||
++i;
|
||||
@@ -207,25 +209,25 @@ inline bool pj_datum_find_nadgrids(srs::dpar::parameters<T> const& params,
|
||||
{
|
||||
out = it->template get_value<srs::detail::nadgrids>();
|
||||
}
|
||||
|
||||
|
||||
return ! out.empty();
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Params,
|
||||
int I = srs::spar::detail::tuples_find_index_if
|
||||
int I = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param<srs::spar::nadgrids>::pred
|
||||
>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct pj_datum_find_nadgrids_static
|
||||
{
|
||||
static void apply(Params const& params, srs::detail::nadgrids & out)
|
||||
{
|
||||
out = boost::tuples::get<I>(params);
|
||||
out = geometry::tuples::get<I>(params);
|
||||
}
|
||||
};
|
||||
template <typename Params, int N>
|
||||
@@ -235,13 +237,13 @@ struct pj_datum_find_nadgrids_static<Params, N, N>
|
||||
{}
|
||||
};
|
||||
|
||||
template <BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_datum_find_nadgrids(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params,
|
||||
template <typename ...Ps>
|
||||
inline bool pj_datum_find_nadgrids(srs::spar::parameters<Ps...> const& params,
|
||||
srs::detail::nadgrids & out)
|
||||
{
|
||||
pj_datum_find_nadgrids_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
|
||||
srs::spar::parameters<Ps...>
|
||||
>::apply(params, out);
|
||||
|
||||
return ! out.empty();
|
||||
@@ -284,7 +286,7 @@ inline bool pj_datum_find_towgs84(srs::dpar::parameters<T> const& params,
|
||||
{
|
||||
typename srs::dpar::parameters<T>::const_iterator
|
||||
it = pj_param_find(params, srs::dpar::towgs84);
|
||||
|
||||
|
||||
if (it != params.end())
|
||||
{
|
||||
srs::detail::towgs84<T> const&
|
||||
@@ -309,20 +311,20 @@ inline bool pj_datum_find_towgs84(srs::dpar::parameters<T> const& params,
|
||||
template
|
||||
<
|
||||
typename Params,
|
||||
int I = srs::spar::detail::tuples_find_index_if
|
||||
int I = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_t<srs::spar::towgs84>::pred
|
||||
>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct pj_datum_find_towgs84_static
|
||||
{
|
||||
template <typename T>
|
||||
static void apply(Params const& params, srs::detail::towgs84<T> & out)
|
||||
{
|
||||
typename boost::tuples::element<I, Params>::type const&
|
||||
towgs84 = boost::tuples::get<I>(params);
|
||||
typename geometry::tuples::element<I, Params>::type const&
|
||||
towgs84 = geometry::tuples::get<I>(params);
|
||||
|
||||
std::size_t n = (std::min<std::size_t>)(towgs84.size(), 7u);
|
||||
std::size_t z = n <= 3 ? 3 : 7;
|
||||
@@ -345,13 +347,13 @@ struct pj_datum_find_towgs84_static<Params, N, N>
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_datum_find_towgs84(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params,
|
||||
template <typename T, typename ...Ps>
|
||||
inline bool pj_datum_find_towgs84(srs::spar::parameters<Ps...> const& params,
|
||||
srs::detail::towgs84<T> & out)
|
||||
{
|
||||
pj_datum_find_towgs84_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
|
||||
srs::spar::parameters<Ps...>
|
||||
>::apply(params, out);
|
||||
|
||||
return ! out.empty();
|
||||
|
||||
@@ -147,7 +147,7 @@ inline std::pair<const pj_datums_type<T>*, int> pj_get_datums()
|
||||
srs::dpar::ellps_airy}
|
||||
};
|
||||
|
||||
return std::make_pair(pj_datums, sizeof(pj_datums) / sizeof(pj_datums[0]));
|
||||
return std::make_pair(pj_datums, (int)(sizeof(pj_datums) / sizeof(pj_datums[0])));
|
||||
}
|
||||
|
||||
static const pj_prime_meridians_type pj_prime_meridians[] =
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -42,8 +42,10 @@
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
#include <boost/geometry/formulas/eccentricity_sqr.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
@@ -127,7 +129,7 @@ inline bool pj_ell_init_ellps(srs::dpar::parameters<T> const& params, T &a, T &b
|
||||
const pj_ellps_type<T>* pj_ellps = pj_get_ellps<T>().first;
|
||||
const int n = pj_get_ellps<T>().second;
|
||||
int i = it->template get_value<int>();
|
||||
|
||||
|
||||
if (i < 0 || i >= n) {
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_unknown_ellp_param) );
|
||||
}
|
||||
@@ -161,23 +163,23 @@ inline bool pj_ell_init_ellps(srs::dpar::parameters<T> const& params, T &a, T &b
|
||||
template
|
||||
<
|
||||
typename Params,
|
||||
int I = srs::spar::detail::tuples_find_index_if
|
||||
int I = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::ellps_traits>::pred
|
||||
>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct pj_ell_init_ellps_static
|
||||
{
|
||||
template <typename T>
|
||||
static bool apply(Params const& params, T &a, T &b)
|
||||
{
|
||||
typedef typename boost::tuples::element<I, Params>::type param_type;
|
||||
typedef typename geometry::tuples::element<I, Params>::type param_type;
|
||||
typedef srs::spar::detail::ellps_traits<param_type> traits_type;
|
||||
typedef typename traits_type::template model_type<T>::type model_type;
|
||||
|
||||
param_type const& param = boost::tuples::get<I>(params);
|
||||
param_type const& param = geometry::tuples::get<I>(params);
|
||||
model_type const& model = traits_type::template model<T>(param);
|
||||
|
||||
a = geometry::get_radius<0>(model);
|
||||
@@ -196,13 +198,13 @@ struct pj_ell_init_ellps_static<Params, N, N>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_ell_init_ellps(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params,
|
||||
template <typename T, typename ...Ps>
|
||||
inline bool pj_ell_init_ellps(srs::spar::parameters<Ps...> const& params,
|
||||
T &a, T &b)
|
||||
{
|
||||
return pj_ell_init_ellps_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
|
||||
srs::spar::parameters<Ps...>
|
||||
>::apply(params, a, b);
|
||||
}
|
||||
|
||||
@@ -242,7 +244,7 @@ inline void pj_ell_init(Params const& params, T &a, T &es)
|
||||
} else if (pj_param_f<srs::spar::rf>(params, "rf", srs::dpar::rf, es)) { /* recip flattening */
|
||||
if (es == 0.0) {
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_rev_flattening_is_zero) );
|
||||
}
|
||||
}
|
||||
es = 1./ es;
|
||||
es = es * (2. - es);
|
||||
is_ell_set = true;
|
||||
@@ -361,69 +363,69 @@ inline void pj_ell_init(Params const& params, T &a, T &es)
|
||||
template <typename Params>
|
||||
struct static_srs_tag_check_nonexpanded
|
||||
{
|
||||
typedef typename boost::mpl::if_c
|
||||
typedef std::conditional_t
|
||||
<
|
||||
srs::spar::detail::tuples_exists_if
|
||||
geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::r>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::r_au>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::r_v>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::r_a>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::r_g>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::r_h>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::r_lat_a>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::r_lat_g>::pred
|
||||
>::value,
|
||||
srs_sphere_tag,
|
||||
// NOTE: The assumption here is that if the user defines either one of:
|
||||
// b, es, e, f, rf parameters then he wants to define spheroid, not sphere
|
||||
typename boost::mpl::if_c
|
||||
std::conditional_t
|
||||
<
|
||||
srs::spar::detail::tuples_exists_if
|
||||
geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::b>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::es>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::e>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::rf>::pred
|
||||
>::value
|
||||
|| srs::spar::detail::tuples_exists_if
|
||||
|| geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param_t<srs::spar::f>::pred
|
||||
>::value,
|
||||
srs_spheroid_tag,
|
||||
void
|
||||
>::type
|
||||
>::type type;
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
template <typename Params>
|
||||
@@ -433,7 +435,7 @@ struct static_srs_tag_check_ellps
|
||||
<
|
||||
typename srs::spar::detail::ellps_traits
|
||||
<
|
||||
typename srs::spar::detail::tuples_find_if
|
||||
typename geometry::tuples::find_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::ellps_traits>::pred
|
||||
@@ -451,7 +453,7 @@ struct static_srs_tag_check_datum
|
||||
<
|
||||
typename srs::spar::detail::datum_traits
|
||||
<
|
||||
typename srs::spar::detail::tuples_find_if
|
||||
typename geometry::tuples::find_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::datum_traits>::pred
|
||||
@@ -504,18 +506,20 @@ struct static_srs_tag<Params, void, void, void>
|
||||
{
|
||||
// User didn't pass any parameter defining model
|
||||
// so use default or generate error
|
||||
typedef typename boost::mpl::if_c
|
||||
typedef std::conditional_t
|
||||
<
|
||||
srs::spar::detail::tuples_exists_if
|
||||
geometry::tuples::exists_if
|
||||
<
|
||||
Params, srs::spar::detail::is_param<srs::spar::no_defs>::pred
|
||||
>::value,
|
||||
void,
|
||||
srs_spheroid_tag // WGS84
|
||||
>::type type;
|
||||
> type;
|
||||
|
||||
static const bool is_found = ! boost::is_same<type, void>::value;
|
||||
BOOST_MPL_ASSERT_MSG((is_found), UNKNOWN_ELLP_PARAM, (Params));
|
||||
static const bool is_found = ! std::is_void<type>::value;
|
||||
BOOST_GEOMETRY_STATIC_ASSERT((is_found),
|
||||
"Expected ellipsoid or sphere definition.",
|
||||
Params);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ inline std::pair<const pj_ellps_type<T>*, int> pj_get_ellps()
|
||||
BOOST_GEOMETRY_PROJECTIONS_DETAIL_PJ_ELLPS_B ("sphere", 6370997.0, 6370997.0, "Normal Sphere (r=6370997)")
|
||||
};
|
||||
|
||||
return std::make_pair(pj_ellps, sizeof(pj_ellps) / sizeof(pj_ellps[0]));
|
||||
return std::make_pair(pj_ellps, (int)(sizeof(pj_ellps) / sizeof(pj_ellps[0])));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017, 2018, 2019.
|
||||
// Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -90,9 +90,16 @@ inline void pj_fwd(Prj const& prj, P const& par, LL const& ll, XY& xy)
|
||||
calc_t x = 0;
|
||||
calc_t y = 0;
|
||||
|
||||
prj.fwd(lp_lon, lp_lat, x, y);
|
||||
geometry::set<0>(xy, par.fr_meter * (par.a * x + par.x0));
|
||||
geometry::set<1>(xy, par.fr_meter * (par.a * y + par.y0));
|
||||
prj.fwd(par, lp_lon, lp_lat, x, y);
|
||||
|
||||
if (par.axis[0] == 0)
|
||||
{
|
||||
geometry::set<0>(xy, par.sign[0] * par.fr_meter * (par.a * x + par.x0));
|
||||
geometry::set<1>(xy, par.sign[1] * par.fr_meter * (par.a * y + par.y0));
|
||||
} else {
|
||||
geometry::set<1>(xy, par.sign[1] * par.fr_meter * (par.a * x + par.x0));
|
||||
geometry::set<0>(xy, par.sign[0] * par.fr_meter * (par.a * y + par.y0));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2022 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// Copyright (c) 2022, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// This file is converted from PROJ, https://github.com/OSGeo/PROJ
|
||||
|
||||
// Last updated version of proj: 9.0.0
|
||||
|
||||
// Original copyright notice:
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Project: PROJ
|
||||
* Purpose: Generic method to compute inverse projection from forward method
|
||||
* Author: Even Rouault <even dot rouault at spatialys dot com>
|
||||
*
|
||||
******************************************************************************
|
||||
* Copyright (c) 2018, Even Rouault <even dot rouault at spatialys dot com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
/** Compute (lam, phi) corresponding to input (xy_x, xy_y) for projection P.
|
||||
*
|
||||
* Uses Newton-Raphson method, extended to 2D variables, that is using
|
||||
* inversion of the Jacobian 2D matrix of partial derivatives. The derivatives
|
||||
* are estimated numerically from the P->fwd method evaluated at close points.
|
||||
*
|
||||
* Note: thresholds used have been verified to work with adams_ws2 and wink2
|
||||
*
|
||||
* Starts with initial guess provided by user in lpInitial
|
||||
*/
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename T, typename Parameters, typename Projection>
|
||||
void pj_generic_inverse_2d(T const& xy_x,
|
||||
T const& xy_y,
|
||||
Parameters const& par,
|
||||
Projection const& proj,
|
||||
T& lp_lat,
|
||||
T& lp_lon)
|
||||
{
|
||||
T deriv_lam_X = 0;
|
||||
T deriv_lam_Y = 0;
|
||||
T deriv_phi_X = 0;
|
||||
T deriv_phi_Y = 0;
|
||||
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
T xyApprox_x;
|
||||
T xyApprox_y;
|
||||
proj->fwd(par, lp_lon, lp_lat, xyApprox_x, xyApprox_y);
|
||||
T const deltaX = xyApprox_x - xy_x;
|
||||
T const deltaY = xyApprox_y - xy_y;
|
||||
if (fabs(deltaX) < 1e-10 && fabs(deltaY) < 1e-10) return;
|
||||
|
||||
if (fabs(deltaX) > 1e-6 || fabs(deltaY) > 1e-6)
|
||||
{
|
||||
// Compute Jacobian matrix (only if we aren't close to the final
|
||||
// result to speed things a bit)
|
||||
T lp2_lat;
|
||||
T lp2_lon;
|
||||
T xy2_x;
|
||||
T xy2_y;
|
||||
T const dLam = lp_lat > 0 ? -1e-6 : 1e-6;
|
||||
lp2_lat = lp_lat + dLam;
|
||||
lp2_lon = lp_lon;
|
||||
proj->fwd(par, lp2_lon, lp2_lat, xy2_x, xy2_y);
|
||||
//xy2 = P->fwd(lp2, P);
|
||||
T const deriv_X_lam = (xy2_x - xyApprox_x) / dLam;
|
||||
T const deriv_Y_lam = (xy2_y - xyApprox_y) / dLam;
|
||||
|
||||
T const dPhi = lp_lon > 0 ? -1e-6 : 1e-6;
|
||||
lp2_lat = lp_lat;
|
||||
lp2_lon = lp_lon + dPhi;
|
||||
proj->fwd(par, lp2_lon, lp2_lat, xy2_x, xy2_y);
|
||||
//xy2 = P->fwd(lp2, P);
|
||||
T const deriv_X_phi = (xy2_x - xyApprox_x) / dPhi;
|
||||
T const deriv_Y_phi = (xy2_y - xyApprox_y) / dPhi;
|
||||
|
||||
// Inverse of Jacobian matrix
|
||||
T const det = deriv_X_lam * deriv_Y_phi - deriv_X_phi * deriv_Y_lam;
|
||||
if (det != 0)
|
||||
{
|
||||
deriv_lam_X = deriv_Y_phi / det;
|
||||
deriv_lam_Y = -deriv_X_phi / det;
|
||||
deriv_phi_X = -deriv_Y_lam / det;
|
||||
deriv_phi_Y = deriv_X_lam / det;
|
||||
}
|
||||
}
|
||||
|
||||
if (xy_x != 0)
|
||||
{
|
||||
// Limit the amplitude of correction to avoid overshoots due to
|
||||
// bad initial guess
|
||||
T const delta_lam = (std::max)(
|
||||
(std::min)(deltaX * deriv_lam_X + deltaY * deriv_lam_Y, 0.3),
|
||||
-0.3);
|
||||
lp_lat -= delta_lam;
|
||||
if (lp_lat < -math::pi<T>())
|
||||
lp_lat = -math::pi<T>();
|
||||
else if (lp_lat > math::pi<T>())
|
||||
lp_lat = math::pi<T>();
|
||||
}
|
||||
|
||||
if (xy_y != 0)
|
||||
{
|
||||
T const delta_phi = (std::max)(
|
||||
(std::min)(deltaX * deriv_phi_X + deltaY * deriv_phi_Y, 0.3),
|
||||
-0.3);
|
||||
lp_lon -= delta_phi;
|
||||
static T const half_pi = math::half_pi<T>();
|
||||
if (lp_lon < -half_pi)
|
||||
lp_lon = -half_pi;
|
||||
else if (lp_lon > half_pi)
|
||||
lp_lon = half_pi;
|
||||
}
|
||||
}
|
||||
//pj_ctx_set_errno(P->ctx, PJD_ERR_NON_CONVERGENT);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
}}} // namespace boost::geometry::projections
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GENERIC_INVERSE_HPP
|
||||
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2018, 2019.
|
||||
// Modifications copyright (c) 2018-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
@@ -41,11 +43,11 @@
|
||||
#define BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_GRIDINFO_HPP
|
||||
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -190,18 +192,18 @@ template <typename IStream>
|
||||
bool pj_gridinfo_load_ctable(IStream & is, pj_gi_load & gi)
|
||||
{
|
||||
pj_ctable & ct = gi.ct;
|
||||
|
||||
|
||||
// Move the input stream by the size of the proj4 original CTABLE
|
||||
std::size_t header_size = 80
|
||||
+ 2 * sizeof(pj_ctable::lp_t)
|
||||
+ sizeof(pj_ctable::ilp_t)
|
||||
+ sizeof(pj_ctable::flp_t*);
|
||||
is.seekg(header_size);
|
||||
|
||||
|
||||
// read all the actual shift values
|
||||
std::size_t a_size = ct.lim.lam * ct.lim.phi;
|
||||
ct.cvs.resize(a_size);
|
||||
|
||||
|
||||
std::size_t ch_size = sizeof(pj_ctable::flp_t) * a_size;
|
||||
is.read(reinterpret_cast<char*>(&ct.cvs[0]), ch_size);
|
||||
|
||||
@@ -213,7 +215,7 @@ bool pj_gridinfo_load_ctable(IStream & is, pj_gi_load & gi)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_gridinfo_load_ctable2() */
|
||||
@@ -274,7 +276,7 @@ inline bool pj_gridinfo_load_ntv1(IStream & is, pj_gi_load & gi)
|
||||
|
||||
std::vector<double> row_buf(r_size);
|
||||
gi.ct.cvs.resize(gi.ct.lim.lam * gi.ct.lim.phi);
|
||||
|
||||
|
||||
for (boost::int32_t row = 0; row < gi.ct.lim.phi; row++ )
|
||||
{
|
||||
is.read(reinterpret_cast<char*>(&row_buf[0]), ch_size);
|
||||
@@ -366,7 +368,7 @@ inline bool pj_gridinfo_load_gtx(IStream & is, pj_gi_load & gi)
|
||||
{
|
||||
boost::int32_t words = gi.ct.lim.lam * gi.ct.lim.phi;
|
||||
std::size_t const ch_size = sizeof(float) * words;
|
||||
|
||||
|
||||
is.seekg(gi.grid_offset);
|
||||
|
||||
// TODO: Consider changing this unintuitive code
|
||||
@@ -827,12 +829,12 @@ inline bool pj_gridinfo_init_ctable2(std::string const& gridname,
|
||||
memcpy( &ct.ll, header + 96, 40 );
|
||||
|
||||
// do some minimal validation to ensure the structure isn't corrupt
|
||||
if ( (ct.lim.lam < 1) || (ct.lim.lam > 100000)
|
||||
if ( (ct.lim.lam < 1) || (ct.lim.lam > 100000)
|
||||
|| (ct.lim.phi < 1) || (ct.lim.phi > 100000) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// trim white space and newlines off id
|
||||
boost::trim_right_if(ct.id, is_trimmable_char());
|
||||
|
||||
@@ -879,12 +881,12 @@ inline bool pj_gridinfo_init_ctable(std::string const& gridname,
|
||||
memcpy( &ct.ll, header + 80, 40 );
|
||||
|
||||
// do some minimal validation to ensure the structure isn't corrupt
|
||||
if ( (ct.lim.lam < 1) || (ct.lim.lam > 100000)
|
||||
if ( (ct.lim.lam < 1) || (ct.lim.lam > 100000)
|
||||
|| (ct.lim.phi < 1) || (ct.lim.phi > 100000) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// trim white space and newlines off id
|
||||
boost::trim_right_if(ct.id, is_trimmable_char());
|
||||
|
||||
@@ -923,7 +925,7 @@ inline bool pj_gridinfo_init(std::string const& gridname,
|
||||
if ( is.fail() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
is.seekg(0);
|
||||
|
||||
// Determine file type.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Boost.Geometry
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// This file was modified by Oracle on 2018.
|
||||
// Modifications copyright (c) 2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2018, 2019.
|
||||
// Modifications copyright (c) 2018-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -92,15 +92,16 @@ inline void pj_gridlist_add_seq_inc(std::vector<std::size_t> & gridindexes,
|
||||
}
|
||||
|
||||
// Generic stream policy and standard grids
|
||||
template <typename StreamPolicy>
|
||||
template <typename StreamPolicy, typename Grids>
|
||||
inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
|
||||
StreamPolicy const& stream_policy,
|
||||
srs::grids & grids,
|
||||
std::vector<std::size_t> & gridindexes)
|
||||
Grids & grids,
|
||||
std::vector<std::size_t> & gridindexes,
|
||||
grids_tag)
|
||||
{
|
||||
// Try to find in the existing list of loaded grids. Add all
|
||||
// matching grids as with NTv2 we can get many grids from one
|
||||
// file (one shared gridname).
|
||||
// file (one shared gridname).
|
||||
if (pj_gridlist_find_all(gridname, grids.gridinfo, gridindexes))
|
||||
return true;
|
||||
|
||||
@@ -117,7 +118,62 @@ inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
|
||||
|
||||
// Add the grid now that it is loaded.
|
||||
pj_gridlist_add_seq_inc(gridindexes, orig_size, grids.gridinfo.size());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Generic stream policy and shared grids
|
||||
template <typename StreamPolicy, typename SharedGrids>
|
||||
inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
|
||||
StreamPolicy const& stream_policy,
|
||||
SharedGrids & grids,
|
||||
std::vector<std::size_t> & gridindexes,
|
||||
shared_grids_tag)
|
||||
{
|
||||
// Try to find in the existing list of loaded grids. Add all
|
||||
// matching grids as with NTv2 we can get many grids from one
|
||||
// file (one shared gridname).
|
||||
{
|
||||
typename SharedGrids::read_locked lck_grids(grids);
|
||||
|
||||
if (pj_gridlist_find_all(gridname, lck_grids.gridinfo, gridindexes))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try to load the named grid.
|
||||
typename StreamPolicy::stream_type is;
|
||||
stream_policy.open(is, gridname);
|
||||
|
||||
pj_gridinfo new_grids;
|
||||
|
||||
if (! pj_gridinfo_init(gridname, is, new_grids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the grid now that it is loaded.
|
||||
|
||||
std::size_t orig_size = 0;
|
||||
std::size_t new_size = 0;
|
||||
|
||||
{
|
||||
typename SharedGrids::write_locked lck_grids(grids);
|
||||
|
||||
// Try to find in the existing list of loaded grids again
|
||||
// in case other thread already added it.
|
||||
if (pj_gridlist_find_all(gridname, lck_grids.gridinfo, gridindexes))
|
||||
return true;
|
||||
|
||||
orig_size = lck_grids.gridinfo.size();
|
||||
new_size = orig_size + new_grids.size();
|
||||
|
||||
lck_grids.gridinfo.resize(new_size);
|
||||
for (std::size_t i = 0 ; i < new_grids.size() ; ++ i)
|
||||
new_grids[i].swap(lck_grids.gridinfo[i + orig_size]);
|
||||
}
|
||||
|
||||
pj_gridlist_add_seq_inc(gridindexes, orig_size, new_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -144,10 +200,11 @@ inline void pj_gridlist_from_nadgrids(srs::detail::nadgrids const& nadgrids,
|
||||
it != nadgrids.end() ; ++it)
|
||||
{
|
||||
bool required = (*it)[0] != '@';
|
||||
|
||||
|
||||
std::string name(it->begin() + (required ? 0 : 1), it->end());
|
||||
|
||||
if ( ! pj_gridlist_merge_gridfile(name, stream_policy, grids, gridindexes)
|
||||
if ( ! pj_gridlist_merge_gridfile(name, stream_policy, grids, gridindexes,
|
||||
typename Grids::tag())
|
||||
&& required )
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_failed_to_load_grid) );
|
||||
@@ -155,15 +212,13 @@ inline void pj_gridlist_from_nadgrids(srs::detail::nadgrids const& nadgrids,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Par, typename GridsStorage>
|
||||
inline void pj_gridlist_from_nadgrids(Par const& defn, srs::projection_grids<GridsStorage> & grids)
|
||||
template <typename Par, typename ProjectionGrids>
|
||||
inline void pj_gridlist_from_nadgrids(Par const& defn, ProjectionGrids & proj_grids)
|
||||
{
|
||||
BOOST_GEOMETRY_ASSERT(grids.storage_ptr != NULL);
|
||||
|
||||
pj_gridlist_from_nadgrids(defn.nadgrids,
|
||||
grids.storage_ptr->stream_policy,
|
||||
grids.storage_ptr->hgrids,
|
||||
grids.hindexes);
|
||||
proj_grids.grids_storage().stream_policy,
|
||||
proj_grids.grids_storage().hgrids,
|
||||
proj_grids.hindexes);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
// Boost.Geometry
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// This file was modified by Oracle on 2018, 2019.
|
||||
// Modifications copyright (c) 2018-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// This file is converted from PROJ4, http://trac.osgeo.org/proj
|
||||
// PROJ4 is originally written by Gerald Evenden (then of the USGS)
|
||||
// PROJ4 is maintained by Frank Warmerdam
|
||||
// This file was converted to Geometry Library by Adam Wulkiewicz
|
||||
|
||||
// Original copyright notice:
|
||||
// Author: Frank Warmerdam, warmerdam@pobox.com
|
||||
|
||||
// Copyright (c) 2000, Frank Warmerdam
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||
// copy of this software and associated documentation files (the "Software"),
|
||||
// to deal in the Software without restriction, including without limitation
|
||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
// and/or sell copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_GRIDLIST_SHARED_HPP
|
||||
#define BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_GRIDLIST_SHARED_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/srs/projections/shared_grids.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/pj_gridinfo.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/pj_gridlist.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_gridlist_merge_grid() */
|
||||
/* */
|
||||
/* Find/load the named gridfile and merge it into the */
|
||||
/* last_nadgrids_list. */
|
||||
/************************************************************************/
|
||||
|
||||
// Generic stream policy and shared grids
|
||||
template <typename StreamPolicy>
|
||||
inline bool pj_gridlist_merge_gridfile(std::string const& gridname,
|
||||
StreamPolicy const& stream_policy,
|
||||
shared_grids & grids,
|
||||
std::vector<std::size_t> & gridindexes)
|
||||
{
|
||||
// Try to find in the existing list of loaded grids. Add all
|
||||
// matching grids as with NTv2 we can get many grids from one
|
||||
// file (one shared gridname).
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(grids.mutex);
|
||||
|
||||
if (pj_gridlist_find_all(gridname, grids.gridinfo, gridindexes))
|
||||
return true;
|
||||
}
|
||||
|
||||
// Try to load the named grid.
|
||||
typename StreamPolicy::stream_type is;
|
||||
stream_policy.open(is, gridname);
|
||||
|
||||
pj_gridinfo new_grids;
|
||||
|
||||
if (! pj_gridinfo_init(gridname, is, new_grids))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add the grid now that it is loaded.
|
||||
|
||||
std::size_t orig_size = 0;
|
||||
std::size_t new_size = 0;
|
||||
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(grids.mutex);
|
||||
|
||||
// Try to find in the existing list of loaded grids again
|
||||
// in case other thread already added it.
|
||||
if (pj_gridlist_find_all(gridname, grids.gridinfo, gridindexes))
|
||||
return true;
|
||||
|
||||
orig_size = grids.gridinfo.size();
|
||||
new_size = orig_size + new_grids.size();
|
||||
|
||||
grids.gridinfo.resize(new_size);
|
||||
for (std::size_t i = 0 ; i < new_grids.size() ; ++ i)
|
||||
new_grids[i].swap(grids.gridinfo[i + orig_size]);
|
||||
}
|
||||
|
||||
pj_gridlist_add_seq_inc(gridindexes, orig_size, new_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
|
||||
}}} // namespace boost::geometry::projections
|
||||
|
||||
#endif // BOOST_GEOMETRY_SRS_PROJECTIONS_IMPL_PJ_GRIDLIST_SHARED_HPP
|
||||
@@ -2,9 +2,10 @@
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -41,16 +42,10 @@
|
||||
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/mpl/find.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/dpar.hpp>
|
||||
#include <boost/geometry/srs/projections/impl/dms_parser.hpp>
|
||||
@@ -63,6 +58,9 @@
|
||||
#include <boost/geometry/srs/projections/proj4.hpp>
|
||||
#include <boost/geometry/srs/projections/spar.hpp>
|
||||
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
@@ -93,20 +91,20 @@ inline void pj_init_proj(srs::dpar::parameters<T> const& params,
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline void pj_init_proj(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& ,
|
||||
template <typename T, typename ...Ps>
|
||||
inline void pj_init_proj(srs::spar::parameters<Ps...> const& ,
|
||||
parameters<T> & par)
|
||||
{
|
||||
typedef srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> params_type;
|
||||
typedef typename srs::spar::detail::tuples_find_if
|
||||
typedef srs::spar::parameters<Ps...> params_type;
|
||||
typedef typename geometry::tuples::find_if
|
||||
<
|
||||
params_type,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::proj_traits>::pred
|
||||
>::type proj_type;
|
||||
|
||||
static const bool is_found = srs::spar::detail::tuples_is_found<proj_type>::value;
|
||||
static const bool is_found = geometry::tuples::is_found<proj_type>::value;
|
||||
|
||||
BOOST_MPL_ASSERT_MSG((is_found), PROJECTION_NOT_NAMED, (params_type));
|
||||
BOOST_GEOMETRY_STATIC_ASSERT((is_found), "Projection not named.", params_type);
|
||||
|
||||
par.id = srs::spar::detail::proj_traits<proj_type>::id;
|
||||
}
|
||||
@@ -227,27 +225,27 @@ template
|
||||
<
|
||||
typename Params,
|
||||
bool Vertical,
|
||||
int UnitsI = srs::spar::detail::tuples_find_index_if
|
||||
int UnitsI = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
boost::mpl::if_c
|
||||
std::conditional_t
|
||||
<
|
||||
Vertical,
|
||||
srs::spar::detail::is_param_t<srs::spar::vunits>,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::units_traits>
|
||||
>::type::template pred
|
||||
>::template pred
|
||||
>::value,
|
||||
int ToMeterI = srs::spar::detail::tuples_find_index_if
|
||||
int ToMeterI = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
boost::mpl::if_c
|
||||
std::conditional_t
|
||||
<
|
||||
Vertical,
|
||||
srs::spar::detail::is_param_t<srs::spar::vto_meter>,
|
||||
srs::spar::detail::is_param_t<srs::spar::to_meter>
|
||||
>::type::template pred
|
||||
>::template pred
|
||||
>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct pj_init_units_static
|
||||
: pj_init_units_static<Params, Vertical, UnitsI, N, N>
|
||||
@@ -259,11 +257,11 @@ struct pj_init_units_static<Params, Vertical, UnitsI, N, N>
|
||||
static const int n = sizeof(pj_units) / sizeof(pj_units[0]);
|
||||
static const int i = srs::spar::detail::units_traits
|
||||
<
|
||||
typename boost::tuples::element<UnitsI, Params>::type
|
||||
typename geometry::tuples::element<UnitsI, Params>::type
|
||||
>::id;
|
||||
static const bool is_valid = i >= 0 && i < n;
|
||||
|
||||
BOOST_MPL_ASSERT_MSG((is_valid), UNKNOWN_UNIT_ID, (Params));
|
||||
BOOST_GEOMETRY_STATIC_ASSERT((is_valid), "Unknown unit ID.", Params);
|
||||
|
||||
template <typename T>
|
||||
static void apply(Params const& ,
|
||||
@@ -289,7 +287,7 @@ struct pj_init_units_static<Params, Vertical, N, ToMeterI, N>
|
||||
T & to_meter, T & fr_meter,
|
||||
T const& , T const& )
|
||||
{
|
||||
to_meter = boost::tuples::get<ToMeterI>(params).value;
|
||||
to_meter = geometry::tuples::get<ToMeterI>(params).value;
|
||||
fr_meter = 1. / to_meter;
|
||||
}
|
||||
};
|
||||
@@ -307,8 +305,8 @@ struct pj_init_units_static<Params, Vertical, N, N, N>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, bool Vertical, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline void pj_init_units(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params,
|
||||
template <typename T, bool Vertical, typename ...Ps>
|
||||
inline void pj_init_units(srs::spar::parameters<Ps...> const& params,
|
||||
T & to_meter,
|
||||
T & fr_meter,
|
||||
T const& default_to_meter,
|
||||
@@ -316,7 +314,7 @@ inline void pj_init_units(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAI
|
||||
{
|
||||
pj_init_units_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
Vertical
|
||||
>::apply(params, to_meter, fr_meter, default_to_meter, default_fr_meter);
|
||||
}
|
||||
@@ -354,7 +352,7 @@ inline void pj_init_pm(srs::detail::proj4_parameters const& params, T& val)
|
||||
}
|
||||
BOOST_CATCH_END
|
||||
}
|
||||
|
||||
|
||||
val = 0.0;
|
||||
}
|
||||
|
||||
@@ -391,21 +389,21 @@ inline void pj_init_pm(srs::dpar::parameters<T> const& params, T& val)
|
||||
template
|
||||
<
|
||||
typename Params,
|
||||
int I = srs::spar::detail::tuples_find_index_if
|
||||
int I = geometry::tuples::find_index_if
|
||||
<
|
||||
Params,
|
||||
srs::spar::detail::is_param_tr<srs::spar::detail::pm_traits>::pred
|
||||
>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct pj_init_pm_static
|
||||
{
|
||||
template <typename T>
|
||||
static void apply(Params const& params, T & val)
|
||||
{
|
||||
typedef typename boost::tuples::element<I, Params>::type param_type;
|
||||
typedef typename geometry::tuples::element<I, Params>::type param_type;
|
||||
|
||||
val = srs::spar::detail::pm_traits<param_type>::value(boost::tuples::get<I>(params));
|
||||
val = srs::spar::detail::pm_traits<param_type>::value(geometry::tuples::get<I>(params));
|
||||
}
|
||||
};
|
||||
template <typename Params, int N>
|
||||
@@ -418,15 +416,90 @@ struct pj_init_pm_static<Params, N, N>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline void pj_init_pm(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params, T& val)
|
||||
template <typename T, typename ...Ps>
|
||||
inline void pj_init_pm(srs::spar::parameters<Ps...> const& params, T& val)
|
||||
{
|
||||
pj_init_pm_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>
|
||||
srs::spar::parameters<Ps...>
|
||||
>::apply(params, val);
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_init_axis() */
|
||||
/************************************************************************/
|
||||
|
||||
template <typename Params, typename T>
|
||||
inline void pj_init_axis(Params const& params, parameters<T> & projdef)
|
||||
{
|
||||
std::string axis = pj_get_param_s(params, "axis");
|
||||
if(! axis.empty())
|
||||
{
|
||||
for (std::size_t i = 0; i < axis.length(); ++i)
|
||||
{
|
||||
switch(axis[i])
|
||||
{
|
||||
case 'w':
|
||||
projdef.sign[i] = -1;
|
||||
projdef.axis[i] = 0;
|
||||
break;
|
||||
case 'e':
|
||||
projdef.sign[i] = 1;
|
||||
projdef.axis[i] = 0;
|
||||
break;
|
||||
case 's':
|
||||
projdef.sign[i] = -1;
|
||||
projdef.axis[i] = 1;
|
||||
break;
|
||||
case 'n':
|
||||
projdef.sign[i] = 1;
|
||||
projdef.axis[i] = 1;
|
||||
break;
|
||||
case 'd':
|
||||
projdef.sign[i] = -1;
|
||||
projdef.axis[i] = 2;
|
||||
break;
|
||||
case 'u':
|
||||
projdef.sign[i] = 1;
|
||||
projdef.axis[i] = 2;
|
||||
break;
|
||||
default:
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_axis) );
|
||||
}
|
||||
}
|
||||
// Currently not support elevation
|
||||
if (projdef.axis[0] + projdef.axis[1] != 1)
|
||||
{
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_axis) );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: implement axis support for other types of parameters
|
||||
|
||||
template <typename T>
|
||||
inline void pj_init_axis(srs::dpar::parameters<T> const& , parameters<T> & )
|
||||
{}
|
||||
|
||||
template <typename Params>
|
||||
struct pj_init_axis_static
|
||||
{
|
||||
template <typename T>
|
||||
static void apply(Params const& , parameters<T> & )
|
||||
{}
|
||||
};
|
||||
|
||||
template <typename T, typename ...Ps>
|
||||
inline void pj_init_axis(srs::spar::parameters<Ps...> const& params, parameters<T> & projdef)
|
||||
{
|
||||
pj_init_axis_static
|
||||
<
|
||||
srs::spar::parameters<Ps...>
|
||||
>::apply(params, projdef);
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_init() */
|
||||
/* */
|
||||
@@ -449,7 +522,7 @@ inline parameters<T> pj_init(Params const& params)
|
||||
// NOTE: proj4 gets defaults from "proj_def.dat".
|
||||
// In Boost.Geometry this is emulated by manually setting them in
|
||||
// pj_ell_init and projections aea, lcc and lagrng
|
||||
|
||||
|
||||
/* set datum parameters */
|
||||
pj_datum_init(params, pin);
|
||||
|
||||
@@ -515,6 +588,9 @@ inline parameters<T> pj_init(Params const& params)
|
||||
/* prime meridian */
|
||||
pj_init_pm(params, pin.from_greenwich);
|
||||
|
||||
/* set axis orientation */
|
||||
pj_init_axis(params, pin);
|
||||
|
||||
return pin;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017.
|
||||
// Modifications copyright (c) 2017, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017, 2019.
|
||||
// Modifications copyright (c) 2017-2019, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -62,10 +62,22 @@ inline void pj_inv(PRJ const& prj, PAR const& par, XY const& xy, LL& ll)
|
||||
|
||||
/* can't do as much preliminary checking as with forward */
|
||||
/* descale and de-offset */
|
||||
calc_t xy_x = (geometry::get<0>(xy) * par.to_meter - par.x0) * par.ra;
|
||||
calc_t xy_y = (geometry::get<1>(xy) * par.to_meter - par.y0) * par.ra;
|
||||
calc_t lon = 0, lat = 0;
|
||||
prj.inv(xy_x, xy_y, lon, lat); /* inverse project */
|
||||
calc_t lon = 0;
|
||||
calc_t lat = 0;
|
||||
calc_t xy_x = 0;
|
||||
calc_t xy_y = 0;
|
||||
|
||||
if (par.axis[0] == 1)
|
||||
{
|
||||
xy_x = (geometry::get<1>(xy) * par.to_meter * par.sign[1] - par.x0) * par.ra;
|
||||
xy_y = (geometry::get<0>(xy) * par.to_meter * par.sign[0] - par.y0) * par.ra;
|
||||
} else {
|
||||
xy_x = (geometry::get<0>(xy) * par.to_meter * par.sign[0] - par.x0) * par.ra;
|
||||
xy_y = (geometry::get<1>(xy) * par.to_meter * par.sign[1] - par.y0) * par.ra;
|
||||
}
|
||||
|
||||
prj.inv(par, xy_x, xy_y, lon, lat); /* inverse project */
|
||||
|
||||
lon += par.lam0; /* reduce from del lp.lam */
|
||||
if (!par.over)
|
||||
lon = adjlon(lon); /* adjust longitude to CM */
|
||||
|
||||
@@ -95,7 +95,7 @@ inline en<T> pj_enfn(T const& es)
|
||||
en[3] = (t *= es) * (C66 - es * C68);
|
||||
en[4] = t * es * C88;
|
||||
}
|
||||
|
||||
|
||||
return en;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -40,9 +40,13 @@
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_PJ_PARAM_HPP
|
||||
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/exception.hpp>
|
||||
|
||||
#include <boost/geometry/srs/projections/impl/dms_parser.hpp>
|
||||
@@ -51,11 +55,6 @@
|
||||
#include <boost/geometry/srs/projections/dpar.hpp>
|
||||
#include <boost/geometry/srs/projections/spar.hpp>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections {
|
||||
|
||||
@@ -67,9 +66,12 @@ inline bool pj_param_pred(srs::detail::proj4_parameter const& p, std::string con
|
||||
return p.name == name;
|
||||
}
|
||||
|
||||
template <typename T, typename Id>
|
||||
inline bool pj_param_pred(srs::dpar::parameter<T> const& p, Id const& id,
|
||||
typename boost::disable_if_c<boost::is_convertible<Id, std::string>::value>::type * = 0)
|
||||
template
|
||||
<
|
||||
typename T, typename Id,
|
||||
std::enable_if_t<! std::is_convertible<Id, std::string>::value, int> = 0
|
||||
>
|
||||
inline bool pj_param_pred(srs::dpar::parameter<T> const& p, Id const& id)
|
||||
{
|
||||
return p.is_id_equal(id);
|
||||
}
|
||||
@@ -103,11 +105,11 @@ template
|
||||
typename StaticParams,
|
||||
typename IsParamPred,
|
||||
int I = tuples_find_index_if<StaticParams, typename IsParamPred::pred>::value,
|
||||
int N = boost::tuples::length<StaticParams>::value
|
||||
int N = geometry::tuples::size<StaticParams>::value
|
||||
>
|
||||
struct pj_param_find_static
|
||||
{
|
||||
typedef boost::tuples::element<I, StaticParams> type;
|
||||
typedef geometry::tuples::element<I, StaticParams> type;
|
||||
typedef const type* result_type;
|
||||
static result_type get(StaticParams const& params)
|
||||
{
|
||||
@@ -131,27 +133,27 @@ inline bool pj_param_exists(Params const& params, Name const& name)
|
||||
return pj_param_find(params, name) != params.end();
|
||||
}
|
||||
|
||||
template <typename Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_param_exists(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& )
|
||||
template <typename Param, typename ...Ps>
|
||||
inline bool pj_param_exists(srs::spar::parameters<Ps...> const& )
|
||||
{
|
||||
return srs::spar::detail::tuples_is_found
|
||||
return geometry::tuples::is_found
|
||||
<
|
||||
typename srs::spar::detail::tuples_find_if
|
||||
typename geometry::tuples::find_if
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
srs::spar::detail::is_param<Param>::template pred
|
||||
>::type
|
||||
>::value;
|
||||
}
|
||||
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_param_exists(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& )
|
||||
template <template <typename> class Param, typename ...Ps>
|
||||
inline bool pj_param_exists(srs::spar::parameters<Ps...> const& )
|
||||
{
|
||||
return srs::spar::detail::tuples_is_found
|
||||
return geometry::tuples::is_found
|
||||
<
|
||||
typename srs::spar::detail::tuples_find_if
|
||||
typename geometry::tuples::find_if
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
srs::spar::detail::is_param_t<Param>::template pred
|
||||
>::type
|
||||
>::value;
|
||||
@@ -185,11 +187,11 @@ inline void set_value_r(T & val, srs::dpar::parameter<T> const& p)
|
||||
template <typename Name>
|
||||
inline void check_name(Name const&)
|
||||
{
|
||||
static const bool is_ok = boost::is_convertible<Name, std::string>::value
|
||||
|| boost::is_same<Name, srs::dpar::name_i>::value
|
||||
|| boost::is_same<Name, srs::dpar::name_f>::value
|
||||
|| boost::is_same<Name, srs::dpar::name_r>::value;
|
||||
BOOST_MPL_ASSERT_MSG((is_ok), INVALID_ARGUMENT, (Name));
|
||||
static const bool is_ok = std::is_convertible<Name, std::string>::value
|
||||
|| std::is_same<Name, srs::dpar::name_i>::value
|
||||
|| std::is_same<Name, srs::dpar::name_f>::value
|
||||
|| std::is_same<Name, srs::dpar::name_r>::value;
|
||||
BOOST_GEOMETRY_STATIC_ASSERT((is_ok), "Invalid argument.", Name);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +205,7 @@ inline bool _pj_param_i(Params const& params, Name const& name, int & par)
|
||||
{
|
||||
set_value(par, *it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -212,12 +214,12 @@ template <typename T, typename Params, typename Name>
|
||||
inline bool _pj_param_f(Params const& params, Name const& name, T & par)
|
||||
{
|
||||
check_name(name);
|
||||
typename Params::const_iterator it = pj_param_find(params, name);
|
||||
typename Params::const_iterator it = pj_param_find(params, name);
|
||||
if (it != params.end())
|
||||
{
|
||||
set_value(par, *it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -226,19 +228,19 @@ template <typename T, typename Params, typename Name>
|
||||
inline bool _pj_param_r(Params const& params, Name const& name, T & par)
|
||||
{
|
||||
check_name(name);
|
||||
typename Params::const_iterator it = pj_param_find(params, name);
|
||||
typename Params::const_iterator it = pj_param_find(params, name);
|
||||
if (it != params.end())
|
||||
{
|
||||
set_value_r(par, *it);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* bool input */
|
||||
inline bool _pj_get_param_b(srs::detail::proj4_parameters const& pl, std::string const& name)
|
||||
{
|
||||
srs::detail::proj4_parameters::const_iterator it = pj_param_find(pl, name);
|
||||
srs::detail::proj4_parameters::const_iterator it = pj_param_find(pl, name);
|
||||
if (it != pl.end())
|
||||
{
|
||||
switch (it->value[0])
|
||||
@@ -251,7 +253,7 @@ inline bool _pj_get_param_b(srs::detail::proj4_parameters const& pl, std::string
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_invalid_boolean_param) );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,12 +270,12 @@ inline bool _pj_get_param_b(srs::dpar::parameters<T> const& pl, srs::dpar::name_
|
||||
/* string input */
|
||||
inline bool pj_param_s(srs::detail::proj4_parameters const& pl, std::string const& name, std::string & par)
|
||||
{
|
||||
srs::detail::proj4_parameters::const_iterator it = pj_param_find(pl, name);
|
||||
srs::detail::proj4_parameters::const_iterator it = pj_param_find(pl, name);
|
||||
if (it != pl.end())
|
||||
{
|
||||
par = it->value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -281,8 +283,8 @@ template
|
||||
<
|
||||
typename Params,
|
||||
template <typename> class IsSamePred,
|
||||
int I = srs::spar::detail::tuples_find_index_if<Params, IsSamePred>::value,
|
||||
int N = boost::tuples::length<Params>::value
|
||||
int I = geometry::tuples::find_index_if<Params, IsSamePred>::value,
|
||||
int N = geometry::tuples::size<Params>::value
|
||||
>
|
||||
struct _pj_param_x_static
|
||||
{
|
||||
@@ -291,7 +293,7 @@ struct _pj_param_x_static
|
||||
static void apply(Params const& params, T & out)
|
||||
{
|
||||
// TODO: int values could be extracted directly from the type
|
||||
out = boost::tuples::get<I>(params).value;
|
||||
out = geometry::tuples::get<I>(params).value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -309,36 +311,36 @@ struct _pj_param_x_static<Params, IsSamePred, N, N>
|
||||
{}
|
||||
};
|
||||
|
||||
template <template <int> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool _pj_param_i(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params, int & par)
|
||||
template <template <int> class Param, typename ...Ps>
|
||||
inline bool _pj_param_i(srs::spar::parameters<Ps...> const& params, int & par)
|
||||
{
|
||||
typedef _pj_param_x_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
srs::spar::detail::is_param_i<Param>::template pred
|
||||
> impl;
|
||||
impl::apply(params, par);
|
||||
return impl::result;
|
||||
}
|
||||
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename T>
|
||||
inline bool _pj_param_f(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params, T & par)
|
||||
template <template <typename> class Param, typename ...Ps, typename T>
|
||||
inline bool _pj_param_f(srs::spar::parameters<Ps...> const& params, T & par)
|
||||
{
|
||||
typedef _pj_param_x_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
srs::spar::detail::is_param_t<Param>::template pred
|
||||
> impl;
|
||||
impl::apply(params, par);
|
||||
return impl::result;
|
||||
}
|
||||
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename T>
|
||||
inline bool _pj_param_r(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params, T & par)
|
||||
template <template <typename> class Param, typename ...Ps, typename T>
|
||||
inline bool _pj_param_r(srs::spar::parameters<Ps...> const& params, T & par)
|
||||
{
|
||||
typedef _pj_param_x_static
|
||||
<
|
||||
srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX>,
|
||||
srs::spar::parameters<Ps...>,
|
||||
srs::spar::detail::is_param_t<Param>::template pred
|
||||
> impl;
|
||||
impl::apply(params, par);
|
||||
@@ -347,8 +349,8 @@ inline bool _pj_param_r(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_
|
||||
return impl::result;
|
||||
}
|
||||
|
||||
template <typename Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool _pj_get_param_b(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& params)
|
||||
template <typename Param, typename ...Ps>
|
||||
inline bool _pj_get_param_b(srs::spar::parameters<Ps...> const& params)
|
||||
{
|
||||
return pj_param_exists<Param>(params);
|
||||
}
|
||||
@@ -361,7 +363,7 @@ inline bool _pj_get_param_b(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DET
|
||||
// {
|
||||
// par = static_cast<Value>(it->template get_value<int>());
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
//}
|
||||
|
||||
@@ -454,15 +456,15 @@ inline bool pj_param_exists(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return pj_param_exists(pl, n);
|
||||
}
|
||||
template <typename Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename Name>
|
||||
inline bool pj_param_exists(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <typename Param, typename ...Ps, typename Name>
|
||||
inline bool pj_param_exists(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
Name const& )
|
||||
{
|
||||
return pj_param_exists<Param>(pl);
|
||||
}
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename Name>
|
||||
inline bool pj_param_exists(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <template <typename> class Param, typename ...Ps, typename Name>
|
||||
inline bool pj_param_exists(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
Name const& )
|
||||
{
|
||||
@@ -483,8 +485,8 @@ inline bool pj_get_param_b(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_get_param_b(pl, n);
|
||||
}
|
||||
template <typename Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_get_param_b(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <typename Param, typename ...Ps>
|
||||
inline bool pj_get_param_b(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_be const& )
|
||||
{
|
||||
@@ -509,8 +511,8 @@ inline bool pj_param_i(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_param_i(pl, n, par);
|
||||
}
|
||||
template <template <int> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_param_i(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <template <int> class Param, typename ...Ps>
|
||||
inline bool pj_param_i(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_i const& ,
|
||||
int & par)
|
||||
@@ -534,8 +536,8 @@ inline int pj_get_param_i(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_get_param_i(pl, n);
|
||||
}
|
||||
template <template <int> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline bool pj_get_param_i(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <template <int> class Param, typename ...Ps>
|
||||
inline bool pj_get_param_i(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_i const& )
|
||||
{
|
||||
@@ -560,8 +562,8 @@ inline bool pj_param_f(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_param_f(pl, n, par);
|
||||
}
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename T>
|
||||
inline bool pj_param_f(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <template <typename> class Param, typename ...Ps, typename T>
|
||||
inline bool pj_param_f(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_f const& ,
|
||||
T & par)
|
||||
@@ -585,8 +587,8 @@ inline T pj_get_param_f(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_get_param_f<T>(pl, n);
|
||||
}
|
||||
template <typename T, template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline T pj_get_param_f(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <typename T, template <typename> class Param, typename ...Ps>
|
||||
inline T pj_get_param_f(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_f const& )
|
||||
{
|
||||
@@ -612,8 +614,8 @@ inline bool pj_param_r(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_param_r(pl, n, par);
|
||||
}
|
||||
template <template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX, typename T>
|
||||
inline bool pj_param_r(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <template <typename> class Param, typename ...Ps, typename T>
|
||||
inline bool pj_param_r(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_r const& ,
|
||||
T & par)
|
||||
@@ -637,8 +639,8 @@ inline T pj_get_param_r(srs::dpar::parameters<T> const& pl,
|
||||
{
|
||||
return _pj_get_param_r<T>(pl, n);
|
||||
}
|
||||
template <typename T, template <typename> class Param, BOOST_GEOMETRY_PROJECTIONS_DETAIL_TYPENAME_PX>
|
||||
inline T pj_get_param_r(srs::spar::parameters<BOOST_GEOMETRY_PROJECTIONS_DETAIL_PX> const& pl,
|
||||
template <typename T, template <typename> class Param, typename ...Ps>
|
||||
inline T pj_get_param_r(srs::spar::parameters<Ps...> const& pl,
|
||||
std::string const& ,
|
||||
srs::dpar::name_r const& )
|
||||
{
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
{
|
||||
|
||||
|
||||
namespace detail {
|
||||
|
||||
/* determine small q */
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
// Boost.Geometry
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
@@ -49,6 +51,7 @@
|
||||
#include <boost/geometry/srs/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/srs/projections/invalid_point.hpp>
|
||||
|
||||
#include <boost/geometry/util/condition.hpp>
|
||||
#include <boost/geometry/util/range.hpp>
|
||||
|
||||
#include <cstring>
|
||||
@@ -249,7 +252,7 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn,
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Transform Z to meters if it isn't already. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( srcdefn.vto_meter != 1.0 && dimension > 2 )
|
||||
if( BOOST_GEOMETRY_CONDITION(srcdefn.vto_meter != 1.0 && dimension > 2) )
|
||||
{
|
||||
for( std::size_t i = 0; i < point_count; i++ )
|
||||
{
|
||||
@@ -261,10 +264,10 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn,
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Transform geocentric source coordinates to lat/long. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( srcdefn.is_geocent )
|
||||
if( BOOST_GEOMETRY_CONDITION(srcdefn.is_geocent) )
|
||||
{
|
||||
// Point should be cartesian 3D (ECEF)
|
||||
if (dimension < 3)
|
||||
if ( BOOST_GEOMETRY_CONDITION(dimension < 3) )
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_geocentric) );
|
||||
//return PJD_ERR_GEOCENTRIC;
|
||||
|
||||
@@ -454,10 +457,10 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn,
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Transform destination latlong to geocentric if required. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
if( dstdefn.is_geocent )
|
||||
if( BOOST_GEOMETRY_CONDITION(dstdefn.is_geocent) )
|
||||
{
|
||||
// Point should be cartesian 3D (ECEF)
|
||||
if (dimension < 3)
|
||||
if ( BOOST_GEOMETRY_CONDITION(dimension < 3) )
|
||||
BOOST_THROW_EXCEPTION( projection_exception(error_geocentric) );
|
||||
//return PJD_ERR_GEOCENTRIC;
|
||||
|
||||
@@ -470,7 +473,7 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn,
|
||||
result = false;
|
||||
else
|
||||
BOOST_THROW_EXCEPTION( projection_exception(err) );
|
||||
|
||||
|
||||
if( dstdefn.fr_meter != 1.0 )
|
||||
{
|
||||
for( std::size_t i = 0; i < point_count; i++ )
|
||||
@@ -569,7 +572,7 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn,
|
||||
{
|
||||
point_type & point = range::at(range, i);
|
||||
coord_t x = get_as_radian<0>(point);
|
||||
|
||||
|
||||
if( is_invalid_point(point) )
|
||||
continue;
|
||||
|
||||
@@ -770,7 +773,7 @@ inline int pj_geocentric_to_wgs84( Par const& defn,
|
||||
for(std::size_t i = 0; i < point_count; i++ )
|
||||
{
|
||||
point_type & point = range::at(rng, i);
|
||||
|
||||
|
||||
if( is_invalid_point(point) )
|
||||
continue;
|
||||
|
||||
@@ -925,7 +928,7 @@ inline bool pj_datum_transform(Par const& srcdefn,
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Create a temporary Z array if one is not provided. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
|
||||
range_wrapper<Range> z_range(range);
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
@@ -54,10 +54,10 @@ namespace detail
|
||||
{
|
||||
static const int static_size = 20;
|
||||
|
||||
int nb;
|
||||
T es;
|
||||
T E;
|
||||
T b[static_size];
|
||||
int nb;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2017, 2018.
|
||||
// Modifications copyright (c) 2017-2018, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2017-2020.
|
||||
// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@@ -48,8 +48,6 @@
|
||||
#include <boost/geometry/srs/projections/constants.hpp>
|
||||
#include <boost/geometry/srs/projections/dpar.hpp>
|
||||
#include <boost/geometry/srs/projections/spar.hpp>
|
||||
#include <boost/mpl/if.hpp>
|
||||
#include <boost/type_traits/is_pod.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projections
|
||||
@@ -97,17 +95,6 @@ struct pj_consts
|
||||
|
||||
T es_orig, a_orig; /* es and a before any +proj related adjustment */
|
||||
|
||||
// C O O R D I N A T E H A N D L I N G
|
||||
|
||||
int over; /* over-range flag */
|
||||
int geoc; /* geocentric latitude flag */
|
||||
int is_latlong; /* proj=latlong ... not really a projection at all */
|
||||
int is_geocent; /* proj=geocent ... not really a projection at all */
|
||||
//int need_ellps; /* 0 for operations that are purely cartesian */
|
||||
|
||||
//enum pj_io_units left; /* Flags for input/output coordinate types */
|
||||
//enum pj_io_units right;
|
||||
|
||||
// C A R T O G R A P H I C O F F S E T S
|
||||
|
||||
T lam0, phi0; /* central longitude, latitude */
|
||||
@@ -119,29 +106,46 @@ struct pj_consts
|
||||
T to_meter, fr_meter; /* cartesian scaling */
|
||||
T vto_meter, vfr_meter; /* Vertical scaling. Internal unit [m] */
|
||||
|
||||
// D A T U M S A N D H E I G H T S Y S T E M S
|
||||
|
||||
detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
|
||||
srs::detail::towgs84<T> datum_params; /* Parameters for 3PARAM and 7PARAM */
|
||||
srs::detail::nadgrids nadgrids; /* Names of horozontal grid files. */
|
||||
// D A T U M S A N D H E I G H T S Y S T E M S
|
||||
|
||||
T from_greenwich; /* prime meridian offset (in radians) */
|
||||
T long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
|
||||
|
||||
srs::detail::towgs84<T> datum_params; /* Parameters for 3PARAM and 7PARAM */
|
||||
srs::detail::nadgrids nadgrids; /* Names of horozontal grid files. */
|
||||
detail::datum_type datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
|
||||
|
||||
bool is_long_wrap_set;
|
||||
|
||||
// C O O R D I N A T E H A N D L I N G
|
||||
|
||||
bool over; /* over-range flag */
|
||||
bool geoc; /* geocentric latitude flag */
|
||||
bool is_latlong; /* proj=latlong ... not really a projection at all */
|
||||
bool is_geocent; /* proj=geocent ... not really a projection at all */
|
||||
//bool need_ellps; /* 0 for operations that are purely cartesian */
|
||||
|
||||
//enum pj_io_units left; /* Flags for input/output coordinate types */
|
||||
//enum pj_io_units right;
|
||||
|
||||
srs::detail::axis axis;
|
||||
srs::detail::axis sign;
|
||||
|
||||
// Initialize all variables
|
||||
pj_consts()
|
||||
: a(0), ra(0)
|
||||
, e(0), es(0), one_es(0), rone_es(0)
|
||||
, es_orig(0), a_orig(0)
|
||||
, over(0), geoc(0), is_latlong(0), is_geocent(0)
|
||||
//, need_ellps(1)
|
||||
//, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC)
|
||||
, lam0(0), phi0(0)
|
||||
, x0(0), y0(0)/*, z0(0), t0(0)*/
|
||||
, k0(0) , to_meter(0), fr_meter(0), vto_meter(0), vfr_meter(0)
|
||||
, from_greenwich(0), long_wrap_center(0)
|
||||
, datum_type(datum_unknown)
|
||||
, from_greenwich(0), long_wrap_center(0), is_long_wrap_set(false)
|
||||
, is_long_wrap_set(false)
|
||||
, over(false), geoc(false), is_latlong(false), is_geocent(false)
|
||||
, axis(0,1,2), sign(1,1,1) //the default east, northing, elevation
|
||||
//, need_ellps(true)
|
||||
//, left(PJ_IO_UNITS_ANGULAR), right(PJ_IO_UNITS_CLASSIC)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user