コード例 #1
0
        private int ReportError(
            [NotNull] Rings rings,
            [NotNull] Dictionary <int, List <int> > pointIndexesById,
            [NotNull] IRow row)
        {
            int firstId;

            if (RingsHaveDifferentIds(pointIndexesById, rings, out firstId))
            {
                int    outerRingIds = firstId;
                string description  = string.Format("Point ids within rings are constant, " +
                                                    "but inner ring point ids differ from outer ring point ids ({0})" +
                                                    "(outer ring = {1}. patch in multipatch)",
                                                    outerRingIds, rings.FirstPatchIndex + 1);

                IGeometry errorGeometry = rings.CreateMultiPatch();

                return(ReportError(description, errorGeometry,
                                   Codes[Code.InnerRingIdDifferentFromOuterRingId],
                                   TestUtils.GetShapeFieldName(row), row));
            }

            int?maxPointsId = GetMaxPointsId(pointIndexesById);

            if (maxPointsId == null)
            {
                IGeometry errorGeometry = rings.CreateMultiPatch();
                string    description   = string.Format(
                    rings.RingsCount <= 1
                                                ? "Different point ids exist in this ring ({0}. patch in multipatch)"
                                                : "Different point ids exist in these rings (out ring = {0}. patch in multipatch)",
                    rings.FirstPatchIndex + 1);

                return(ReportError(description, errorGeometry,
                                   Codes[Code.DifferentIdInRing],
                                   TestUtils.GetShapeFieldName(row),
                                   row));
            }

            return(ReportError(rings, pointIndexesById, maxPointsId.Value, row));
        }
コード例 #2
0
        private int ReportError(
            [NotNull] Rings rings,
            [NotNull] IDictionary <int, List <int> > pointIndexesById,
            int maxPointsId,
            [NotNull] IRow row)
        {
            int totalPointCount = 0;
            int errorPointCount = 0;

            foreach (KeyValuePair <int, List <int> > pair in pointIndexesById)
            {
                int        id           = pair.Key;
                List <int> pointIndexes = pair.Value;

                totalPointCount += pointIndexes.Count;

                if (id == maxPointsId)
                {
                    continue;
                }

                errorPointCount += pointIndexes.Count;
            }

            if (errorPointCount < 5 && errorPointCount * 2 < totalPointCount)
            {
                return(ReportPointErrors(pointIndexesById, maxPointsId, rings, row));
            }

            string description;

            if (rings.RingsCount > 1)
            {
                description = string.Format(
                    "{0} point ids differ from the most frequent point id {1} " +
                    "({2} occurrences) in the rings (outer ring = {3}. patch in multipatch)",
                    errorPointCount, maxPointsId, pointIndexesById[maxPointsId].Count,
                    rings.FirstPatchIndex);
            }
            else
            {
                description = string.Format(
                    "{0} point ids differ from the most frequent point id {1} " +
                    "({2} occurrences) in the ring ({3}. patch in multipatch)",
                    errorPointCount, maxPointsId, pointIndexesById[maxPointsId].Count,
                    rings.FirstPatchIndex);
            }

            return(ReportError(description, rings.CreateMultiPatch(),
                               Codes[Code.DifferentIdInRing], TestUtils.GetShapeFieldName(row),
                               row));
        }