private static void RunTest([NotNull] IFeatureClass polygonFeatureClass,
                                    [NotNull] IFeatureClass pointFeatureClass,
                                    int minimumPointCount, int maximumPointCount,
                                    [CanBeNull] string relevantPointCondition,
                                    bool countPointOnPolygonBorder,
                                    double tileSize,
                                    [CanBeNull] IEnvelope envelope, int expectedErrorCount)
        {
            var test = new QaContainedPointsCount(polygonFeatureClass, pointFeatureClass,
                                                  minimumPointCount, maximumPointCount,
                                                  relevantPointCondition,
                                                  countPointOnPolygonBorder);

            // run in container without envelope

            var containerRunner = new QaContainerTestRunner(tileSize, test);

            if (envelope == null)
            {
                containerRunner.Execute();
            }
            else
            {
                containerRunner.Execute(envelope);
            }

            Assert.AreEqual(expectedErrorCount, containerRunner.Errors.Count);
        }
        private static IList <QaError> Run([NotNull] ITest test, double?tileSize = null,
                                           IEnvelope testExtent = null)
        {
            Console.WriteLine(@"Tile size: {0}",
                              tileSize == null ? "<null>" : tileSize.ToString());
            const string newLine = "\n";

            // r# unit test output adds 2 lines for Environment.NewLine
            Console.Write(newLine);

            QaTestRunnerBase runner;

            if (tileSize == null)
            {
                var testRunner = new QaTestRunner(test);
                testRunner.Execute();
                runner = testRunner;
            }
            else
            {
                var testRunner = new QaContainerTestRunner(tileSize.Value, test)
                {
                    KeepGeometry = true
                };
                int errorCount = testExtent == null
                                                         ? testRunner.Execute()
                                                         : testRunner.Execute(testExtent);

                runner = testRunner;
            }

            return(runner.Errors);
        }
Example #3
0
        public void CanAllowSingleConnectedLineShorterThanNearDistance()
        {
            const string testName = "CanAllowSingleConnectedLineShorterThanNearDistance";

            IFeatureClass lineClass = CreateFeatureClass(string.Format("{0}_lines", testName),
                                                         esriGeometryType.esriGeometryPolyline);

            IFeature longLine = lineClass.CreateFeature();

            longLine.Shape = CurveConstruction.StartLine(0, 0)
                             .LineTo(100, 0)
                             .Curve;
            longLine.Store();

            IFeature shortLine = lineClass.CreateFeature();

            shortLine.Shape = CurveConstruction.StartLine(100, 0)
                              .LineTo(101, 0)
                              .Curve;
            shortLine.Store();

            IEnvelope verificationEnvelope = GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaNodeLineCoincidence(lineClass, new[] { lineClass }, 2, false);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute(verificationEnvelope);

            AssertUtils.NoError(runner);
        }
Example #4
0
        public void CanTestByTangents()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTestByTangents");

            IFeature row1 = fc.CreateFeature();

            row1.Shape =
                CurveConstruction.StartLine(0, 0, 0)
                .LineTo(0, 1, 0)
                .LineTo(0.1, 0, 0)
                .LineTo(0.1, 1, 100)
                .LineTo(0.1, 2, 100)
                .CircleTo(GeometryFactory.CreatePoint(0.2, 0, 100))
                .Curve;
            row1.Store();

            var test = new QaMinSegAngle(fc, 0.1, true)
            {
                UseTangents = true
            };

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            Assert.AreEqual(1, runner.Errors.Count);
        }
Example #5
0
        public void CanTestInDegrees()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTestInDegrees");

            IFeature row1 = fc.CreateFeature();

            row1.Shape =
                CurveConstruction.StartLine(0, 0, 0)
                .LineTo(0, 1, 0)
                .LineTo(0.1, 0, 0)
                .LineTo(0.1, 1, 100)
                .LineTo(0.1, 2, 100)
                .CircleTo(GeometryFactory.CreatePoint(0.2, 0, 100))
                .Curve;
            row1.Store();

            double limit = FormatUtils.Radians2AngleInUnits(0.1, AngleUnit.Degree);
            var    test  = new QaMinSegAngle(fc, limit, true);

            test.AngularUnit = AngleUnit.Degree;

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            Assert.AreEqual(2, runner.Errors.Count);
        }
        public void TestTopgisTMultiPatches()
        {
            IWorkspace workspace = TestDataUtils.OpenTopgisTlm();

            IFeatureClass gebaeude =
                ((IFeatureWorkspace)workspace).OpenFeatureClass(
                    "TOPGIS_TLM.TLM_GEBAEUDE");

            var test = new QaMpVertexNotNearFace(
                gebaeude, new[] { gebaeude }, 1, 0.2);

            test.VerifyWithinFeature    = true;
            test.PointCoincidence       = 0.1;
            test.EdgeCoincidence        = 0.1;
            test.IgnoreNonCoplanarFaces = true;
            test.MinimumSlopeDegrees    = 15;

            var runner = new QaContainerTestRunner(10000, test);

            runner.LogErrors = false;

            IFeatureWorkspace ws =
                TestWorkspaceUtils.CreateTestFgdbWorkspace("QaMpVertexNotNearFaceTest");
            var logger = new SimpleErrorWorkspace(ws);

            runner.TestContainer.QaError += logger.TestContainer_QaError;

            runner.Execute();

            Console.WriteLine(runner.Errors.Count);
        }
Example #7
0
        public void CanTest2SegmentCircle()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTest2SegmentCircle");

            IFeature row1 = fc.CreateFeature();

            IConstructCircularArc arc = new CircularArcClass();

            arc.ConstructCircle(GeometryFactory.CreatePoint(0, 0, 0), 3, false);

            IPolyline polyline = CreatePolyLine((ISegment)arc);

            int  segmentIndex;
            int  newPartIndex;
            bool splitHappened;

            polyline.SplitAtDistance(0.5, true, false,
                                     out splitHappened,
                                     out newPartIndex,
                                     out segmentIndex);
            Assert.True(splitHappened);

            row1.Shape = polyline;
            row1.Store();

            var test = new QaMinSegAngle(fc, 0.1, true);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute();

            // assert that two segment closed curve does not always report two
            // errors when using linearized segments
            Assert.AreEqual(0, runner.Errors.Count);
        }
Example #8
0
        public void CanHandleZeroLengthEndSegments()
        {
            const string featureClassName = "TLM_STEHENDES_GEWAESSER";

            var    locator = TestDataUtils.GetTestDataLocator();
            string path    = locator.GetPath("QaBorderSense.gdb");

            IFeatureWorkspace workspace = WorkspaceUtils.OpenFileGdbFeatureWorkspace(path);

            IFeatureClass featureClass = workspace.OpenFeatureClass(featureClassName);

            // expect counter-clockwise: 0 errors
            var runnerCounterClockwise = new QaContainerTestRunner(1000,
                                                                   new QaBorderSense(
                                                                       featureClass, false));

            Assert.AreEqual(0, runnerCounterClockwise.Execute());

            // expect clockwise: 1 error
            var runnerClockwise = new QaContainerTestRunner(1000,
                                                            new QaBorderSense(featureClass,
                                                                              true));

            Assert.AreEqual(1, runnerClockwise.Execute());
        }
Example #9
0
        public void MultipartTest()
        {
            IFeatureWorkspace workspace =
                TestWorkspaceUtils.CreateInMemoryWorkspace("MultipartTest");

            IFieldsEdit fields = new FieldsClass();

            fields.AddField(FieldUtils.CreateOIDField());
            fields.AddField(FieldUtils.CreateShapeField(
                                "Shape", esriGeometryType.esriGeometryPolyline, CreateLV95(),
                                1000));

            IFeatureClass featureClass = DatasetUtils.CreateSimpleFeatureClass(
                workspace, "Border", fields);

            AddFeature(featureClass,
                       CurveConstruction.StartLine(0, 0).LineTo(4, 0).MoveTo(6, 0).LineTo(6, 10)
                       .Curve);
            AddFeature(featureClass, CurveConstruction.StartLine(6, 10).LineTo(4, 10).Curve);
            AddFeature(featureClass,
                       CurveConstruction.StartLine(4, 0).LineTo(6, 0).MoveTo(4, 10).LineTo(0, 0)
                       .Curve);

            // expect counter-clockwise: 0 errors
            var runnerCounterClockwise = new QaContainerTestRunner(
                1000, new QaBorderSense(featureClass, false));

            Assert.AreEqual(0, runnerCounterClockwise.Execute());

            // expect clockwise: 1 error
            var runnerClockwise = new QaContainerTestRunner(
                1000, new QaBorderSense(featureClass, true));

            Assert.AreEqual(1, runnerClockwise.Execute());
        }
Example #10
0
        public void MultipartTest()
        {
            IFeatureWorkspace workspace =
                TestWorkspaceUtils.CreateInMemoryWorkspace("MultipartTest");

            IFieldsEdit fields = new FieldsClass();

            fields.AddField(FieldUtils.CreateOIDField());
            fields.AddField(FieldUtils.CreateShapeField(
                                "Shape", esriGeometryType.esriGeometryPolyline, CreateLV95(),
                                1000));

            IFeatureClass linesFc = DatasetUtils.CreateSimpleFeatureClass(workspace, "Flow",
                                                                          fields);

            AddFeature(
                linesFc,
                CurveConstruction.StartLine(0, 0).LineTo(4, 0).MoveTo(6, 0).LineTo(6, 10).Curve);
            AddFeature(linesFc, CurveConstruction.StartLine(4, 0).LineTo(6, 0).Curve);

            AddFeature(linesFc, CurveConstruction.StartLine(0, 20).LineTo(4, 20).Curve);

            AddFeature(
                linesFc,
                CurveConstruction.StartLine(0, 30).LineTo(4, 30).MoveTo(0, 32).LineTo(4, 30)
                .MoveTo(4, 30).LineTo(8, 30).Curve);

            // expect counter-clockwise: 0 errors
            var runner = new QaContainerTestRunner(
                1000, new QaFlowLogic(linesFc));

            Assert.AreEqual(3, runner.Execute());
        }
        public void CanReportNoVertexOnNearbyEdgeLineErrorInLeftTile()
        {
            const string testName = "CanReportNoVertexOnNearbyEdgeLineErrorInLeftTile";

            IFeatureClass vertexClass = CreateFeatureClass(
                $"{testName}_vertex", esriGeometryType.esriGeometryPolyline);

            IFeature lineRow = vertexClass.CreateFeature();

            lineRow.Shape = CurveConstruction.StartLine(300, 100)
                            .LineTo(201, 100)
                            .Curve;
            lineRow.Store();
            IFeature lineRow2 = vertexClass.CreateFeature();

            lineRow2.Shape = CurveConstruction.StartLine(199, 150)
                             .LineTo(199, 50)
                             .Curve;
            lineRow2.Store();

            IEnvelope verificationEnvelope =
                GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaVertexCoincidenceSelf(vertexClass)
            {
                EdgeTolerance = 3
            };

            var runner = new QaContainerTestRunner(200, test);

            runner.Execute(verificationEnvelope);

            AssertUtils.OneError(runner,
                                 "VertexCoincidence.NoVertexOnNearbyEdge.DifferentFeature");
        }
        public void CanReportMultiPointErrorInSameTile()
        {
            const string testName = "CanReportMultiPointErrorInSameTile";

            IFeatureClass vertexClass = CreateFeatureClass(
                $"{testName}_vertex", esriGeometryType.esriGeometryMultipoint);

            IFeature multiPointClass = vertexClass.CreateFeature();

            multiPointClass.Shape =
                GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(201, 199));
            multiPointClass.Store();
            IFeature vertexRow1 = vertexClass.CreateFeature();

            vertexRow1.Shape =
                GeometryFactory.CreateMultipoint(GeometryFactory.CreatePoint(199, 199));
            vertexRow1.Store();

            IEnvelope verificationEnvelope =
                GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaVertexCoincidenceSelf(vertexClass)
            {
                PointTolerance = 3
            };

            var runner = new QaContainerTestRunner(500, test);

            runner.Execute(verificationEnvelope);

            Assert.AreEqual(2, runner.Errors.Count);
        }
Example #13
0
        private static void TestReferencedGuid(IFeatureWorkspace ws)
        {
            IFieldsEdit fields1 = new FieldsClass();

            fields1.AddField(FieldUtils.CreateOIDField());
            fields1.AddField(FieldUtils.CreateField("Pk", esriFieldType.esriFieldTypeGUID));

            ITable tbl1 = DatasetUtils.CreateTable(ws, "TestReferencedGuid1", null, fields1);

            IFieldsEdit fields2 = new FieldsClass();

            fields2.AddField(FieldUtils.CreateOIDField());
            fields2.AddField(FieldUtils.CreateTextField("Fk", 50));

            ITable tbl2 = DatasetUtils.CreateTable(ws, "TestReferencedGuid2", null, fields2);

            IFieldsEdit fields3 = new FieldsClass();

            fields3.AddField(FieldUtils.CreateOIDField());
            fields3.AddField(FieldUtils.CreateField("Fk", esriFieldType.esriFieldTypeGUID));

            ITable tbl3 = DatasetUtils.CreateTable(ws, "TestReferencedGuid3", null, fields3);

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)ws).StartEditing(false);
            ((IWorkspaceEdit)ws).StopEditing(true);

            for (int i = 0; i < 5; i++)
            {
                Guid guid = Guid.NewGuid();
                CreateRow(tbl1, guid.ToString("B"));

                if (i % 2 == 0)
                {
                    CreateRow(tbl2, guid.ToString());
                }
                else
                {
                    CreateRow(tbl3, guid.ToString("B"));
                }
            }

            var test = new QaUnreferencedRows(tbl1,
                                              new[] { tbl2, tbl3 },
                                              new[] { "pk,fk", "pk,fk" });

            using (var r = new QaTestRunner(test))
            {
                r.Execute();
                Assert.AreEqual(0, r.Errors.Count);
            }

            var container = new QaContainerTestRunner(10000, test);

            container.Execute();
            Assert.AreEqual(0, container.Errors.Count);
        }
Example #14
0
        private static void TestReferenced(IFeatureWorkspace ws)
        {
            IFieldsEdit fields1 = new FieldsClass();

            fields1.AddField(FieldUtils.CreateOIDField());
            fields1.AddField(FieldUtils.CreateSmallIntegerField("Pk"));

            ITable tbl1 = DatasetUtils.CreateTable(ws, "TestReferenced1", null, fields1);

            IFieldsEdit fields2 = new FieldsClass();

            fields2.AddField(FieldUtils.CreateOIDField());
            fields2.AddField(FieldUtils.CreateSmallIntegerField("Fk"));

            ITable tbl2 = DatasetUtils.CreateTable(ws, "TestReferenced2", null, fields2);

            IFieldsEdit fields3 = new FieldsClass();

            fields3.AddField(FieldUtils.CreateOIDField());
            fields3.AddField(FieldUtils.CreateIntegerField("Fk"));

            ITable tbl3 = DatasetUtils.CreateTable(ws, "TestReferenced3", null, fields3);

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)ws).StartEditing(false);
            ((IWorkspaceEdit)ws).StopEditing(true);

            CreateRow(tbl1, 1);
            CreateRow(tbl1, 2);
            CreateRow(tbl1, 3);
            CreateRow(tbl1, 4);
            CreateRow(tbl1, 5);

            CreateRow(tbl2, 1);
            CreateRow(tbl2, 3);
            CreateRow(tbl2, 5);

            CreateRow(tbl3, 2);
            CreateRow(tbl3, 4);

            var test = new QaUnreferencedRows(tbl1,
                                              new[] { tbl2, tbl3 },
                                              new[] { "pk,fk", "pk,fk" });

            using (var r = new QaTestRunner(test))
            {
                r.Execute();
                Assert.AreEqual(0, r.Errors.Count);
            }

            var container = new QaContainerTestRunner(10000, test);

            container.Execute();
            Assert.AreEqual(0, container.Errors.Count);
        }
Example #15
0
        private static void TestNMRelation(IFeatureWorkspace ws)
        {
            IFieldsEdit fields1 = new FieldsClass();

            fields1.AddField(FieldUtils.CreateOIDField());
            fields1.AddField(FieldUtils.CreateIntegerField("Pk"));

            ITable tbl1 = DatasetUtils.CreateTable(ws, "TestNMRelation1", null, fields1);

            IFieldsEdit fields2 = new FieldsClass();

            fields2.AddField(FieldUtils.CreateOIDField());
            fields2.AddField(FieldUtils.CreateIntegerField("Fk"));

            ITable tbl2 = DatasetUtils.CreateTable(ws, "TestNMRelation2", null, fields2);

            IRelationshipClass rel = CreateSimpleMNRelationship(ws, "TestNMRelationRel", tbl1,
                                                                tbl2, "Pk", "Fk");

            ((IWorkspaceEdit)ws).StartEditing(false);
            IRow r11 = CreateRow(tbl1, 8);
            IRow r12 = CreateRow(tbl1, 12);
            IRow r13 = CreateRow(tbl1, 7);

            IRow r21 = CreateRow(tbl2, 9);
            IRow r22 = CreateRow(tbl2, 5);
            IRow r23 = CreateRow(tbl2, 4);

            Assert.NotNull(r12);             // not used otherwise

            rel.CreateRelationship((IObject)r11, (IObject)r21);
            rel.CreateRelationship((IObject)r11, (IObject)r23);
            rel.CreateRelationship((IObject)r13, (IObject)r22);

            r22.set_Value(1, 6);
            r22.Store();

            ((IWorkspaceEdit)ws).StopEditing(true);

            var test = new QaUnreferencedRows(tbl1,
                                              new[] { tbl2 },
                                              new[] { "pk,pk,TestNMRelationRel,fk,fk" });

            using (var r = new QaTestRunner(test))
            {
                r.Execute();
                Assert.AreEqual(2, r.Errors.Count);
            }

            var container = new QaContainerTestRunner(10000, test);

            container.Execute();
            Assert.AreEqual(2, container.Errors.Count);
        }
Example #16
0
        public void CanTestDefinedExtentMultipleTilesWithLinesNearTileBoundary()
        {
            IPolycurve leftOfTileBoundary = CurveConstruction.StartLine(99.5, 10)
                                            .LineTo(99.5, 90)
                                            .Curve;
            IPolycurve rightOfTileBoundary = CurveConstruction.StartLine(100.5, 10)
                                             .LineTo(100.5, 90)
                                             .Curve;

            IFeatureClass fc = CreateLineClass(_testWs, "CanTestDefinedExtentMultipleTiles_fc");

            IFeature row = fc.CreateFeature();

            row.Shape = rightOfTileBoundary;
            row.Store();

            IFeatureClass nearClass = CreateLineClass(_testWs,
                                                      "CanTestDefinedExtentMultipleTiles_near");

            IFeature nearRow = nearClass.CreateFeature();

            nearRow.Shape = leftOfTileBoundary;
            nearRow.Store();

            IPolygon polygon = GeometryFactory.CreatePolygon(
                GeometryFactory.CreateEnvelope(0, 0, 200, 200));

            const double maximumDistance = 1.5;

            // one tile for the entire verification extent
            QaContainerTestRunner runnerLargeTileSize = CreateTestRunner(
                fc, nearClass, 200, maximumDistance);

            runnerLargeTileSize.Execute(polygon);

            AssertUtils.NoError(runnerLargeTileSize);

            // 4 tiles.
            // The feature is in the second tile, to the right of the left tile boundary, but within the search distance of it.
            // The 'near feature' is in the first tile, to the left of the right tile boundary, but within the search distance of it.

            // NOTE currently this results in an error, since the 'near feature' is not returned again for the second tile
            // (the test container assumes that it was already considered in the first tile; in this case however, it is
            // needed for a feature in the *second* tile, which was not yet returned for the first tile.

            // -> if the search geometry overlaps the tile boundary but the source feature for the search DOES NOT, then
            //    features must be returned by the search even if they overlap a previous tile
            QaContainerTestRunner runnerSmallTileSize = CreateTestRunner(
                fc, nearClass, 100, maximumDistance);

            runnerSmallTileSize.Execute(polygon);

            AssertUtils.NoError(runnerSmallTileSize);
        }
        private static void TestValueInUniqueTable(IFeatureWorkspace ws)
        {
            ITable table1 =
                DatasetUtils.CreateTable(ws, "TestValueInUniqueTable1",
                                         FieldUtils.CreateOIDField(),
                                         FieldUtils.CreateField("RouteId",
                                                                esriFieldType
                                                                .esriFieldTypeInteger));

            ITable table2 =
                DatasetUtils.CreateTable(ws, "TestValueInUniqueTable2",
                                         FieldUtils.CreateOIDField(),
                                         FieldUtils.CreateField("OtherId",
                                                                esriFieldType
                                                                .esriFieldTypeInteger));

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)ws).StartEditing(false);
            ((IWorkspaceEdit)ws).StopEditing(true);

            IRow row1 = table1.CreateRow();

            row1.set_Value(1, 3);
            row1.Store();

            for (int i = 0; i < 5; i++)
            {
                IRow r = table1.CreateRow();
                r.set_Value(1, 8);
                r.Store();
            }

            IRow row2 = table2.CreateRow();

            row2.set_Value(1, 3);
            row2.Store();

            const bool limitToTestedRows = false;
            var        test = new QaGroupConstraints(new[] { table1, table2 },
                                                     new[] { "RouteID", "OtherId" },
                                                     new[] { "'Haltung'", "'B'" },
                                                     1, limitToTestedRows);

            using (var runner = new QaTestRunner(test))
            {
                runner.Execute();
                Assert.AreEqual(1, runner.Errors.Count);
            }

            var containerRunner = new QaContainerTestRunner(100, test);

            containerRunner.Execute();
            Assert.AreEqual(1, containerRunner.Errors.Count);
        }
Example #18
0
        public void CanTestFullExtentMultipleTiles()
        {
            IFeatureClass fc = CreatePointClass(_testWs, "CanTestFullExtentMultipleTiles");

            AddPoints(fc);

            QaContainerTestRunner runner = CreateTestRunner(fc, 10, 9.5);

            runner.Execute();

            Assert.AreEqual(2, runner.Errors.Count);
        }
Example #19
0
        public void PerformanceTest()
        {
            var ws = (IFeatureWorkspace)TestDataUtils.OpenTopgisTlm();

            IFeatureClass ptFc   = ws.OpenFeatureClass("TOPGIS_TLM.TLM_EINZELBAUM_GEBUESCH");
            IFeatureClass polyFc = ws.OpenFeatureClass("TOPGIS_TLM.TLM_BODENBEDECKUNG");

            var test = new QaPointNotNear(ptFc, polyFc, 2);

            test.SetConstraint(1, "Objektart = 12");             // wald

            double tileSize = 10000;
            var    runner   = new QaContainerTestRunner(tileSize, test);

            IEnvelope testBox = GeometryFactory.CreateEnvelope(2554000, 1147000, 2561000, 1151000);
            var       w       = new Stopwatch();

            w.Start();
            runner.Execute(testBox);
            w.Stop();
            string msg = $"Direct:{w.ElapsedMilliseconds} ms";

            Console.WriteLine(msg);
            int nDirect = runner.Errors.Count;

            QaPointNotNear.UseQueryPointAndDistance = true;

            runner.ClearErrors();
            w.Reset();
            w.Start();
            runner.Execute(testBox);
            w.Stop();
            msg = $"QueryDistance:{w.ElapsedMilliseconds} ms";
            Console.WriteLine(msg);
            int nQuery = runner.Errors.Count;

            QaPointNotNear.UseQueryPointAndDistance = false;

            Assert.AreEqual(nQuery, nDirect);
        }
Example #20
0
        public void CanReportManyErrors()
        {
            const string testName = "CanReportManyErrors";

            IFeatureClass nodeClass = CreateFeatureClass(string.Format("{0}_node", testName),
                                                         esriGeometryType.esriGeometryPoint);
            IFeatureClass nearClass = CreateFeatureClass(string.Format("{0}_near", testName),
                                                         esriGeometryType.esriGeometryPolyline);

            var nearClasses = new List <IFeatureClass> {
                nearClass
            };

            IFeature nodeRow = nodeClass.CreateFeature();

            nodeRow.Shape = GeometryFactory.CreatePoint(0, 0);
            nodeRow.Store();
            IFeature nodeRow1 = nodeClass.CreateFeature();

            nodeRow1.Shape = GeometryFactory.CreatePoint(4, 4);
            nodeRow1.Store();
            IFeature nodeRow2 = nodeClass.CreateFeature();

            nodeRow2.Shape = GeometryFactory.CreatePoint(1, 4);
            nodeRow2.Store();
            IFeature nodeRow3 = nodeClass.CreateFeature();

            nodeRow3.Shape = GeometryFactory.CreatePoint(5, 3);
            nodeRow3.Store();

            IFeature nearRow = nearClass.CreateFeature();

            nearRow.Shape = CurveConstruction.StartLine(1, 1)
                            .LineTo(2, 1)
                            .LineTo(3, 3)
                            .LineTo(1, 2)
                            .LineTo(1, 3)
                            .Curve;
            nearRow.Store();

            IEnvelope verificationEnvelope = GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaNodeLineCoincidence(nodeClass, nearClasses, 4);

            var runner = new QaContainerTestRunner(1000, test);

            runner.Execute(verificationEnvelope);

            Assert.AreEqual(4, runner.Errors.Count);
        }
Example #21
0
        public void TestMultipart()
        {
            IFeatureWorkspace ws = TestWorkspaceUtils.CreateInMemoryWorkspace("Testmultipart");

            IFieldsEdit fields = new FieldsClass();

            fields.AddField(FieldUtils.CreateOIDField());
            fields.AddField(FieldUtils.CreateIntegerField("LineTyp", "LineTyp"));
            fields.AddField(FieldUtils.CreateShapeField(
                                "Shape", esriGeometryType.esriGeometryPolyline,
                                SpatialReferenceUtils.CreateSpatialReference
                                    ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95,
                                    true), 1000, false, false));

            IFeatureClass fc =
                DatasetUtils.CreateSimpleFeatureClass(ws, "TestConnections", fields,
                                                      null);
            IList <ITable> tbls = new[] { (ITable)fc };

            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 1);
                row.Shape =
                    CurveConstruction.StartLine(1, 1).LineTo(2, 2).MoveTo(3, 2).LineTo(4, 2).Curve;
                row.Store();
            }
            {
                IFeature row = fc.CreateFeature();
                row.set_Value(1, 2);
                row.Shape =
                    CurveConstruction.StartLine(1, 5).LineTo(2, 2).Curve;
                row.Store();
            }

            IList <QaConnectionRule> rules = new List <QaConnectionRule>
            {
                new QaConnectionRule(tbls, new[] { "LineTyp = 1" }),
                new QaConnectionRule(tbls, new[] { "LineTyp = 2" })
            };
            var test = new QaConnections(new[] { fc }, rules, 0);

            test.UseMultiParts = false;
            var runner = new QaContainerTestRunner(1000, test);

            Assert.AreEqual(0, runner.Execute());

            test.UseMultiParts = true;
            runner             = new QaContainerTestRunner(1000, test);
            Assert.AreEqual(1, runner.Execute());
        }
Example #22
0
        public void CanTestDefinedExtentMultipleTiles()
        {
            IFeatureClass fc = CreatePointClass(_testWs, "CanTestDefinedExtentMultipleTiles");

            AddPoints(fc);

            QaContainerTestRunner runner = CreateTestRunner(fc, 10, 9.5);

            IEnvelope envelope = GeometryFactory.CreateEnvelope(9, 9, 41, 41);

            runner.Execute(GeometryFactory.CreatePolygon(envelope));

            Assert.AreEqual(2, runner.Errors.Count);
        }
Example #23
0
        public void CanTestDefinedExtentPartialLines()
        {
            IFeatureClass fc = CreateLineClass(_testWs, "CanTestDefinedExtentPartialLines");

            AddLines(fc);

            QaContainerTestRunner runner = CreateTestRunner(fc, 1000, 9.5);

            IEnvelope envelope = GeometryFactory.CreateEnvelope(9, 9, 20.5, 20.5);

            runner.Execute(GeometryFactory.CreatePolygon(envelope));

            Assert.AreEqual(0, runner.Errors.Count);
        }
Example #24
0
        public void CanTestDefinedSmallPolySingleTile()
        {
            IFeatureClass fc = CreatePointClass(_testWs, "CanTestDefinedSmallPolySingleTile");

            AddPoints(fc);

            QaContainerTestRunner runner = CreateTestRunner(fc, 1000, 9.5);

            IEnvelope envelope = GeometryFactory.CreateEnvelope(10.5, 10.5, 11.5, 11.5);

            runner.Execute(GeometryFactory.CreatePolygon(envelope));

            Assert.AreEqual(0, runner.Errors.Count);
        }
        private static void TestGroupContraints(IFeatureWorkspace ws)
        {
            ITable tbl =
                DatasetUtils.CreateTable(ws, "TestGroupContraints",
                                         FieldUtils.CreateOIDField(),
                                         FieldUtils.CreateTextField("Kostenstelle", 20));

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)ws).StartEditing(false);
            ((IWorkspaceEdit)ws).StopEditing(true);

            IRow row1 = tbl.CreateRow();

            row1.set_Value(1, "123456-10");
            row1.Store();

            IRow row2 = tbl.CreateRow();

            row2.set_Value(1, "123456-11");
            row2.Store();

            IRow row3 = tbl.CreateRow();

            row3.set_Value(1, "123456-11");
            row3.Store();

            IRow row4 = tbl.CreateRow();

            row4.set_Value(1, "023456-10");
            row4.Store();

            const bool limitToTestedRows = false;
            var        test = new QaGroupConstraints(tbl,
                                                     "IIF(LEN(Kostenstelle) >=6, SUBSTRING(Kostenstelle, 1, 6), '')",
                                                     "SUBSTRING(Kostenstelle, 8, 9)",
                                                     1,
                                                     limitToTestedRows);

            using (var runner = new QaTestRunner(test))
            {
                runner.Execute();
                Assert.AreEqual(1, runner.Errors.Count);
            }

            var containerRunner = new QaContainerTestRunner(100, test);

            containerRunner.Execute();
            Assert.AreEqual(1, containerRunner.Errors.Count);
        }
Example #26
0
        public void CanReportErrorUseMultipleTolerancesInTileLeft()
        {
            const string testName = "CanReportErrorUseMultipleTolerancesInTileLeft";

            IFeatureClass nodeClass = CreateFeatureClass(string.Format("{0}_node", testName),
                                                         esriGeometryType.esriGeometryPoint);
            IFeatureClass nearClass = CreateFeatureClass(string.Format("{0}_near", testName),
                                                         esriGeometryType.esriGeometryPolyline);
            IFeatureClass nearClass1 = CreateFeatureClass(string.Format("{0}_near1", testName),
                                                          esriGeometryType.esriGeometryPolyline);

            var nearClasses = new List <IFeatureClass> {
                nearClass, nearClass1
            };

            IFeature nodeRow = nodeClass.CreateFeature();

            nodeRow.Shape = GeometryFactory.CreatePoint(201, 199);
            nodeRow.Store();

            IFeature nearRow = nearClass.CreateFeature();

            nearRow.Shape = CurveConstruction.StartLine(199, 198)
                            .LineTo(100, 100)
                            .Curve;
            nearRow.Store();

            IFeature nearRow1 = nearClass1.CreateFeature();

            nearRow1.Shape = CurveConstruction.StartLine(100, 205)
                             .LineTo(199, 199)
                             .LineTo(100, 103)
                             .Curve;
            nearRow1.Store();

            IEnvelope verificationEnvelope = GeometryFactory.CreateEnvelope(0, 0, 500, 500);

            var test = new QaNodeLineCoincidence(nodeClass, nearClasses,
                                                 new List <double> {
                2.0, 3.0
            }, 0, false, false);

            var runner = new QaContainerTestRunner(200, test);

            runner.Execute(verificationEnvelope);

            AssertUtils.OneError(runner,
                                 "NodeLineCoincidence.NodeTooCloseToLine.BetweenFeatures");
        }
        public void CanDetectBorderGapBackslashed()
        {
            IFeatureClass fcArea1;
            IFeatureClass fcArea2;
            IFeatureClass fcBorder1;
            IFeatureClass fcBorder2;

            CreateFeatureClasses(out fcArea1, out fcArea2, out fcBorder1, out fcBorder2);

            // border lines are not coincident
            AddLineFeature(fcBorder1, -2, 2, 1, -2, stateId: "A");
            AddLineFeature(fcBorder2, 1.01, -2, -1.99, 2, stateId: "B");

            AddFeature(fcArea1,
                       CurveConstruction.StartPoly(-2, 2)
                       .LineTo(1, -2)
                       .LineTo(-5, -10)
                       .ClosePolygon(), stateId: "A");                              // connected
            AddFeature(fcArea2,
                       CurveConstruction.StartPoly(1.01, -2)
                       .LineTo(-1.99, 2)
                       .LineTo(5, 10)
                       .ClosePolygon(), stateId: "B");                              // connected

            var test = new QaEdgeMatchCrossingAreas(fcArea1, fcBorder1,
                                                    fcArea2, fcBorder2,
                                                    searchDistance: 0.2,
                                                    boundingClasses1: null,
                                                    boundingClasses2: null)
            {
                AreaClass1BorderMatchCondition = "AREA.STATE = BORDER.STATE",
                AreaClass2BorderMatchCondition = "AREA.STATE = BORDER.STATE",
                CrossingAreaMatchCondition     = "AREA1.STATE <> AREA2.STATE"
            };

            AssertUtils.ExpectedErrors(3, Run(test, 1000));

            AssertUtils.ExpectedErrors(3, Run(test, 1));

            var runner = new QaContainerTestRunner(1, test)
            {
                KeepGeometry = true
            };

            runner.Execute(GeometryFactory.CreateEnvelope(-9, -4, 9, 8));
            AssertUtils.ExpectedErrors(3, runner.Errors);
        }
        public void TestTOP_4404()
        {
            var ws = (IFeatureWorkspace)
                     TestDataUtils.OpenPgdb("AVR_CH1903_LV03_original.mdb");
            IFeatureClass avr_lie = ws.OpenFeatureClass("avr_lie");
            IFeatureClass avr_gem = ws.OpenFeatureClass("avr_gem");

            var test = new QaPartCoincidenceOther(avr_lie, avr_gem,
                                                  0.02, 1, 0.1,
                                                  false, 5000, 0);

            test.SetConstraint(0, "ObjectId=2988");
            test.SetConstraint(1, "ObjectId=3");
            var runner = new QaContainerTestRunner(10000, test);

            runner.Execute();
        }
        public void CanDetectBorderGapVertical()
        {
            IFeatureClass fcArea1;
            IFeatureClass fcArea2;
            IFeatureClass fcBorder1;
            IFeatureClass fcBorder2;

            CreateFeatureClasses(out fcArea1, out fcArea2, out fcBorder1, out fcBorder2);

            // border lines are not coincident
            AddLineFeature(fcBorder1, 0, 0, 0, 10, stateId: "A");
            AddLineFeature(fcBorder1, 0.7, -0.3, 10, -0.3, stateId: "A");
            AddLineFeature(fcBorder2, 0.3, 10, 0.3, 0, stateId: "B");
            AddLineFeature(fcBorder2, 10, 0, 0.7, 0, stateId: "B");

            AddAreaFeature(fcArea1, -10, 0, 0, 10, stateId: "A");             // connected
            AddAreaFeature(fcArea1, 0.7, -5, 10, -0.3, stateId: "A");         // connected
            AddAreaFeature(fcArea2, 0.3, 0, 10, 10, stateId: "B");            // connected

            var test = new QaEdgeMatchCrossingAreas(fcArea1, fcBorder1,
                                                    fcArea2, fcBorder2,
                                                    searchDistance: 0.5,
                                                    boundingClasses1: null,
                                                    boundingClasses2: null)
            {
                AreaClass1BorderMatchCondition = "AREA.STATE = BORDER.STATE",
                AreaClass2BorderMatchCondition = "AREA.STATE = BORDER.STATE",
                CrossingAreaMatchCondition     = "AREA1.STATE <> AREA2.STATE"
            };

            AssertUtils.ExpectedErrors(2, Run(test, 1000));

            AssertUtils.ExpectedErrors(2, Run(test, 3));

            var runner = new QaContainerTestRunner(3, test)
            {
                KeepGeometry = true
            };

            runner.Execute(GeometryFactory.CreateEnvelope(-9, -4, 9, 8));
            AssertUtils.ExpectedErrors(2, runner.Errors);
        }
        public void TestReportDuplicatesPairwise()
        {
            IFeatureClass featureClass = CreateLineFeatureClass(_testWs, "TestCombinedLists");

            // make sure the table is known by the workspace
            ((IWorkspaceEdit)_testWs).StartEditing(false);
            ((IWorkspaceEdit)_testWs).StopEditing(true);

            IPolycurve shape1 = CurveConstruction.StartLine(100, 0)
                                .LineTo(200, 0)
                                .Curve;

            IPolycurve shape2 = CurveConstruction.StartLine(200, 100)
                                .LineTo(300, 100)
                                .Curve;

            IPolycurve shape3 = CurveConstruction.StartLine(300, 200)
                                .LineTo(400, 200)
                                .Curve;

            AddFeature(featureClass, shape1);
            AddFeature(featureClass, shape2);
            AddFeature(featureClass, shape3);

            // first set of duplicates
            AddFeature(featureClass, shape1);
            AddFeature(featureClass, shape2);
            AddFeature(featureClass, shape3);

            // second set of duplicates
            AddFeature(featureClass, shape1);
            AddFeature(featureClass, shape2);
            AddFeature(featureClass, shape3);

            var test = new QaDuplicateGeometrySelf(featureClass, null, false);

            var testRunner = new QaContainerTestRunner(1000, test);

            testRunner.Execute();

            Assert.AreEqual(9, testRunner.Errors.Count);
        }