-
Notifications
You must be signed in to change notification settings - Fork 310
/
ValidatingNoder.cs
58 lines (50 loc) · 1.77 KB
/
ValidatingNoder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Collections.Generic;
using NetTopologySuite.Geometries;
namespace NetTopologySuite.Noding
{
/// <summary>
/// A wrapper for <see cref="INoder"/>s which validates
/// the output arrangement is correctly noded.
/// An arrangement of line segments is fully noded if
/// there is no line segment
/// which has another segment intersecting its interior.
/// If the noding is not correct, a <see cref="TopologyException"/> is thrown
/// with details of the first invalid location found.
/// </summary>
/// <author>Martin Davis</author>
/// <seealso cref="FastNodingValidator"/>
public sealed class ValidatingNoder : INoder
{
private readonly INoder _noder;
private IList<ISegmentString> _nodedSs;
/// <summary>
/// Creates a noding validator wrapping the given <paramref name="noder"/>
/// </summary>
/// <param name="noder">The noder to validate</param>
public ValidatingNoder(INoder noder)
{
this._noder = noder;
}
/// <summary>
/// Checks whether the output of the wrapped noder is fully noded.
/// Throws an exception if it is not.
/// </summary>
/// <exception cref="TopologyException"></exception>
public void ComputeNodes(IList<ISegmentString> segStrings)
{
_noder.ComputeNodes(segStrings);
_nodedSs = _noder.GetNodedSubstrings();
Validate();
}
private void Validate()
{
var nv = new FastNodingValidator(_nodedSs);
nv.CheckValid();
}
/// <inheritdoc cref="INoder.GetNodedSubstrings"/>
public IList<ISegmentString> GetNodedSubstrings()
{
return _nodedSs;
}
}
}