write.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP
  11. #define BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP
  12. #include <boost/geometry/multi/core/tags.hpp>
  13. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  14. #include <boost/geometry/multi/io/wkt/detail/prefix.hpp>
  15. #include <boost/geometry/io/wkt/write.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail { namespace wkt
  20. {
  21. template <typename Multi, typename StreamPolicy, typename PrefixPolicy>
  22. struct wkt_multi
  23. {
  24. template <typename Char, typename Traits>
  25. static inline void apply(std::basic_ostream<Char, Traits>& os,
  26. Multi const& geometry)
  27. {
  28. os << PrefixPolicy::apply();
  29. // TODO: check EMPTY here
  30. os << "(";
  31. for (typename boost::range_iterator<Multi const>::type
  32. it = boost::begin(geometry);
  33. it != boost::end(geometry);
  34. ++it)
  35. {
  36. if (it != boost::begin(geometry))
  37. {
  38. os << ",";
  39. }
  40. StreamPolicy::apply(os, *it);
  41. }
  42. os << ")";
  43. }
  44. };
  45. }} // namespace wkt::impl
  46. #endif
  47. #ifndef DOXYGEN_NO_DISPATCH
  48. namespace dispatch
  49. {
  50. template <typename Multi>
  51. struct wkt<Multi, multi_point_tag>
  52. : detail::wkt::wkt_multi
  53. <
  54. Multi,
  55. detail::wkt::wkt_point
  56. <
  57. typename boost::range_value<Multi>::type,
  58. detail::wkt::prefix_null
  59. >,
  60. detail::wkt::prefix_multipoint
  61. >
  62. {};
  63. template <typename Multi>
  64. struct wkt<Multi, multi_linestring_tag>
  65. : detail::wkt::wkt_multi
  66. <
  67. Multi,
  68. detail::wkt::wkt_sequence
  69. <
  70. typename boost::range_value<Multi>::type
  71. >,
  72. detail::wkt::prefix_multilinestring
  73. >
  74. {};
  75. template <typename Multi>
  76. struct wkt<Multi, multi_polygon_tag>
  77. : detail::wkt::wkt_multi
  78. <
  79. Multi,
  80. detail::wkt::wkt_poly
  81. <
  82. typename boost::range_value<Multi>::type,
  83. detail::wkt::prefix_null
  84. >,
  85. detail::wkt::prefix_multipolygon
  86. >
  87. {};
  88. } // namespace dispatch
  89. #endif
  90. }} // namespace boost::geometry
  91. #endif // BOOST_GEOMETRY_MULTI_IO_WKT_WRITE_HPP