Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

+ cleanups: use preincrement iterators in for loop etc ..

  • Loading branch information...
commit 8228d99186457919fa92cfaf85f5f3bbe47343c6 1 parent d7abfc2
@artemp artemp authored
Showing with 19 additions and 13 deletions.
  1. +19 −13 include/mapnik/simplify_converter.hpp
View
32 include/mapnik/simplify_converter.hpp
@@ -17,7 +17,8 @@
namespace mapnik
{
-struct weighted_vertex : private boost::noncopyable {
+struct weighted_vertex : private boost::noncopyable
+{
vertex2d coord;
double weight;
weighted_vertex *prev;
@@ -27,20 +28,23 @@ struct weighted_vertex : private boost::noncopyable {
coord(coord_),
weight(std::numeric_limits<double>::infinity()),
prev(NULL),
- next(NULL) { }
+ next(NULL) {}
- double nominalWeight() {
+ double nominalWeight()
+ {
if (prev == NULL || next == NULL || coord.cmd != SEG_LINETO) {
return std::numeric_limits<double>::infinity();
}
- vertex2d& A = prev->coord;
- vertex2d& B = next->coord;
- vertex2d& C = coord;
+ vertex2d const& A = prev->coord;
+ vertex2d const& B = next->coord;
+ vertex2d const& C = coord;
return std::abs((double)((A.x - C.x) * (B.y - A.y) - (A.x - B.x) * (C.y - A.y))) / 2.0;
}
- struct ascending_sort {
- bool operator() (const weighted_vertex *a, const weighted_vertex *b) {
+ struct ascending_sort
+ {
+ bool operator() (const weighted_vertex *a, const weighted_vertex *b)
+ {
return b->weight > a->weight;
}
};
@@ -360,7 +364,8 @@ struct MAPNIK_DECL simplify_converter
}
}
- status init_vertices_visvalingam_whyatt() {
+ status init_vertices_visvalingam_whyatt()
+ {
typedef std::set<weighted_vertex *, weighted_vertex::ascending_sort> VertexSet;
typedef std::vector<weighted_vertex *> VertexList;
@@ -371,13 +376,13 @@ struct MAPNIK_DECL simplify_converter
v_list.push_back(new weighted_vertex(vtx));
}
- if (!v_list.size()) {
+ if (v_list.empty()) {
return status_ = process;
}
// Connect the vertices in a linked list and insert them into the set.
VertexSet v;
- for (VertexList::iterator i = v_list.begin(); i != v_list.end(); i++)
+ for (VertexList::iterator i = v_list.begin(); i != v_list.end(); ++i)
{
(*i)->prev = i == v_list.begin() ? NULL : *(i - 1);
(*i)->next = i + 1 == v_list.end() ? NULL : *(i + 1);
@@ -415,9 +420,10 @@ struct MAPNIK_DECL simplify_converter
v.clear();
// Traverse the remaining list and insert them into the vertex cache.
- for (VertexList::iterator i = v_list.begin(); i != v_list.end(); i++)
+ for (VertexList::iterator i = v_list.begin(); i != v_list.end(); ++i)
{
- if ((*i)->weight >= tolerance_) {
+ if ((*i)->weight >= tolerance_)
+ {
vertices_.push_back((*i)->coord);
}
delete *i;
Please sign in to comment.
Something went wrong with that request. Please try again.