Beispiel #1
0
        /// <summary>
        /// Constructor. Copies the contents of the xyPolyline parameter.
        /// </summary>
        /// <param name="xyPolyline">Polyline to copy.</param>
        /// <returns>None</returns>
        public XYPolyline(XYPolyline xyPolyline)
        {
            _points = new List <XYPoint>();

            foreach (XYPoint xypoint in xyPolyline.Points)
            {
                _points.Add(xypoint);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Constructor. Copies the contents of the xyPolyline parameter.
        /// </summary>
        /// <param name="xyPolyline">Polyline to copy.</param>
        /// <returns>None</returns>
        public XYPolyline(XYPolyline xyPolyline)
        {
            _points = new ArrayList();

            foreach (XYPoint xypoint in xyPolyline.Points)
            {
                _points.Add(new XYPoint(xypoint.X, xypoint.Y));
            }
        }
Beispiel #3
0
    /// <summary>
    /// Constructor. Copies the contents of the xyPolyline parameter.
    /// </summary>
    /// <param name="xyPolyline">Polyline to copy.</param>
    /// <returns>None</returns>
    public XYPolyline(XYPolyline xyPolyline)
	  {
          _points = new List<XYPoint>();

          foreach (XYPoint xypoint in xyPolyline.Points)
		  {
			  _points.Add(xypoint);
		  }

	  }
Beispiel #4
0
    /// <summary>
    /// Constructor. Copies the contents of the xyPolyline parameter.
    /// </summary>
    /// <param name="xyPolyline">Polyline to copy.</param>
    /// <returns>None</returns>
    public XYPolyline(XYPolyline xyPolyline)
	  {
		  _points = new ArrayList();

		  foreach (XYPoint xypoint in xyPolyline.Points)
		  {
			  _points.Add(new XYPoint(xypoint.X, xypoint.Y));
		  }

	  }
		public void GetLength()
		{
			XYPolyline xyPolyline = new XYPolyline();
			xyPolyline.Points.Add(new XYPoint(6,2));
			xyPolyline.Points.Add(new XYPoint(2,2));
			xyPolyline.Points.Add(new XYPoint(8,2));
			xyPolyline.Points.Add(new XYPoint(8,4));
			xyPolyline.Points.Add(new XYPoint(5,4));
			xyPolyline.Points.Add(new XYPoint(9,7));
			
			Assert.AreEqual((double) 20, xyPolyline.GetLength()); 
		}
        /// <summary>
        /// Calculates the length of polyline inside polygon. Lines segments on the edges of
        /// polygons are included with half their length.
        /// </summary>
        /// <param name="polyline">Polyline</param>
        /// <param name="polygon">Polygon</param>
        /// <returns>
        /// Length of polyline inside polygon.
        /// </returns>
        public static double CalculateLengthOfPolylineInsidePolygon(XYPolyline polyline, XYPolygon polygon)
        {
            double lengthInside         = 0;
            int    numberOfLineSegments = polyline.Points.Count - 1;

            for (int i = 0; i < numberOfLineSegments; i++)
            {
                XYLine line = new XYLine(polyline.GetLine(i));
                lengthInside += CalculateLengthOfLineInsidePolygon(line, polygon);
            }
            return(lengthInside);
        }
		public void GetLine()
		{
			XYPolyline xyPolyline = new XYPolyline();
			xyPolyline.Points.Add(new XYPoint(6,2));
			xyPolyline.Points.Add(new XYPoint(2,2));
			xyPolyline.Points.Add(new XYPoint(8,2));
			xyPolyline.Points.Add(new XYPoint(8,4));
			xyPolyline.Points.Add(new XYPoint(5,4));
			xyPolyline.Points.Add(new XYPoint(9,7));
	
			Assert.AreEqual(new XYLine(6,2,2,2),xyPolyline.GetLine(0));
			Assert.AreEqual(new XYLine(2,2,8,2),xyPolyline.GetLine(1));
			Assert.AreEqual(new XYLine(8,2,8,4),xyPolyline.GetLine(2));
			Assert.AreEqual(new XYLine(8,4,5,4),xyPolyline.GetLine(3));
			Assert.AreEqual(new XYLine(5,4,9,7),xyPolyline.GetLine(4));
		}
        /// <summary>
        /// Finds the shortest distance between any line segment of the polyline
        /// and the point.
        /// </summary>
        /// <param name="polyLine">PolyLine.</param>
        /// <param name="point">Point</param>
        /// <returns>
        ///	<p>Length of the shortest path between the polyline and the point.</p>
        /// </returns>
        public static double CalculatePolylineToPointDistance(XYPolyline polyLine, XYPoint point)
        {
            double dist = 0;
            int    i    = 0;

            while (i < polyLine.Points.Count - 1)
            {
                if (i == 0)
                {
                    dist = CalculateLineToPointDistance(polyLine.GetLine(0), point);
                }
                else
                {
                    dist = Math.Min(dist, CalculateLineToPointDistance(polyLine.GetLine(i), point));
                }
                i++;
            }
            return(dist);
        }
Beispiel #9
0
        /// <summary>
        /// Compares the object type and the coordinates of the object and the
        /// object passed as parameter.
        /// </summary>
        /// <returns>True if object type is XYPolygon and the coordinates are
        /// equal to to the coordinates of the current object. False otherwise.</returns>
        public override bool Equals(Object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return(false);
            }
            XYPolyline e = (XYPolygon)obj;

            if (Points.Count != e.Points.Count)
            {
                return(false);
            }
            for (int i = 0; i < Points.Count; i++)
            {
                if (!((XYPoint)Points[i]).Equals(e.Points[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #10
0
 /// <summary>
 /// Static method that validates an object with an IElementSet interface. The method
 /// raises an Exception in case IElementSet does not describe a valid ElementSet.
 /// The checks made are:
 ///   <p>ElementType: Check</p>
 ///   <p>XYPoint:     Only one vertex in each element.</p>
 ///   <p>XYPolyline:  At least two vertices in each element.</p>
 ///   <p>             All line segments in each element has length > 0</p>
 ///   <p>XYPolygon:   At least three vertices in each element.</p>
 ///   <p>             Area of each element is larger than 0</p>
 ///   <p>             All line segments in each element has length > 0</p>
 ///   <p>             No line segments within an element crosses.</p>
 /// </summary>
 ///
 /// <param name="elementSet">Object that implement the IElementSet interface</param>
 ///
 /// <returns>
 /// The method has no return value.
 /// </returns>
 public static void CheckElementSet(IElementSet elementSet)
 {
     try
     {
         if (elementSet.ElementType == ElementType.XYPoint)
         {
             for (int i = 0; i < elementSet.ElementCount; i++)
             {
                 try
                 {
                     if (elementSet.GetVertexCount(i) != 1)
                     {
                         throw new System.Exception("Number of vertices in point element is different from 1.");
                     }
                 }
                 catch (System.Exception e)
                 {
                     throw new System.Exception("ElementID = " + elementSet.GetElementID(i), e);
                 }
             }
         }
         else if (elementSet.ElementType == ElementType.XYPolyLine)
         {
             for (int i = 0; i < elementSet.ElementCount; i++)
             {
                 try
                 {
                     XYPolyline xypolyline = new XYPolyline();
                     for (int j = 0; j < elementSet.GetVertexCount(i); j++)
                     {
                         XYPoint xypoint = new XYPoint(elementSet.GetXCoordinate(i, j), elementSet.GetYCoordinate(i, j));
                         xypolyline.Points.Add(xypoint);
                     }
                     xypolyline.Validate();
                 }
                 catch (System.Exception e)
                 {
                     throw new System.Exception("ElementID = " + elementSet.GetElementID(i), e);
                 }
             }
         }
         else if (elementSet.ElementType == ElementType.XYPolygon)
         {
             for (int i = 0; i < elementSet.ElementCount; i++)
             {
                 try
                 {
                     XYPolygon xypolygon = new XYPolygon();
                     for (int j = 0; j < elementSet.GetVertexCount(i); j++)
                     {
                         XYPoint xypoint = new XYPoint(elementSet.GetXCoordinate(i, j), elementSet.GetYCoordinate(i, j));
                         xypolygon.Points.Add(xypoint);
                     }
                     xypolygon.Validate();
                 }
                 catch (System.Exception e)
                 {
                     throw new System.Exception("ElementID = " + elementSet.GetElementID(i), e);
                 }
             }
         }
     }
     catch (System.Exception e)
     {
         throw new System.Exception("ElementSet with ID = " + elementSet.ID + " is invalid", e);
     }
 }
	  private XYPolyline CreateXYPolyline(IElementSet elementSet, int index)
	  {
		  if (!(elementSet.ElementType == ElementType.XYPolyLine || elementSet.ElementType == ElementType.XYLine))
		  {
			  throw new System.Exception("Cannot create XYPolyline");
		  }

		  XYPolyline xyPolyline = new XYPolyline();
		  for (int i = 0; i < elementSet.GetVertexCount(index); i++)
		  {
			  xyPolyline.Points.Add(new XYPoint(elementSet.GetXCoordinate(index,i), elementSet.GetYCoordinate(index,i)));
		  }

		  return xyPolyline;
	  }
    public void Equals()
    {
      XYPolygon p1 = new XYPolygon();
      p1.Points.Add(new XYPoint(0, 3));
      p1.Points.Add(new XYPoint(3, 0));
      p1.Points.Add(new XYPoint(8, 0));
      p1.Points.Add(new XYPoint(8, 2));
      p1.Points.Add(new XYPoint(3, 1));
      p1.Points.Add(new XYPoint(3, 3));
      p1.Points.Add(new XYPoint(8, 3));
      p1.Points.Add(new XYPoint(4, 7));

      XYPolygon p2 = new XYPolygon();
      p2.Points.Add(new XYPoint(0, 3));
      p2.Points.Add(new XYPoint(3, 0));
      p2.Points.Add(new XYPoint(8, 0));
      p2.Points.Add(new XYPoint(8, 2));
      p2.Points.Add(new XYPoint(3, 1));
      p2.Points.Add(new XYPoint(3, 3));
      p2.Points.Add(new XYPoint(8, 3));
      p2.Points.Add(new XYPoint(4, 7));
      
      XYPolygon p3 = new XYPolygon();
      p3.Points.Add(new XYPoint(0, 3));
      p3.Points.Add(new XYPoint(3, 0));
      p3.Points.Add(new XYPoint(8, 0));
      p3.Points.Add(new XYPoint(8, 2));
      p3.Points.Add(new XYPoint(3, 1.1));
      p3.Points.Add(new XYPoint(3, 3));
      p3.Points.Add(new XYPoint(8, 3));
      p3.Points.Add(new XYPoint(4, 7));

      XYPolygon p4 = new XYPolygon();
      p4.Points.Add(new XYPoint(0, 3));
      p4.Points.Add(new XYPoint(3, 0));
      p4.Points.Add(new XYPoint(8, 0));
      p4.Points.Add(new XYPoint(8, 2));
      p4.Points.Add(new XYPoint(3, 1));
      p4.Points.Add(new XYPoint(3, 3));
      p4.Points.Add(new XYPoint(8, 3));
 
      XYPolyline p5 = new XYPolyline();
      p5.Points.Add(new XYPoint(0, 3));
      p5.Points.Add(new XYPoint(3, 0));
      p5.Points.Add(new XYPoint(8, 0));
      p5.Points.Add(new XYPoint(8, 2));
      p5.Points.Add(new XYPoint(3, 1.1));
      p5.Points.Add(new XYPoint(3, 3));
      p5.Points.Add(new XYPoint(8, 3));
      p5.Points.Add(new XYPoint(4, 7));
      
      Assert.AreEqual(true, p1.Equals(p1),"Test1");     
      Assert.AreEqual(true, p1.Equals(p2),"Test2");     
      Assert.AreEqual(false, p1.Equals(p3),"Test3");
      Assert.AreEqual(false, p1.Equals(p4),"Test4");
      Assert.AreEqual(false, p1.Equals(p5),"Test5");
    }
    /// <summary>
    /// Static method that validates an object with an IElementSet interface. The method 
    /// raises an Exception in case IElementSet does not describe a valid ElementSet.
    /// The checks made are:
    ///   <p>ElementType: Check</p>
    ///   <p>XYPoint:     Only one vertex in each element.</p>
    ///   <p>XYPolyline:  At least two vertices in each element.</p>
    ///   <p>             All line segments in each element has length > 0</p>
    ///   <p>XYPolygon:   At least three vertices in each element.</p>
    ///   <p>             Area of each element is larger than 0</p>
    ///   <p>             All line segments in each element has length > 0</p>
    ///   <p>             No line segments within an element crosses.</p>
    /// </summary>
    /// 
    /// <param name="elementSet">Object that implement the IElementSet interface</param>
    /// 
    /// <returns>
    /// The method has no return value.
    /// </returns>
    public static void CheckElementSet(IElementSet elementSet)
		{
      try
      {
        if(elementSet.ElementType == ElementType.XYPoint)
        {
          for (int i = 0; i < elementSet.ElementCount; i++)
          {
            try
            {              
              if(elementSet.GetVertexCount(i) != 1)
              {
                throw new System.Exception("Number of vertices in point element is different from 1.");
              }
            }
            catch (System.Exception e)
            {
              throw new System.Exception("ElementID = "+elementSet.GetElementID(i),e);
            }
          }
        }
        else if(elementSet.ElementType == ElementType.XYPolyLine)
        {
          for (int i = 0; i < elementSet.ElementCount; i++)
          {
            try
            {
              XYPolyline xypolyline = new XYPolyline();
              for (int j = 0; j < elementSet.GetVertexCount(i); j++)
              {
                XYPoint xypoint = new XYPoint(elementSet.GetXCoordinate(i,j),elementSet.GetYCoordinate(i,j));
                xypolyline.Points.Add(xypoint);
              }
              xypolyline.Validate();
            }
            catch (System.Exception e)
            {
              throw new System.Exception("ElementID = "+elementSet.GetElementID(i),e);
            }
          }
        }
        else if(elementSet.ElementType == ElementType.XYPolygon)
        {
          for (int i = 0; i < elementSet.ElementCount; i++)
          {
            try
            {
              XYPolygon xypolygon = new XYPolygon();
              for (int j = 0; j < elementSet.GetVertexCount(i); j++)
              {
                XYPoint xypoint = new XYPoint(elementSet.GetXCoordinate(i,j),elementSet.GetYCoordinate(i,j));
                xypolygon.Points.Add(xypoint);
              }
              xypolygon.Validate();
            }         
            catch (System.Exception e)
            {
              throw new System.Exception("ElementID = "+elementSet.GetElementID(i),e);
            }
          }
        }
      }
      catch (System.Exception e)
      {
        throw new System.Exception("ElementSet with ID = "+elementSet.ID+" is invalid",e);
      }
		}
Beispiel #14
0
 public void Equals()
 {
   XYLine l1 = new XYLine(0, 3, 3, 0);
   XYLine l2 = new XYLine(0, 3, 3, 0);
   XYLine l3 = new XYLine(3, 3, 3, 0);
   XYPolyline pl1 = new XYPolyline();
   pl1.Points.Add(new XYPoint(0, 3));
   pl1.Points.Add(new XYPoint(3, 0));
   
   Assert.AreEqual(true, l1.Equals(l1),"Test1");     
   Assert.AreEqual(true, l1.Equals(l2),"Test2");     
   Assert.AreEqual(false, l1.Equals(l3),"Test3");
   Assert.AreEqual(false, l1.Equals(pl1),"Test4");
 }
        private void panelViewer_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            // write x and y coordinates			
			double x = ((e.X - _margin) /  _scale) + _minX;
			double y = _minY - (e.Y + _margin - panelViewer.ClientSize.Height) / _scale;
			if( _scale != double.MaxValue )
				this.label3.Text = "(" + x.ToString("F3") +", " + y.ToString("F3") + ")";			
			else
				this.label3.Text = "";


            // write elementSet ID and element index
            this.label4.Text = " ";
            this.label7.Text = " ";
            this.label8.Text = " ";
            this.label9.Text = " ";
            this.label10.Text = " ";
            this.label11.Text = " ";

            for (int elementSetNumber = 0; elementSetNumber < this._elementSets.Count; elementSetNumber++)
            {
                string elementID = " ";
                int elementIndex = -9;
                double distance = 10e30;

                IElementSet elementSet = (IElementSet) _elementSets[elementSetNumber];
                
                if (elementSetNumber == 0)
                {
                    this.label7.Text = elementSet.ID.Substring(0, Math.Min(20, elementSet.ID.Length));
                }
                if (elementSetNumber == 1)
                {
                    this.label9.Text = elementSet.ID.Substring(0, Math.Min(20, elementSet.ID.Length));
                }

                for (int index = 0; index < elementSet.ElementCount; index++)
                {
                    if (((IElementSet) _elementSets[elementSetNumber]).ElementType == ElementType.XYPolygon)
                    {
                        XYPolygon xyPolygon = new XYPolygon();

                        for (int i = 0; i < elementSet.GetVertexCount(index); i++)
                        {
                            xyPolygon.Points.Add(new XYPoint(elementSet.GetXCoordinate(index,i), elementSet.GetYCoordinate(index,i)));
                        }

                        if (XYGeometryTools.IsPointInPolygon(x,y,xyPolygon))
                        {
                            elementID = elementSet.GetElementID(index);
                            elementIndex = index;
                        }
                    }

                    
                    if (((IElementSet) _elementSets[elementSetNumber]).ElementType == ElementType.XYPolyLine)
                    {
                        XYPolyline xyPolyline = new XYPolyline();
                        for (int i = 0; i < elementSet.GetVertexCount(index); i++)
                        {
                            xyPolyline.Points.Add(new XYPoint(elementSet.GetXCoordinate(index,i), elementSet.GetYCoordinate(index,i)));
                        }
                        double xx =  XYGeometryTools.CalculatePolylineToPointDistance(xyPolyline, new XYPoint(x,y));
                        if (xx < distance)
                        {
                            distance = xx;
                            if (xx < 0.3 * xyPolyline.GetLength())
                            {
                                elementIndex = index;
                                elementID = elementSet.GetElementID(index);
                            }
                        }

                    }

                    if (elementSetNumber == 0 && elementIndex >= 0)
                    {
                        this.label4.Text = "Index: " + elementIndex.ToString();
                        this.label8.Text = "ID: " + elementID.Substring(0, Math.Min(17, elementID.Length));
                    }
                    if (elementSetNumber == 1 && elementIndex >= 0)
                    {
                        this.label10.Text = "Index: " + elementIndex.ToString();
                        this.label11.Text = "ID: " + elementID.Substring(0, Math.Min(17, elementID.Length));
                    }
                }
            }
        }
 public void CalculatePolylineToPointDistance()
 {
   XYPolyline polyline = new XYPolyline();
   polyline.Points.Add(new XYPoint(0,0));
   polyline.Points.Add(new XYPoint(1,1));
   polyline.Points.Add(new XYPoint(2,2));
   polyline.Points.Add(new XYPoint(4,2));
   polyline.Points.Add(new XYPoint(6,0));
   Assert.AreEqual(Math.Sqrt(2),XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(-1,-1)),1e-12,"Test1");
   Assert.AreEqual(Math.Sqrt(2),XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(2,0)),1e-12,"Test2");
   Assert.AreEqual(0,XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(2,2)),1e-12,"Test3");
   Assert.AreEqual(1,XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(3,1)),1e-12,"Test4");
   Assert.AreEqual(1,XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(3,3)),1e-12,"Test5");
   Assert.AreEqual(2,XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(3,4)),1e-12,"Test6");
   Assert.AreEqual(0,XYGeometryTools.CalculatePolylineToPointDistance(polyline, new XYPoint(6,0)),1e-12,"Test7");
 }
    public void CalculateLengthOfPolylineInsidePolygon()
    {
        XYPolygon xypolygon = new XYPolygon();
        xypolygon.Points.Add(new XYPoint(1,1));
        xypolygon.Points.Add(new XYPoint(9,1));
        xypolygon.Points.Add(new XYPoint(5,5));
        xypolygon.Points.Add(new XYPoint(5,3));
        xypolygon.Points.Add(new XYPoint(3,3));
        xypolygon.Points.Add(new XYPoint(3,8));
        xypolygon.Points.Add(new XYPoint(9,8));
        xypolygon.Points.Add(new XYPoint(9,11));
        xypolygon.Points.Add(new XYPoint(1,11));

        XYPolyline xypolyline = new XYPolyline();
        xypolyline.Points.Add(new XYPoint(9,13));
        xypolyline.Points.Add(new XYPoint(7,12));
        xypolyline.Points.Add(new XYPoint(7,10));
        xypolyline.Points.Add(new XYPoint(2,10));
        xypolyline.Points.Add(new XYPoint(2,3));

        Assert.AreEqual(13,XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(xypolyline, xypolygon));

        XYPolygon rectangle = new XYPolygon();
        rectangle.Points.Add(new XYPoint(10,10));
        rectangle.Points.Add(new XYPoint(20,10));
        rectangle.Points.Add(new XYPoint(20,40));
        rectangle.Points.Add(new XYPoint(10,40));

        XYPolyline line1 = new XYPolyline();
        line1.Points.Add(new XYPoint(0,20));
        line1.Points.Add(new XYPoint(30,20));
        Assert.AreEqual(10, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line1, rectangle));  // horizontal line crossing
        
        XYPolyline line2 = new XYPolyline();
        line2.Points.Add(new XYPoint(10,20));
        line2.Points.Add(new XYPoint(20,20));
        Assert.AreEqual(10, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line2, rectangle));  // fits inside

        XYPolyline line3 = new XYPolyline();
        line3.Points.Add(new XYPoint(0,40));
        line3.Points.Add(new XYPoint(30,40));
        Assert.AreEqual(5, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line3, rectangle));

        XYPolyline line4 = new XYPolyline();
        line4.Points.Add(new XYPoint(20,40));
        line4.Points.Add(new XYPoint(20,0));
        
        Assert.AreEqual(15, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line4, rectangle));

        XYPolyline line5 = new XYPolyline();
        line5.Points.Add(new XYPoint(20,40));
        line5.Points.Add(new XYPoint(20,10));
        Assert.AreEqual(15, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line5, rectangle));

        XYPolyline line6 = new XYPolyline();
        line6.Points.Add(new XYPoint(10,40));
        line6.Points.Add(new XYPoint(30,40));
        Assert.AreEqual(5, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line6, rectangle));

        XYPolyline line7 = new XYPolyline();
        line7.Points.Add(new XYPoint(10,20));
        line7.Points.Add(new XYPoint(30,20));
        Assert.AreEqual(10, XYGeometryTools.CalculateLengthOfPolylineInsidePolygon(line7, rectangle));


        



    }
		/// <summary>
		/// Calculates the length of polyline inside polygon. Lines segments on the edges of 
		/// polygons are included with half their length.
		/// </summary>
		/// <param name="polyline">Polyline</param>
		/// <param name="polygon">Polygon</param>
		/// <returns>
		/// Length of polyline inside polygon.
		/// </returns>
		public static double CalculateLengthOfPolylineInsidePolygon(XYPolyline polyline, XYPolygon polygon)
		{
			double lengthInside = 0;
			int numberOfLineSegments = polyline.Points.Count - 1;
			for (int i = 0; i < numberOfLineSegments; i++)
			{
				XYLine line = new XYLine(polyline.GetLine(i));
				lengthInside += CalculateLengthOfLineInsidePolygon(line,polygon);
			}
			return lengthInside;
		}
 /// <summary>
 /// Finds the shortest distance between any line segment of the polyline 
 /// and the point.
 /// </summary>
 /// <param name="polyLine">PolyLine.</param>
 /// <param name="point">Point</param>
 /// <returns>
 ///	<p>Length of the shortest path between the polyline and the point.</p>
 /// </returns>
 public static double CalculatePolylineToPointDistance (XYPolyline polyLine, XYPoint point)
 {
   double dist = 0;
   int i = 0;
   while (i < polyLine.Points.Count - 1) 
   {
     if (i == 0) 
     {
       dist = CalculateLineToPointDistance (polyLine.GetLine(0), point);
     }
     else
     {
       dist = Math.Min(dist, CalculateLineToPointDistance (polyLine.GetLine(i), point));
     }
     i++;
   }
   return dist;
 }