DeleteFeatures() публичный Метод

在指定的数据集中删除一组要素。
public DeleteFeatures ( string datasourceName, string datasetName, int ids ) : EditResult
datasourceName string 数据源名称,必设参数。
datasetName string 数据集名称,必设参数。
ids int 待删除要素的 ID 数组,必设参数。
Результат EditResult
Пример #1
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);

        }
Пример #2
0
 public void DeleteFeaturesTest_NUllDataset()
 {
     Data data = new Data("http://" + ip + ":8090/iserver/services/data-world/rest");
     int[] ids = new int[] { 2, 3 };
     EditResult result = data.DeleteFeatures("World", "", ids);
     Assert.IsFalse(result.Succeed);
     Assert.AreEqual(result.Message, "参数 datasetName 不能为空。");
 }