Ejemplo n.º 1
0
        private int ReportError([NotNull] IList <ParallelSegmentPair> relatedPairs,
                                [NotNull] IRow row)
        {
            if (relatedPairs.Count == 0)
            {
                return(NoError);
            }

            double maxAngleOffset = -1;

            foreach (ParallelSegmentPair parallelSegmentPair in relatedPairs)
            {
                double angleOffset = Math.Abs(parallelSegmentPair.AzimuthDifference);
                if (angleOffset > maxAngleOffset)
                {
                    maxAngleOffset = angleOffset;
                }
            }

            IssueCode issueCode;
            string    description = GetDescription(relatedPairs, maxAngleOffset, out issueCode);

            IGeometry errorGeometry = SegmentPairUtils.CreateGeometry(relatedPairs);

            return(ReportError(description, errorGeometry,
                               issueCode, TestUtils.GetShapeFieldName(row),
                               row));
        }
        private int ReportError([NotNull] IList <PerpendicularSegmentPair> relatedPairs,
                                [NotNull] IRow row)
        {
            if (relatedPairs.Count == 0)
            {
                return(NoError);
            }

            double maxAngleOffset = -1;

            foreach (PerpendicularSegmentPair perpendicularSegmentPair in relatedPairs)
            {
                double angleOffset =
                    Math.Abs(perpendicularSegmentPair.AzimuthDifference - Math.PI / 2);
                if (angleOffset > maxAngleOffset)
                {
                    maxAngleOffset = angleOffset;
                }
            }

            double azimuthDiffDeg      = MathUtils.ToDegrees(maxAngleOffset);
            double azimuthToleranceDeg = MathUtils.ToDegrees(_azimuthToleranceRad);
            string angleFormat         = FormatUtils.CompareFormat(
                azimuthDiffDeg, ">", azimuthToleranceDeg, "N1");

            string    description;
            IssueCode issueCode;
            string    offsetDescription = string.Format("{0} > {1}",
                                                        FormatAngle(maxAngleOffset, angleFormat),
                                                        FormatAngle(_azimuthToleranceRad,
                                                                    angleFormat));

            if (relatedPairs.Count == 1)
            {
                description =
                    string.Format(
                        "The two segments are almost, but not sufficently perpendicular " +
                        "(angle from perpendicular: {0})",
                        offsetDescription);
                issueCode = Codes[Code.NotSufficientlyPerpendicular_TwoSegments];
            }
            else
            {
                description =
                    string.Format(
                        "The segments of this group are almost, but not sufficently perpendicular " +
                        "(maximum angle from perpendicular {0})",
                        offsetDescription);
                issueCode = Codes[Code.NotSufficientlyPerpendicular_GroupOfSegments];
            }

            IGeometry errorGeometry = SegmentPairUtils.CreateGeometry(relatedPairs);

            return(ReportError(description, errorGeometry,
                               issueCode,
                               TestUtils.GetShapeFieldName(row),
                               row));
        }
Ejemplo n.º 3
0
        private int ReportError([NotNull] IList <HeightSegmentPair> relatedPairs,
                                [NotNull] IRow row)
        {
            if (relatedPairs.Count == 0)
            {
                return(NoError);
            }

            double maxHeightOffset = -1;

            foreach (HeightSegmentPair heightSegmentPair in relatedPairs)
            {
                double heightOffset = Math.Abs(heightSegmentPair.HeightDifference);
                if (heightOffset > maxHeightOffset)
                {
                    maxHeightOffset = heightOffset;
                }
            }

            ISpatialReference sr = ((IFeature)row).Shape.SpatialReference;
            string            description;
            string            offsetDescription = FormatLengthComparison(maxHeightOffset, ">",
                                                                         _heightTolerance, sr);
            IssueCode issueCode;

            if (relatedPairs.Count == 1)
            {
                description =
                    string.Format(
                        "The two segments have a similar, but not equal height (height difference: {0})",
                        offsetDescription);
                issueCode = Codes[Code.HeightsSimilarButNotEqual_TwoSegments];
            }
            else
            {
                description =
                    string.Format(
                        "Segments in this group have similar, but not equal heights (maximum height difference: {0})",
                        offsetDescription);
                issueCode = Codes[Code.HeightsSimilarButNotEqual_SegmentGroup];
            }

            IGeometry errorGeometry = SegmentPairUtils.CreateGeometry(relatedPairs);

            return(ReportError(description, errorGeometry,
                               issueCode, TestUtils.GetShapeFieldName(row),
                               row));
        }
        private int ReportErrors(
            [NotNull] IEnumerable <PerpendicularSegmentPair> errorSegments,
            [NotNull] IRow row)
        {
            var errorCount     = 0;
            var unhandledPairs = new List <PerpendicularSegmentPair>(errorSegments);

            while (unhandledPairs.Count > 0)
            {
                var relatedPairs = new List <PerpendicularSegmentPair>();
                relatedPairs.Add(unhandledPairs[0]);
                unhandledPairs.RemoveAt(0);

                SegmentPairUtils.AddRelatedPairsRecursive(relatedPairs, unhandledPairs);

                errorCount += ReportError(relatedPairs, row);
            }

            return(errorCount);
        }