Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r61739 - in sandbox/geometry: boost/geometry/iterators boost/geometry/strategies/transform libs/geometry/test/extensions/algorithms libs/geometry/test/extensions/gis/latlong libs/geometry/test/extensions/gis/projections libs/geometry/test/iterators libs/geometry/test/multi/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-05-02 17:38:14


Author: barendgehrels
Date: 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
New Revision: 61739
URL: http://svn.boost.org/trac/boost/changeset/61739

Log:
Implemented circular_iterator to reverse also backwards
Reversed const std::string -> std::string const for consistency
Default mirror tempate argument for map transformer
Set embed manifest to false because of after-link errors, sometimes but not always, on VC2005 / Win7 / 64 bits
Text files modified:
   sandbox/geometry/boost/geometry/iterators/circular_iterator.hpp | 24 ++++++++
   sandbox/geometry/boost/geometry/iterators/ever_circling_iterator.hpp | 2
   sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp | 2
   sandbox/geometry/libs/geometry/test/extensions/algorithms/midpoints.cpp | 4
   sandbox/geometry/libs/geometry/test/extensions/algorithms/selected.cpp | 4
   sandbox/geometry/libs/geometry/test/extensions/gis/latlong/parse_dms.cpp | 12 ++--
   sandbox/geometry/libs/geometry/test/extensions/gis/projections/projection.cpp | 2
   sandbox/geometry/libs/geometry/test/extensions/gis/projections/projections.cpp | 4
   sandbox/geometry/libs/geometry/test/iterators/circular_iterator.cpp | 114 +++++++++++++++++++++------------------
   sandbox/geometry/libs/geometry/test/iterators/circular_iterator.vcproj | 2
   sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.cpp | 2
   sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.vcproj | 2
   sandbox/geometry/libs/geometry/test/iterators/segment_iterator.cpp | 2
   sandbox/geometry/libs/geometry/test/iterators/segment_iterator.vcproj | 2
   sandbox/geometry/libs/geometry/test/multi/algorithms/multi_distance.cpp | 6 +-
   15 files changed, 110 insertions(+), 74 deletions(-)

Modified: sandbox/geometry/boost/geometry/iterators/circular_iterator.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/iterators/circular_iterator.hpp (original)
+++ sandbox/geometry/boost/geometry/iterators/circular_iterator.hpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -15,6 +15,7 @@
 
 #include <boost/geometry/iterators/base.hpp>
 
+
 namespace boost { namespace geometry
 {
 
@@ -68,6 +69,27 @@
             check_end();
         }
     }
+ inline void decrement()
+ {
+ if (this->base() != m_end)
+ {
+ // If at begin, go back to end (assumed this is possible...)
+ if (this->base() == m_begin)
+ {
+ this->base_reference() = this->m_end;
+ }
+
+ // Decrement
+ (this->base_reference())--;
+
+ // If really back at start, go to end == end of iteration
+ if (this->base() == m_start)
+ {
+ this->base_reference() = this->m_end;
+ }
+ }
+ }
+
 
     inline void check_end()
     {
@@ -87,6 +109,8 @@
     Iterator m_start;
 };
 
+
 }} // namespace boost::geometry
 
+
 #endif // BOOST_GEOMETRY_ITERATORS_CIRCULAR_ITERATOR_HPP

Modified: sandbox/geometry/boost/geometry/iterators/ever_circling_iterator.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/iterators/ever_circling_iterator.hpp (original)
+++ sandbox/geometry/boost/geometry/iterators/ever_circling_iterator.hpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -56,7 +56,7 @@
         this->base_reference() = start;
     }
 
- /// Navigate to a certain position, should be in [start .. end], it at end
+ /// Navigate to a certain position, should be in [start .. end], if at end
     /// it will circle again.
     inline void moveto(Iterator it)
     {

Modified: sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -32,7 +32,7 @@
 template
 <
     typename P1, typename P2,
- bool Mirror, bool SameScale = true,
+ bool Mirror = false, bool SameScale = true,
     std::size_t Dimension1 = dimension<P1>::type::value,
     std::size_t Dimension2 = dimension<P2>::type::value
>

Modified: sandbox/geometry/libs/geometry/test/extensions/algorithms/midpoints.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/algorithms/midpoints.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/algorithms/midpoints.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -26,7 +26,7 @@
 #include <test_common/test_point.hpp>
 
 template <typename G>
-void test_midpoints(const G& g, bool start_and_end)
+void test_midpoints(G const& g, bool start_and_end)
 {
     G processed;
     boost::geometry::midpoints(g, start_and_end, std::back_inserter(processed));
@@ -34,7 +34,7 @@
 }
 
 template <typename G>
-void test_midpoints(const std::string& wkt)
+void test_midpoints(std::string const& wkt)
 {
     G g;
     boost::geometry::read_wkt(wkt, g);

Modified: sandbox/geometry/libs/geometry/test/extensions/algorithms/selected.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/algorithms/selected.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/algorithms/selected.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -23,14 +23,14 @@
 #include <test_common/test_point.hpp>
 
 template <typename G, typename P>
-void test_selected(const G& g, const P& point, bool result, double dist)
+void test_selected(G const& g, P const& point, bool result, double dist)
 {
     bool sel = boost::geometry::selected(g, point, dist);
     BOOST_CHECK_EQUAL(sel, result);
 }
 
 template <typename G, typename P>
-void test_selected(const std::string& wkt, const P& point, bool result, double dist)
+void test_selected(std::string const& wkt, P const& point, bool result, double dist)
 {
     G g;
     boost::geometry::read_wkt(wkt, g);

Modified: sandbox/geometry/libs/geometry/test/extensions/gis/latlong/parse_dms.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/gis/latlong/parse_dms.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/gis/latlong/parse_dms.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -16,36 +16,36 @@
 
 
 
-void check(const boost::geometry::dms_result& r, double v, int axis)
+void check(boost::geometry::dms_result const& r, double v, int axis)
 {
- const double d = r;
+ double const d = r;
     BOOST_CHECK_CLOSE(d, v, 0.0001);
     BOOST_CHECK(int(r.axis()) == axis);
 }
 
 template <bool as_radian>
-void test_dms(const std::string& s, double v, int axis)
+void test_dms(std::string const& s, double v, int axis)
 {
     boost::geometry::strategy::dms_parser<as_radian> parser;
     check(parser(s.c_str()), v, axis);
 }
 
 template <bool as_radian>
-void test_dms_french(const std::string& s, double v, int axis)
+void test_dms_french(std::string const& s, double v, int axis)
 {
     boost::geometry::strategy::dms_parser<as_radian, 'N', 'E', 'S', 'O'> parser;
     check(parser(s.c_str()), v, axis);
 }
 
 template <bool as_radian>
-void test_dms_dutch(const std::string& s, double v, int axis)
+void test_dms_dutch(std::string const& s, double v, int axis)
 {
     boost::geometry::strategy::dms_parser<as_radian, 'N', 'O', 'Z', 'W'> parser;
     check(parser(s.c_str()), v, axis);
 }
 
 template <bool as_radian>
-void test_dms_case(const std::string& s, double v, int axis)
+void test_dms_case(std::string const& s, double v, int axis)
 {
     boost::geometry::strategy::dms_parser<as_radian, 'n', 'e', 's', 'w'> parser;
     check(parser(s.c_str()), v, axis);

Modified: sandbox/geometry/libs/geometry/test/extensions/gis/projections/projection.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/gis/projections/projection.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/gis/projections/projection.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -33,7 +33,7 @@
 void test_one(double lon, double lat,
               typename boost::geometry::coordinate_type<P2>::type x,
               typename boost::geometry::coordinate_type<P2>::type y,
- const std::string& parameters)
+ std::string const& parameters)
 {
     boost::geometry::projection::parameters par = boost::geometry::projection::detail::pj_init_plus(parameters);
     Prj prj(par);

Modified: sandbox/geometry/libs/geometry/test/extensions/gis/projections/projections.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/gis/projections/projections.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/gis/projections/projections.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -47,7 +47,7 @@
               double lon, double lat,
               typename boost::geometry::coordinate_type<P>::type x,
               typename boost::geometry::coordinate_type<P>::type y,
- const std::string& parameters)
+ std::string const& parameters)
 {
     typedef typename boost::geometry::coordinate_type<P>::type coord_type;
     typedef boost::geometry::point_ll<coord_type, boost::geometry::cs::geographic<boost::geometry::degree> > lonlat_type;
@@ -75,7 +75,7 @@
               typename boost::geometry::coordinate_type<P>::type x,
               typename boost::geometry::coordinate_type<P>::type y,
               double lon, double lat,
- const std::string& parameters)
+ std::string const& parameters)
 {
     typedef typename boost::geometry::coordinate_type<P>::type coord_type;
     typedef boost::geometry::point_ll<coord_type, boost::geometry::cs::geographic<boost::geometry::degree> > lonlat_type;

Modified: sandbox/geometry/libs/geometry/test/iterators/circular_iterator.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/circular_iterator.cpp (original)
+++ sandbox/geometry/libs/geometry/test/iterators/circular_iterator.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -19,80 +19,86 @@
 #include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
 #include <boost/geometry/geometries/cartesian2d.hpp>
 
-template <typename G>
-void test_geometry(const std::string& wkt)
-{
- G geo;
- boost::geometry::read_wkt(wkt, geo);
- typedef typename boost::range_const_iterator<G>::type normal_iterator;
- typedef boost::geometry::circular_iterator<normal_iterator> circular_iterator;
 
- circular_iterator end(boost::end(geo));
+template <typename Geometry, typename CircularIterator>
+void test_forward(Geometry const& geometry, CircularIterator end,
+ int offset, std::string const& expected)
+{
+ CircularIterator it(boost::begin(geometry), boost::end(geometry),
+ boost::begin(geometry) + offset);
 
+ std::ostringstream out;
+ for (; it != end; ++it)
     {
- // 1: normal start position
- normal_iterator start = boost::begin(geo);
-
- std::ostringstream out;
- for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
- it != end; ++it)
- {
- out << boost::geometry::get<0>(*it);
- }
- BOOST_CHECK_EQUAL(out.str(), "12345");
+ out << boost::geometry::get<0>(*it);
     }
+ BOOST_CHECK_EQUAL(out.str(), expected);
+}
 
- {
- // 2: start somewhere in the middle
- normal_iterator start = boost::begin(geo) + 2;
 
- std::ostringstream out;
- for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
- it != end; ++it)
- {
- out << boost::geometry::get<0>(*it);
- }
- BOOST_CHECK_EQUAL(out.str(), "34512");
- }
+template <typename Geometry, typename CircularIterator>
+void test_backward(Geometry const& geometry, CircularIterator end,
+ int offset, std::string const& expected)
+{
+ CircularIterator it(boost::begin(geometry), boost::end(geometry),
+ boost::begin(geometry) + offset);
 
+ std::ostringstream out;
+ for (; it != end; --it)
     {
- // 3: start at end position
- normal_iterator start = boost::begin(geo) + boost::size(geo) - 1;
-
- std::ostringstream out;
- for (circular_iterator it(boost::begin(geo), boost::end(geo), start);
- it != end; ++it)
- {
- out << boost::geometry::get<0>(*it);
- }
- BOOST_CHECK_EQUAL(out.str(), "51234");
+ out << boost::geometry::get<0>(*it);
     }
+ BOOST_CHECK_EQUAL(out.str(), expected);
+}
+
 
- {
- // 4: check copy behaviour
- G copy;
 
- {
- normal_iterator start = boost::begin(geo) + 2;
- circular_iterator it(boost::begin(geo), boost::end(geo), start);
- std::copy<circular_iterator>(it, end, std::back_inserter(copy));
- }
-
- std::ostringstream out;
- for (normal_iterator cit = boost::begin(copy); cit != boost::end(copy); ++cit)
- {
- out << boost::geometry::get<0>(*cit);
- }
- BOOST_CHECK_EQUAL(out.str(), "34512");
+template <typename G>
+void test_geometry(std::string const& wkt)
+{
+ G geo;
+ boost::geometry::read_wkt(wkt, geo);
+ typedef typename boost::range_const_iterator<G>::type normal_iterator;
+ typedef boost::geometry::circular_iterator<normal_iterator> circular_iterator;
+
+ circular_iterator end(boost::end(geo));
+
+ // 2: start somewhere in the middle (first == test before)
+ test_forward(geo, end, 0, "12345");
+ test_forward(geo, end, 1, "23451");
+ test_forward(geo, end, 2, "34512");
+ test_forward(geo, end, 3, "45123");
+ test_forward(geo, end, 4, "51234");
+
+ test_backward(geo, end, 0, "15432");
+ test_backward(geo, end, 1, "21543");
+ test_backward(geo, end, 2, "32154");
+ test_backward(geo, end, 3, "43215");
+ test_backward(geo, end, 4, "54321");
+
+ // 4: check copy behaviour
+ G copy;
+
+ normal_iterator start = boost::begin(geo) + 2;
+ circular_iterator it(boost::begin(geo), boost::end(geo), start);
+ std::copy<circular_iterator>(it, end, std::back_inserter(copy));
+
+ std::ostringstream out;
+ for (normal_iterator cit = boost::begin(copy); cit != boost::end(copy); ++cit)
+ {
+ out << boost::geometry::get<0>(*cit);
     }
+ BOOST_CHECK_EQUAL(out.str(), "34512");
 }
 
+
 template <typename P>
 void test_all()
 {
     test_geometry<boost::geometry::linestring<P> >("linestring(1 1,2 2,3 3,4 4,5 5)");
 }
 
+
 int test_main(int, char* [])
 {
     test_all<boost::geometry::point_2d>();

Modified: sandbox/geometry/libs/geometry/test/iterators/circular_iterator.vcproj
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/circular_iterator.vcproj (original)
+++ sandbox/geometry/libs/geometry/test/iterators/circular_iterator.vcproj 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -69,6 +69,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"
@@ -142,6 +143,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"

Modified: sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.cpp (original)
+++ sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -18,7 +18,7 @@
 #include <boost/geometry/geometries/cartesian2d.hpp>
 
 template <typename G>
-void test_geometry(const std::string& wkt)
+void test_geometry(std::string const& wkt)
 {
     G geo;
     boost::geometry::read_wkt(wkt, geo);

Modified: sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.vcproj
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.vcproj (original)
+++ sandbox/geometry/libs/geometry/test/iterators/ever_circling_iterator.vcproj 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -69,6 +69,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"
@@ -142,6 +143,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"

Modified: sandbox/geometry/libs/geometry/test/iterators/segment_iterator.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/segment_iterator.cpp (original)
+++ sandbox/geometry/libs/geometry/test/iterators/segment_iterator.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -23,7 +23,7 @@
 #include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
 
 template <typename C>
-void test_linestring(const std::string& wkt, const std::string& expected)
+void test_linestring(std::string const& wkt, std::string const& expected)
 {
     typedef C point_list;
     typedef typename C::value_type point;

Modified: sandbox/geometry/libs/geometry/test/iterators/segment_iterator.vcproj
==============================================================================
--- sandbox/geometry/libs/geometry/test/iterators/segment_iterator.vcproj (original)
+++ sandbox/geometry/libs/geometry/test/iterators/segment_iterator.vcproj 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -68,6 +68,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"
@@ -140,6 +141,7 @@
                         />
                         <Tool
                                 Name="VCManifestTool"
+ EmbedManifest="false"
                         />
                         <Tool
                                 Name="VCXDCMakeTool"

Modified: sandbox/geometry/libs/geometry/test/multi/algorithms/multi_distance.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/multi/algorithms/multi_distance.cpp (original)
+++ sandbox/geometry/libs/geometry/test/multi/algorithms/multi_distance.cpp 2010-05-02 17:38:12 EDT (Sun, 02 May 2010)
@@ -29,7 +29,7 @@
 
 
 template <typename Geometry1, typename Geometry2>
-void test_distance(const std::string& wkt1, const std::string& wkt2, double expected)
+void test_distance(std::string const& wkt1, std::string const& wkt2, double expected)
 {
     Geometry1 g1;
     Geometry2 g2;
@@ -41,8 +41,8 @@
 }
 
 template <typename Geometry1, typename Geometry2, typename Strategy>
-void test_distance(const Strategy& strategy, const std::string& wkt1,
- const std::string& wkt2, double expected)
+void test_distance(Strategy const& strategy, std::string const& wkt1,
+ std::string const& wkt2, double expected)
 {
     Geometry1 g1;
     Geometry2 g2;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk