コード例 #1
0
        public void Learning_CanFindFeaturesWithNonZSimpleSearchGeometry()
        {
            // 10.2.1: Test fails (correct) with COM Exception on OpenCursor
            // 10.4.1: Test fails (correct) with COM Exception on OpenCursor
            // 10.6.1: Test passes (incorrectly!), no features found

            IFeatureWorkspace ws = OpenTestWorkspace();
            IFeatureClass     fc = ws.OpenFeatureClass("TOPGIS_TLM.TLM_STRASSE");

            IEnvelope nonZSimpleEnvelope = GeometryFactory.CreateEnvelope(2600000, 1200000,
                                                                          2700000, 1300000);

            GeometryUtils.MakeZAware(nonZSimpleEnvelope);

            Assert.False(((IZAware)nonZSimpleEnvelope).ZSimple, "Must be non-Z-simple");

            ISpatialReference spatialReference = DatasetUtils.GetSpatialReference(fc);

            nonZSimpleEnvelope.SpatialReference = spatialReference;

            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.GeometryField = fc.ShapeFieldName;
            spatialFilter.set_GeometryEx(nonZSimpleEnvelope, true);
            spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            Assert.AreEqual(0, GdbQueryUtils.GetFeatures(fc, spatialFilter, true).Count(),
                            "Behaviour changed: Now features are found even with non-Z-simple search geometry.");
        }
コード例 #2
0
        public void CanGetRowsInLongList()
        {
            IFeatureWorkspace ws = OpenTestWorkspace();
            IFeatureClass     fc = ws.OpenFeatureClass("TOPGIS_TLM.TLM_STRASSE");

            // fill list
            const int max = 2000;
            Dictionary <int, IRow> dic = GetFirstNRows((ITable)fc, max);

            var selList = new List <int>(max);

            foreach (IRow row in GdbQueryUtils.GetRowsInList((ITable)fc, fc.OIDFieldName,
                                                             dic.Keys, false, null))
            {
                selList.Add(row.OID);
                IRow origRow = dic[row.OID];
                Assert.AreEqual(origRow.OID, row.OID, "");
                //dic[row.OID] = null; REMARK: this changes list dic.Keys and leads to an error in foreach
            }

            Assert.AreEqual(dic.Count, selList.Count, "List counts differ");

            var oidList = new List <int>(dic.Keys);

            oidList.Sort();
            selList.Sort();
            for (var i = 0; i < oidList.Count; i++)
            {
                Assert.AreEqual(oidList[i], selList[i], "{0}th element differs", i);
            }
        }
コード例 #3
0
        public void CanGetRowsNotInUUIDList()
        {
            IFeatureWorkspace ws  = OpenTestWorkspace();
            ITable            tbl = ws.OpenTable("TOPGIS_TLM.TLM_STRASSE");

            var          nRows  = 0;
            IQueryFilter filter = new QueryFilterClass();

            foreach (
                // ReSharper disable once UnusedVariable
                IRow row in
                GdbQueryUtils.GetRowsNotInList(tbl, filter, true, "UUID",
                                               new[]
            {
                "{8C5517C9-B19F-4CC1-A6A1-D3DD317BCDD1}"
            }))
            {
                nRows++;
            }

            filter.WhereClause = "UUID not in ('{8C5517C9-B19F-4CC1-A6A1-D3DD317BCDD1}')";
            int n = tbl.RowCount(filter);

            Assert.AreEqual(n, nRows, "");
        }
コード例 #4
0
ファイル: TableViewTest.cs プロジェクト: sungaoyong/ProSuite
        private static void AssertFilteredRowCount(
            int expectedCount,
            [NotNull] string expression,
            params IFeature[] features)
        {
            TableView view = CreateTableView(expression, features);

            Assert.AreEqual(expectedCount, view.FilteredRowCount,
                            "Unexpected filtered row count");
        }
コード例 #5
0
        private static IFeature GetFeatureUsingGetFeatures(
            [NotNull] IFeatureClass featureClass, int oid)
        {
            var singleOidList = new List <int> {
                oid
            };

            IList <IFeature> features = new List <IFeature>(
                GdbQueryUtils.GetFeatures(featureClass, singleOidList, false));

            Assert.AreEqual(1, features.Count, "unexpected feature count");
            return(features[0]);
        }
コード例 #6
0
ファイル: TableViewTest.cs プロジェクト: sungaoyong/ProSuite
        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");
        }
コード例 #7
0
        private static int ByteArrayCompare(byte[] a1, byte[] a2)
        {
            Assert.AreEqual(a1.Length, a2.Length, "Length difference");

            for (int i = 0; i < a1.Length; i++)
            {
                int compareValue = a1[i].CompareTo(a2[i]);

                if (compareValue != 0)
                {
                    return(compareValue);
                }
            }

            return(0);
        }
コード例 #8
0
        public void CanGetRowsNotInStringList()
        {
            IFeatureWorkspace ws  = OpenTestWorkspace();
            ITable            tbl = ws.OpenTable("TOPGIS_TLM.TLM_STRASSE");

            var          nRows  = 0;
            IQueryFilter filter = new QueryFilterClass();

            foreach (
                // ReSharper disable once UnusedVariable
                IRow row in
                GdbQueryUtils.GetRowsNotInList(tbl, filter, true, "OPERATEUR",
                                               new[] { "STR_Imp" }))
            {
                nRows++;
            }

            filter.WhereClause = "OPERATEUR not in ('STR_Imp')";
            int n = tbl.RowCount(filter);

            Assert.AreEqual(n, nRows, "");
        }
コード例 #9
0
        public void CanGetRowsNotInIntList()
        {
            IFeatureWorkspace ws  = OpenTestWorkspace();
            ITable            tbl = ws.OpenTable("TOPGIS_TLM.TLM_STRASSE");

            var          nRows  = 0;
            IQueryFilter filter = new QueryFilterClass();

            foreach (
                // ReSharper disable once UnusedVariable
                IRow row in
                GdbQueryUtils.GetRowsNotInList(tbl, filter, true, "OBJEKTART",
                                               new object[] { 1, 2, 3 }))
            {
                nRows++;
            }

            filter.WhereClause = "OBJEKTART not in (1, 2, 3)";
            int n = tbl.RowCount(filter);

            Assert.AreEqual(n, nRows, "");
        }
コード例 #10
0
 public void CanThrowAreEqual()
 {
     NUnit.Framework.Assert.Throws <AssertionException>(
         () => Assert.AreEqual(111, 112, "equal"));
 }
コード例 #11
0
 public void CanAssertAreEqual()
 {
     Assert.AreEqual(111, 111, "equal");
 }
コード例 #12
0
        public void CanCreateSpatialFilterWithSubResolutionPolyline()
        {
            IFeatureWorkspace ws = OpenTestWorkspace();
            IFeatureClass     fc = ws.OpenFeatureClass("TOPGIS_TLM.TLM_STRASSE");

            IPolyline subResolutionPolyline = GeometryFactory.CreatePolyline(2600000, 1200000,
                                                                             2600000.0001,
                                                                             1200000.0001);

            subResolutionPolyline.SpatialReference = ((IGeoDataset)fc).SpatialReference;

            Exception expectedEx = null;

            try
            {
                ISpatialFilter standardFilter = new SpatialFilterClass();
                standardFilter.Geometry   = subResolutionPolyline;
                standardFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIndexIntersects;
                // ReSharper disable once UnusedVariable
                IFeatureCursor failingCursor = fc.Search(standardFilter, true);
            }
            catch (Exception ex)
            {
                expectedEx = ex;
            }

            if (RuntimeUtils.Is10_2 || RuntimeUtils.Is10_3 || RuntimeUtils.Is10_4orHigher)
            {
                Assert.Null(expectedEx);
            }
            else
            {
                Assert.NotNull(expectedEx);
            }

            IQueryFilter filter = GdbQueryUtils.CreateSpatialFilter(
                fc, subResolutionPolyline, esriSpatialRelEnum.esriSpatialRelIntersects, false,
                null);

            Assert.True(((ISpatialFilter)filter).FilterOwnsGeometry,
                        "Filter should own geometry due to cloned geometry in GetValidSearchGeometry.");
            Assert.AreEqual(((ISpatialFilter)filter).SearchOrder,
                            esriSearchOrder.esriSearchOrderSpatial,
                            "Default should be spatial.");
            Assert.AreEqual(((ISpatialFilter)filter).SpatialRel,
                            esriSpatialRelEnum.esriSpatialRelIntersects,
                            "Default should be spatial.");

            IFeatureCursor cursor = fc.Search(filter, true);

            Marshal.ReleaseComObject(cursor);

            // test the exact half of the resolution - which is the limit
            double resolution = GeometryUtils.GetXyResolution(fc);

            subResolutionPolyline = GeometryFactory.CreatePolyline(2600000 - 0.00001,
                                                                   1200000 - 0.00001,
                                                                   2600000 + resolution -
                                                                   0.00001,
                                                                   1200000 + resolution -
                                                                   0.00001);

            filter = GdbQueryUtils.CreateSpatialFilter(
                fc, subResolutionPolyline, esriSpatialRelEnum.esriSpatialRelIntersects, false,
                null);

            cursor = fc.Search(filter, true);
            Marshal.ReleaseComObject(cursor);
        }