예제 #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);
     }
 }
예제 #2
0
 /*
  * /// <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);
     }
 }
            /// <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);
            }
예제 #4
0
        /// <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);
        }
예제 #5
0
        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);
        }
            /// <inheritdoc cref="GeometryTransformer.TransformCoordinates(ICoordinateSequence, IGeometry)"/>>
            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));
            }
예제 #7
0
        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);
        }
예제 #8
0
 /// <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);
 }