Esempio n. 1
0
        private IEnumerable <IFeature> GetConnectedBorderFeatures(
            [NotNull] IGeometry geometry,
            [NotNull] IFeature geometryFeature, int geometryClassIndex,
            int borderClassIndex,
            [NotNull] Func <ITable, IQueryFilter, QueryFilterHelper, IEnumerable <IRow> > search,
            ITable borderClass,
            ISpatialFilter spatialFilter,
            QueryFilterHelper filterHelper,
            RowPairCondition borderMatchCondition)
        {
            spatialFilter.Geometry = geometry;

            var result = new List <IFeature>(5);

            foreach (IRow borderRow in search(borderClass,
                                              spatialFilter,
                                              filterHelper))
            {
                if (!borderMatchCondition.IsFulfilled(geometryFeature, geometryClassIndex,
                                                      borderRow, borderClassIndex))
                {
                    continue;
                }

                result.Add((IFeature)borderRow);
            }

            return(result);
        }
Esempio n. 2
0
        GetAttributeConstraintViolations(
            [NotNull] IFeature feature, int classIndex,
            [NotNull] IFeature neighborFeature, int neighborClassIndex,
            [NotNull] RowPairCondition rowPairCondition,
            [NotNull] EqualFieldValuesCondition equalFieldValuesCondition,
            bool reportIndividually = false)
        {
            if (reportIndividually)
            {
                string       message;
                IColumnNames errorColumnNames;
                if (!rowPairCondition.IsFulfilled(feature, classIndex,
                                                  neighborFeature,
                                                  neighborClassIndex,
                                                  out message,
                                                  out errorColumnNames))
                {
                    var affectedFields = new HashSet <string>(
                        errorColumnNames.GetInvolvedColumnNames(),
                        StringComparer.OrdinalIgnoreCase);

                    yield return(new AttributeConstraintViolation(
                                     string.Format(
                                         LocalizableStrings
                                         .EdgeMatchUtils_AttributeConstraints_ConstraintNotFulfilled,
                                         message), affectedFields, message));
                }

                IEnumerable <UnequalField> unequalFields =
                    equalFieldValuesCondition.GetNonEqualFields(feature, classIndex,
                                                                neighborFeature,
                                                                neighborClassIndex);
                foreach (UnequalField unequalField in unequalFields)
                {
                    yield return(new AttributeConstraintViolation(
                                     string.Format(
                                         LocalizableStrings.EdgeMatchUtils_AttributeConstraints_ValuesNotEqual,
                                         unequalField.Message), unequalField.FieldName, unequalField.Message));
                }
            }
            else
            {
                string description;
                string affectedComponents;
                string textValue;
                bool   areConstraintsFulfilled = AreAttributeConstraintsFulfilled(
                    feature, classIndex,
                    neighborFeature, neighborClassIndex,
                    rowPairCondition,
                    equalFieldValuesCondition,
                    out description, out affectedComponents, out textValue);

                if (!areConstraintsFulfilled)
                {
                    yield return(new AttributeConstraintViolation(description,
                                                                  affectedComponents,
                                                                  textValue));
                }
            }
        }
Esempio n. 3
0
        private static bool AreAttributeConstraintsFulfilled(
            [NotNull] IFeature feature, int classIndex,
            [NotNull] IFeature neighborFeature, int neighborClassIndex,
            [NotNull] RowPairCondition rowPairCondition,
            [NotNull] EqualFieldValuesCondition equalFieldValuesCondition,
            [NotNull] out string errorDescription,
            [CanBeNull] out string affectedComponents,
            [NotNull] out string textValue)
        {
            var affectedFields = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            // compare attributes that are required to match
            var          descriptionBuilder = new StringBuilder();
            var          textValueBuilder   = new StringBuilder();
            string       message;
            IColumnNames errorColumnNames;

            if (!rowPairCondition.IsFulfilled(feature, classIndex,
                                              neighborFeature,
                                              neighborClassIndex,
                                              out message,
                                              out errorColumnNames))
            {
                descriptionBuilder.AppendFormat(
                    LocalizableStrings.EdgeMatchUtils_AttributeConstraints_ConstraintNotFulfilled,
                    message);

                foreach (string affectedColumn in errorColumnNames.GetInvolvedColumnNames())
                {
                    affectedFields.Add(affectedColumn);
                }

                textValueBuilder.Append(message);
            }

            IEnumerable <UnequalField> unequalFields =
                equalFieldValuesCondition.GetNonEqualFields(feature, classIndex,
                                                            neighborFeature, neighborClassIndex);

            if (HasUnequalFields(unequalFields, out message, affectedFields))
            {
                if (descriptionBuilder.Length > 0)
                {
                    descriptionBuilder.Append(". ");
                }

                descriptionBuilder.AppendFormat(
                    LocalizableStrings.EdgeMatchUtils_AttributeConstraints_ValuesNotEqual,
                    message);

                if (textValueBuilder.Length > 0)
                {
                    textValueBuilder.Append("|");
                }

                textValueBuilder.Append(message);
            }

            errorDescription   = descriptionBuilder.ToString();
            affectedComponents = FormatAffectedComponents(affectedFields);
            textValue          = textValueBuilder.ToString();

            return(errorDescription.Length == 0);
        }