Merge pull request #1610 from strk/2.1.x-whole-centroid

Fix "whole" multi centroid computation (#1606)
This commit is contained in:
Dane Springmeyer 2012-11-29 18:04:13 -08:00
commit 3ec3a7cd66
5 changed files with 33 additions and 5 deletions

View file

@ -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;

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,21 @@
<Map maximum-extent="736908, 4390316, 2060771, 5942346">
<Style name="whole">
<Rule>
<MarkersSymbolizer placement="point" multi-policy="whole" fill="yellow" width="20" allow-overlap="true"/>
</Rule>
</Style>
<Style name="boundary">
<Rule>
<LineSymbolizer />
</Rule>
</Style>
<Layer name="multi">
<StyleName>boundary</StyleName>
<StyleName>whole</StyleName>
<Datasource>
<Parameter name="type">csv</Parameter>
<Parameter name="file">../data/whole-centroid.csv</Parameter>
<Parameter name="separator">|</Parameter>
</Datasource>
</Layer>
</Map>

View file

@ -28,6 +28,8 @@ files = [
{'name': "lines-3", 'sizes': sizes_few_square},
{'name': "lines-shield", 'sizes': sizes_few_square},
{'name': "marker-multi-policy", 'sizes':[(600,400)]},
{'name': "whole-centroid", 'sizes':[(600,400)],
'bbox': mapnik.Box2d(736908, 4390316, 2060771, 5942346)},
{'name': "simple-E"},
{'name': "simple-NE"},
{'name': "simple-NW"},