using GeoAPI.Geometries;
using GisSharpBlog.NetTopologySuite.GeometriesGraph;
using GisSharpBlog.NetTopologySuite.Operation;
namespace GisSharpBlog.NetTopologySuite.Geometries
{
///
/// Basic implementation of MultiLineString.
///
public class MultiLineString : GeometryCollection, IMultiLineString
{
///
/// Constructs a MultiLineString.
///
///
/// The LineStrings for this MultiLineString,
/// or null or an empty array to create the empty
/// point. Elements may be empty LineStrings,
/// but not nulls.
///
///
public MultiLineString(ILineString[] lineStrings, IGeometryFactory factory) : base(lineStrings, factory) {}
///
/// Constructs a MultiLineString.
///
///
/// The LineStrings for this MultiLineString,
/// or null or an empty array to create the empty
/// point. Elements may be empty LineStrings,
/// but not nulls.
///
///
/// For create this is used a standard
/// with == .
///
public MultiLineString(ILineString[] lineStrings) : this(lineStrings, DefaultFactory) {}
///
/// Gets a value indicating whether this instance is closed.
///
/// true if this instance is closed; otherwise, false.
public bool IsClosed
{
get
{
if (IsEmpty)
{
return false;
}
for (int i = 0; i < geometries.Length; i++)
{
if (!((ILineString) geometries[i]).IsClosed)
{
return false;
}
}
return true;
}
}
///
///
///
///
public override Dimensions Dimension
{
get
{
return Dimensions.Curve;
}
}
///
///
///
///
public override Dimensions BoundaryDimension
{
get
{
if (IsClosed)
{
return Dimensions.False;
}
return Dimensions.Point;
}
}
///
///
///
///
public override string GeometryType
{
get
{
return "MultiLineString";
}
}
///
///
///
///
public override bool IsSimple
{
get
{
return (new IsSimpleOp()).IsSimple((IMultiLineString) this);
}
}
///
///
///
///
public override IGeometry Boundary
{
get
{
if (IsEmpty)
{
return Factory.CreateGeometryCollection(null);
}
GeometryGraph g = new GeometryGraph(0, this);
ICoordinate[] pts = g.GetBoundaryPoints();
return Factory.CreateMultiPoint(pts);
}
}
///
/// Creates a in the reverse order to this object.
/// Both the order of the component LineStrings
/// and the order of their coordinate sequences are reversed.
///
/// a in the reverse order.
public IMultiLineString Reverse()
{
int nLines = geometries.Length;
ILineString[] revLines = new ILineString[nLines];
for (int i = 0; i < geometries.Length; i++)
{
revLines[nLines - 1 - i] = ((ILineString) geometries[i]).Reverse();
}
return Factory.CreateMultiLineString(revLines);
}
///
///
///
///
///
///
public override bool EqualsExact(IGeometry other, double tolerance)
{
if (!IsEquivalentClass((IGeometry) other))
{
return false;
}
return base.EqualsExact(other, tolerance);
}
}
}