Ejemplo n.º 1
0
        public void getWorkspaceFactoryTest()
        {
            FeatureEdit target = FeatureEdit.getInstance();

            // get shapefile workspace factory
            string            extension = "shp";
            IWorkspaceFactory actual    = target.getWorkspaceFactory(extension);

            Assert.IsNotNull(actual);

            // get mdb workspace factory
            extension = "mdb";
            actual    = target.getWorkspaceFactory(extension);
            Assert.IsNotNull(actual);

            // get gdb workspace factory
            extension = "gdb";
            actual    = target.getWorkspaceFactory(extension);
            Assert.IsNotNull(actual);

            // get mdb workspace factory
            extension = "mdb";
            actual    = target.getWorkspaceFactory(extension);
            Assert.IsNotNull(actual);
        }
Ejemplo n.º 2
0
        public void equalPointsTest()
        {
            FeatureEdit fe = FeatureEdit.getInstance();
            // equal
            IPoint point1 = new PointClass()
            {
                X = 2.356, Y = 3.34
            };
            IPoint point2 = new PointClass()
            {
                X = 2.356, Y = 3.34
            };
            double tolerance = 0.0001;
            bool   expected  = true;
            bool   actual    = fe.equalPoints(point1, point2, tolerance);

            Assert.AreEqual(expected, actual);

            // not equal
            IPoint point3 = new PointClass()
            {
                X = 2.345, Y = 1.13
            };
            IPoint point4 = new PointClass()
            {
                X = 1.234, Y = 2.45
            };

            expected = false;
            actual   = fe.equalPoints(point3, point4, tolerance);
            Assert.AreEqual(expected, actual);

            // use equal Z value
            IPoint point5 = new PointClass()
            {
                X = 2.123, Y = 1.323, Z = 134
            };
            IPoint point6 = new PointClass()
            {
                X = 2.123, Y = 1.323, Z = 134
            };

            expected = true;
            actual   = fe.equalPoints(point5, point6, tolerance);
            Assert.AreEqual(expected, actual);

            // use not equal Z value
            IPoint point7 = new PointClass()
            {
                X = 2.123, Y = 1.323, Z = 134
            };
            IPoint point8 = new PointClass()
            {
                X = 2.123, Y = 1.323, Z = 136
            };

            expected = false;
            actual   = fe.equalPoints(point7, point8, tolerance);
            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void exportSelectedFeatureToShpTest()
        {
            FeatureEdit   target       = FeatureEdit.getInstance();
            IFeatureLayer featureLayer = null;         // TODO: 初始化为适当的值
            ISelectionSet selectionSet = null;         // TODO: 初始化为适当的值
            string        outName      = string.Empty; // TODO: 初始化为适当的值

            target.exportSelectedFeatureToShp(featureLayer, selectionSet, outName);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
Ejemplo n.º 4
0
        public void getFeatureWorkspaceFromFileTest()
        {
            FeatureEdit       target    = FeatureEdit.getInstance();
            string            filename  = TestInitialize.m_testDataPath + "shapefiles\\airports.shp";
            string            extention = "shp";
            IFeatureWorkspace actual;

            actual = target.getFeatureWorkspaceFromFile(filename, extention);
            Assert.IsNotNull(actual);
        }
Ejemplo n.º 5
0
        public void getFeatureValueTest()
        {
            FeatureEdit target = FeatureEdit.getInstance();

            IFeatureClass featureClass = m_featureWorkspace.OpenFeatureClass("airports");
            IFeature      feature      = featureClass.GetFeature(0);
            string        fieldName    = "NAME";
            object        expected     = "NOATAK";
            object        actual       = target.getFeatureValue(feature, fieldName);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 6
0
        public void setFeatureBufferValueTest()
        {
            FeatureEdit    target    = FeatureEdit.getInstance(); // TODO: 初始化为适当的值
            IFeatureBuffer feaBuf    = null;                      // TODO: 初始化为适当的值
            string         fieldName = string.Empty;              // TODO: 初始化为适当的值
            object         value     = null;                      // TODO: 初始化为适当的值
            bool           expected  = false;                     // TODO: 初始化为适当的值
            bool           actual;

            actual = target.setFeatureBufferValue(feaBuf, fieldName, value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Ejemplo n.º 7
0
        public void setFeatureValueTest()
        {
            FeatureEdit target = FeatureEdit.getInstance();

            IFeatureClass featureClass = m_featureWorkspace.OpenFeatureClass("airports");
            IFeature      feature      = featureClass.GetFeature(0);
            string        fieldName    = string.Empty;
            object        value        = null;
            bool          save         = false;
            bool          expected     = false;
            bool          actual;

            actual = target.setFeatureValue(feature, fieldName, value, save);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Ejemplo n.º 8
0
        public void equalFeatureTest()
        {
            FeatureEdit fe = FeatureEdit.getInstance();

            IFeatureClass featureClass = m_featureWorkspace.OpenFeatureClass("airports");
            IFeature      f1           = featureClass.GetFeature(0);
            IFeature      f2           = featureClass.CreateFeature();

            f2.Shape = f1.ShapeCopy;
            for (int i = 1; i < f1.Fields.FieldCount; i++)
            {
                f2.set_Value(i, f1.get_Value(i));
            }
            Assert.IsTrue(fe.equalFeature(f1, f2));
            // 最后删除掉这个新建的测试要素
            f2.Delete();
        }
Ejemplo n.º 9
0
        public ActionResult Edit(int id)
        {
            var service = CreateFeatureService();
            var detail  = service.GetFeaturesByPropertyID(id);
            var model   = new FeatureEdit
            {
                PropertyID           = detail.PropertyID,
                FeatureID            = detail.FeatureID,
                DistanceFromPopulace = detail.DistanceFromPopulace,
                RoadAccess           = detail.RoadAccess,
                CityWater            = detail.CityWater,
                CityElectric         = detail.CityElectric,
                CitySewer            = detail.CitySewer,
                Internet             = detail.CitySewer,
                AlternateWater       = detail.AlternateWater,
                AlternateElectric    = detail.AlternateElectric,
                AlternateSewage      = detail.AlternateSewage,
                BodyOfWater          = detail.BodyOfWater,
                NearbyBodyOfWater    = detail.NearbyBodyOfWater
            };

            return(View(model));
        }
Ejemplo n.º 10
0
        public bool UpdateFeature(FeatureEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Features.Single(e => e.PropertyID == model.PropertyID && e.UserID == _userId);

                entity.PropertyID           = model.PropertyID;
                entity.FeatureID            = model.FeatureID;
                entity.DistanceFromPopulace = model.DistanceFromPopulace;
                entity.RoadAccess           = model.RoadAccess;
                entity.CityWater            = model.CityWater;
                entity.CityElectric         = model.CityElectric;
                entity.CitySewer            = model.CitySewer;
                entity.Internet             = model.Internet;
                entity.AlternateWater       = model.AlternateWater;
                entity.AlternateElectric    = model.AlternateElectric;
                entity.AlternateSewage      = model.AlternateSewage;
                entity.BodyOfWater          = model.BodyOfWater;
                entity.NearbyBodyOfWater    = model.NearbyBodyOfWater;


                return(ctx.SaveChanges() == 1);
            }
        }
Ejemplo n.º 11
0
        public ActionResult Edit(int id, FeatureEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.PropertyID != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateFeatureService();

            if (service.UpdateFeature(model))
            {
                TempData["SaveResult"] = "Your property's featuers were updated.";
                return(RedirectToAction("Index", "Property"));
            }

            ModelState.AddModelError("", "Your property's features could not be updated.");
            return(View(model));
        }
Ejemplo n.º 12
0
        public void equalGeometryTest()
        {
            FeatureEdit fe = FeatureEdit.getInstance();

            // 测试两个相同的几何对象
            IGeometry        geo1 = new PolylineClass();
            IPointCollection pc1  = geo1 as IPointCollection;

            pc1.AddPoint(new PointClass()
            {
                X = 1.2, Y = 2.3
            });
            pc1.AddPoint(new PointClass()
            {
                X = 1.4, Y = 2.5
            });
            pc1.AddPoint(new PointClass()
            {
                X = 1.1, Y = 2.8
            });

            IGeometry        geo2 = new PolylineClass();
            IPointCollection pc2  = geo2 as IPointCollection;

            pc2.AddPoint(new PointClass()
            {
                X = 1.2, Y = 2.3
            });
            pc2.AddPoint(new PointClass()
            {
                X = 1.4, Y = 2.5
            });
            pc2.AddPoint(new PointClass()
            {
                X = 1.1, Y = 2.8
            });

            bool actual = fe.equalGeometry(geo1, geo2);

            Assert.IsTrue(actual);

            // 测试两个不同的几何对象
            IGeometry        geo3 = new PolylineClass();
            IPointCollection pc3  = geo3 as IPointCollection;

            pc3.AddPoint(new PointClass()
            {
                X = 1.1, Y = 2.8
            });
            pc3.AddPoint(new PointClass()
            {
                X = 1.4, Y = 2.5
            });
            pc3.AddPoint(new PointClass()
            {
                X = 1.1, Y = 2.8
            });

            actual = fe.equalGeometry(geo1, geo3);
            Assert.IsFalse(actual);
        }
Ejemplo n.º 13
0
        public void getFeatureEditInstanceTest()
        {
            FeatureEdit fe = FeatureEdit.getInstance();

            Assert.IsNotNull(fe);
        }