示例#1
0
        private static IFeature CreateFeature([NotNull] FeatureClassMock featureClass,
                                              double x, object xFieldValue,
                                              double y, object yFieldValue,
                                              double z, object zFieldValue)
        {
            int fieldIndexX = featureClass.FindField(_fieldNameX);
            int fieldIndexY = featureClass.FindField(_fieldNameY);
            int fieldIndexZ = featureClass.FindField(_fieldNameZ);

            IFeature feature = featureClass.CreateFeature(GeometryFactory.CreatePoint(x, y, z));

            if (fieldIndexX >= 0)
            {
                feature.set_Value(fieldIndexX, xFieldValue);
            }

            if (fieldIndexY >= 0)
            {
                feature.set_Value(fieldIndexY, yFieldValue);
            }

            if (fieldIndexZ >= 0)
            {
                feature.set_Value(fieldIndexZ, zFieldValue);
            }

            feature.Store();

            return(feature);
        }
        public void CanTestConstraint()
        {
            ISpatialReference sref = SpatialReferenceUtils.CreateSpatialReference(
                WellKnownHorizontalCS.LV95);

            var multiPatchClass = new FeatureClassMock(
                1, "multipatch", esriGeometryType.esriGeometryMultiPatch,
                esriFeatureType.esriFTSimple, sref);

            multiPatchClass.AddField("Level", esriFieldType.esriFieldTypeInteger);
            int levelIndex = multiPatchClass.FindField("Level");

            var polygonClass = new FeatureClassMock(
                1, "polygon", esriGeometryType.esriGeometryPolygon,
                esriFeatureType.esriFTSimple, sref);

            polygonClass.AddField("Level", esriFieldType.esriFieldTypeInteger);

            var multiPatchConstruction = new MultiPatchConstruction();

            multiPatchConstruction.StartOuterRing(0, 0, 0)
            .Add(5, 0, 0)
            .Add(5, 1, 5)
            .Add(0, 1, 5);

            IFeature multiPatchRow =
                multiPatchClass.CreateFeature(multiPatchConstruction.MultiPatch);

            multiPatchRow.set_Value(levelIndex, 2);

            CurveConstruction curveConstruction =
                CurveConstruction.StartPoly(0, 0, 50)
                .LineTo(10, 0, 50)
                .LineTo(0, 10, 50);

            IFeature polygonRow =
                polygonClass.CreateFeature(curveConstruction.ClosePolygon());

            polygonRow.set_Value(levelIndex, 1);

            var test = new QaZDifferenceSelfWrapper(
                new[] { (IFeatureClass)multiPatchClass, polygonClass },
                20, 0,
                ZComparisonMethod.BoundingBox,
                "U.Level > L.Level");

            var runner     = new QaTestRunner(test);
            int errorCount = test.TestDirect(multiPatchRow, 0, polygonRow, 1);

            Assert.AreEqual(1, errorCount);
            Assert.AreEqual(1, runner.Errors.Count);
        }