Exemplo n.º 1
0
        private string GetErrorMessage([NotNull] MMonotonicitySequence sequence)
        {
            var sb = new StringBuilder();

            string segmentInfo = sequence.SegmentCount == 1
                                                     ? "one segment"
                                                     : string.Format("{0} segments", sequence.SegmentCount);

            sb.AppendFormat("M values are {0} for {1}",
                            GetMonotonicityTypeString(sequence.MonotonicityType,
                                                      sequence.FeatureIsFlipped),
                            segmentInfo);

            if (sequence.MonotonicityType == esriMonotinicityEnum.esriValueDecreases ||
                sequence.MonotonicityType == esriMonotinicityEnum.esriValueIncreases)
            {
                sb.AppendFormat(". {0}",
                                GetExpectedMonotonicityString(sequence,
                                                              _expectedMonotonicity));

                if (sequence.FeatureIsFlipped != null &&
                    sequence.FeatureIsFlipped.Value)
                {
                    sb.Append(" (against the feature orientation)");
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
        private static string GetExpectedMonotonicityString(
            [NotNull] MMonotonicitySequence sequence,
            MonotonicityDirection expectedMonotonicity)
        {
            switch (expectedMonotonicity)
            {
            case MonotonicityDirection.Decreasing:
                return("The M values should be decreasing");

            case MonotonicityDirection.Increasing:
                return("The M values should be increasing");

            case MonotonicityDirection.Any:
                return(string.Format("The M value trend for the line is {0}",
                                     GetMonotonicityTypeString(
                                         sequence.FeatureMonotonicityTrend,
                                         sequence.FeatureIsFlipped)));

            default:
                throw new ArgumentException(
                          string.Format("Unexpected monotonicity direction: {0}",
                                        expectedMonotonicity));
            }
        }
Exemplo n.º 3
0
        public static IEnumerable <MMonotonicitySequence> GetMonotonicitySequences(
            [NotNull] ISegmentCollection segments,
            [NotNull] IEnumerable <esriMonotinicityEnum> monotonicityTypes)
        {
            MMonotonicitySequence currentSequence = null;
            var types = new HashSet <esriMonotinicityEnum>(monotonicityTypes);

            if (types.Count == 0)
            {
                yield break;
            }

            IEnumSegment enumSegments = segments.EnumSegments;

            enumSegments.Reset();

            ISegment segment;
            var      partIndex    = 0;
            var      segmentIndex = 0;

            enumSegments.Next(out segment, ref partIndex, ref segmentIndex);
            bool recycling = enumSegments.IsRecycling;

            while (segment != null)
            {
                esriMonotinicityEnum currentMonotonicity = GetMonotonicityType(segment);

                if (types.Contains(currentMonotonicity))
                {
                    if (currentSequence == null)
                    {
                        currentSequence = new MMonotonicitySequence(currentMonotonicity,
                                                                    segment.SpatialReference);
                    }

                    if (currentSequence.MonotonicityType != currentMonotonicity)
                    {
                        yield return(currentSequence);

                        currentSequence = new MMonotonicitySequence(currentMonotonicity,
                                                                    segment.SpatialReference);
                    }

                    currentSequence.Add(recycling
                                                                    ? GeometryFactory.Clone(segment)
                                                                    : segment);
                }
                else
                {
                    if (currentSequence != null)
                    {
                        yield return(currentSequence);

                        currentSequence = null;
                    }
                }

                if (recycling)
                {
                    Marshal.ReleaseComObject(segment);
                }

                enumSegments.Next(out segment, ref partIndex, ref segmentIndex);
            }

            if (currentSequence != null)
            {
                yield return(currentSequence);
            }
        }