[geometry] Small tweak, avoid inner rings with e.g. two points only. Plus comment update / tab removal

[SVN r79669]
This commit is contained in:
Barend Gehrels
2012-07-22 13:05:29 +00:00
parent f6f6dc7b73
commit 7e6ea5baef
2 changed files with 32 additions and 22 deletions

View File

@@ -75,15 +75,15 @@ inline OutputIterator add_rings(SelectionMap const& map,
OutputIterator out)
{
typedef typename SelectionMap::const_iterator iterator;
typedef typename SelectionMap::mapped_type property_type;
typedef typename property_type::area_type area_type;
typedef typename SelectionMap::mapped_type property_type;
typedef typename property_type::area_type area_type;
area_type const zero = 0;
std::size_t const min_num_points = core_detail::closure::minimum_ring_size
<
geometry::closure
<
typename boost::range_value
area_type const zero = 0;
std::size_t const min_num_points = core_detail::closure::minimum_ring_size
<
geometry::closure
<
typename boost::range_value
<
RingCollection const
>::type
@@ -117,15 +117,14 @@ inline OutputIterator add_rings(SelectionMap const& map,
}
}
// Only add rings if they satisfy minimal requirements.
// This cannot be done earlier (during traversal), not
// everything is figured out yet (sum of positive/negative rings)
// TODO: individual rings can still contain less than 3 points.
if (geometry::num_points(result) >= min_num_points
&& math::larger(geometry::area(result), zero))
{
*out++ = result;
}
// Only add rings if they satisfy minimal requirements.
// This cannot be done earlier (during traversal), not
// everything is figured out yet (sum of positive/negative rings)
if (geometry::num_points(result) >= min_num_points
&& math::larger(geometry::area(result), zero))
{
*out++ = result;
}
}
}
return out;

View File

@@ -77,12 +77,23 @@ struct convert_ring<polygon_tag>
}
else
{
interior_rings(destination).resize(
interior_rings(destination).size() + 1);
geometry::convert(source, interior_rings(destination).back());
if (reverse)
// Avoid adding interior rings which are invalid because of number of points:
if (geometry::num_points(source) >=
core_detail::closure::minimum_ring_size
<
geometry::closure
<
Destination
>::value
>::value)
{
boost::reverse(interior_rings(destination).back());
interior_rings(destination).resize(
interior_rings(destination).size() + 1);
geometry::convert(source, interior_rings(destination).back());
if (reverse)
{
boost::reverse(interior_rings(destination).back());
}
}
}
}