当前位置: 首页>>代码示例>>C#>>正文


C# FeatureDataTable.Load方法代码示例

本文整理汇总了C#中FeatureDataTable.Load方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureDataTable.Load方法的具体用法?C# FeatureDataTable.Load怎么用?C# FeatureDataTable.Load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FeatureDataTable的用法示例。


在下文中一共展示了FeatureDataTable.Load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InsertFeaturesTest

        public void InsertFeaturesTest()
        {
            FeatureDataTable<UInt32> schema = new FeatureDataTable<UInt32>("OID", _geoFactory);
            schema.Columns.AddRange(new DataColumn[]
                                        {
                                            new DataColumn("Name", typeof (String)),
                                            new DataColumn("DateCreated", typeof (DateTime)),
                                            new DataColumn("Visits", typeof (Int64)),
                                            new DataColumn("Weight", typeof (Double))
                                        });

            ShapeFileProvider shapeFile = ShapeFileProvider.Create("UnitTestData", "Test3", ShapeType.PolyLine, schema, _geoFactory);
            shapeFile.Open();

            IExtents computedBounds = _geoFactory.CreateExtents();

            List<FeatureDataRow<UInt32>> rows = new List<FeatureDataRow<UInt32>>();

            for (Int32 i = 0; i < 10000; i++)
            {
                DateTime dateCreated = new DateTime(_rnd.Next(1900, 2155), _rnd.Next(1, 12), _rnd.Next(1, 28));
                FeatureDataRow<UInt32> feature = schema.NewRow((UInt32) i);

                Char[] chars = new Char[_rnd.Next(0, 254)];
                for (Int32 charIndex = 0; charIndex < chars.Length; charIndex++)
                {
                    chars[charIndex] = (Char) (Byte) _rnd.Next(32, 126);
                }

                feature["Name"] = new String(chars);
                feature["DateCreated"] = dateCreated;
                feature["Visits"] = _rnd.Next(0, Int32.MaxValue) << _rnd.Next(0, 32);
                feature["Weight"] = _rnd.NextDouble()*_rnd.Next(0, 100000);

                ICoordinateSequence coordinates
                    = _geoFactory.CoordinateSequenceFactory.Create(generateCoordinates());
                
                ILineString line = _geoFactory.CreateLineString(coordinates);

                computedBounds.ExpandToInclude(line.Extents);

                feature.Geometry = line;

                rows.Add(feature);
            }

            shapeFile.Insert(rows);
            shapeFile.Close();

            shapeFile = new ShapeFileProvider(@"UnitTestData\Test3.shp", _geoFactory, _coordSysFactory, false);
            shapeFile.Open();

            Assert.AreEqual(10000, shapeFile.GetFeatureCount());
            Assert.AreEqual(computedBounds, shapeFile.GetExtents());

            FeatureDataTable dataTable = new FeatureDataTable("ShapeFile test", _geoFactory);
            FeatureQueryExpression query = FeatureQueryExpression.Intersects(shapeFile.GetExtents());
            IFeatureDataReader reader = shapeFile.ExecuteFeatureQuery(query);
            dataTable.Load(reader, LoadOption.OverwriteChanges, null);

            Assert.AreEqual(10000, dataTable.Rows.Count);
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:62,代码来源:ShapeFileTests.cs

示例2: ExecuteIntersectionQueryByBoundingBoxTest

 public void ExecuteIntersectionQueryByBoundingBoxTest()
 {
     ShapeFileProvider shapeFile = new ShapeFileProvider(
         BcRoadsShapeFile, _geoFactory, _coordSysFactory);
     shapeFile.Open();
     FeatureDataTable data = new FeatureDataTable("ShapeFile test", _geoFactory);
     FeatureQueryExpression query = FeatureQueryExpression.Intersects(shapeFile.GetExtents());
     IFeatureDataReader reader = shapeFile.ExecuteFeatureQuery(query);
     data.Load(reader, LoadOption.OverwriteChanges, null);
     Assert.AreEqual(shapeFile.GetFeatureCount(), data.Rows.Count);
     shapeFile.Close();
 }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:12,代码来源:ShapeFileTests.cs

示例3: InsertFeatureTest

        public void InsertFeatureTest()
        {
            FeatureDataTable<UInt32> schema = new FeatureDataTable<UInt32>("oid", _geoFactory);
            schema.Columns.AddRange(new DataColumn[]
                                        {
                                            new DataColumn("Name", typeof (String)),
                                            new DataColumn("DateCreated", typeof (DateTime)),
                                            new DataColumn("Visits", typeof (Int32)),
                                            new DataColumn("Weight", typeof (Single))
                                        });

            ShapeFileProvider shapeFile = ShapeFileProvider.Create("UnitTestData", "Test2", ShapeType.Point, schema, _geoFactory);
            shapeFile.Open();

            DateTime dateCreated = DateTime.Now;
            FeatureDataRow<UInt32> feature = schema.NewRow(1);
            feature["Name"] = "Test feature";
            feature["DateCreated"] = dateCreated;
            feature["Visits"] = 0;
            feature["Weight"] = 100.0f;
            feature.Geometry = _geoFactory.CreatePoint2D(1, 1);

            shapeFile.Insert(feature);
            shapeFile.Close();

            shapeFile = new ShapeFileProvider(@"UnitTestData\Test2.shp", _geoFactory);
            shapeFile.Open();

            Assert.AreEqual(1, shapeFile.GetFeatureCount());

            FeatureDataTable dataTable = new FeatureDataTable("ShapeFile test", _geoFactory);
            FeatureQueryExpression query = FeatureQueryExpression.Intersects(_geoFactory.CreateExtents2D(0.9, 0.9, 1, 1));
            IFeatureDataReader reader = shapeFile.ExecuteFeatureQuery(query);
            dataTable.Load(reader, LoadOption.OverwriteChanges, null);

            Assert.AreEqual(1, dataTable.Rows.Count);

            FeatureDataRow newFeature = dataTable.Rows[0] as FeatureDataRow;
            Assert.AreEqual(_geoFactory.CreatePoint2D(1, 1), newFeature.Geometry);
            Assert.AreEqual(newFeature["Name"], "Test feature");
            DateTime dateCreatedActual = (DateTime) newFeature["DateCreated"];
            Assert.AreEqual(dateCreatedActual.Year, dateCreated.Year);
            Assert.AreEqual(dateCreatedActual.Month, dateCreated.Month);
            Assert.AreEqual(dateCreatedActual.Day, dateCreated.Day);
            Assert.AreEqual(newFeature["Visits"], 0);
            Assert.AreEqual(newFeature["Weight"], 100.0f);
            shapeFile.Close();
        }
开发者ID:pobingwanghai,项目名称:SharpMapV2,代码行数:48,代码来源:ShapeFileTests.cs

示例4: LoadingTableFromReader

 public void LoadingTableFromReader()
 {
     FeatureDataTable table = new FeatureDataTable();
     FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource();
     table.Load(provider.ExecuteIntersectionQuery(provider.GetExtents()));
 }
开发者ID:sridhar19091986,项目名称:sharpmapcf,代码行数:6,代码来源:FeatureDataTableTests.cs


注:本文中的FeatureDataTable.Load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。