srs_transformer.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // This file was modified by Oracle on 2017.
  4. // Modifications copyright (c) 2017, Oracle and/or its affiliates.
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Use, modification and distribution is subject to the Boost Software License,
  7. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_GEOMETRY_STRATEGIES_TRANSFORM_SRS_TRANSFORMER_HPP
  10. #define BOOST_GEOMETRY_STRATEGIES_TRANSFORM_SRS_TRANSFORMER_HPP
  11. namespace boost { namespace geometry
  12. {
  13. namespace strategy { namespace transform
  14. {
  15. /*!
  16. \brief Transformation strategy to do transform using a forward
  17. Map Projection or SRS transformation.
  18. \ingroup transform
  19. \tparam ProjectionOrTransformation SRS projection or transformation type
  20. */
  21. template
  22. <
  23. typename ProjectionOrTransformation
  24. >
  25. class srs_forward_transformer
  26. {
  27. public:
  28. inline srs_forward_transformer()
  29. {}
  30. template <typename Parameters>
  31. inline srs_forward_transformer(Parameters const& parameters)
  32. : m_proj_or_transform(parameters)
  33. {}
  34. template <typename Parameters1, typename Parameters2>
  35. inline srs_forward_transformer(Parameters1 const& parameters1, Parameters2 const& parameters2)
  36. : m_proj_or_transform(parameters1, parameters2)
  37. {}
  38. template <typename Geometry1, typename Geometry2>
  39. inline bool apply(Geometry1 const& g1, Geometry2 & g2) const
  40. {
  41. return m_proj_or_transform.forward(g1, g2);
  42. }
  43. private:
  44. ProjectionOrTransformation m_proj_or_transform;
  45. };
  46. /*!
  47. \brief Transformation strategy to do transform using an inverse
  48. Map Projection or SRS transformation.
  49. \ingroup transform
  50. \tparam ProjectionOrTransformation SRS projection or transformation type
  51. */
  52. template
  53. <
  54. typename ProjectionOrTransformation
  55. >
  56. class srs_inverse_transformer
  57. {
  58. public:
  59. inline srs_inverse_transformer()
  60. {}
  61. template <typename Parameters>
  62. inline srs_inverse_transformer(Parameters const& parameters)
  63. : m_proj_or_transform(parameters)
  64. {}
  65. template <typename Parameters1, typename Parameters2>
  66. inline srs_inverse_transformer(Parameters1 const& parameters1, Parameters2 const& parameters2)
  67. : m_proj_or_transform(parameters1, parameters2)
  68. {}
  69. template <typename Geometry1, typename Geometry2>
  70. inline bool apply(Geometry1 const& g1, Geometry2 & g2) const
  71. {
  72. return m_proj_or_transform.inverse(g1, g2);
  73. }
  74. private:
  75. ProjectionOrTransformation m_proj_or_transform;
  76. };
  77. }} // namespace strategy::transform
  78. }} // namespace boost::geometry
  79. #endif // BOOST_GEOMETRY_STRATEGIES_TRANSFORM_SRS_TRANSFORMER_HPP