1 #pragma once
2
3 #include <mapbox/geometry/empty.hpp>
4 #include <mapbox/feature.hpp>
5
6 #include <iostream>
7 #include <string>
8
9 namespace mapbox {
10 namespace geometry {
11
operator <<(std::ostream & os,const empty &)12 std::ostream& operator<<(std::ostream& os, const empty&)
13 {
14 return os << "[]";
15 }
16
17 template <typename T>
operator <<(std::ostream & os,const point<T> & point)18 std::ostream& operator<<(std::ostream& os, const point<T>& point)
19 {
20 return os << "[" << point.x << "," << point.y << "]";
21 }
22
23 template <typename T, template <class, class...> class C, class... Args>
operator <<(std::ostream & os,const C<T,Args...> & cont)24 std::ostream& operator<<(std::ostream& os, const C<T, Args...>& cont)
25 {
26 os << "[";
27 for (auto it = cont.cbegin();;)
28 {
29 os << *it;
30 if (++it == cont.cend())
31 {
32 break;
33 }
34 os << ",";
35 }
36 return os << "]";
37 }
38
39 template <typename T>
operator <<(std::ostream & os,const line_string<T> & geom)40 std::ostream& operator<<(std::ostream& os, const line_string<T>& geom)
41 {
42 return os << static_cast<typename line_string<T>::container_type>(geom);
43 }
44
45 template <typename T>
operator <<(std::ostream & os,const linear_ring<T> & geom)46 std::ostream& operator<<(std::ostream& os, const linear_ring<T>& geom)
47 {
48 return os << static_cast<typename linear_ring<T>::container_type>(geom);
49 }
50
51 template <typename T>
operator <<(std::ostream & os,const polygon<T> & geom)52 std::ostream& operator<<(std::ostream& os, const polygon<T>& geom)
53 {
54 return os << static_cast<typename polygon<T>::container_type>(geom);
55 }
56
57 template <typename T>
operator <<(std::ostream & os,const multi_point<T> & geom)58 std::ostream& operator<<(std::ostream& os, const multi_point<T>& geom)
59 {
60 return os << static_cast<typename multi_point<T>::container_type>(geom);
61 }
62
63 template <typename T>
operator <<(std::ostream & os,const multi_line_string<T> & geom)64 std::ostream& operator<<(std::ostream& os, const multi_line_string<T>& geom)
65 {
66 return os << static_cast<typename multi_line_string<T>::container_type>(geom);
67 }
68
69 template <typename T>
operator <<(std::ostream & os,const multi_polygon<T> & geom)70 std::ostream& operator<<(std::ostream& os, const multi_polygon<T>& geom)
71 {
72 return os << static_cast<typename multi_polygon<T>::container_type>(geom);
73 }
74
75 template <typename T>
operator <<(std::ostream & os,const geometry<T> & geom)76 std::ostream& operator<<(std::ostream& os, const geometry<T>& geom)
77 {
78 geometry<T>::visit(geom, [&](const auto& g) { os << g; });
79 return os;
80 }
81
82 template <typename T>
operator <<(std::ostream & os,const geometry_collection<T> & geom)83 std::ostream& operator<<(std::ostream& os, const geometry_collection<T>& geom)
84 {
85 return os << static_cast<typename geometry_collection<T>::container_type>(geom);
86 }
87
88 } // namespace geometry
89
90 namespace feature {
91
operator <<(std::ostream & os,const null_value_t &)92 std::ostream& operator<<(std::ostream& os, const null_value_t&)
93 {
94 return os << "[]";
95 }
96
97 } // namespace feature
98 } // namespace mapbox
99