/Src/Dependencies/Boost/libs/geometry/test/multi/algorithms/multi_transform.cpp

http://hadesmem.googlecode.com/ · C++ · 97 lines · 65 code · 19 blank · 13 comment · 0 complexity · 3469674d9b5cc8cca94404f924cd9212 MD5 · raw file

  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Copyright (c) 2008-2011 Bruno Lalande, Paris, France.
  5. // Copyright (c) 2009-2011 Mateusz Loskot, London, UK.
  6. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  7. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  8. // Use, modification and distribution is subject to the Boost Software License,
  9. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  10. // http://www.boost.org/LICENSE_1_0.txt)
  11. #include <iostream>
  12. #include <sstream>
  13. #include <geometry_test_common.hpp>
  14. #include <boost/geometry/algorithms/transform.hpp>
  15. #include <boost/geometry/strategies/strategies.hpp>
  16. #include <boost/geometry/geometries/geometries.hpp>
  17. #include <boost/geometry/geometries/point_xy.hpp>
  18. #include <boost/geometry/multi/algorithms/transform.hpp>
  19. #include <boost/geometry/multi/geometries/multi_point.hpp>
  20. #include <boost/geometry/multi/geometries/multi_linestring.hpp>
  21. #include <boost/geometry/multi/geometries/multi_polygon.hpp>
  22. #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
  23. #include <boost/geometry/domains/gis/io/wkt/read_wkt_multi.hpp>
  24. // This test is a little different from transform.cpp test.
  25. // This test explicitly tests all geometries, including multi*
  26. // while the transform.cpp tests various strategies.
  27. template <typename Geometry>
  28. void test_transform(std::string const& wkt, std::string const& expected)
  29. {
  30. typedef typename bg::point_type<Geometry>::type point_type;
  31. Geometry geometry_in, geometry_out;
  32. bg::read_wkt(wkt, geometry_in);
  33. bg::transform(geometry_in, geometry_out,
  34. bg::strategy::transform::scale_transformer<point_type>(2, 2));
  35. std::ostringstream detected;
  36. detected << bg::wkt(geometry_out);
  37. BOOST_CHECK_EQUAL(detected.str(), expected);
  38. }
  39. template <typename T>
  40. void test_all()
  41. {
  42. typedef bg::model::d2::point_xy<T> P;
  43. test_transform<P>(
  44. "POINT(1 1)",
  45. "POINT(2 2)");
  46. test_transform<bg::model::linestring<P> >(
  47. "LINESTRING(1 1,2 2)",
  48. "LINESTRING(2 2,4 4)");
  49. test_transform<bg::model::segment<P> >(
  50. "LINESTRING(1 1,2 2)",
  51. "LINESTRING(2 2,4 4)");
  52. test_transform<bg::model::ring<P> >(
  53. "POLYGON((0 0,0 1,1 0,0 0))",
  54. "POLYGON((0 0,0 2,2 0,0 0))");
  55. test_transform<bg::model::polygon<P> >(
  56. "POLYGON((0 0,0 1,1 0,0 0))",
  57. "POLYGON((0 0,0 2,2 0,0 0))");
  58. test_transform<bg::model::box<P> >(
  59. "POLYGON((0 0,0 1,1 1,1 0,0 0))",
  60. "POLYGON((0 0,0 2,2 2,2 0,0 0))");
  61. test_transform<bg::model::multi_point<P> >(
  62. "MULTIPOINT((1 1),(2 2))",
  63. "MULTIPOINT((2 2),(4 4))");
  64. test_transform<bg::model::multi_linestring<bg::model::linestring<P> > >(
  65. "MULTILINESTRING((1 1,2 2))",
  66. "MULTILINESTRING((2 2,4 4))");
  67. test_transform<bg::model::multi_polygon<bg::model::polygon<P> > >(
  68. "MULTIPOLYGON(((0 0,0 1,1 0,0 0)))",
  69. "MULTIPOLYGON(((0 0,0 2,2 0,0 0)))");
  70. }
  71. int test_main(int, char* [])
  72. {
  73. test_all<double>();
  74. #ifdef HAVE_TTMATH
  75. test_all<ttmath_big>();
  76. #endif
  77. return 0;
  78. }