Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/geometry/io/wkt/write.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/geometry/io/wkt/write.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/geometry/io/wkt/write.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -3,6 +3,7 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. +// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -19,23 +20,26 @@ #include <boost/array.hpp> #include <boost/range.hpp> -#include <boost/typeof/typeof.hpp> +#include <boost/variant/apply_visitor.hpp> +#include <boost/variant/static_visitor.hpp> +#include <boost/variant/variant_fwd.hpp> + +#include <boost/geometry/algorithms/detail/interior_iterator.hpp> #include <boost/geometry/algorithms/assign.hpp> #include <boost/geometry/algorithms/convert.hpp> +#include <boost/geometry/algorithms/disjoint.hpp> #include <boost/geometry/algorithms/not_implemented.hpp> #include <boost/geometry/core/exterior_ring.hpp> #include <boost/geometry/core/interior_rings.hpp> #include <boost/geometry/core/ring_type.hpp> +#include <boost/geometry/core/tags.hpp> #include <boost/geometry/geometries/concepts/check.hpp> #include <boost/geometry/geometries/ring.hpp> #include <boost/geometry/io/wkt/detail/prefix.hpp> -#include <boost/variant/apply_visitor.hpp> -#include <boost/variant/static_visitor.hpp> -#include <boost/variant/variant_fwd.hpp> namespace boost { namespace geometry { @@ -119,31 +123,49 @@ { template <typename Char, typename Traits> static inline void apply(std::basic_ostream<Char, Traits>& os, - Range const& range) + Range const& range, bool force_closed) { typedef typename boost::range_iterator<Range const>::type iterator_type; + typedef stream_coordinate + < + point_type, 0, dimension<point_type>::type::value + > stream_type; + bool first = true; os << PrefixPolicy::apply(); // TODO: check EMPTY here - for (iterator_type it = boost::begin(range); - it != boost::end(range); - ++it) + iterator_type begin = boost::begin(range); + iterator_type end = boost::end(range); + for (iterator_type it = begin; it != end; ++it) { os << (first ? "" : ","); - stream_coordinate - < - point_type, 0, dimension<point_type>::type::value - >::apply(os, *it); + stream_type::apply(os, *it); first = false; } + // optionally, close range to ring by repeating the first point + if (force_closed + && boost::size(range) > 1 + && geometry::disjoint(*begin, *(end - 1))) + { + os << ","; + stream_type::apply(os, *begin); + } + os << SuffixPolicy::apply(); } + template <typename Char, typename Traits> + static inline void apply(std::basic_ostream<Char, Traits>& os, + Range const& range) + { + apply(os, range, false); + } + private: typedef typename boost::range_value<Range>::type point_type; }; @@ -170,23 +192,52 @@ Polygon const& poly) { typedef typename ring_type<Polygon const>::type ring; + bool const force_closed = true; os << PrefixPolicy::apply(); // TODO: check EMPTY here os << "("; - wkt_sequence<ring>::apply(os, exterior_ring(poly)); + wkt_sequence<ring>::apply(os, exterior_ring(poly), force_closed); - typename interior_return_type<Polygon const>::type rings - = interior_rings(poly); - for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) + typename interior_return_type<Polygon const>::type + rings = interior_rings(poly); + for (typename detail::interior_iterator<Polygon const>::type + it = boost::begin(rings); it != boost::end(rings); ++it) { os << ","; - wkt_sequence<ring>::apply(os, *it); + wkt_sequence<ring>::apply(os, *it, force_closed); } os << ")"; } }; +template <typename Multi, typename StreamPolicy, typename PrefixPolicy> +struct wkt_multi +{ + template <typename Char, typename Traits> + static inline void apply(std::basic_ostream<Char, Traits>& os, + Multi const& geometry) + { + os << PrefixPolicy::apply(); + // TODO: check EMPTY here + os << "("; + + for (typename boost::range_iterator<Multi const>::type + it = boost::begin(geometry); + it != boost::end(geometry); + ++it) + { + if (it != boost::begin(geometry)) + { + os << ","; + } + StreamPolicy::apply(os, *it); + } + + os << ")"; + } +}; + template <typename Box> struct wkt_box { @@ -316,6 +367,47 @@ > {}; +template <typename Multi> +struct wkt<Multi, multi_point_tag> + : detail::wkt::wkt_multi + < + Multi, + detail::wkt::wkt_point + < + typename boost::range_value<Multi>::type, + detail::wkt::prefix_null + >, + detail::wkt::prefix_multipoint + > +{}; + +template <typename Multi> +struct wkt<Multi, multi_linestring_tag> + : detail::wkt::wkt_multi + < + Multi, + detail::wkt::wkt_sequence + < + typename boost::range_value<Multi>::type + >, + detail::wkt::prefix_multilinestring + > +{}; + +template <typename Multi> +struct wkt<Multi, multi_polygon_tag> + : detail::wkt::wkt_multi + < + Multi, + detail::wkt::wkt_poly + < + typename boost::range_value<Multi>::type, + detail::wkt::prefix_null + >, + detail::wkt::prefix_multipolygon + > +{}; + template <typename Geometry> struct devarianted_wkt @@ -396,13 +488,10 @@ /*! \brief Main WKT-streaming function +\tparam Geometry \tparam_geometry +\param geometry \param_geometry \ingroup wkt -\par Example: -Small example showing how to use the wkt helper function -\dontinclude doxygen_1.cpp -\skip example_as_wkt_vector -\line { -\until } +\qbk{[include reference/io/wkt.qbk]} */ template <typename Geometry> inline wkt_manipulator<Geometry> wkt(Geometry const& geometry)