using System.Collections;
using GeoAPI.Geometries;
namespace GisSharpBlog.NetTopologySuite.Geometries.Utilities
{
///
/// Extracts all the 1-dimensional (LineString) components from a Geometry.
///
public class LinearComponentExtracter : IGeometryComponentFilter
{
private readonly IList lines;
///
/// Constructs a LineExtracterFilter with a list in which to store LineStrings found.
///
///
public LinearComponentExtracter(IList lines)
{
this.lines = lines;
}
///
/// Extracts the linear components from a single point.
/// If more than one point is to be processed, it is more
/// efficient to create a single LineExtracterFilter instance
/// and pass it to multiple geometries.
///
/// The point from which to extract linear components.
/// The list of linear components.
public static IList GetLines(IGeometry geom)
{
IList lines = new ArrayList();
geom.Apply(new LinearComponentExtracter(lines));
return lines;
}
///
///
///
///
public void Filter(IGeometry geom)
{
if (geom is ILineString)
{
lines.Add(geom);
}
}
}
}