pretty_print_geometry.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Tests
  3. // Copyright (c) 2014, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_GEOMETRY_TEST_PRETTY_PRINT_GEOMETRY_HPP
  8. #define BOOST_GEOMETRY_TEST_PRETTY_PRINT_GEOMETRY_HPP
  9. #include <iostream>
  10. #include <boost/geometry/core/tag.hpp>
  11. #include <boost/geometry/core/tags.hpp>
  12. #include <boost/geometry/io/dsv/write.hpp>
  13. #include <boost/geometry/io/wkt/write.hpp>
  14. template
  15. <
  16. typename Geometry,
  17. typename Tag = typename boost::geometry::tag<Geometry>::type
  18. >
  19. struct pretty_print_geometry
  20. {
  21. static inline std::ostream&
  22. apply(std::ostream& os, Geometry const& geometry)
  23. {
  24. os << boost::geometry::wkt(geometry);
  25. return os;
  26. }
  27. };
  28. template <typename Box>
  29. struct pretty_print_geometry<Box, boost::geometry::box_tag>
  30. {
  31. static inline std::ostream&
  32. apply(std::ostream& os, Box const& box)
  33. {
  34. return os << "BOX" << boost::geometry::dsv(box);
  35. }
  36. };
  37. template <typename Segment>
  38. struct pretty_print_geometry<Segment, boost::geometry::segment_tag>
  39. {
  40. static inline std::ostream&
  41. apply(std::ostream& os, Segment const& segment)
  42. {
  43. return os << "SEGMENT" << boost::geometry::dsv(segment);
  44. }
  45. };
  46. template <typename Ring>
  47. struct pretty_print_geometry<Ring, boost::geometry::ring_tag>
  48. {
  49. static inline std::ostream&
  50. apply(std::ostream& os, Ring const& ring)
  51. {
  52. return os << "RING" << boost::geometry::dsv(ring);
  53. }
  54. };
  55. #endif // BOOST_GEOMETRY_TEST_PRETTY_PRINT_GEOMETRY_HPP