Ejemplo n.º 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));
        }
Ejemplo n.º 2
0
        private static void AssertFilteredMultiViewRowCount(
            int expectedCount, [NotNull] string expression,
            [NotNull] IFeatureClass featureClass, [NotNull] IFeature feature,
            [NotNull] ITable table, [NotNull] IRow row)
        {
            MultiTableView view = TableViewFactory.Create(new[] { (ITable)featureClass, table },
                                                          new[] { "F", "T" },
                                                          expression);

            view.Add(feature, row);

            Assert.AreEqual(expectedCount, view.FilteredRowCount,
                            "Unexpected filtered row count");
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// create a filter that gets the lines crossing the current row,
        /// with the same attribute constraints as the table
        /// </summary>
        private void InitFilter()
        {
            IList <ISpatialFilter>    spatialFilters;
            IList <QueryFilterHelper> filterHelpers;

            // there is one table and hence one filter (see constructor)
            // Create copy of this filter and use it for quering crossing lines
            CopyFilters(out spatialFilters, out filterHelpers);

            _spatialFilter = spatialFilters[0];
            _selectHelper  = filterHelpers[0];

            _spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelTouches;

            if (_constraint != null)
            {
                _compareHelper = TableViewFactory.Create(
                    new[] { InvolvedTables[0], InvolvedTables[0] },
                    new[] { "L", "R" },
                    _constraint,
                    GetSqlCaseSensitivity());
            }
        }