Beispiel #1
0
        public void CanMatchRows()
        {
            const string  textField1    = "Text1";
            const string  textField2    = "Text2";
            const string  textFieldBoth = "Text";
            IFeatureClass fc1           = CreateFeatureClass("CanMatchRows_fc1",
                                                             esriGeometryType.esriGeometryPolygon,
                                                             FieldUtils.CreateTextField(textField1, 1),
                                                             FieldUtils.CreateTextField(textFieldBoth, 1));
            IFeatureClass fc2 = CreateFeatureClass("CanMatchRows_fc2",
                                                   esriGeometryType.esriGeometryPolygon,
                                                   FieldUtils.CreateTextField(textFieldBoth, 1),
                                                   FieldUtils.CreateTextField(textField2, 1));

            const bool     caseSensitive = true;
            MultiTableView view          = TableViewFactory.Create(new[] { (ITable)fc1, (ITable)fc2 },
                                                                   new[] { "G1", "G2" },
                                                                   "G1.TEXT1 = G2.TEXT2 AND G1.Text = 'x' AND G2.Text = 'y'",
                                                                   caseSensitive);

            IFeature f1A = fc1.CreateFeature();

            f1A.Value[fc1.FindField(textField1)]    = "A";
            f1A.Value[fc1.FindField(textFieldBoth)] = "x";
            f1A.Store();

            IFeature f2A = fc2.CreateFeature();

            f2A.Value[fc2.FindField(textField2)]    = "A";
            f2A.Value[fc2.FindField(textFieldBoth)] = "y";
            f2A.Store();

            Assert.IsTrue(view.MatchesConstraint(f1A, f2A));
            Assert.AreEqual("G1.TEXT1 = 'A'; G2.TEXT2 = 'A'; G1.TEXT = 'x'; G2.TEXT = 'y'",
                            view.ToString(f1A, f2A));

            IFeature f1B = fc1.CreateFeature();

            f1B.Value[fc1.FindField(textField1)]    = "b";
            f1B.Value[fc1.FindField(textFieldBoth)] = "x";
            f1B.Store();

            IFeature f2B = fc2.CreateFeature();

            f2B.Value[fc2.FindField(textField2)]    = "B";          // different case --> no match
            f2B.Value[fc2.FindField(textFieldBoth)] = "y";
            f2B.Store();

            Assert.IsFalse(view.MatchesConstraint(f1B, f2B));
            Assert.AreEqual("G1.TEXT1 = 'b'; G2.TEXT2 = 'B'; G1.TEXT = 'x'; G2.TEXT = 'y'",
                            view.ToString(f1B, f2B));
        }
Beispiel #2
0
        public void CanUseShapeAreaAlias()
        {
            IFeatureClass fc1 = CreateFeatureClass("CanUseShapeAreaAlias_fc1",
                                                   esriGeometryType.esriGeometryPolygon);
            IFeatureClass fc2 = CreateFeatureClass("CanUseShapeAreaAlias_fc2",
                                                   esriGeometryType.esriGeometryPolygon);

            const bool     caseSensitive = true;
            MultiTableView view          = TableViewFactory.Create(new[] { (ITable)fc1, (ITable)fc2 },
                                                                   new[] { "G1", "G2" },
                                                                   "G1.$ShapeArea < G2.$ShapeArea",
                                                                   caseSensitive);

            IFeature f1A = fc1.CreateFeature();

            f1A.Shape = GeometryFactory.CreatePolygon(0, 0, 10, 10);
            f1A.Store();

            IFeature f1B = fc1.CreateFeature();

            f1B.Shape = GeometryFactory.CreatePolygon(0, 0, 100, 100);
            f1B.Store();

            IFeature f2A = fc2.CreateFeature();

            f2A.Shape = GeometryFactory.CreatePolygon(0, 0, 100, 100);
            f2A.Store();

            IFeature f2B = fc2.CreateFeature();

            f2B.Shape = GeometryFactory.CreatePolygon(0, 0, 10, 10);
            f2B.Store();

            Assert.IsTrue(view.MatchesConstraint(f1A, f2A));
            Assert.AreEqual("G1.$SHAPEAREA = 100; G2.$SHAPEAREA = 10000",
                            view.ToString(f1A, f2A));

            Assert.IsFalse(view.MatchesConstraint(f1B, f2B));
            Assert.AreEqual("G1.$SHAPEAREA = 10000; G2.$SHAPEAREA = 100",
                            view.ToString(f1B, f2B));
        }
Beispiel #3
0
        private int CheckConstraint([NotNull] DirectedRow line,
                                    [CanBeNull] IRow centroid)
        {
            if (_constraintHelper == null && centroid != null)
            {
                _constraintHelper = CreateConstraintHelper(
                    line.Row.Row.Table, centroid.Table);
            }

            Assert.Null(line.LeftCentroid, "left centroid is not null");

            var errorCount = 0;

            if (line.RightCentroid != null)
            {
                var lineFeature = (IFeature)line.Row.Row;

                if (centroid != null &&
                    !_constraintHelper.MatchesConstraint(lineFeature,
                                                         centroid,
                                                         line.RightCentroid))
                {
                    errorCount +=
                        ReportError(
                            _constraintHelper.ToString(lineFeature,
                                                       centroid,
                                                       line.RightCentroid),
                            lineFeature.Shape,
                            Codes[Code.DoesNotMatchConstraint], null,
                            lineFeature, centroid, line.RightCentroid);
                }

                line.RightCentroid = null;
            }
            else
            {
                line.LeftCentroid = centroid;
            }

            return(errorCount);
        }
        private int CheckRows([NotNull] IRow row,
                              [NotNull] IGeometry shape,
                              [NotNull] IFeature touchingFeature)
        {
            if (_compareHelper != null)
            {
                if (_compareHelper.MatchesConstraint(row, touchingFeature))
                {
                    return(NoError);
                }
            }
            else if (_compareFieldIndexes != null)
            {
                foreach (int fieldIndex in _compareFieldIndexes)
                {
                    if (!Equals(row.Value[fieldIndex], touchingFeature.Value[fieldIndex]))
                    {
                        // different field value -> area boundary is justified
                        return(NoError);
                    }
                }
            }

            IGeometry errorGeometry = GetErrorGeometry(shape, touchingFeature);

            if (errorGeometry == null)
            {
                return(NoError);
            }

            IssueCode issueCode;

            return(ReportError(GetErrorDescription(row, touchingFeature, out issueCode),
                               errorGeometry,
                               issueCode, null,
                               row, touchingFeature));
        }