Beispiel #1
0
 /// <summary>
 /// The validate method check if the XYPolyline is valid. The checks
 /// made are:
 ///   - is number of points >= 3
 ///   - is the length of all line segments positiv
 ///   - do any lines cross
 ///   - is the area positiv
 /// Exception is raised if the constraints are not met.
 /// </summary>
 public new void Validate()
 {
     if (Points.Count < 3)
     {
         throw new System.Exception("Number of vertices in polygon element is less than 3.");
     }
     if (GetArea() <= 0)
     {
         throw new System.Exception("Area of polygon is negative or zero. XYPolygons must be ordered counter clockwise.");
     }
     for (int j = 0; j < Points.Count; j++)
     {
         if (GetLine(j).GetLength() == 0)
         {
             throw new System.Exception("Length of line segment no: " +
                                        j.ToString() + " (0-based) of XYPolygon is zero.");
         }
     }
     for (int j = 0; j < Points.Count; j++)
     {
         for (int m = 0; m < j; m++)
         {
             if (XYGeometryTools.DoLineSegmentsIntersect(GetLine(j), GetLine(m)))
             {
                 throw new System.Exception("Line no: " + j.ToString() + " and line no: " +
                                            m.ToString() + " of XYPolygon crosses.");
             }
         }
     }
 }