using System; using GeoAPI.Geometries; using GisSharpBlog.NetTopologySuite.Geometries; namespace GisSharpBlog.NetTopologySuite.Operation.Valid { /// /// Contains information about the nature and location of /// a validation error. /// public enum TopologyValidationErrors { /// /// Not used. /// [Obsolete("Not used")] Error = 0, /// /// No longer used: /// repeated points are considered valid as per the SFS. /// [Obsolete("No longer used: repeated points are considered valid as per the SFS")] RepeatedPoint = 1, /// /// Indicates that a hole of a polygon lies partially /// or completely in the exterior of the shell. /// HoleOutsideShell = 2, /// /// Indicates that a hole lies /// in the interior of another hole in the same polygon. /// NestedHoles = 3, /// /// Indicates that the interior of a polygon is disjoint /// (often caused by set of contiguous holes splitting /// the polygon into two parts). /// DisconnectedInteriors = 4, /// /// Indicates that two rings of a polygonal geometry intersect. /// SelfIntersection = 5, /// /// Indicates that a ring self-intersects. /// RingSelfIntersection = 6, /// /// Indicates that a polygon component of a /// lies inside another polygonal component. /// NestedShells = 7, /// /// Indicates that a polygonal geometry /// contains two rings which are identical. /// DuplicateRings = 8, /// /// Indicates that either: /// - A contains a single point. /// - A contains 2 or 3 points. /// TooFewPoints = 9, /// /// Indicates that the X or Y ordinate of /// a is not a valid /// numeric value (e.g. ). /// InvalidCoordinate = 10, /// /// Indicates that a ring is not correctly closed /// (the first and the last coordinate are different). /// RingNotClosed = 11, } /// /// Contains information about the nature and location of a Geometry /// validation error. /// public class TopologyValidationError { // NOTE: modified for "safe" assembly in Sql 2005 // Added readonly! /// /// These messages must synch up with the indexes above /// private static readonly string[] errMsg = { "Topology Validation Error", "Repeated Point", "Hole lies outside shell", "Holes are nested", "Interior is disconnected", "Self-intersection", "Ring Self-intersection", "Nested shells", "Duplicate Rings", "Too few points in geometry component", "Invalid Coordinate" }; private TopologyValidationErrors errorType; private ICoordinate pt; /// /// /// /// /// public TopologyValidationError(TopologyValidationErrors errorType, ICoordinate pt) { this.errorType = errorType; if(pt != null) this.pt = (ICoordinate) pt.Clone(); } /// /// /// /// public TopologyValidationError(TopologyValidationErrors errorType) : this(errorType, null) { } /// /// /// public ICoordinate Coordinate { get { return pt; } } /// /// /// public TopologyValidationErrors ErrorType { get { return errorType; } } /// /// /// public String Message { get { return errMsg[(int) errorType]; } } /// /// /// /// public override string ToString() { return Message + " at or near point " + pt; } } }