Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix "whole" multi centroid computation (#1606)

Still lacks a testcase
  • Loading branch information...
commit 9cccf2ba77b08b98a79df9ac2cc1863d5eb0439a 1 parent 9728f34
@strk strk authored
Showing with 8 additions and 5 deletions.
  1. +8 −5 include/mapnik/geom_util.hpp
View
13 include/mapnik/geom_util.hpp
@@ -340,12 +340,10 @@ bool centroid_geoms(Iter start, Iter end, double & x, double & y)
double start_x = x0;
double start_y = y0;
- bool empty = true;
-
double atmp = 0.0;
double xtmp = 0.0;
double ytmp = 0.0;
- unsigned count = 1;
+ unsigned count = 0;
while (start!=end)
{
@@ -353,7 +351,11 @@ bool centroid_geoms(Iter start, Iter end, double & x, double & y)
path.rewind(0);
unsigned command = path.vertex(&x0, &y0);
if (command == SEG_END) continue;
- empty = false;
+
+ if ( ! count++ ) {
+ start_x = x0;
+ start_y = y0;
+ }
while (SEG_END != (command = path.vertex(&x1, &y1)))
{
@@ -369,9 +371,10 @@ bool centroid_geoms(Iter start, Iter end, double & x, double & y)
y0 = y1;
++count;
}
+
}
- if ( empty ) return false;
+ if (count == 0) return false;
if (count <= 2) {
x = (start_x + x0) * 0.5;
Please sign in to comment.
Something went wrong with that request. Please try again.