/// <summary>
        /// Assumes input is valid
        /// (e.g. <paramref name="start" /> minor or equals to <paramref name="end" />).
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        private IGeometry ComputeLinear(LinearLocation start, LinearLocation end)
        {
            LinearGeometryBuilder builder = new LinearGeometryBuilder(line.Factory);

            builder.FixInvalidLines = true;

            if (!start.IsVertex)
            {
                builder.Add(start.GetCoordinate(line));
            }

            LinearIterator it = new LinearIterator(line, start);

            foreach (LinearIterator.LinearElement element in it)
            {
                int compare = end.CompareLocationValues(element.ComponentIndex, element.VertexIndex, 0.0);
                if (compare < 0)
                {
                    break;
                }

                ICoordinate pt = element.SegmentStart;
                builder.Add(pt);
                if (element.IsEndOfLine)
                {
                    builder.EndLine();
                }
            }

            if (!end.IsVertex)
            {
                builder.Add(end.GetCoordinate(line));
            }

            return(builder.GetGeometry());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:LinearElement"/> class.
 /// </summary>
 /// <param name="iterator">The iterator.</param>
 public LinearElement(LinearIterator iterator)
 {
     this.iterator = iterator;
 }