/// <summary>
 /// Remove the segs in the section of the line.
 /// </summary>
 /// <param name="line"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 private void Remove(TaggedLineString line, int start, int end)
 {
     for (int i = start; i < end; i++)
     {
         TaggedLineSegment seg = line.GetSegment(i);
         _inputIndex.Remove(seg);
     }
 }
 /*
  * /// <summary>
  * ///
  * /// </summary>
  * public LineSegmentIndex() { }
  */
 /// <summary>
 ///
 /// </summary>
 /// <param name="line"></param>
 public void Add(TaggedLineString line)
 {
     TaggedLineSegment[] segs = line.Segments;
     for (int i = 0; i < segs.Length; i++)
     {
         TaggedLineSegment seg = segs[i];
         Add(seg);
     }
 }
示例#3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="coords"></param>
 /// <param name="parent"></param>
 /// <returns></returns>
 protected override ICoordinateSequence TransformCoordinates(ICoordinateSequence coords, IGeometry parent)
 {
     // for linear components (including rings), simplify the linestring
     if (parent is ILineString)
     {
         TaggedLineString taggedLine = _container._lineStringMap[(ILineString)parent];
         return(CreateCoordinateSequence(taggedLine.ResultCoordinates));
     }
     // for anything else (e.g. points) just copy the coordinates
     return(base.TransformCoordinates(coords, parent));
 }
 /// <summary>
 /// Tests whether a segment is in a section of a <see cref="TaggedLineString"/>.
 /// </summary>
 /// <param name="line"></param>
 /// <param name="sectionIndex"></param>
 /// <param name="seg"></param>
 /// <returns></returns>
 private static bool IsInLineSection(TaggedLineString line,
     int[] sectionIndex, TaggedLineSegment seg)
 {
     // not in this line
     if (seg.Parent != line.Parent)
         return false;
     int segIndex = seg.Index;
     if (segIndex >= sectionIndex[0] &&
         segIndex < sectionIndex[1])
         return true;
     return false;
 }
        // /*
        //  * Index of section to be tested for flattening - reusable
        //  */
        //  private int[] validSectionIndex = new int[2];

        /// <summary>
        ///
        /// </summary>
        /// <param name="parentLine"></param>
        /// <param name="sectionIndex"></param>
        /// <param name="candidateSeg"></param>
        /// <returns></returns>
        private bool HasBadIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
        {
            if (HasBadOutputIntersection(candidateSeg))
            {
                return(true);
            }
            if (HasBadInputIntersection(parentLine, sectionIndex, candidateSeg))
            {
                return(true);
            }
            return(false);
        }
示例#6
0
            /// <summary>
            /// Filters linear geometries.
            /// </summary>
            /// <param name="geom">A geometry of any type</param>
            public void Filter(IGeometry geom)
            {
                var line = geom as ILineString;

                if (line != null)
                {
                    var minSize = line.IsClosed ? 4 : 2;

                    var taggedLine = new TaggedLineString(line, minSize);
                    _container._lineStringMap.Add(line, taggedLine);
                }
            }
        /// <summary>
        /// Tests whether a segment is in a section of a TaggedLineString-
        /// </summary>
        /// <param name="line"></param>
        /// <param name="sectionIndex"></param>
        /// <param name="seg"></param>
        /// <returns></returns>
        private static bool IsInLineSection(TaggedLineString line, int[] sectionIndex, TaggedLineSegment seg)
        {
            // not in this line
            if (seg.Parent != line.Parent)
            {
                return(false);
            }
            int segIndex = seg.Index;

            if (segIndex >= sectionIndex[0] && segIndex < sectionIndex[1])
            {
                return(true);
            }
            return(false);
        }
            /// <summary>
            /// Filters linear geometries.
            /// </summary>
            /// <param name="geom">A geometry of any type</param>
            public void Filter(IGeometry geom)
            {
                ILineString line = geom as ILineString;

                if (line == null)
                {
                    return;
                }
                if (line.IsEmpty)
                {
                    return;
                }
                int minSize = line.IsClosed ? 4 : 2;
                TaggedLineString taggedLine = new TaggedLineString(line, minSize);

                _container._lineStringMap.Add(line, taggedLine);
            }
        /// <summary>
        ///
        /// </summary>
        /// <param name="parentLine"></param>
        /// <param name="sectionIndex"></param>
        /// <param name="candidateSeg"></param>
        /// <returns></returns>
        private bool HasBadInputIntersection(TaggedLineString parentLine, int[] sectionIndex, LineSegment candidateSeg)
        {
            IList <LineSegment> querySegs = _inputIndex.Query(candidateSeg);

            foreach (TaggedLineSegment querySeg in querySegs)
            {
                if (HasInteriorIntersection(querySeg, candidateSeg))
                {
                    if (IsInLineSection(parentLine, sectionIndex, querySeg))
                    {
                        continue;
                    }
                    return(true);
                }
            }
            return(false);
        }
            /// <summary>
            ///
            /// </summary>
            /// <param name="coords"></param>
            /// <param name="parent"></param>
            /// <returns></returns>
            protected override ICoordinateSequence TransformCoordinates(ICoordinateSequence coords, IGeometry parent)
            {
                // for empty coordinate sequences return null
                if (coords.Count == 0)
                {
                    return(null);
                }

                // for linear components (including rings), simplify the linestring
                ILineString s = parent as ILineString;

                if (s != null)
                {
                    TaggedLineString taggedLine = _container._lineStringMap[s];
                    return(CreateCoordinateSequence(taggedLine.ResultCoordinates));
                }
                // for anything else (e.g. points) just copy the coordinates
                return(base.TransformCoordinates(coords, parent));
            }
 /// <summary>
 /// Simplifies the given <see cref="TaggedLineString"/>
 /// using the distance tolerance specified.
 /// </summary>
 /// <param name="line">The linestring to simplify.</param>
 public void Simplify(TaggedLineString line)
 {
     _line = line;
     _linePts = line.ParentCoordinates;
     SimplifySection(0, _linePts.Length - 1, 0);
 }
 /// <summary>
 /// Remove the segs in the section of the line.
 /// </summary>
 /// <param name="line"></param>
 /// <param name="start"></param>
 /// <param name="end"></param>
 private void Remove(TaggedLineString line, int start, int end)
 {
     for (int i = start; i < end; i++)
     {
         TaggedLineSegment seg = line.GetSegment(i);
         _inputIndex.Remove(seg);
     }
 }
 private bool HasBadIntersection(TaggedLineString parentLine,
     int[] sectionIndex, LineSegment candidateSeg)
 {
     bool badOutput = HasBadOutputIntersection(candidateSeg);
     if (badOutput)
         return true;
     bool badInput = HasBadInputIntersection(parentLine, sectionIndex, candidateSeg);
     if (badInput)
         return true;
     return false;
 }
 private bool HasBadInputIntersection(TaggedLineString parentLine,
     int[] sectionIndex, LineSegment candidateSeg)
 {
     IList<LineSegment> querySegs = _inputIndex.Query(candidateSeg);
     foreach (TaggedLineSegment querySeg in querySegs)
     {
         bool interior = HasInteriorIntersection(querySeg, candidateSeg);
         if (interior)
         {
             bool inline = IsInLineSection(parentLine, sectionIndex, querySeg);
             if (inline)
                 continue;
             return true;
         }
     }
     return false;
 }
 /// <summary>
 /// Filters linear geometries.
 /// </summary>
 /// <param name="geom">A geometry of any type</param>
 public void Filter(IGeometry geom)
 {
     ILineString line = geom as ILineString;
     if (line == null)
         return;
     if (line.IsEmpty)
         return;
     int minSize = line.IsClosed ? 4 : 2;
     TaggedLineString taggedLine = new TaggedLineString(line, minSize);
     _container._lineStringMap.Add(line, taggedLine);
 }
 /// <summary>
 /// Simplifies the given <see cref="TaggedLineString"/>
 /// using the distance tolerance specified.
 /// </summary>
 /// <param name="line">The linestring to simplify</param>
 public void Simplify(TaggedLineString line)
 {
     _line    = line;
     _linePts = line.ParentCoordinates;
     SimplifySection(0, _linePts.Length - 1, 0);
 }