Skip to content

Commit df04b36

Browse files
Fixed Writing 3D WKT:Z prefix
1 parent bb0f00e commit df04b36

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

example/01_point_example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int main()
129129
assign_values(d3a, 1, 2, 3);
130130
assign_values(d3b, 4, 5, 6);
131131
d3 = distance(d3a, d3b);
132-
132+
std::cout << wkt(d3a) << std::endl;
133133

134134

135135
// Other examples show other types of points, geometries and more algorithms

include/boost/geometry/io/wkt/detail/prefix.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ struct prefix_point
3232
static inline const char* apply() { return "POINT"; }
3333
};
3434

35+
struct prefix_point_z
36+
{
37+
static inline const char* apply() { return "POINT Z"; }
38+
};
39+
3540
struct prefix_polygon
3641
{
3742
static inline const char* apply() { return "POLYGON"; }

include/boost/geometry/io/wkt/write.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ struct double_closing_parenthesis
113113
/*!
114114
\brief Stream points as \ref WKT
115115
*/
116-
template <typename Point, typename Policy>
116+
template <typename Point, typename Policy1, typename Policy2>
117117
struct wkt_point
118118
{
119119
template <typename Char, typename Traits>
120120
static inline void apply(std::basic_ostream<Char, Traits>& os, Point const& p, bool)
121121
{
122-
os << Policy::apply() << "(";
122+
if(dimension<Point>::type::value == 3) os << Policy2::apply() << "(";
123+
else os << Policy1::apply() << "(";
123124
stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p);
124125
os << ")";
125126
}
@@ -350,7 +351,8 @@ struct wkt<Point, point_tag>
350351
: detail::wkt::wkt_point
351352
<
352353
Point,
353-
detail::wkt::prefix_point
354+
detail::wkt::prefix_point,
355+
detail::wkt::prefix_point_z
354356
>
355357
{};
356358

@@ -417,6 +419,7 @@ struct wkt<Multi, multi_point_tag>
417419
detail::wkt::wkt_point
418420
<
419421
typename boost::range_value<Multi>::type,
422+
detail::wkt::prefix_null,
420423
detail::wkt::prefix_null
421424
>,
422425
detail::wkt::prefix_multipoint

0 commit comments

Comments
 (0)