/// <summary>
        /// Determines whether the specified polyline has valid point occurrences.
        /// If a point occurs once, the point connects a chain of segments.
        /// If a point occurs twice, and this only occurs for one point, this point is the point that closes the polyline to form a shape.
        /// If a point occurs more than twice, the shape is connecting back on itself. This case is best handled as a composite shape.
        /// </summary>
        /// <param name="polyline">The polyline.</param>
        /// <returns><c>true</c> if [is valid point ordering] [the specified polyline]; otherwise, <c>false</c>.</returns>
        public static bool IsValidPointOccurrences(PolyLine polyline)
        {
            PointBoundary points         = polyline.PointBoundary();
            bool          closureCounted = false;
            var           selectQuery    =
                from point in points
                group point by point into g
                select new { Point = g.Key, Count = g.Count() };

            foreach (var point in selectQuery)
            {
                if (point.Count == 2 && !closureCounted)
                {
                    closureCounted = true;
                    continue;
                }
                if (point.Count > 1)
                {
                    return(false);
                }
            }

            return(true);
        }
 /// <summary>
 /// Returns the points that define the shape.
 /// </summary>
 /// <returns>PointBoundary.</returns>
 public PointBoundary PointBoundary()
 {
     return(_polyline.PointBoundary());
 }