AddFeatures() public method

在指定数据集中增加一组同类型的要素。
public AddFeatures ( string datasourceName, String datasetName, List targetFeatures ) : EditResult
datasourceName string 数据源名称,必设参数。
datasetName String 数据集名称,必设参数。
targetFeatures List 待添加的要素列表,列表中的要素必须是同一种类型,必设参数。
return EditResult
 public void AddFeaturesTest_NUllFeatures2()
 {
     Data data = new Data("http://" + ip + ":8090/iserver/services/data-world/rest");
     List<Feature> list = new List<Feature>();
     EditResult result = data.AddFeatures("World", "Capitals", list);
     Assert.IsFalse(result.Succeed);
     Assert.AreEqual(result.Message, "参数 targetFeatures 不能为空。");
 }
        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);

        }
 public void AddFeaturesTest_NUllFeatures()
 {
     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.AddFeatures("World", "Capitals", null);
     Assert.IsFalse(result.Succeed);
     Assert.AreEqual(result.Message, "参数 targetFeatures 不能为空。");
 }