/// <summary> Remove the segs in the section of the line</summary>
        /// <param name="line">
        /// </param>
        /// <param name="pts">
        /// </param>
        /// <param name="sectionStartIndex">
        /// </param>
        /// <param name="sectionEndIndex">
        /// </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
        public void Add(TaggedLineString line)
        {
            TaggedLineSegment[] segs = line.Segments;

            for (int i = 0; i < segs.Length - 1; i++)
            {
                TaggedLineSegment seg = segs[i];

                Add(seg);
            }
        }
        public void Simplify(TaggedLineString line)
        {
            if (line == null)
            {
                throw new ArgumentNullException("line");
            }

            this.line = line;
            linePts   = line.ParentCoordinates.ToArray();

            SimplifySection(0, linePts.Length - 1, 0);
        }
        private bool HasBadIntersection(TaggedLineString parentLine,
                                        int[] sectionIndex, LineSegment candidateSeg)
        {
            if (HasBadOutputIntersection(candidateSeg))
            {
                return(true);
            }

            if (HasBadInputIntersection(parentLine,
                                        sectionIndex, candidateSeg))
            {
                return(true);
            }

            return(false);
        }
        /// <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);
        }
        private bool HasBadInputIntersection(TaggedLineString parentLine,
                                             int[] sectionIndex, LineSegment candidateSeg)
        {
            IList querySegs = inputIndex.Query(candidateSeg);

            for (IEnumerator i = querySegs.GetEnumerator(); i.MoveNext();)
            {
                TaggedLineSegment querySeg = (TaggedLineSegment)i.Current;
                if (HasInteriorIntersection(querySeg, candidateSeg))
                {
                    if (IsInLineSection(parentLine, sectionIndex, querySeg))
                    {
                        continue;
                    }
                    return(true);
                }
            }
            return(false);
        }
            protected override ICoordinateList Transform(
                ICoordinateList coords, Geometry parent)
            {
                if (parent == null)
                {
                    throw new ArgumentNullException("parent");
                }

                GeometryType geomType = parent.GeometryType;

                if (geomType == GeometryType.LineString ||
                    geomType == GeometryType.LinearRing)
                {
                    TaggedLineString taggedLine =
                        (TaggedLineString)m_objSimplifier.linestringMap[parent];

                    return(taggedLine.ResultCoordinates);
                }

                // for anything else (e.g. points) just copy the coordinates
                return(base.Transform(coords, parent));
            }
            public void Visit(Geometry geometry)
            {
                if (geometry == null)
                {
                    throw new ArgumentNullException("geometry");
                }

                GeometryType geomType = geometry.GeometryType;

                if (geomType == GeometryType.LinearRing)
                {
                    TaggedLineString taggedLine =
                        new TaggedLineString((LineString)geometry, 4);

                    m_objSimplifier.linestringMap[geometry] = taggedLine;
                }
                else if (geomType == GeometryType.LineString)
                {
                    TaggedLineString taggedLine =
                        new TaggedLineString((LineString)geometry, 2);

                    m_objSimplifier.linestringMap[geometry] = taggedLine;
                }
            }