UpdateFeatures() public method

在指定的数据集中,更新一组要素。 参数 targetFeatures 是新要素列表,其要素 ID 与数据集中待更新的要素 ID 相同,根据 ID 查找到待更新的要素, 然后将原要素更新到新的要素。
public UpdateFeatures ( string datasourceName, string datasetName, List targetFeatures ) : EditResult
datasourceName string 数据源名称,必设参数。
datasetName string 数据源名称,必设参数。
targetFeatures List 新要素列表。其 ID 与要更新的要素 ID 相同,必设参数。
return EditResult
コード例 #1
0
 public void UpdateFeaturesTest_NUllID()
 {
     Data data = new Data("http://" + ip + ":8090/iserver/services/data-world/rest");
     List<Feature> list = new List<Feature>();
     Feature feature = new Feature();
     //World  Capitals
     feature.FieldNames = new string[4] { "SMID", "CAPITAL", "COUNTRY", "CAP_POP" };
     feature.FieldValues = new string[4] { "166", "古代", "update现代", "300001" };
     feature.Geometry = new Geometry();
     feature.Geometry.Id = 166;
     feature.Geometry.Type = GeometryType.POINT;
     feature.Geometry.Parts = new int[1] { 1 };
     feature.Geometry.Points = new Point2D[1];
     feature.Geometry.Points[0] = new Point2D(50, 50);
     feature.Geometry.Style = new Style();
     list.Add(feature);
     EditResult result = data.UpdateFeatures("World", "Capitals", list);
     Assert.IsFalse(result.Succeed);
     Assert.AreEqual(result.Message, "参数 Feature.Id 不合法。");
 }
コード例 #2
0
        public void AddFeaturesTest()
        {
            Data data = new Data("http://" + ip + ":8090/iserver/services/data-world/rest");
            List<Feature> list = new List<Feature>();
            Feature feature1 = new Feature();
            //World  Capitals
            feature1.FieldNames = new string[3] { "CAPITAL", "COUNTRY", "CAP_POP" };
            feature1.FieldValues = new string[3] { "古代", "现代", "30000" };
            feature1.Geometry = new Geometry();
            feature1.Geometry.Type = GeometryType.POINT;
            feature1.Geometry.Parts = new int[1] { 1 };
            feature1.Geometry.Points = new Point2D[1];
            feature1.Geometry.Points[0] = new Point2D(50, 50);
            list.Add(feature1);

            Feature feature2 = new Feature();
            //World  Capitals
            feature2.FieldNames = new string[3] { "CAPITAL", "COUNTRY", "CAP_POP" };
            feature2.FieldValues = new string[3] { "测试", "测试", "300" };
            feature2.Geometry = new Geometry();
            feature2.Geometry.Type = GeometryType.POINT;
            feature2.Geometry.Parts = new int[1] { 1 };
            feature2.Geometry.Points = new Point2D[1];
            feature2.Geometry.Points[0] = new Point2D(50, 50);
            list.Add(feature2);

            EditResult result = data.AddFeatures("World", "Capitals", list);
            Assert.IsTrue(result.Succeed);
            Assert.AreEqual(result.Ids.Count(), 2);


            List<Feature> listUpdate = new List<Feature>();
            Feature featureUpdate = new Feature();
            //World  Capitals
            featureUpdate.Id = result.Ids[0];
            featureUpdate.FieldNames = new string[4] { "SMID", "CAPITAL", "COUNTRY", "CAP_POP" };
            featureUpdate.FieldValues = new string[4] { "166", "古代", "update现代", "300001" };
            featureUpdate.Geometry = new Geometry();
            featureUpdate.Geometry.Id = result.Ids[0];
            featureUpdate.Geometry.Type = GeometryType.POINT;
            featureUpdate.Geometry.Parts = new int[1] { 1 };
            featureUpdate.Geometry.Points = new Point2D[1];
            featureUpdate.Geometry.Points[0] = new Point2D(50, 50);
            featureUpdate.Geometry.Style = new Style();
            listUpdate.Add(featureUpdate);
            EditResult resultUpdate = data.UpdateFeatures("World", "Capitals", listUpdate);
            Assert.IsTrue(resultUpdate.Succeed);


            EditResult resultDelete = data.DeleteFeatures("World", "Capitals", result.Ids);
            Assert.IsTrue(resultDelete.Succeed);

        }
コード例 #3
0
 public void UpdateFeaturesTest_NUllFeatures2()
 {
     Data data = new Data("http://" + ip + ":8090/iserver/services/data-world/rest");
     List<Feature> list = new List<Feature>();
     EditResult result = data.UpdateFeatures("World", "Capitals", list);
     Assert.IsFalse(result.Succeed);
     Assert.AreEqual(result.Message, "参数 targetFeatures 不能为空。");
 }