TopologyValidationError.cs :  » GIS » DeepEarth » GisSharpBlog » NetTopologySuite » Operation » Valid » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GIS » DeepEarth 
DeepEarth » GisSharpBlog » NetTopologySuite » Operation » Valid » TopologyValidationError.cs
using System;
using GeoAPI.Geometries;
using GisSharpBlog.NetTopologySuite.Geometries;

namespace GisSharpBlog.NetTopologySuite.Operation.Valid{
    /// <summary>
    /// Contains information about the nature and location of 
    /// a <see cref="Geometry" /> validation error.
    /// </summary>
    public enum TopologyValidationErrors
    {     
        /// <summary>
        /// Not used.
        /// </summary>
        [Obsolete("Not used")]
        Error = 0,

        /// <summary>
        /// No longer used: 
        /// repeated points are considered valid as per the SFS.
        /// </summary>
        [Obsolete("No longer used: repeated points are considered valid as per the SFS")]
        RepeatedPoint = 1,

        /// <summary>
        /// Indicates that a hole of a polygon lies partially 
        /// or completely in the exterior of the shell.
        /// </summary>
        HoleOutsideShell = 2,

        /// <summary>
        /// Indicates that a hole lies 
        /// in the interior of another hole in the same polygon.
        /// </summary>
        NestedHoles = 3,

        /// <summary>
        /// Indicates that the interior of a polygon is disjoint
        /// (often caused by set of contiguous holes splitting 
        /// the polygon into two parts).
        /// </summary>
        DisconnectedInteriors = 4,

        /// <summary>
        /// Indicates that two rings of a polygonal geometry intersect.
        /// </summary>
        SelfIntersection = 5,

        /// <summary>
        /// Indicates that a ring self-intersects.
        /// </summary>
        RingSelfIntersection = 6,

        /// <summary>
        /// Indicates that a polygon component of a 
        /// <see cref="MultiPolygon" /> lies inside another polygonal component.
        /// </summary>
        NestedShells = 7,

        /// <summary>
        /// Indicates that a polygonal geometry 
        /// contains two rings which are identical.
        /// </summary>
        DuplicateRings = 8,

        /// <summary>
        /// Indicates that either:
        /// - A <see cref="LineString" /> contains a single point.
        /// - A <see cref="LinearRing" /> contains 2 or 3 points.
        /// </summary>
        TooFewPoints = 9,

        /// <summary>
        /// Indicates that the <c>X</c> or <c>Y</c> ordinate of
        /// a <see cref="Coordinate" /> is not a valid 
        /// numeric value (e.g. <see cref="Double.NaN" />).
        /// </summary>
        InvalidCoordinate = 10,

        /// <summary>
        /// Indicates that a ring is not correctly closed
        /// (the first and the last coordinate are different).
        /// </summary>
        RingNotClosed = 11,
    }

    /// <summary>
    /// Contains information about the nature and location of a <c>Geometry</c>
    /// validation error.
    /// </summary>
    public class TopologyValidationError 
    {        
        // NOTE: modified for "safe" assembly in Sql 2005
        // Added readonly!

        /// <summary>
        /// These messages must synch up with the indexes above
        /// </summary>
        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;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorType"></param>
        /// <param name="pt"></param>
        public TopologyValidationError(TopologyValidationErrors errorType, ICoordinate pt)
        {
            this.errorType = errorType;
            if(pt != null)
                this.pt = (ICoordinate) pt.Clone();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="errorType"></param>
        public TopologyValidationError(TopologyValidationErrors errorType) : this(errorType, null) { }

        /// <summary>
        /// 
        /// </summary>
        public ICoordinate Coordinate
        {
            get
            {
                return pt;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public TopologyValidationErrors ErrorType
        {
            get
            {
                return errorType;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public String Message
        {
            get
            {
                return errMsg[(int) errorType];
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Message + " at or near point " + pt;
        }
    }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.