private static ICollection <esriMonotinicityEnum> GetActualErrorMonotonicities( [NotNull] IPolyline singlePartPolyline, MonotonicityDirection expectedMonotonicity, [NotNull] Func <bool> isFeatureFlipped, bool allowConstantValues, out bool?featureFlipped, out esriMonotinicityEnum?monotonicityTrend) { var mSegmentation = (IMSegmentation3)singlePartPolyline; int actualMonotonicityTypes = mSegmentation.MMonotonicity; monotonicityTrend = null; featureFlipped = null; var result = new HashSet <esriMonotinicityEnum>(); if (!allowConstantValues) { if (ContainsMonotonicityType(actualMonotonicityTypes, esriMonotinicityEnum.esriValueLevel)) { result.Add(esriMonotinicityEnum.esriValueLevel); } } if (expectedMonotonicity == MonotonicityDirection.Any) { if (ContainsAllMonotonicityTypes(actualMonotonicityTypes, esriMonotinicityEnum.esriValueIncreases, esriMonotinicityEnum.esriValueDecreases)) { monotonicityTrend = GetMonotonicityTrend(singlePartPolyline); result.Add( monotonicityTrend == esriMonotinicityEnum.esriValueDecreases ? esriMonotinicityEnum.esriValueIncreases : esriMonotinicityEnum.esriValueDecreases); } return(result); } esriMonotinicityEnum violatingMonotonicityType = GetViolatingMonotonicityType(expectedMonotonicity, isFeatureFlipped, out featureFlipped); if (ContainsMonotonicityType(actualMonotonicityTypes, violatingMonotonicityType)) { result.Add(violatingMonotonicityType); } return(result); }
private static esriMonotinicityEnum GetViolatingMonotonicityType( MonotonicityDirection expectedMonotonicity, [NotNull] Func <bool> isFeatureFlipped, out bool?featureFlipped) { MonotonicityDirection expectedMonotonicityDirectionForFeature = GetExpectedMonotonicityDirectionForFeature(expectedMonotonicity, isFeatureFlipped, out featureFlipped); return(GetViolatingMonotonicityType(expectedMonotonicityDirectionForFeature)); }
private static esriMonotinicityEnum GetViolatingMonotonicityType( MonotonicityDirection expectedMonotonicity) { switch (expectedMonotonicity) { case MonotonicityDirection.Any: throw new ArgumentException("Unexpected monotonicity direction (Any)"); case MonotonicityDirection.Increasing: return(esriMonotinicityEnum.esriValueDecreases); case MonotonicityDirection.Decreasing: return(esriMonotinicityEnum.esriValueIncreases); default: throw new ArgumentOutOfRangeException(nameof(expectedMonotonicity)); } }
public QaMonotonicMeasures( [Doc(nameof(DocStrings.QaMonotonicMeasures_lineClass))][NotNull] IFeatureClass lineClass, [Doc(nameof(DocStrings.QaMonotonicMeasures_allowConstantValues))] bool allowConstantValues, [Doc(nameof(DocStrings.QaMonotonicMeasures_expectedMonotonicity))] MonotonicityDirection expectedMonotonicity, [Doc(nameof(DocStrings.QaMonotonicMeasures_flipExpression))][CanBeNull] string flipExpression) : base((ITable)lineClass) { Assert.ArgumentNotNull(lineClass, nameof(lineClass)); _lineClass = lineClass; _expectedMonotonicity = expectedMonotonicity; _flipExpression = StringUtils.IsNotEmpty(flipExpression) ? flipExpression : null; _hasM = DatasetUtils.HasM(lineClass); _allowConstantValues = allowConstantValues; }
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)); } }
private static IEnumerable <ZMonotonicitySequence> GetErrorSequencesFromSinglePart( [NotNull] IPolyline singlePartPolyline, MonotonicityDirection expectedMonotonicity, [NotNull] Func <bool> isFeatureFlipped, bool allowConstantValues) { bool?featureFlipped = null; var points = (IPointCollection4)singlePartPolyline; int segmentCount = points.PointCount - 1; WKSPointZ[] wksPointZs = new WKSPointZ[points.PointCount]; GeometryUtils.QueryWKSPointZs(points, wksPointZs); ZMonotonicitySequence currentSequence = null; double trend = wksPointZs[segmentCount].Z - wksPointZs[0].Z; esriMonotinicityEnum monotonicityTrend = MeasureUtils.GetMonotonicityType(trend); var checkedMonotonicity = GetCheckedMonotonicityDirection( expectedMonotonicity, monotonicityTrend); esriMonotinicityEnum?preMonotonicity = null; IEnumSegment enumSegments = null; bool?recycling = null; for (int segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) { double dz = wksPointZs[segmentIndex + 1].Z - wksPointZs[segmentIndex].Z; esriMonotinicityEnum monotonicity = MeasureUtils.GetMonotonicityType(dz); if (monotonicity == esriMonotinicityEnum.esriValueDecreases || monotonicity == esriMonotinicityEnum.esriValueIncreases) { if (!featureFlipped.HasValue) { featureFlipped = isFeatureFlipped(); } if (featureFlipped.Value) { monotonicity = monotonicity == esriMonotinicityEnum.esriValueDecreases ? esriMonotinicityEnum.esriValueIncreases : esriMonotinicityEnum.esriValueDecreases; } } if (monotonicity != preMonotonicity) { if (currentSequence != null) { yield return(currentSequence); } preMonotonicity = monotonicity; currentSequence = null; } if (currentSequence == null) { if (monotonicity == esriMonotinicityEnum.esriValueLevel && allowConstantValues) { // ok } else if (monotonicity == esriMonotinicityEnum.esriValueIncreases && checkedMonotonicity == MonotonicityDirection.Increasing) { // ok } else if (monotonicity == esriMonotinicityEnum.esriValueDecreases && checkedMonotonicity == MonotonicityDirection.Decreasing) { // ok } else if (checkedMonotonicity == MonotonicityDirection.Any) { if (monotonicity == esriMonotinicityEnum.esriValueIncreases) { checkedMonotonicity = MonotonicityDirection.Increasing; } else if (monotonicity == esriMonotinicityEnum.esriValueDecreases) { checkedMonotonicity = MonotonicityDirection.Decreasing; } } else { currentSequence = new ZMonotonicitySequence(monotonicity, singlePartPolyline.SpatialReference) { FeatureMonotonicityTrend = monotonicityTrend, FeatureIsFlipped = featureFlipped }; } } if (currentSequence != null) { if (enumSegments == null) { enumSegments = ((ISegmentCollection)singlePartPolyline) .EnumSegments; } var segment = GetSegment(enumSegments, segmentIndex); if (!recycling.HasValue) { recycling = enumSegments.IsRecycling; } currentSequence.Add(recycling.Value ? GeometryFactory.Clone(segment) : segment); if (recycling.Value) { Marshal.ReleaseComObject(segment); } } } if (currentSequence != null) { yield return(currentSequence); } if (enumSegments != null) { enumSegments.Reset(); } }