summaryrefslogtreecommitdiff
path: root/boost/geometry/algorithms/centroid.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/algorithms/centroid.hpp')
-rw-r--r--boost/geometry/algorithms/centroid.hpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/boost/geometry/algorithms/centroid.hpp b/boost/geometry/algorithms/centroid.hpp
index 1b99ab2ef3..8ef017a3f1 100644
--- a/boost/geometry/algorithms/centroid.hpp
+++ b/boost/geometry/algorithms/centroid.hpp
@@ -220,19 +220,22 @@ struct centroid_range_state
iterator_type it = boost::begin(view);
iterator_type end = boost::end(view);
- typename PointTransformer::result_type
- previous_pt = transformer.apply(*it);
-
- for ( ++it ; it != end ; ++it)
+ if (it != end)
{
typename PointTransformer::result_type
- pt = transformer.apply(*it);
+ previous_pt = transformer.apply(*it);
- strategy.apply(static_cast<point_type const&>(previous_pt),
- static_cast<point_type const&>(pt),
- state);
-
- previous_pt = pt;
+ for ( ++it ; it != end ; ++it)
+ {
+ typename PointTransformer::result_type
+ pt = transformer.apply(*it);
+
+ strategy.apply(static_cast<point_type const&>(previous_pt),
+ static_cast<point_type const&>(pt),
+ state);
+
+ previous_pt = pt;
+ }
}
}
};