SegmentNode.cs :  » GIS » DeepEarth » GisSharpBlog » NetTopologySuite » Noding » 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 » Noding » SegmentNode.cs
using System;
using System.IO;
using GeoAPI.Geometries;
using GisSharpBlog.NetTopologySuite.Geometries;

namespace GisSharpBlog.NetTopologySuite.Noding{
    /// <summary>
    /// Represents an intersection point between two <see cref="SegmentString" />s.
    /// </summary>
    public class SegmentNode : IComparable
    {        

        /// <summary>
        /// 
        /// </summary>
        public readonly ICoordinate Coordinate = null;   // the point of intersection
        
        /// <summary>
        /// 
        /// </summary>
        public readonly int SegmentIndex = 0;   // the index of the containing line segment in the parent edge

        private readonly SegmentString segString = null;
        private readonly Octants segmentOctant = Octants.Null;
        private readonly bool isInterior = false;

        /// <summary>
        /// Initializes a new instance of the <see cref="SegmentNode"/> class.
        /// </summary>
        /// <param name="segString"></param>
        /// <param name="coord"></param>
        /// <param name="segmentIndex"></param>
        /// <param name="segmentOctant"></param>
        public SegmentNode(SegmentString segString, ICoordinate coord, int segmentIndex, Octants segmentOctant) 
        {
            this.segString = segString;
            this.Coordinate = new Coordinate(coord);
            this.SegmentIndex = segmentIndex;
            this.segmentOctant = segmentOctant;
            isInterior = !coord.Equals2D(segString.GetCoordinate(segmentIndex));
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public bool IsInterior
        { 
            get
            {
                return isInterior; 
            }

        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="maxSegmentIndex"></param>
        /// <returns></returns>
        public bool IsEndPoint(int maxSegmentIndex)
        {
            if(SegmentIndex == 0 && ! isInterior) 
                return true;
            if(SegmentIndex == maxSegmentIndex) 
                return true;
            return false;
        } 

        /// <summary>
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>
        /// -1 this SegmentNode is located before the argument location, or
        ///  0 this SegmentNode is at the argument location, or
        ///  1 this SegmentNode is located after the argument location.   
        /// </returns>
        public int CompareTo(object obj)
        {
            SegmentNode other = (SegmentNode) obj;
            if(SegmentIndex < other.SegmentIndex) 
                return -1;
            if(SegmentIndex > other.SegmentIndex) 
                return 1;
            if (Coordinate.Equals2D(other.Coordinate)) 
                return 0;
            return SegmentPointComparator.Compare(segmentOctant, Coordinate, other.Coordinate);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="outstream"></param>
        public void Write(StreamWriter outstream)
        {
            outstream.Write(Coordinate);
            outstream.Write(" seg # = " + SegmentIndex);
        }
    }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.