public void ChangeViewAttributeFilterTriggersNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean resetNotificationOccured = false; view.ListChanged += delegate(Object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.Reset) { resetNotificationOccured = true; } }; Assert.False(resetNotificationOccured); Assert.Throws <NotSupportedException>(delegate { view.RowFilter = "FeatureName LIKE 'A m*'"; }); Assert.True(resetNotificationOccured); }
public void ChangeViewSpatialFilterTriggersNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean resetNotificationOccured = false; view.ListChanged += delegate(Object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.Reset) { resetNotificationOccured = true; } }; Assert.False(resetNotificationOccured); IExtents queryExtents = _factories.GeoFactory.CreateExtents2D(0, 0, 10, 10); SpatialBinaryExpression expression = SpatialBinaryExpression.Intersects(queryExtents); view.SpatialFilter = expression; Assert.True(resetNotificationOccured); }
public void AddingRowToTableTriggersViewListChangedItemAddedNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); FeatureQueryExpression query = FeatureQueryExpression.Intersects(halfBounds); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; view.ListChanged += delegate(Object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemAdded) { addNotificationOccured = true; } }; FeatureDataRow row = table.NewRow(); row["Oid"] = Guid.NewGuid(); row["FeatureName"] = "New row"; row.Geometry = _factories.GeoFactory.CreatePoint2D(44, 44); table.AddRow(row); Assert.True(addNotificationOccured); }
public void MovingRowTriggersViewListChangedItemMovedNotification() { // TODO: implement MovingRowTriggersViewListChangedItemMovedNotification FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; view.ListChanged += delegate(Object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.ItemMoved) { addNotificationOccured = true; } }; Assert.True(addNotificationOccured); }
public void ChangeViewSpatialFilterReturnsOnlyFilteredRows() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader); IGeometry queryExtents = _factories.GeoFactory.CreateExtents2D(0, 0, 10, 10).ToGeometry(); List <FeatureDataRow> expectedRows = new List <FeatureDataRow>(); foreach (FeatureDataRow row in table) { IGeometry g = row.Geometry; if (queryExtents.Intersects(g)) { expectedRows.Add(row); } } FeatureDataView view = new FeatureDataView(table); SpatialBinaryExpression expression = SpatialBinaryExpression.Intersects(queryExtents); view.SpatialFilter = expression; Assert.Equal(expectedRows.Count, view.Count); }
public void SettingOidFilterAllowsOnlyFeaturesContainingFilteredOidsInView() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable <Guid> table = new FeatureDataTable <Guid>("Oid", _factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); Guid[] ids = new Guid[3]; ids[0] = (table.Rows[1] as FeatureDataRow <Guid>).Id; ids[1] = (table.Rows[4] as FeatureDataRow <Guid>).Id; ids[2] = (table.Rows[6] as FeatureDataRow <Guid>).Id; FeatureDataView view = new FeatureDataView(table); view.OidFilter = new OidCollectionExpression(ids); Assert.Equal(3, view.Count); Assert.True(view.Find(ids[0]) > -1); Assert.True(view.Find(ids[1]) > -1); Assert.True(view.Find(ids[2]) > -1); Assert.Equal(-1, view.Find((table.Rows[0] as FeatureDataRow <Guid>).Id)); Assert.Equal(-1, view.Find((table.Rows[2] as FeatureDataRow <Guid>).Id)); Assert.Equal(-1, view.Find((table.Rows[3] as FeatureDataRow <Guid>).Id)); Assert.Equal(-1, view.Find((table.Rows[5] as FeatureDataRow <Guid>).Id)); }
public void LoadingTableFromReader() { FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); table.Load(provider.ExecuteFeatureQuery(query)); }
public void NullSpatialFilterReturnsAllRows() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); table.Load(data.ExecuteFeatureQuery(query)); FeatureDataView view = new FeatureDataView(table); Assert.Equal(table.Rows.Count, view.Count); }
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(); }
public void DefaultViewReturnsAllRows() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader); Assert.Equal(table.Rows.Count, table.DefaultView.Count); }
public void AddNewRowThrowsNotSupported() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Assert.Throws <NotSupportedException>(delegate { view.AddNew(); }); }
public void CreatingDataViewReturnsValidDataView() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Assert.IsType(typeof(FeatureDataTable), view.Table); Assert.Same(table, view.Table); }
public void SpatialQueryTypeIsWhatIsSpecifiedAtCreateTime() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); IGeometry filter = _factories.GeoFactory.CreateExtents2D(0, 0, 10, 10).ToGeometry(); FeatureDataView view = new FeatureDataView(table, filter, "", DataViewRowState.CurrentRows); Assert.Equal(SpatialOperation.Intersects, view.SpatialFilter.Op); }
public void ExecutingQueryOnTableTriggersViewListChangedResetNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); IExtents dataExtents = data.GetExtents(); IExtents halfBounds = _factories.GeoFactory.CreateExtents( dataExtents.Min, dataExtents.Max); halfBounds.Scale(0.5); FeatureQueryExpression query = FeatureQueryExpression.Intersects(halfBounds); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; view.ListChanged += delegate(Object sender, ListChangedEventArgs e) { if (e.ListChangedType == ListChangedType.Reset) { addNotificationOccured = true; } }; IExtents otherHalfBounds = _factories.GeoFactory.CreateExtents( dataExtents.Min, dataExtents.Max); otherHalfBounds.TranslateRelativeToWidth(0.5, 0.5); otherHalfBounds.Scale(0.5); query = FeatureQueryExpression.Intersects(otherHalfBounds); reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); Assert.True(addNotificationOccured); }
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(); }
public void CreatingDataViewWithEqualsSpatialExpressionSucceeds() { // This test is here so that when it is supported, the test breaks and is rewritten FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); Point <BufferedCoordinate> empty = _factories.GeoFactory.CreatePoint() as Point <BufferedCoordinate>; new FeatureDataView(table, empty, SpatialOperation.Equals, "", DataViewRowState.CurrentRows); }
private void createDataViewOnNewTable(out FeatureDataView view, out FeatureDataTable <Guid> table, Boolean includeGeometryCollections) { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory, includeGeometryCollections); table = new FeatureDataTable <Guid>("Oid", _factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); view = new FeatureDataView(table); }
public void MergeSchemaToKeyedTableWithDifferentKeyNameButSameTypeShouldKeepKeyButAddOtherColumns() { FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); IFeatureDataReader reader = provider.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable <Guid> target = new FeatureDataTable <Guid>("GID", _factories.GeoFactory); table.MergeSchemaTo(target); DataTableHelper.AssertTableStructureIdentical(table, target); }
public void MergeSchemaToSchemalessTargetShouldCreateIdenticalTable() { FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); IFeatureDataReader reader = provider.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable target = new FeatureDataTable(_factories.GeoFactory); table.MergeSchemaTo(target); DataTableHelper.AssertTableStructureIdentical(table, target); }
//[ExpectedException(typeof (NotImplementedException))] public void DataViewManagerIsAFeatureDataViewManager() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataSet dataSet = new FeatureDataSet(_factories.GeoFactory); dataSet.Tables.Add(table); FeatureDataView view = dataSet.DefaultViewManager.CreateDataView(table); Assert.NotNull(view.DataViewManager); Assert.IsType(typeof(FeatureDataViewManager), view.DataViewManager); }
public void CloneToCopiesTableStructureAndNoData() { FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(provider.GetExtents()); IFeatureDataReader reader = provider.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable clone = new FeatureDataTable(_factories.GeoFactory); table.CloneTo(clone); DataTableHelper.AssertTableStructureIdentical(table, clone); Assert.Equal(0, clone.Rows.Count); }
public void SettingGeometryFilterToIdenticalGeometryDoesntChangeFilterObject() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); IGeometry filter = _factories.GeoFactory.CreateExtents2D(0, 0, 10, 10).ToGeometry(); FeatureDataView view = new FeatureDataView(table, filter, "", DataViewRowState.CurrentRows); IGeometry filterCopy = filter.Clone(); Assert.NotSame(filter, filterCopy); Assert.Equal(filter, filterCopy); SpatialBinaryExpression expression = SpatialBinaryExpression.Intersects(filterCopy); view.SpatialFilter = expression; Assert.NotSame(expression, view.SpatialFilter); }
public void ChangeViewAttributeFilterReturnsOnlyFilteredRows() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory); FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory); FeatureQueryExpression query = FeatureQueryExpression.Intersects(data.GetExtents()); IFeatureDataReader reader = data.ExecuteFeatureQuery(query); table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Int32 expectedRowCount = 0; foreach (FeatureDataRow row in table.Rows) { if (row["FeatureName"].ToString().StartsWith("A m")) { expectedRowCount++; } } Assert.Throws <NotSupportedException>(delegate { view.RowFilter = "FeatureName LIKE 'A m*'"; }); Assert.Equal(expectedRowCount, view.Count); }
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); }
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(); }
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); }
public void LoadingTableFromReader() { FeatureDataTable table = new FeatureDataTable(); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(); table.Load(provider.ExecuteIntersectionQuery(provider.GetExtents())); }