Exemplo n.º 1
0
        private static ISpatialReference CreateSpatialReference(double mTolerance,
                                                                double xyTolerance)
        {
            ISpatialReference result = SpatialReferenceUtils.CreateSpatialReference
                                           ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            SpatialReferenceUtils.SetMDomain(result, 0, 1000000, mTolerance / 10, mTolerance);
            SpatialReferenceUtils.SetXYDomain(result, -1000, -1000, 100000, 100000,
                                              xyTolerance / 10, xyTolerance);
            return(result);
        }
Exemplo n.º 2
0
        private static void TestInvalidArguments(IFeatureWorkspace ws)
        {
            ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference
                                       ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            ISpatialReference srM = SpatialReferenceUtils.CreateSpatialReference
                                        ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            SpatialReferenceUtils.SetMDomain(srM, 0, 1000000, 0.001, 0.002);

            IFieldsEdit fieldsPoint = new FieldsClass();

            fieldsPoint.AddField(FieldUtils.CreateOIDField());
            fieldsPoint.AddField(FieldUtils.CreateDoubleField("DoubleField"));
            fieldsPoint.AddField(FieldUtils.CreateIntegerField("IntField"));
            fieldsPoint.AddField(FieldUtils.CreateTextField("StringField", 50));
            fieldsPoint.AddField(FieldUtils.CreateShapeField(
                                     "Shape", esriGeometryType.esriGeometryPoint, sr, 1000));

            IFeatureClass fcPoints =
                DatasetUtils.CreateSimpleFeatureClass(ws, "InvalidArgumentsPoints", fieldsPoint);

            IFieldsEdit fieldsLine = new FieldsClass();

            fieldsLine.AddField(FieldUtils.CreateOIDField());
            fieldsLine.AddField(FieldUtils.CreateShapeField(
                                    "Shape", esriGeometryType.esriGeometryPolyline, sr, 1000));

            IFeatureClass fcLines =
                DatasetUtils.CreateSimpleFeatureClass(ws, "InvalidArgumentsLines", fieldsLine);

            IFieldsEdit fieldsLineM = new FieldsClass();

            fieldsLineM.AddField(FieldUtils.CreateOIDField());
            fieldsLineM.AddField(FieldUtils.CreateShapeField(
                                     "Shape", esriGeometryType.esriGeometryPolyline, srM, 1000,
                                     false, true));

            IFeatureClass fcLinesM =
                DatasetUtils.CreateSimpleFeatureClass(ws, "InvalidArgumentsLinesM", fieldsLineM);

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

            var success = true;

            try
            {
                var test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.01, 0.01,
                                                  LineMSource.Nearest, false);
                Assert.IsNotNull(test);
            }
            catch (ArgumentException)
            {
                success = false;
            }

            Assert.IsFalse(success);

            success = true;
            try
            {
                var test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLinesM }, 0.01, 0.01,
                                                  LineMSource.Nearest, false);
                Assert.IsNotNull(test);
            }
            catch (ArgumentException)
            {
                success = false;
            }

            Assert.IsFalse(success);

            success = true;
            try
            {
                var test = new QaMeasuresAtPoints(fcPoints, "UnknownField", new[] { fcLinesM },
                                                  0.01, 0.01, LineMSource.Nearest, false);
                Assert.IsNotNull(test);
            }
            catch (EvaluateException)
            {
                success = false;
            }

            Assert.IsFalse(success);
        }
Exemplo n.º 3
0
        private static void TestNearVertex(IFeatureWorkspace ws)
        {
            ISpatialReference srM = SpatialReferenceUtils.CreateSpatialReference
                                        ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            SpatialReferenceUtils.SetMDomain(srM, 0, 1000000, 0.001, 0.002);

            IFieldsEdit fieldsPoint = new FieldsClass();

            fieldsPoint.AddField(FieldUtils.CreateOIDField());
            fieldsPoint.AddField(FieldUtils.CreateShapeField(
                                     "Shape", esriGeometryType.esriGeometryPoint, srM, 1000, false,
                                     true));

            IFeatureClass fcPoints =
                DatasetUtils.CreateSimpleFeatureClass(ws, "NearVertexPoints", fieldsPoint);

            IFieldsEdit fieldsLine = new FieldsClass();

            fieldsLine.AddField(FieldUtils.CreateOIDField());
            fieldsLine.AddField(FieldUtils.CreateShapeField(
                                    "Shape", esriGeometryType.esriGeometryPolyline, srM, 1000,
                                    false, true));

            IFeatureClass fcLines =
                DatasetUtils.CreateSimpleFeatureClass(ws, "NearVertexLines", fieldsLine);

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

            IFeature point1 = fcPoints.CreateFeature();

            point1.Shape = CreatePoint(100.1, 100.1, 2);
            point1.Store();

            IFeature   fLine1 = fcLines.CreateFeature();
            IPolycurve l1     =
                CurveConstruction.StartLine(CreatePoint(100, 100, 2))
                .LineTo(CreatePoint(101, 100, 1000))
                .Curve;

            ((IMAware)l1).MAware = true;
            fLine1.Shape         = l1;
            fLine1.Store();

            var test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 1, 0.01,
                                              LineMSource.Nearest, false);
            var container = new QaContainerTestRunner(10000, test);

            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);             // neareast --> error

            test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 1, 0.01,
                                          LineMSource.VertexPreferred, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(0, container.Errors.Count);             // Vertex near point1 --> vertex --> OK

            test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 1, 0.01,
                                          LineMSource.VertexRequired, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(0, container.Errors.Count);             // Vertex near point1 --> vertex --> OK

            test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.12, 0.01,
                                          LineMSource.VertexPreferred, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);
            // No Vertex near point1 --> neareast --> error

            test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.12, 0.01,
                                          LineMSource.VertexRequired, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);
            // No Vertex near point1 --> required --> error

            test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.05, 0.01,
                                          LineMSource.Nearest, true);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);
            // No Line near point1 --> line required --> error
        }
Exemplo n.º 4
0
        private static void TestWithErrors(IFeatureWorkspace ws)
        {
            ISpatialReference srM = SpatialReferenceUtils.CreateSpatialReference
                                        ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            SpatialReferenceUtils.SetMDomain(srM, 0, 1000000, 0.001, 0.002);

            IFieldsEdit fieldsPoint = new FieldsClass();

            fieldsPoint.AddField(FieldUtils.CreateOIDField());
            fieldsPoint.AddField(FieldUtils.CreateDoubleField("DoubleField"));
            fieldsPoint.AddField(FieldUtils.CreateIntegerField("IntField"));
            fieldsPoint.AddField(FieldUtils.CreateTextField("StringField", 50));
            fieldsPoint.AddField(FieldUtils.CreateDoubleField("EmptyField"));
            fieldsPoint.AddField(FieldUtils.CreateShapeField(
                                     "Shape", esriGeometryType.esriGeometryPoint, srM, 1000, false,
                                     true));

            IFeatureClass fcPoints =
                DatasetUtils.CreateSimpleFeatureClass(ws, "WithErrorsPoints", fieldsPoint);

            IFieldsEdit fieldsLine = new FieldsClass();

            fieldsLine.AddField(FieldUtils.CreateOIDField());
            fieldsLine.AddField(FieldUtils.CreateShapeField(
                                    "Shape", esriGeometryType.esriGeometryPolyline, srM, 1000,
                                    false, true));

            IFeatureClass fcLines =
                DatasetUtils.CreateSimpleFeatureClass(ws, "WithErrorsLines", fieldsLine);

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

            IFeature point1 = fcPoints.CreateFeature();

            point1.set_Value(1, 2);             // DoubleField
            point1.set_Value(2, 2);             // IntField
            point1.set_Value(3, "A");           // StringField
            point1.Shape = CreatePoint(100, 100, 2);
            point1.Store();

            IFeature   fLine1 = fcLines.CreateFeature();
            IPolycurve l1     =
                CurveConstruction.StartLine(CreatePoint(100, 100, 1))
                .LineTo(CreatePoint(200, 200, 1))
                .Curve;

            ((IMAware)l1).MAware = true;
            fLine1.Shape         = l1;
            fLine1.Store();

            var test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.01, 0.01,
                                              LineMSource.Nearest, false);
            var container = new QaContainerTestRunner(10000, test);

            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);

            test = new QaMeasuresAtPoints(fcPoints, "DoubleField", new[] { fcLines }, 0.01,
                                          0.01, LineMSource.Nearest, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);

            test = new QaMeasuresAtPoints(fcPoints, "IntField", new[] { fcLines }, 0.01, 0.01,
                                          LineMSource.Nearest, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);

            test = new QaMeasuresAtPoints(fcPoints, "EmptyField", new[] { fcLines }, 0.01, 0.01,
                                          LineMSource.Nearest, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);

            test = new QaMeasuresAtPoints(fcPoints, "0.5 * EmptyField", new[] { fcLines }, 0.01,
                                          0.01, LineMSource.Nearest, false);
            container = new QaContainerTestRunner(10000, test);
            container.Execute();
            Assert.AreEqual(1, container.Errors.Count);
        }
Exemplo n.º 5
0
        private static void TestValidWithPointM(IFeatureWorkspace ws)
        {
            ISpatialReference sr = SpatialReferenceUtils.CreateSpatialReference
                                       ((int)esriSRProjCS2Type.esriSRProjCS_CH1903Plus_LV95, true);

            SpatialReferenceUtils.SetMDomain(sr, 0, 1000000, 0.001, 0.002);

            IFieldsEdit fieldsPoint = new FieldsClass();

            fieldsPoint.AddField(FieldUtils.CreateOIDField());
            fieldsPoint.AddField(FieldUtils.CreateShapeField(
                                     "Shape", esriGeometryType.esriGeometryPoint, sr, 1000, false,
                                     true));

            IFeatureClass fcPoints =
                DatasetUtils.CreateSimpleFeatureClass(ws, "ValidWithPointMPoints", fieldsPoint);

            IFieldsEdit fieldsLine = new FieldsClass();

            fieldsLine.AddField(FieldUtils.CreateOIDField());
            fieldsLine.AddField(FieldUtils.CreateShapeField(
                                    "Shape", esriGeometryType.esriGeometryPolyline, sr, 1000,
                                    false, true));

            IFeatureClass fcLines =
                DatasetUtils.CreateSimpleFeatureClass(ws, "ValidWithPointMLines", fieldsLine);

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

            IFeature point1 = fcPoints.CreateFeature();

            point1.Shape = CreatePoint(100, 100, 20);
            point1.Store();

            IFeature   fLine1 = fcLines.CreateFeature();
            IPolycurve l1     =
                CurveConstruction.StartLine(CreatePoint(100, 100, 20))
                .LineTo(CreatePoint(200, 200, 50))
                .Curve;

            ((IMAware)l1).MAware = true;
            fLine1.Shape         = l1;
            fLine1.Store();

            IFeature   fLine2 = fcLines.CreateFeature();
            IPolycurve l2     =
                CurveConstruction.StartLine(CreatePoint(50, 50, 10))
                .LineTo(CreatePoint(150, 150, 30))
                .Curve;

            ((IMAware)l2).MAware = true;
            fLine2.Shape         = l2;
            fLine2.Store();

            var test = new QaMeasuresAtPoints(fcPoints, null, new[] { fcLines }, 0.01, 0.01,
                                              LineMSource.Nearest, false);

            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);
        }