Merge pull request #1616 from strk/master-whole-centroid

Fix "whole" multi centroid computation
This commit is contained in:
Dane Springmeyer 2012-11-29 17:52:28 -08:00
commit abb7ed865c
6 changed files with 34 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

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

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