using System.Collections;
using GeoAPI.Geometries;
namespace GisSharpBlog.NetTopologySuite.Geometries.Utilities
{
///
/// Extracts all the 2-dimensional (Polygon) components from a Geometry.
///
public class PolygonExtracter : IGeometryFilter
{
///
/// Returns the Polygon components from a single point.
/// If more than one point is to be processed, it is more
/// efficient to create a single PolygonExtracterFilter instance
/// and pass it to multiple geometries.
///
///
public static IList GetPolygons(IGeometry geom)
{
IList comps = new ArrayList();
geom.Apply(new PolygonExtracter(comps));
return comps;
}
private IList comps;
///
/// Constructs a PolygonExtracterFilter with a list in which to store Polygons found.
///
///
public PolygonExtracter(IList comps)
{
this.comps = comps;
}
///
///
///
///
public void Filter(IGeometry geom)
{
if (geom is IPolygon)
comps.Add(geom);
}
}
}