From 014d775d6fba5ee210687e747ab0e2bd3d32ba32 Mon Sep 17 00:00:00 2001 From: "justsome.handle" Date: Tue, 13 May 2008 23:20:25 +0000 Subject: [PATCH] Renamed ILayerProvider interface hierarchy to remove "Layer" from name Removed many IFeatureProvider query method variations leaving only methods returning IFeatureDataReader Created new IFeatureAdaptor interface containing removed methods as temporary holding ground until the correct configuration for methods dealing with FeatureDataSet, FeatureDataTable, and asynchronous versions is determined. Updated FeatureProvider, GeometryProvider, and ShapeFileProvider and tests to conform to new interface --- .../ShapeFileTests.cs | 77 ++-- .../ShapeFileDataReader.cs | 44 +- .../ShapeFileProvider.cs | 400 ++++++++++-------- SharpMap.SimpleGeometries/Geometry.cs | 14 +- SharpMap.Tests/Data/FeatureDataTableTests.cs | 18 +- SharpMap.Tests/Data/FeatureDataViewTests.cs | 69 ++- SharpMap.Tests/DataSourceHelper.cs | 2 +- SharpMap.Tests/MapTests.cs | 6 +- .../Rendering/BasicGeometryRenderer2DTests.cs | 7 +- SharpMap/Data/FeatureMerger.cs | 14 +- ...ureLayerProvider.cs => IFeatureAdapter.cs} | 104 +---- SharpMap/Data/IFeatureProvider.cs | 117 +++++ ...yerProvider`1.cs => IFeatureProvider`1.cs} | 2 +- .../Data/{ILayerProvider.cs => IProvider.cs} | 2 +- ...terLayerProvider.cs => IRasterProvider.cs} | 2 +- ...vider.cs => IWritableFeatureProvider`1.cs} | 2 +- .../FeatureProvider/FeatureProvider.cs | 222 +++++----- .../GeometryProvider/GeometryProvider.cs | 286 ++++++------- SharpMap/Layers/FeatureLayer.cs | 54 ++- SharpMap/Layers/GeometryLayer.cs | 6 +- SharpMap/Layers/IFeatureLayer.cs | 2 +- SharpMap/Layers/ILayer.cs | 2 +- SharpMap/Layers/IRasterLayer.cs | 2 +- SharpMap/Layers/LabelLayer.cs | 2 +- SharpMap/Layers/Layer.cs | 10 +- SharpMap/Layers/LayerGroup.cs | 2 +- SharpMap/Layers/RasterLayer.cs | 4 +- SharpMap/SharpMap.csproj | 11 +- 28 files changed, 827 insertions(+), 656 deletions(-) rename SharpMap/Data/{IFeatureLayerProvider.cs => IFeatureAdapter.cs} (72%) create mode 100644 SharpMap/Data/IFeatureProvider.cs rename SharpMap/Data/{IFeatureLayerProvider`1.cs => IFeatureProvider`1.cs} (95%) rename SharpMap/Data/{ILayerProvider.cs => IProvider.cs} (95%) rename SharpMap/Data/{IRasterLayerProvider.cs => IRasterProvider.cs} (94%) rename SharpMap/Data/{IWritableFeatureLayerProvider.cs => IWritableFeatureProvider`1.cs} (94%) diff --git a/SharpMap.Data.Providers.ShapeFile.Tests/ShapeFileTests.cs b/SharpMap.Data.Providers.ShapeFile.Tests/ShapeFileTests.cs index e0685518..86cc565c 100644 --- a/SharpMap.Data.Providers.ShapeFile.Tests/ShapeFileTests.cs +++ b/SharpMap.Data.Providers.ShapeFile.Tests/ShapeFileTests.cs @@ -404,6 +404,7 @@ public void CloseExclusiveTest() } [Test] + [Ignore("Retarget or delete test; IEnumerable method variations obsoleted in favor of returning IFeatureDataReader")] public void GetGeometriesInViewTest() { ShapeFileProvider shapeFile = new ShapeFileProvider( @@ -411,24 +412,25 @@ public void GetGeometriesInViewTest() shapeFile.Open(); List geometries = new List(); - geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(shapeFile.GetExtents())); + //geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(shapeFile.GetExtents())); Assert.AreEqual(shapeFile.GetFeatureCount(), geometries.Count); geometries.Clear(); IGeometry empty = _geoFactory.CreatePoint(); - geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(empty)); + //geometries.AddRange(shapeFile.ExecuteGeometryIntersectionQuery(empty)); Assert.AreEqual(0, geometries.Count); } [Test] - [ExpectedException(typeof (ShapeFileInvalidOperationException))] + [Ignore("Retarget or delete test; IEnumerable method variations obsoleted in favor of returning IFeatureDataReader")] + [ExpectedException(typeof(ShapeFileInvalidOperationException))] public void GetGeometriesInViewWhenClosedThrowsExceptionTest() { ShapeFileProvider shapeFile = new ShapeFileProvider( @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); IGeometry empty = _geoFactory.CreatePoint(); - new List(shapeFile.ExecuteGeometryIntersectionQuery(empty)); + //new List(shapeFile.ExecuteGeometryIntersectionQuery(empty)); } [Test] @@ -437,10 +439,10 @@ public void ExecuteIntersectionQueryByBoundingBoxTest() ShapeFileProvider shapeFile = new ShapeFileProvider( @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); shapeFile.Open(); - FeatureDataSet data = new FeatureDataSet("ShapeFile test", _geoFactory); - shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), data); - Assert.AreEqual(1, data.Tables.Count); - Assert.AreEqual(shapeFile.GetFeatureCount(), data.Tables[0].Rows.Count); + FeatureDataTable data = new FeatureDataTable("ShapeFile test", _geoFactory); + IFeatureDataReader reader = shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents()); + data.Load(reader, LoadOption.OverwriteChanges, null); + Assert.AreEqual(shapeFile.GetFeatureCount(), data.Rows.Count); shapeFile.Close(); } @@ -450,8 +452,7 @@ public void ExecuteIntersectionQueryByBoundingBoxWhenClosedThrowsExceptionTest() { ShapeFileProvider shapeFile = new ShapeFileProvider( @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); - FeatureDataSet data = new FeatureDataSet("ShapeFile test", _geoFactory); - shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), data); + IFeatureDataReader reader = shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents()); } [Test] @@ -578,14 +579,13 @@ public void InsertFeatureTest() Assert.AreEqual(1, shapeFile.GetFeatureCount()); - FeatureDataSet dataSet = new FeatureDataSet("ShapeFile test", _geoFactory); - - shapeFile.ExecuteIntersectionQuery(_geoFactory.CreateExtents2D(0.9, 0.9, 1, 1), dataSet); + FeatureDataTable dataTable = new FeatureDataTable("ShapeFile test", _geoFactory); + IFeatureDataReader reader = shapeFile.ExecuteIntersectionQuery(_geoFactory.CreateExtents2D(0.9, 0.9, 1, 1)); + dataTable.Load(reader, LoadOption.OverwriteChanges, null); - Assert.AreEqual(1, dataSet.Tables.Count); - Assert.AreEqual(1, dataSet.Tables[0].Rows.Count); + Assert.AreEqual(1, dataTable.Rows.Count); - FeatureDataRow newFeature = dataSet.Tables[0].Rows[0] as FeatureDataRow; + 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"]; @@ -653,12 +653,11 @@ ICoordinateSequence coordinates Assert.AreEqual(10000, shapeFile.GetFeatureCount()); Assert.AreEqual(computedBounds, shapeFile.GetExtents()); - FeatureDataSet dataSet = new FeatureDataSet("ShapeFile test", _geoFactory); - - shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents(), dataSet); + FeatureDataTable dataTable = new FeatureDataTable("ShapeFile test", _geoFactory); + IFeatureDataReader reader = shapeFile.ExecuteIntersectionQuery(shapeFile.GetExtents()); + dataTable.Load(reader, LoadOption.OverwriteChanges, null); - Assert.AreEqual(1, dataSet.Tables.Count); - Assert.AreEqual(10000, dataSet.Tables[0].Rows.Count); + Assert.AreEqual(10000, dataTable.Rows.Count); } [Test] @@ -726,6 +725,28 @@ private IProjectedCoordinateSystem createExpectedCoordinateSystem() return expected; } + [Test] + [ExpectedException(typeof(ShapeFileInvalidOperationException))] + public void GetSchemaTableFailsifShapeFileNotOpen() + { + ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP", _geoFactory); + + DataTable schemaTable = shapeFile.GetSchemaTable(); + } + + [Test] + public void GetSchemaTableReturnsOid() + { + ShapeFileProvider shapeFile = new ShapeFileProvider( + @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); + shapeFile.Open(); + + DataTable schemaTable = shapeFile.GetSchemaTable(); + + Assert.AreEqual(34, schemaTable.Rows.Count); + Assert.AreEqual("OID", schemaTable.Rows[0][ProviderSchemaHelper.ColumnNameColumn]); + } + [Test] [ExpectedException(typeof (ShapeFileInvalidOperationException))] public void SetTableSchemaShouldFailIfShapeFileNotOpen() @@ -743,8 +764,7 @@ public void SetTableSchemaShouldMatchShapeFileSchema() @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); shapeFile.Open(); IGeometry empty = _geoFactory.CreatePoint(); - FeatureDataTable queryTable = new FeatureDataTable("OID", _geoFactory); - shapeFile.ExecuteIntersectionQuery(empty, queryTable); + FeatureDataTable queryTable = shapeFile.CreateNewTable() as FeatureDataTable; FeatureDataTable nonKeyedTable = new FeatureDataTable(_geoFactory); shapeFile.SetTableSchema(nonKeyedTable); @@ -762,12 +782,9 @@ public void SetTableSchemaWithDifferentKeyCase() ShapeFileProvider shapeFile = new ShapeFileProvider(@"..\..\..\TestData\BCROADS.SHP", _geoFactory); shapeFile.Open(); IGeometry empty = _geoFactory.CreatePoint(); - FeatureDataTable queryTable = new FeatureDataTable("OID", _geoFactory); - shapeFile.ExecuteIntersectionQuery(empty, queryTable); FeatureDataTable keyedTable = new FeatureDataTable("oid", _geoFactory); shapeFile.SetTableSchema(keyedTable); - DataTableHelper.AssertTableStructureIdentical(keyedTable, queryTable); } [Test] @@ -778,8 +795,8 @@ public void SetTableSchemaWithDifferentKeyCaseAndSchemaMergeAction() @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); shapeFile.Open(); IGeometry empty = _geoFactory.CreatePoint(); - FeatureDataTable queryTable = new FeatureDataTable("OID", _geoFactory); - shapeFile.ExecuteIntersectionQuery(empty, queryTable); + FeatureDataTable queryTable = shapeFile.CreateNewTable() as FeatureDataTable; + // expecting a new FeatureDataTable("OID", _geoFactory); FeatureDataTable keyedTable = new FeatureDataTable("oid", _geoFactory); shapeFile.SetTableSchema(keyedTable, SchemaMergeAction.CaseInsensitive); @@ -794,8 +811,8 @@ public void SetTableSchemaWithDifferentKeyNameAndSchemaMergeAction() @"..\..\..\TestData\BCROADS.SHP", _geoFactory, _coordSysFactory); shapeFile.Open(); IGeometry empty = _geoFactory.CreatePoint(); - FeatureDataTable queryTable = new FeatureDataTable("OID", _geoFactory); - shapeFile.ExecuteIntersectionQuery(empty, queryTable); + FeatureDataTable queryTable = shapeFile.CreateNewTable() as FeatureDataTable; + // expecting a new FeatureDataTable("OID", _geoFactory); FeatureDataTable keyedTable = new FeatureDataTable("FID", _geoFactory); shapeFile.SetTableSchema(keyedTable, SchemaMergeAction.KeyByType); diff --git a/SharpMap.Data.Providers.ShapeFile/ShapeFileDataReader.cs b/SharpMap.Data.Providers.ShapeFile/ShapeFileDataReader.cs index 83e8e0c7..40a0aa5e 100644 --- a/SharpMap.Data.Providers.ShapeFile/ShapeFileDataReader.cs +++ b/SharpMap.Data.Providers.ShapeFile/ShapeFileDataReader.cs @@ -145,14 +145,18 @@ public Boolean HasOid { get { - checkState(); - return true; + checkDisposed(); + return true; } } public Boolean IsFullyLoaded { - get { return _options == QueryExecutionOptions.FullFeature; } + get + { + return (_options | QueryExecutionOptions.BoundingBoxes) + == (QueryExecutionOptions.FullFeature | QueryExecutionOptions.BoundingBoxes); + } } public Type OidType @@ -173,15 +177,15 @@ public Int32 Depth { get { - checkState(); - return 0; + checkDisposed(); + return 0; } } public DataTable GetSchemaTable() { - checkState(); - return _schemaTable.Copy(); + checkDisposed(); + return _schemaTable.Copy(); } public Boolean IsClosed @@ -197,7 +201,7 @@ public Boolean NextResult() public Boolean Read() { - checkState(); + checkDisposed(); Boolean reading = _objectEnumerator.MoveNext(); @@ -222,12 +226,12 @@ public Int32 FieldCount { get { - checkState(); - return _schemaTable.Rows.Count; + checkDisposed(); + return _schemaTable.Rows.Count; } } - public Boolean GetBoolean(Int32 i) + public Boolean GetBoolean(Int32 i) { checkState(); checkIndex(i); @@ -302,8 +306,7 @@ public Type GetFieldType(Int32 i) { checkState(); checkIndex(i); - - return _currentFeature[i].GetType(); + return _currentFeature.GetFieldType(i); } public Single GetFloat(Int32 i) @@ -370,13 +373,13 @@ public Int64 GetInt64(Int32 i) public String GetName(Int32 i) { - checkState(); - return _schemaTable.Rows[i][0] as String; + checkDisposed(); + return _schemaTable.Rows[i][0] as String; } public Int32 GetOrdinal(String name) { - checkState(); + checkDisposed(); if (name == null) throw new ArgumentNullException("name"); @@ -475,14 +478,19 @@ private void checkIndex(Int32 i) private void checkState() { - if (IsDisposed) throw new ObjectDisposedException(GetType().ToString()); + checkDisposed(); if (_currentFeature == null) { throw new InvalidOperationException("The Read method must be called before accessing values."); } } - #endregion + private void checkDisposed() + { + if (IsDisposed) throw new ObjectDisposedException(GetType().ToString()); + } + + #endregion #region IEnumerable Members diff --git a/SharpMap.Data.Providers.ShapeFile/ShapeFileProvider.cs b/SharpMap.Data.Providers.ShapeFile/ShapeFileProvider.cs index 4889c97e..90ddc1f6 100644 --- a/SharpMap.Data.Providers.ShapeFile/ShapeFileProvider.cs +++ b/SharpMap.Data.Providers.ShapeFile/ShapeFileProvider.cs @@ -63,7 +63,7 @@ namespace SharpMap.Data.Providers.ShapeFile /// myLayer.DataSource = new ShapeFile(@"C:\data\MyShapeData.shp"); /// /// - public class ShapeFileProvider : IWritableFeatureLayerProvider + public class ShapeFileProvider : IWritableFeatureProvider { //#region FilterMethod @@ -830,76 +830,86 @@ public void Open(Boolean exclusive) #region IFeatureLayerProvider Members - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, - FeatureDataSet dataSet, - AsyncCallback callback, - Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, + // FeatureDataSet dataSet, + // AsyncCallback callback, + // Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, - AsyncCallback callback, Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, + // AsyncCallback callback, Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, - AsyncCallback callback, Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, + // AsyncCallback callback, Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, - QueryExecutionOptions options, AsyncCallback callback, - Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, + // QueryExecutionOptions options, AsyncCallback callback, + // Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, - AsyncCallback callback, Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, + // AsyncCallback callback, Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, - QueryExecutionOptions options, AsyncCallback callback, - Object asyncState) - { - checkOpen(); - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, + // QueryExecutionOptions options, AsyncCallback callback, + // Object asyncState) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public IAsyncResult BeginGetFeatures(IEnumerable oids, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } + //public IAsyncResult BeginGetFeatures(IEnumerable oids, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} public FeatureDataTable CreateNewTable() { return getNewTable(); } - public IEnumerable EndGetFeatures(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public IEnumerable EndGetFeatures(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} - public void EndExecuteFeatureQuery(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public void EndExecuteFeatureQuery(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} public IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query) { + if (query == null) throw new ArgumentNullException("query"); checkOpen(); - throw new NotImplementedException(); + if (query.QueryType != SpatialExpressionType.Intersects) + { + throw new NotImplementedException("Only intersections implemented"); + } + if (query.Oids != null) + { + throw new NotImplementedException("Oid filter not implemented"); + } + return ExecuteIntersectionQuery(query.QueryRegion.Extents, + QueryExecutionOptions.FullFeature); } /// @@ -912,19 +922,19 @@ public IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query) /// Thrown if method is called and the shapefile is closed. /// Check before calling. /// - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) - { - checkOpen(); - FeatureDataTable dt = HasDbf - ? _dbaseFile.NewTable - : FeatureDataTable.CreateEmpty(ShapeFileConstants.IdColumnName, _geoFactory); + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) + //{ + // checkOpen(); + // FeatureDataTable dt = HasDbf + // ? _dbaseFile.NewTable + // : FeatureDataTable.CreateEmpty(ShapeFileConstants.IdColumnName, _geoFactory); - dt.TableName = Path.GetFileNameWithoutExtension(Filename); + // dt.TableName = Path.GetFileNameWithoutExtension(Filename); - ExecuteFeatureQuery(query, dt); + // ExecuteFeatureQuery(query, dt); - dataSet.Tables.Add(dt); - } + // dataSet.Tables.Add(dt); + //} /// /// Retrieves features into a that @@ -932,55 +942,55 @@ public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet d /// /// Spatial query to execute. /// FeatureDataTable to fill data into. - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) - { - checkOpen(); + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) + //{ + // checkOpen(); - IExtents extents = query.QueryRegion.Extents; + // IExtents extents = query.QueryRegion.Extents; - IEnumerable records; + // IEnumerable records; - // Get candidates by intersecting the spatial index tree - // or enumerating all rows - if (IsSpatiallyIndexed) - { - IEnumerable keys = _spatialIndex.Query(extents); - records = intersectFeatureGeometry(keys, query.QueryRegion); - } - else - { - throw new NotImplementedException( - "Allow shapefile provider to be created without an index. [workitem:13025]"); - } + // // Get candidates by intersecting the spatial index tree + // // or enumerating all rows + // if (IsSpatiallyIndexed) + // { + // IEnumerable keys = _spatialIndex.Query(extents); + // records = intersectFeatureGeometry(keys, query.QueryRegion); + // } + // else + // { + // throw new NotImplementedException( + // "Allow shapefile provider to be created without an index. [workitem:13025]"); + // } - FeatureDataTable result = getNewTable(); + // FeatureDataTable result = getNewTable(); - foreach (IFeatureDataRecord record in records) - { - FeatureDataRow feature = record as FeatureDataRow; + // foreach (IFeatureDataRecord record in records) + // { + // FeatureDataRow feature = record as FeatureDataRow; - Debug.Assert(feature != null); + // Debug.Assert(feature != null); - if (Filter == null || Filter(feature)) - { - result.AddRow(feature); - } - } + // if (Filter == null || Filter(feature)) + // { + // result.AddRow(feature); + // } + // } - table.Merge(result, true); - } + // table.Merge(result, true); + //} - public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) - { - checkOpen(); + //public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) + //{ + // checkOpen(); - IEnumerable ids = _spatialIndex.Query(geometry.Extents); + // IEnumerable ids = _spatialIndex.Query(geometry.Extents); - foreach (IFeatureDataRecord feature in intersectFeatureGeometry(ids, geometry)) - { - yield return feature.Geometry; - } - } + // foreach (IFeatureDataRecord feature in intersectFeatureGeometry(ids, geometry)) + // { + // yield return feature.Geometry; + // } + //} public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry) { @@ -994,44 +1004,44 @@ public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry, QueryExec throw new NotImplementedException(); } - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) - { - checkOpen(); - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) - { - checkOpen(); - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) - { - checkOpen(); - if (geometry == null) throw new ArgumentNullException("geometry"); + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) + //{ + // checkOpen(); + // if (geometry == null) throw new ArgumentNullException("geometry"); - FeatureDataTable result = getNewTable(); + // FeatureDataTable result = getNewTable(); - foreach (IdBounds bounds in _spatialIndex.Query(geometry.Extents)) - { - // not sure of the best way to do this: get geometry and check it - // or get feature and check it. Need to measure. - if (geometry.Intersects(GetGeometryById(bounds.Id))) - { - FeatureDataRow feature = getFeature(bounds.Id, result); - result.AddRow(feature); - } - } + // foreach (IdBounds bounds in _spatialIndex.Query(geometry.Extents)) + // { + // // not sure of the best way to do this: get geometry and check it + // // or get feature and check it. Need to measure. + // if (geometry.Intersects(GetGeometryById(bounds.Id))) + // { + // FeatureDataRow feature = getFeature(bounds.Id, result); + // result.AddRow(feature); + // } + // } - table.Merge(result, true); - } + // table.Merge(result, true); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) - { - checkOpen(); - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) + //{ + // checkOpen(); + // throw new NotImplementedException(); + //} /// /// Returns geometries whose bounding box intersects . @@ -1058,20 +1068,20 @@ public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, /// Thrown if method is called and the /// shapefile is closed. Check before calling. /// - public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) - { - checkOpen(); + //public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) + //{ + // checkOpen(); - foreach (UInt32 oid in GetIntersectingObjectIds(bounds)) - { - IGeometry g = GetGeometryById(oid); + // foreach (UInt32 oid in GetIntersectingObjectIds(bounds)) + // { + // IGeometry g = GetGeometryById(oid); - if (!ReferenceEquals(g, null)) - { - yield return g; - } - } - } + // if (!ReferenceEquals(g, null)) + // { + // yield return g; + // } + // } + //} /// /// Retrieves a for the features that @@ -1138,10 +1148,10 @@ public IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds, QueryExecuti /// Thrown if method is called and the shapefile is closed. /// Check before calling. /// - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) - { - ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.FullFeature); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) + //{ + // ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.FullFeature); + //} /// /// Retrieves the data associated with all the features that @@ -1160,17 +1170,17 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) /// Thrown when a value other than /// is supplied for . /// - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) - { - checkOpen(); + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // checkOpen(); - // TODO: search the dataset for the table and merge results. - FeatureDataTable dt = getNewTable(); + // // TODO: search the dataset for the table and merge results. + // FeatureDataTable dt = getNewTable(); - ExecuteIntersectionQuery(bounds, dt, options); + // ExecuteIntersectionQuery(bounds, dt, options); - dataSet.Tables.Add(dt); - } + // dataSet.Tables.Add(dt); + //} /// /// Retrieves the data associated with all the features that @@ -1178,10 +1188,10 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, Qu /// /// BoundingBox to intersect with. /// FeatureDataTable to fill data into. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) - { - ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.FullFeature); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) + //{ + // ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.FullFeature); + //} /// /// Retrieves the data associated with all the features that @@ -1194,28 +1204,28 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) /// Thrown when a value other than /// is supplied for . /// - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) - { - checkOpen(); + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) + //{ + // checkOpen(); - if (options != QueryExecutionOptions.FullFeature) - { - throw new ArgumentException("Only QueryExecutionOptions.All is supported.", "options"); - } + // if (options != QueryExecutionOptions.FullFeature) + // { + // throw new ArgumentException("Only QueryExecutionOptions.All is supported.", "options"); + // } - if (!(table is FeatureDataTable)) - { - throw new ArgumentException("Parameter 'table' must be of type FeatureDataTable."); - } + // if (!(table is FeatureDataTable)) + // { + // throw new ArgumentException("Parameter 'table' must be of type FeatureDataTable."); + // } - FeatureDataTable keyedTable = table as FeatureDataTable; + // FeatureDataTable keyedTable = table as FeatureDataTable; - SetTableSchema(keyedTable); + // SetTableSchema(keyedTable); - IEnumerable objectsInQuery = GetIntersectingObjectIds(bounds); + // IEnumerable objectsInQuery = GetIntersectingObjectIds(bounds); - keyedTable.Merge(getFeatureRecordsFromIds(objectsInQuery, keyedTable), GeometryFactory); - } + // keyedTable.Merge(getFeatureRecordsFromIds(objectsInQuery, keyedTable), GeometryFactory); + //} public IGeometryFactory GeometryFactory { @@ -1229,10 +1239,10 @@ public IGeometryFactory GeometryFactory } } - public IEnumerable GetFeatures(IEnumerable oids) - { - return GetFeatures(getUint32IdsFromObjects(oids)); - } + //public IEnumerable GetFeatures(IEnumerable oids) + //{ + // return GetFeatures(getUint32IdsFromObjects(oids)); + //} /// /// Returns the number of features in the entire data source. @@ -1252,8 +1262,32 @@ public Int32 GetFeatureCount() /// A DataTable that describes the column metadata. public DataTable GetSchemaTable() { + checkOpen(); //enableReading(); - return _dbaseFile.GetSchemaTable(); + DataTable schemaTable = _dbaseFile.GetSchemaTable(); + + DataRow oidColumn = schemaTable.NewRow(); + oidColumn[ProviderSchemaHelper.ColumnNameColumn] = "OID"; + oidColumn[ProviderSchemaHelper.ColumnSizeColumn] = 0; + oidColumn[ProviderSchemaHelper.ColumnOrdinalColumn] = 0; + oidColumn[ProviderSchemaHelper.NumericPrecisionColumn] = 0; + oidColumn[ProviderSchemaHelper.NumericScaleColumn] = 0; + oidColumn[ProviderSchemaHelper.DataTypeColumn] = typeof (UInt32); + oidColumn[ProviderSchemaHelper.AllowDBNullColumn] = true; + oidColumn[ProviderSchemaHelper.IsReadOnlyColumn] = false; + oidColumn[ProviderSchemaHelper.IsUniqueColumn] = true; + oidColumn[ProviderSchemaHelper.IsRowVersionColumn] = false; + oidColumn[ProviderSchemaHelper.IsKeyColumn] = true; + oidColumn[ProviderSchemaHelper.IsAutoIncrementColumn] = false; + oidColumn[ProviderSchemaHelper.IsLongColumn] = false; + schemaTable.Rows.InsertAt(oidColumn, 0); + + for (int i = 1; i < schemaTable.Rows.Count; i++) + { + schemaTable.Rows[i][ProviderSchemaHelper.ColumnOrdinalColumn] = i; + } + + return schemaTable; } /// diff --git a/SharpMap.SimpleGeometries/Geometry.cs b/SharpMap.SimpleGeometries/Geometry.cs index 2ae1f324..8f9a7cc7 100644 --- a/SharpMap.SimpleGeometries/Geometry.cs +++ b/SharpMap.SimpleGeometries/Geometry.cs @@ -248,7 +248,7 @@ private IEnumerable getBoundCoordinates(Extents box) /// public String AsText() { - return WktWriter.ToWkt(this); + return FactoryInternal.WktWriter.Write(this); } /// @@ -257,7 +257,7 @@ public String AsText() /// public Byte[] AsBinary() { - return WkbWriter.ToWkb(this); + return FactoryInternal.WkbWriter.Write(this); } /// @@ -353,6 +353,16 @@ public Boolean Equals(IGeometry g, Tolerance tolerance) throw new NotImplementedException(); } + public bool EqualsExact(IGeometry g) + { + throw new NotImplementedException(); + } + + public bool EqualsExact(IGeometry g, Tolerance tolerance) + { + throw new NotImplementedException(); + } + #region IEquatable Members public Boolean Equals(IGeometry other) diff --git a/SharpMap.Tests/Data/FeatureDataTableTests.cs b/SharpMap.Tests/Data/FeatureDataTableTests.cs index 0f13bbc4..29e53705 100644 --- a/SharpMap.Tests/Data/FeatureDataTableTests.cs +++ b/SharpMap.Tests/Data/FeatureDataTableTests.cs @@ -122,7 +122,8 @@ public void CloneToCopiesTableStructureAndNoData() { FeatureDataTable table = new FeatureDataTable(_geoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), table); + IFeatureDataReader reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable clone = new FeatureDataTable(_geoFactory); table.CloneTo(clone); @@ -136,7 +137,8 @@ public void MergeSchemaToSchemalessTargetShouldCreateIdenticalTable() { FeatureDataTable table = new FeatureDataTable(_geoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), table); + IFeatureDataReader reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable target = new FeatureDataTable(_geoFactory); table.MergeSchema(target); @@ -149,10 +151,12 @@ public void MergeSchemaToIdenticalTableShouldRemainIdentical() { FeatureDataTable table = new FeatureDataTable(_geoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), table); + IFeatureDataReader reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable target = new FeatureDataTable(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), target); + reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + target.Load(reader, LoadOption.OverwriteChanges, null); table.MergeSchema(target); @@ -164,7 +168,8 @@ public void MergeSchemaToKeyedTableShouldKeepKeyButAddOtherColumns() { FeatureDataTable table = new FeatureDataTable(_geoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), table); + IFeatureDataReader reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable target = new FeatureDataTable("Oid", _geoFactory); @@ -179,7 +184,8 @@ public void MergeSchemaToKeyedTableWithDifferentKeyNameButSameTypeShouldKeepKeyB { FeatureDataTable table = new FeatureDataTable(_geoFactory); FeatureProvider provider = DataSourceHelper.CreateFeatureDatasource(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), table); + IFeatureDataReader reader = provider.ExecuteIntersectionQuery(provider.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataTable target = new FeatureDataTable("GID", _geoFactory); diff --git a/SharpMap.Tests/Data/FeatureDataViewTests.cs b/SharpMap.Tests/Data/FeatureDataViewTests.cs index 3b5bf86c..a803c914 100644 --- a/SharpMap.Tests/Data/FeatureDataViewTests.cs +++ b/SharpMap.Tests/Data/FeatureDataViewTests.cs @@ -31,7 +31,8 @@ public void CreatingDataViewReturnsValidDataView() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Assert.IsInstanceOfType(typeof (FeatureDataTable), view.Table); Assert.AreSame(table, view.Table); @@ -49,7 +50,8 @@ public void CreatingDataViewWithCrossesSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Crosses, "", DataViewRowState.CurrentRows); } @@ -62,7 +64,8 @@ public void CreatingDataViewWithContainsSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Contains, "", DataViewRowState.CurrentRows); } @@ -75,7 +78,8 @@ public void CreatingDataViewWithEqualsSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Equals, "", DataViewRowState.CurrentRows); } @@ -88,7 +92,8 @@ public void CreatingDataViewWithNoneSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.None, "", DataViewRowState.CurrentRows); } @@ -101,7 +106,8 @@ public void CreatingDataViewWithOverlapsSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Overlaps, "", DataViewRowState.CurrentRows); } @@ -114,7 +120,8 @@ public void CreatingDataViewWithTouchesSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Touches, "", DataViewRowState.CurrentRows); } @@ -127,7 +134,8 @@ public void CreatingDataViewWithWithinSpatialExpressionTypeNotSupported() FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Point empty = _geoFactory.CreatePoint() as Point; new FeatureDataView(table, empty, SpatialExpressionType.Within, "", DataViewRowState.CurrentRows); } @@ -143,7 +151,8 @@ public void ChangeViewAttributeFilterReturnsOnlyFilteredRows() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Int32 expectedRowCount = 0; @@ -171,7 +180,8 @@ public void ChangeViewAttributeFilterTriggersNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean resetNotificationOccured = false; @@ -259,7 +269,8 @@ public void ChangeViewSpatialFilterTriggersNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean resetNotificationOccured = false; @@ -294,7 +305,8 @@ public void ExecutingQueryOnTableTriggersViewListChangedResetNotification() dataExtents.Min, dataExtents.Max); halfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(halfBounds, table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(halfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; @@ -312,7 +324,8 @@ public void ExecutingQueryOnTableTriggersViewListChangedResetNotification() otherHalfBounds.TranslateRelativeToWidth(0.5, 0.5); otherHalfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(otherHalfBounds, table); + reader = data.ExecuteIntersectionQuery(otherHalfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); Assert.IsTrue(addNotificationOccured); } @@ -330,7 +343,8 @@ public void AddingRowToTableTriggersViewListChangedItemAddedNotification() IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(halfBounds, table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(halfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; @@ -365,7 +379,8 @@ public void RemovingRowFromTableTriggersViewListChangedItemDeletedNotification() IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(halfBounds, table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(halfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; @@ -397,7 +412,8 @@ public void ChangingRowTriggersViewListChangedItemChangedNotification() IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(halfBounds, table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(halfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; @@ -431,7 +447,8 @@ public void MovingRowTriggersViewListChangedItemMovedNotification() IExtents halfBounds = data.GetExtents(); halfBounds.Scale(0.5); - data.ExecuteIntersectionQuery(halfBounds, table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(halfBounds); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean addNotificationOccured = false; @@ -482,7 +499,8 @@ public void SettingOidFilterAllowsOnlyFeaturesContainingFilteredOidsInView() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable("Oid", _geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); Guid[] ids = new Guid[3]; ids[0] = (table.Rows[1] as FeatureDataRow).Id; ids[1] = (table.Rows[4] as FeatureDataRow).Id; @@ -509,7 +527,8 @@ public void ChangingOidFilterTriggersNotification() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable("Oid", _geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); Boolean resetNotificationOccured = false; @@ -555,7 +574,8 @@ public void AddNewRowThrowsNotSupported() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataView view = new FeatureDataView(table); view.AddNew(); } @@ -569,7 +589,8 @@ public void SettingGeometryFilterToIdenticalGeometryDoesntChangeFilterObject() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); IGeometry filter = _geoFactory.CreateExtents2D(0, 0, 10, 10).ToGeometry(); FeatureDataView view = new FeatureDataView(table, filter, "", DataViewRowState.CurrentRows); IGeometry filterCopy = filter.Clone(); @@ -588,7 +609,8 @@ public void SpatialQueryTypeIsWhatIsSpecifiedAtCreateTime() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); IGeometry filter = _geoFactory.CreateExtents2D(0, 0, 10, 10).ToGeometry(); FeatureDataView view = new FeatureDataView(table, filter, "", DataViewRowState.CurrentRows); Assert.AreEqual(SpatialExpressionType.Intersects, view.GeometryFilterType); @@ -604,7 +626,8 @@ public void DataViewManagerIsAFeatureDataViewManager() { FeatureProvider data = DataSourceHelper.CreateFeatureDatasource(_geoFactory); FeatureDataTable table = new FeatureDataTable(_geoFactory); - data.ExecuteIntersectionQuery(data.GetExtents(), table); + IFeatureDataReader reader = data.ExecuteIntersectionQuery(data.GetExtents()); + table.Load(reader, LoadOption.OverwriteChanges, null); FeatureDataSet dataSet = new FeatureDataSet(_geoFactory); dataSet.Tables.Add(table); FeatureDataView view = dataSet.DefaultViewManager.CreateDataView(table); diff --git a/SharpMap.Tests/DataSourceHelper.cs b/SharpMap.Tests/DataSourceHelper.cs index efc8b4e1..b92c806a 100644 --- a/SharpMap.Tests/DataSourceHelper.cs +++ b/SharpMap.Tests/DataSourceHelper.cs @@ -11,7 +11,7 @@ namespace SharpMap.Tests { internal static class DataSourceHelper { - internal static IFeatureLayerProvider CreateGeometryDatasource(IGeometryFactory geoFactory) + internal static IFeatureProvider CreateGeometryDatasource(IGeometryFactory geoFactory) { Collection geoms = new Collection(); geoms.Add(geoFactory.WktReader.Read("POINT EMPTY")); diff --git a/SharpMap.Tests/MapTests.cs b/SharpMap.Tests/MapTests.cs index 9914ad6c..a65f0969 100644 --- a/SharpMap.Tests/MapTests.cs +++ b/SharpMap.Tests/MapTests.cs @@ -28,7 +28,7 @@ public void GetLayerByNameReturnsCorrectLayer() MockRepository mocks = new MockRepository(); Map map = new Map(_geoFactory); - IFeatureLayerProvider dataSource = mocks.Stub(); + IFeatureProvider dataSource = mocks.Stub(); dataSource.GeometryFactory = _geoFactory; map.AddLayer(new GeometryLayer("Layer 1", dataSource)); @@ -45,7 +45,7 @@ public void GetLayerByNameReturnsCorrectLayer() public void DuplicateLayerNamesThrowsException() { Map map = new Map(_geoFactory); - IFeatureLayerProvider dataSource = DataSourceHelper.CreateFeatureDatasource(_geoFactory); + IFeatureProvider dataSource = DataSourceHelper.CreateFeatureDatasource(_geoFactory); map.AddLayer(new GeometryLayer("Layer 1", dataSource)); map.AddLayer(new GeometryLayer("Layer 3", dataSource)); @@ -59,7 +59,7 @@ public void FindLayerByPredicateReturnsMatchingLayers() MockRepository mocks = new MockRepository(); Map map = new Map(_geoFactory); - IFeatureLayerProvider dataSource = mocks.Stub(); + IFeatureProvider dataSource = mocks.Stub(); dataSource.GeometryFactory = _geoFactory; map.AddLayer(new GeometryLayer("Layer 1", dataSource)); diff --git a/SharpMap.Tests/Rendering/BasicGeometryRenderer2DTests.cs b/SharpMap.Tests/Rendering/BasicGeometryRenderer2DTests.cs index defdcd7d..90e3184a 100644 --- a/SharpMap.Tests/Rendering/BasicGeometryRenderer2DTests.cs +++ b/SharpMap.Tests/Rendering/BasicGeometryRenderer2DTests.cs @@ -5,6 +5,7 @@ using NetTopologySuite.Coordinates; using NUnit.Framework; using SharpMap.Data; +using SharpMap.Expressions; using SharpMap.Rendering; using SharpMap.Rendering.Rendering2D; using SharpMap.Styles; @@ -149,13 +150,15 @@ public override IEnumerable RenderSymbols(IEnumerable loc [Ignore("Test not yet implemented")] public void RenderFeatureTest() { - IFeatureLayerProvider provider = DataSourceHelper.CreateGeometryDatasource(_geoFactory); + IFeatureProvider provider = DataSourceHelper.CreateGeometryDatasource(_geoFactory); TestVectorRenderer vectorRenderer = new TestVectorRenderer(); BasicGeometryRenderer2D geometryRenderer = new BasicGeometryRenderer2D(vectorRenderer); FeatureDataTable features = new FeatureDataTable(_geoFactory); - provider.ExecuteIntersectionQuery(provider.GetExtents(), features); + IExtents extents = provider.GetExtents(); + features.Merge(provider.ExecuteIntersectionQuery(extents) as IEnumerable, + provider.GeometryFactory); foreach (FeatureDataRow feature in features) { diff --git a/SharpMap/Data/FeatureMerger.cs b/SharpMap/Data/FeatureMerger.cs index b6c3e3cb..94d962d1 100644 --- a/SharpMap/Data/FeatureMerger.cs +++ b/SharpMap/Data/FeatureMerger.cs @@ -260,7 +260,19 @@ internal void MergeFeatures(IEnumerable sourceFeatures, IGeo internal void MergeSchema(FeatureDataTable source) { - _mergeSchema(_innerMerger, source); + try + { + _mergeSchema(_innerMerger, source); + } + catch (NullReferenceException ex) + { + if (source == null) + throw; + if (source.PrimaryKey.Length > 0 && _targetDataTable.PrimaryKey.Length > 0) + { + throw new DataException("Possible incompatible keys for merging schema", ex); + } + } } internal Boolean PreserveChanges diff --git a/SharpMap/Data/IFeatureLayerProvider.cs b/SharpMap/Data/IFeatureAdapter.cs similarity index 72% rename from SharpMap/Data/IFeatureLayerProvider.cs rename to SharpMap/Data/IFeatureAdapter.cs index 489d45e2..44b531c3 100644 --- a/SharpMap/Data/IFeatureLayerProvider.cs +++ b/SharpMap/Data/IFeatureAdapter.cs @@ -1,5 +1,5 @@ -// Portions copyright 2005 - 2006: Morten Nielsen (www.iter.dk) -// Portions copyright 2006 - 2008: Rory Plaire (codekaizen@gmail.com) +// Portions copyright 2006 - 2008: Rory Plaire (codekaizen@gmail.com) +// Portions copyright 2008: Ron Emmert (justsome.handle@gmail.com) // // This file is part of SharpMap. // SharpMap is free software; you can redistribute it and/or modify @@ -19,17 +19,19 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; using GeoAPI.Geometries; -using System.Globalization; using SharpMap.Expressions; namespace SharpMap.Data { /// - /// Interface for feature data providers. + /// Represents a set of methods and properties used to fill and refresh a FeatureDataTable /// - public interface IFeatureLayerProvider : ILayerProvider + /// + /// Currently a place to dump all the extraneous FeatureDataTable and FeatureDataSet related + /// methods from IFeatureLayerProvider, but we have better uses planned for it. + /// + public interface IFeatureAdapter { /// /// Begins to retrieve the features which match the specified @@ -43,7 +45,7 @@ public interface IFeatureLayerProvider : ILayerProvider /// /// Custom state to pass to the . /// - IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, + IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState); /// @@ -58,7 +60,7 @@ IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, /// /// Custom state to pass to the . /// - IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, + IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, AsyncCallback callback, Object asyncState); /// @@ -73,7 +75,7 @@ IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, /// /// Custom state to pass to the . /// - IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, + IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState); /// @@ -104,7 +106,7 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataS /// /// Custom state to pass to the . /// - IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, + IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, AsyncCallback callback, Object asyncState); /// @@ -125,16 +127,6 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable tab IAsyncResult BeginGetFeatures(IEnumerable oids, AsyncCallback callback, Object asyncState); - /// - /// Creates a new from the data source's - /// schema. - /// - /// - /// A which is configured for the - /// data source's schema. - /// - FeatureDataTable CreateNewTable(); - /// /// Ends a retrieval of the features, waiting on the /// if the operation is not complete. @@ -142,15 +134,6 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable tab void EndExecuteFeatureQuery(IAsyncResult asyncResult); IEnumerable EndGetFeatures(IAsyncResult asyncResult); - - /// - /// Retrieves a for the features that - /// match the given . - /// - /// Spatial query to execute. - /// An IFeatureDataReader to iterate over the results. - IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query); - /// /// Retrieves features into a that /// match the given . @@ -191,40 +174,6 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable tab /// IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry); - /// - /// Retrieves a for the features that - /// are intersected by . - /// - /// to intersect with. - /// An IFeatureDataReader to iterate over the results. - IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds); - - /// - /// Retrieves a for the features that - /// are intersected by . - /// - /// to intersect with. - /// An to iterate over the results. - IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry); - - /// - /// Retrieves a for the features that - /// are intersected by . - /// - /// to intersect with. - /// Options indicating which data to retrieve. - /// An IFeatureDataReader to iterate over the results. - IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds, QueryExecutionOptions options); - - /// - /// Retrieves a for the features that - /// are intersected by . - /// - /// to intersect with. - /// Options indicating which data to retrieve. - /// An to iterate over the results. - IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry, QueryExecutionOptions options); - /// /// Retrieves the data associated with all the features that /// are intersected by . @@ -293,8 +242,6 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable tab /// Options indicating which data to retrieve. void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options); - IGeometryFactory GeometryFactory { get; set; } - /// /// Returns a for obtaining features /// from a set of feature object identifiers (oids). @@ -304,32 +251,5 @@ IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable tab /// A set of features corresponding one-to-one to the given . /// IEnumerable GetFeatures(IEnumerable oids); - - /// - /// Returns the number of features in the entire data source. - /// - /// Count of the features in the entire data source. - Int32 GetFeatureCount(); - - /// - /// Returns a with rows describing the columns in the schema - /// for the configured provider. Provides the same result as - /// . - /// - /// - /// A DataTable that describes the column metadata. - DataTable GetSchemaTable(); - - /// - /// Gets the locale of the data as a CultureInfo. - /// - CultureInfo Locale { get; } - - /// - /// Configures a with the schema - /// present in the IProvider with the given connection. - /// - /// The FeatureDataTable to configure the schema of. - void SetTableSchema(FeatureDataTable table); } } diff --git a/SharpMap/Data/IFeatureProvider.cs b/SharpMap/Data/IFeatureProvider.cs new file mode 100644 index 00000000..a3310d8d --- /dev/null +++ b/SharpMap/Data/IFeatureProvider.cs @@ -0,0 +1,117 @@ +// Portions copyright 2005 - 2006: Morten Nielsen (www.iter.dk) +// Portions copyright 2006 - 2008: Rory Plaire (codekaizen@gmail.com) +// +// This file is part of SharpMap. +// SharpMap is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// SharpMap is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. + +// You should have received a copy of the GNU Lesser General Public License +// along with SharpMap; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using GeoAPI.Geometries; +using System.Globalization; +using SharpMap.Expressions; + +namespace SharpMap.Data +{ + /// + /// Interface for feature data providers. + /// + public interface IFeatureProvider : IProvider + { + + /// + /// Creates a new from the data source's + /// schema. + /// + /// + /// A which is configured for the + /// data source's schema. + /// + FeatureDataTable CreateNewTable(); + + + /// + /// Retrieves a for the features that + /// match the given . + /// + /// Spatial query to execute. + /// An IFeatureDataReader to iterate over the results. + IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query); + + /// + /// Retrieves a for the features that + /// are intersected by . + /// + /// to intersect with. + /// An IFeatureDataReader to iterate over the results. + IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds); + + /// + /// Retrieves a for the features that + /// are intersected by . + /// + /// to intersect with. + /// An to iterate over the results. + IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry); + + /// + /// Retrieves a for the features that + /// are intersected by . + /// + /// to intersect with. + /// Options indicating which data to retrieve. + /// An IFeatureDataReader to iterate over the results. + IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds, QueryExecutionOptions options); + + /// + /// Retrieves a for the features that + /// are intersected by . + /// + /// to intersect with. + /// Options indicating which data to retrieve. + /// An to iterate over the results. + IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry, QueryExecutionOptions options); + + IGeometryFactory GeometryFactory { get; set; } + + /// + /// Returns the number of features in the entire data source. + /// + /// Count of the features in the entire data source. + Int32 GetFeatureCount(); + + /// + /// Returns a with rows describing the columns in the schema + /// for the configured provider. Provides the same result as + /// . + /// + /// + /// A DataTable that describes the column metadata. + DataTable GetSchemaTable(); + + /// + /// Gets the locale of the data as a CultureInfo. + /// + CultureInfo Locale { get; } + + /// + /// Configures a with the schema + /// present in the IProvider with the given connection. + /// + /// The FeatureDataTable to configure the schema of. + void SetTableSchema(FeatureDataTable table); + } +} diff --git a/SharpMap/Data/IFeatureLayerProvider`1.cs b/SharpMap/Data/IFeatureProvider`1.cs similarity index 95% rename from SharpMap/Data/IFeatureLayerProvider`1.cs rename to SharpMap/Data/IFeatureProvider`1.cs index e2b8ab0c..b8dbb3fa 100644 --- a/SharpMap/Data/IFeatureLayerProvider`1.cs +++ b/SharpMap/Data/IFeatureProvider`1.cs @@ -23,7 +23,7 @@ namespace SharpMap.Data /// /// Interface for data providers with features having ID values. /// - public interface IFeatureLayerProvider : IFeatureLayerProvider + public interface IFeatureProvider : IFeatureProvider { /// /// Returns all objects whose diff --git a/SharpMap/Data/ILayerProvider.cs b/SharpMap/Data/IProvider.cs similarity index 95% rename from SharpMap/Data/ILayerProvider.cs rename to SharpMap/Data/IProvider.cs index 43b6f931..5cba40e6 100644 --- a/SharpMap/Data/ILayerProvider.cs +++ b/SharpMap/Data/IProvider.cs @@ -26,7 +26,7 @@ namespace SharpMap.Data /// /// Interface for layer data providers. /// - public interface ILayerProvider : IDisposable + public interface IProvider : IDisposable { /// /// Applies a coordinate transformation to the geometries in diff --git a/SharpMap/Data/IRasterLayerProvider.cs b/SharpMap/Data/IRasterProvider.cs similarity index 94% rename from SharpMap/Data/IRasterLayerProvider.cs rename to SharpMap/Data/IRasterProvider.cs index 090da32a..83a88930 100644 --- a/SharpMap/Data/IRasterLayerProvider.cs +++ b/SharpMap/Data/IRasterProvider.cs @@ -23,7 +23,7 @@ namespace SharpMap.Data /// /// Defines the interface to a provider of raster data. /// - public interface IRasterLayerProvider : ILayerProvider + public interface IRasterProvider : IProvider { /// /// Retrieves a for the raster data that diff --git a/SharpMap/Data/IWritableFeatureLayerProvider.cs b/SharpMap/Data/IWritableFeatureProvider`1.cs similarity index 94% rename from SharpMap/Data/IWritableFeatureLayerProvider.cs rename to SharpMap/Data/IWritableFeatureProvider`1.cs index cfa9e4a0..0efac6d2 100644 --- a/SharpMap/Data/IWritableFeatureLayerProvider.cs +++ b/SharpMap/Data/IWritableFeatureProvider`1.cs @@ -25,7 +25,7 @@ namespace SharpMap.Data /// /// Type of the value used for feature object identifiers. /// - public interface IWritableFeatureLayerProvider : IFeatureLayerProvider + public interface IWritableFeatureProvider : IFeatureProvider { /// /// Inserts a feature into the data source. diff --git a/SharpMap/Data/Providers/FeatureProvider/FeatureProvider.cs b/SharpMap/Data/Providers/FeatureProvider/FeatureProvider.cs index 8e18d497..257d2224 100644 --- a/SharpMap/Data/Providers/FeatureProvider/FeatureProvider.cs +++ b/SharpMap/Data/Providers/FeatureProvider/FeatureProvider.cs @@ -29,7 +29,7 @@ namespace SharpMap.Data.Providers.FeatureProvider /// /// In-memory provider for arbitrary feature data. /// - public class FeatureProvider : IWritableFeatureLayerProvider + public class FeatureProvider : IWritableFeatureProvider { internal readonly static String OidColumnName = "Oid"; private FeatureDataTable _features; @@ -131,40 +131,40 @@ public void SetTableSchema(FeatureDataTable table, SchemaMergeAction schem #region IFeatureLayerProvider Members - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginGetFeatures(System.Collections.IEnumerable oids, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginGetFeatures(System.Collections.IEnumerable oids, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} public FeatureDataTable CreateNewTable() { @@ -173,15 +173,15 @@ public FeatureDataTable CreateNewTable() return table; } - public void EndExecuteFeatureQuery(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public void EndExecuteFeatureQuery(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} - public IEnumerable EndGetFeatures(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public IEnumerable EndGetFeatures(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} /// /// Throws an NotImplementedException. @@ -192,9 +192,19 @@ public IEnumerable EndGetFeatures(IAsyncResult asyncResult) /// An IFeatureDataReader to iterate over the results. /// Always throws this exception. public IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query) - { - throw new NotImplementedException(); - } + { + if (query == null) throw new ArgumentNullException("query"); + + if (query.QueryType != SpatialExpressionType.Intersects) + { + throw new NotImplementedException("Only intersection query currently implemented"); + } + + FeatureDataReader reader = new FeatureDataReader(_geoFactory, _features, + query.QueryRegion.Extents, + QueryExecutionOptions.FullFeature); + return reader; + } /// /// Throws an NotImplementedException. @@ -204,10 +214,10 @@ public IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query) /// Spatial query to execute. /// FeatureDataSet to fill data into. /// Always throws this exception. - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) - { - throw new NotImplementedException(); - } + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) + //{ + // throw new NotImplementedException(); + //} /// /// Retrieves features into a that @@ -215,21 +225,21 @@ public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet d /// /// Spatial query to execute. /// FeatureDataTable to fill data into. - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) - { - if (query.QueryType != SpatialExpressionType.Intersects) - { - throw new NotImplementedException( - "A query type other than SpatialQueryType.Intersects is not supported."); - } - - ExecuteIntersectionQuery(query.QueryRegion.Extents, table); - } - - public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) - { - throw new NotImplementedException(); - } + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) + //{ + // if (query.QueryType != SpatialExpressionType.Intersects) + // { + // throw new NotImplementedException( + // "A query type other than SpatialQueryType.Intersects is not supported."); + // } + + // ExecuteIntersectionQuery(query.QueryRegion.Extents, table); + //} + + //public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) + //{ + // throw new NotImplementedException(); + //} public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry) { @@ -241,25 +251,25 @@ public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry, QueryExec throw new NotImplementedException(); } - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) + //{ + // throw new NotImplementedException(); + //} /// /// Gets the geometries intersecting the specified . @@ -268,10 +278,10 @@ public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, /// /// An enumeration of features within the specified . /// - public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) - { - throw new NotImplementedException(); - } + //public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) + //{ + // throw new NotImplementedException(); + //} /// /// Retrieves a for the features that @@ -303,10 +313,10 @@ public IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds, QueryExecuti /// /// BoundingBox to intersect with. /// FeatureDataSet to fill data into. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) - { - ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.FullFeature); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) + //{ + // ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.FullFeature); + //} /// /// Retrieves the data associated with all the features that @@ -315,10 +325,10 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) /// BoundingBox to intersect with. /// FeatureDataSet to fill data into. /// Options indicating which data to retrieve. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // throw new NotImplementedException(); + //} /// /// Retrieves the data associated with all the features that @@ -326,10 +336,10 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, Qu /// /// BoundingBox to intersect with. /// FeatureDataTable to fill data into. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) - { - ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.FullFeature); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) + //{ + // ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.FullFeature); + //} /// /// Retrieves the data associated with all the features that @@ -338,12 +348,12 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) /// BoundingBox to intersect with. /// FeatureDataTable to fill data into. /// Options indicating which data to retrieve. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) - { - IFeatureDataReader reader = ExecuteIntersectionQuery(bounds, options); + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) + //{ + // IFeatureDataReader reader = ExecuteIntersectionQuery(bounds, options); - table.Load(reader); - } + // table.Load(reader); + //} public IGeometryFactory GeometryFactory { @@ -366,10 +376,10 @@ public Int32 GetFeatureCount() return _features.FeatureCount; } - public IEnumerable GetFeatures(System.Collections.IEnumerable oids) - { - throw new NotImplementedException(); - } + //public IEnumerable GetFeatures(System.Collections.IEnumerable oids) + //{ + // throw new NotImplementedException(); + //} /// /// Returns a with rows describing the columns in the schema diff --git a/SharpMap/Data/Providers/GeometryProvider/GeometryProvider.cs b/SharpMap/Data/Providers/GeometryProvider/GeometryProvider.cs index 449b36fe..ae9db586 100644 --- a/SharpMap/Data/Providers/GeometryProvider/GeometryProvider.cs +++ b/SharpMap/Data/Providers/GeometryProvider/GeometryProvider.cs @@ -60,7 +60,7 @@ namespace SharpMap.Data.Providers.GeometryProvider /// /// /// - public class GeometryProvider : IFeatureLayerProvider + public class GeometryProvider : IFeatureProvider { private IGeometryFactory _geoFactory; private ICoordinateTransformation _coordinateTransformation; @@ -335,55 +335,55 @@ public void Open() #region IFeatureLayerProvider Members - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } - - public IAsyncResult BeginGetFeatures(IEnumerable oids, AsyncCallback callback, Object asyncState) - { - throw new NotImplementedException(); - } + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} + + //public IAsyncResult BeginGetFeatures(IEnumerable oids, AsyncCallback callback, Object asyncState) + //{ + // throw new NotImplementedException(); + //} public FeatureDataTable CreateNewTable() { return null; } - public void EndExecuteFeatureQuery(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public void EndExecuteFeatureQuery(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} - public IEnumerable EndGetFeatures(IAsyncResult asyncResult) - { - throw new NotImplementedException(); - } + //public IEnumerable EndGetFeatures(IAsyncResult asyncResult) + //{ + // throw new NotImplementedException(); + //} /// /// Throws an NotSupportedException. @@ -401,10 +401,10 @@ public IFeatureDataReader ExecuteFeatureQuery(FeatureSpatialExpression query) /// The geometry used to query with. /// FeatureDataTable to fill data into. /// Type of spatial query to execute. - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) - { - throw new NotSupportedException(); - } + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable table) + //{ + // throw new NotSupportedException(); + //} /// /// Throws an NotSupportedException. @@ -412,15 +412,15 @@ public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataTable /// The geometry used to query with. /// FeatureDataSet to fill data into. /// Type of spatial query to execute. - public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) - { - throw new NotSupportedException(); - } + //public void ExecuteFeatureQuery(FeatureSpatialExpression query, FeatureDataSet dataSet) + //{ + // throw new NotSupportedException(); + //} - public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) - { - throw new NotImplementedException(); - } + //public IEnumerable ExecuteGeometryIntersectionQuery(IGeometry geometry) + //{ + // throw new NotImplementedException(); + //} public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry) { @@ -432,25 +432,25 @@ public IFeatureDataReader ExecuteIntersectionQuery(IGeometry geometry, QueryExec throw new NotImplementedException(); } - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table) + //{ + // throw new NotImplementedException(); + //} - public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) - { - throw new NotImplementedException(); - } + //public void ExecuteIntersectionQuery(IGeometry geometry, FeatureDataTable table, QueryExecutionOptions options) + //{ + // throw new NotImplementedException(); + //} /// /// Retrieves a for the features that @@ -481,10 +481,10 @@ public IFeatureDataReader ExecuteIntersectionQuery(IExtents bounds, QueryExecuti /// /// BoundingBox to intersect with. /// FeatureDataSet to fill data into. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) - { - ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.Geometries); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) + //{ + // ExecuteIntersectionQuery(bounds, dataSet, QueryExecutionOptions.Geometries); + //} /// /// Retrieves the data associated with all the features that @@ -493,20 +493,20 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet) /// BoundingBox to intersect with. /// FeatureDataSet to fill data into. /// Options indicating which data to retrieve. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) - { - if (dataSet == null) throw new ArgumentNullException("dataSet"); + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, QueryExecutionOptions options) + //{ + // if (dataSet == null) throw new ArgumentNullException("dataSet"); - FeatureDataTable table = dataSet.Tables[ConnectionId]; + // FeatureDataTable table = dataSet.Tables[ConnectionId]; - if(table == null) - { - table = new FeatureDataTable(ConnectionId, _geoFactory); - dataSet.Tables.Add(table); - } + // if(table == null) + // { + // table = new FeatureDataTable(ConnectionId, _geoFactory); + // dataSet.Tables.Add(table); + // } - ExecuteIntersectionQuery(bounds, table); - } + // ExecuteIntersectionQuery(bounds, table); + //} /// /// Retrieves the data associated with all the features that @@ -514,10 +514,10 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataSet dataSet, Qu /// /// BoundingBox to intersect with. /// FeatureDataTable to fill data into. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) - { - ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.Geometries); - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) + //{ + // ExecuteIntersectionQuery(bounds, table, QueryExecutionOptions.Geometries); + //} /// /// Retrieves the data associated with all the features that @@ -526,60 +526,60 @@ public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table) /// BoundingBox to intersect with. /// FeatureDataTable to fill data into. /// Options indicating which data to retrieve. - public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) - { - if (table == null) throw new ArgumentNullException("table"); - - List intersection = new List(); - - foreach (IGeometry geometry in Geometries) - { - if (bounds.Intersects(geometry.Extents)) - { - intersection.Add(geometry); - } - } - - foreach (FeatureDataRow row in table) - { - if (intersection.Exists(delegate(IGeometry match) { return match.Equals(row.Geometry); })) - { - intersection.Remove(row.Geometry); - } - } - - foreach (IGeometry geometry in intersection) - { - FeatureDataRow row = table.NewRow(); - row.Geometry = geometry; - table.AddRow(row); - } - } + //public void ExecuteIntersectionQuery(IExtents bounds, FeatureDataTable table, QueryExecutionOptions options) + //{ + // if (table == null) throw new ArgumentNullException("table"); + + // List intersection = new List(); + + // foreach (IGeometry geometry in Geometries) + // { + // if (bounds.Intersects(geometry.Extents)) + // { + // intersection.Add(geometry); + // } + // } + + // foreach (FeatureDataRow row in table) + // { + // if (intersection.Exists(delegate(IGeometry match) { return match.Equals(row.Geometry); })) + // { + // intersection.Remove(row.Geometry); + // } + // } + + // foreach (IGeometry geometry in intersection) + // { + // FeatureDataRow row = table.NewRow(); + // row.Geometry = geometry; + // table.AddRow(row); + // } + //} /// /// Returns features within the specified bounding bounds. /// /// The bounding bounds to intersect with. /// An enumeration of all geometries which intersect . - public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) - { - List list = new List(); - - IGeometry boxGeom = bounds.ToGeometry(); - - foreach (IGeometry g in _geometries) - { - if (!g.IsEmpty) - { - if (g.Intersects(boxGeom)) - { - list.Add(g); - } - } - } - - return list.AsReadOnly(); - } + //public IEnumerable ExecuteGeometryIntersectionQuery(IExtents bounds) + //{ + // List list = new List(); + + // IGeometry boxGeom = bounds.ToGeometry(); + + // foreach (IGeometry g in _geometries) + // { + // if (!g.IsEmpty) + // { + // if (g.Intersects(boxGeom)) + // { + // list.Add(g); + // } + // } + // } + + // return list.AsReadOnly(); + //} public IGeometryFactory GeometryFactory { @@ -593,10 +593,10 @@ public IGeometryFactory GeometryFactory } } - public IEnumerable GetFeatures(IEnumerable oids) - { - throw new NotImplementedException(); - } + //public IEnumerable GetFeatures(IEnumerable oids) + //{ + // throw new NotImplementedException(); + //} /// /// Retrieves the number of features accessible with this provider. @@ -679,7 +679,7 @@ public IEnumerable GetFeatures(IEnumerable oids) #endregion #region IFeatureLayerProvider Explicit Members - void IFeatureLayerProvider.SetTableSchema(FeatureDataTable table) + void IFeatureProvider.SetTableSchema(FeatureDataTable table) { table.Clear(); } diff --git a/SharpMap/Layers/FeatureLayer.cs b/SharpMap/Layers/FeatureLayer.cs index 8243fb25..70ec4842 100644 --- a/SharpMap/Layers/FeatureLayer.cs +++ b/SharpMap/Layers/FeatureLayer.cs @@ -45,7 +45,7 @@ public abstract class FeatureLayer : Layer, IFeatureLayer /// which handles /// events from . /// - protected FeatureLayer(IFeatureLayerProvider dataSource) + protected FeatureLayer(IFeatureProvider dataSource) : this(String.Empty, dataSource) { } @@ -56,7 +56,7 @@ protected FeatureLayer(IFeatureLayerProvider dataSource) /// /// Name of the layer. /// Data source. - protected FeatureLayer(String layername, IFeatureLayerProvider dataSource) + protected FeatureLayer(String layername, IFeatureProvider dataSource) : this(layername, new VectorStyle(), dataSource, true) { } @@ -71,7 +71,7 @@ protected FeatureLayer(String layername, IFeatureLayerProvider dataSource) /// events from the /// table. /// - protected FeatureLayer(String layername, IFeatureLayerProvider dataSource, + protected FeatureLayer(String layername, IFeatureProvider dataSource, Boolean handleFeatureDataRequest) : this(layername, new VectorStyle(), dataSource, handleFeatureDataRequest) { @@ -86,7 +86,7 @@ protected FeatureLayer(String layername, IFeatureLayerProvider dataSource, /// Style to apply to the layer. /// Data source. protected FeatureLayer(String layername, VectorStyle style, - IFeatureLayerProvider dataSource) + IFeatureProvider dataSource) : this(layername, style, dataSource, true) {} /// @@ -101,7 +101,7 @@ protected FeatureLayer(String layername, VectorStyle style, /// table. /// protected FeatureLayer(String layername, VectorStyle style, - IFeatureLayerProvider dataSource, + IFeatureProvider dataSource, Boolean handleFeatureDataRequest) : base(layername, style, dataSource) { @@ -141,9 +141,9 @@ protected FeatureLayer(String layername, VectorStyle style, /// Gets the data source for this layer as a more /// strongly-typed IFeatureLayerProvider. /// - public new IFeatureLayerProvider DataSource + public new IFeatureProvider DataSource { - get { return base.DataSource as IFeatureLayerProvider; } + get { return base.DataSource as IFeatureProvider; } } /// @@ -167,12 +167,15 @@ public void LoadFeaturesByOids(IEnumerable oids) { if (!AsyncQuery) { - IEnumerable features = DataSource.GetFeatures(oids); + FeatureSpatialExpression query = new FeatureSpatialExpression(null,SpatialExpressionType.None, oids); + IEnumerable features = DataSource.ExecuteFeatureQuery(query); MergeFeatures(features); } else { - DataSource.BeginGetFeatures(oids, getFeaturesCallback, null); + //DataSource.BeginGetFeatures(oids, getFeaturesCallback, null); + //Async moved; probably to adapter + throw new NotImplementedException("Asynchronous option not implemented"); } } @@ -263,14 +266,17 @@ query as FeatureSpatialExpression if (!AsyncQuery) { - DataSource.ExecuteFeatureQuery(featureQuery, _features); + //DataSource.ExecuteFeatureQuery(featureQuery, _features); + MergeFeatures(DataSource.ExecuteFeatureQuery(featureQuery)); } else { - FeatureDataTable featureCache = new FeatureDataTable(DataSource.GeometryFactory); - DataSource.SetTableSchema(featureCache); - DataSource.BeginExecuteFeatureQuery(featureQuery, featureCache, - queryCallback, featureCache); + // Async implementation moved; probably to adapter + //FeatureDataTable featureCache = new FeatureDataTable(DataSource.GeometryFactory); + //DataSource.SetTableSchema(featureCache); + //DataSource.BeginExecuteFeatureQuery(featureQuery, featureCache, + // queryCallback, featureCache); + throw new NotImplementedException("Asynchronous option not implemented"); } base.LoadLayerData(query); @@ -302,20 +308,24 @@ private void handleFeaturesRequested(Object sender, FeaturesNotFoundEventArgs e) private void queryCallback(IAsyncResult result) { - FeatureDataTable features = result.AsyncState as FeatureDataTable; + // TODO: disabled until asynchronous interface shift completed + //FeatureDataTable features = result.AsyncState as FeatureDataTable; - if (features != null) - { - Features.Merge(features); - } + //if (features != null) + //{ + // Features.Merge(features); + //} - DataSource.EndExecuteFeatureQuery(result); + //DataSource.EndExecuteFeatureQuery(result); + throw new NotImplementedException("Asynchronous option not implemented"); } private void getFeaturesCallback(IAsyncResult result) { - IEnumerable features = DataSource.EndGetFeatures(result); - MergeFeatures(features); + // TODO: disabled until asynchronous interface shift completed + //IEnumerable features = DataSource.EndGetFeatures(result); + //MergeFeatures(features); + throw new NotImplementedException("Asynchronous option not implemented"); } #endregion diff --git a/SharpMap/Layers/GeometryLayer.cs b/SharpMap/Layers/GeometryLayer.cs index 194807dc..a8f44e09 100644 --- a/SharpMap/Layers/GeometryLayer.cs +++ b/SharpMap/Layers/GeometryLayer.cs @@ -38,7 +38,7 @@ public class GeometryLayer : FeatureLayer, ILayer /// /// Initializes a new, empty vector layer. /// - public GeometryLayer(IFeatureLayerProvider dataSource) + public GeometryLayer(IFeatureProvider dataSource) : this(String.Empty, dataSource) { } @@ -48,7 +48,7 @@ public GeometryLayer(IFeatureLayerProvider dataSource) /// /// Name of the layer. /// Data source. - public GeometryLayer(String layername, IFeatureLayerProvider dataSource) + public GeometryLayer(String layername, IFeatureProvider dataSource) : this(layername, new VectorStyle(), dataSource) { } @@ -59,7 +59,7 @@ public GeometryLayer(String layername, IFeatureLayerProvider dataSource) /// Name of the layer. /// Style to apply to the layer. /// Data source. - public GeometryLayer(String layername, VectorStyle style, IFeatureLayerProvider dataSource) + public GeometryLayer(String layername, VectorStyle style, IFeatureProvider dataSource) : base(layername, style, dataSource) { } diff --git a/SharpMap/Layers/IFeatureLayer.cs b/SharpMap/Layers/IFeatureLayer.cs index 42398b85..0a6e19ab 100644 --- a/SharpMap/Layers/IFeatureLayer.cs +++ b/SharpMap/Layers/IFeatureLayer.cs @@ -31,7 +31,7 @@ public interface IFeatureLayer : ILayer /// Gets the data source for this layer as a more /// strongly-typed IFeatureLayerProvider. /// - new IFeatureLayerProvider DataSource { get; } + new IFeatureProvider DataSource { get; } /// /// Gets a of cached features for the layer. diff --git a/SharpMap/Layers/ILayer.cs b/SharpMap/Layers/ILayer.cs index 58fdeacf..d0784be7 100644 --- a/SharpMap/Layers/ILayer.cs +++ b/SharpMap/Layers/ILayer.cs @@ -49,7 +49,7 @@ public interface ILayer : INotifyPropertyChanged, IDisposable /// /// Gets the data source used to create this layer. /// - ILayerProvider DataSource { get; } + IProvider DataSource { get; } /// /// Gets or sets a value representing the visibility of the layer. diff --git a/SharpMap/Layers/IRasterLayer.cs b/SharpMap/Layers/IRasterLayer.cs index d0665d2c..f6aae02f 100644 --- a/SharpMap/Layers/IRasterLayer.cs +++ b/SharpMap/Layers/IRasterLayer.cs @@ -22,6 +22,6 @@ namespace SharpMap.Layers { public interface IRasterLayer : ILayer { - new IRasterLayerProvider DataSource { get; } + new IRasterProvider DataSource { get; } } } \ No newline at end of file diff --git a/SharpMap/Layers/LabelLayer.cs b/SharpMap/Layers/LabelLayer.cs index 90c1f851..b45e6b1f 100644 --- a/SharpMap/Layers/LabelLayer.cs +++ b/SharpMap/Layers/LabelLayer.cs @@ -72,7 +72,7 @@ public class LabelLayer : FeatureLayer /// /// Name of the layer. /// Data source provider for the layer. - public LabelLayer(String layerName, IFeatureLayerProvider dataSource) + public LabelLayer(String layerName, IFeatureProvider dataSource) : base(layerName, dataSource) { _multipartGeometryBehaviour = MultipartGeometryLabelingBehavior.Default; diff --git a/SharpMap/Layers/Layer.cs b/SharpMap/Layers/Layer.cs index 68135de2..e7a4f2bd 100644 --- a/SharpMap/Layers/Layer.cs +++ b/SharpMap/Layers/Layer.cs @@ -124,7 +124,7 @@ public static PropertyDescriptor AreFeaturesSelectableProperty private String _layerName; private IStyle _style; private Boolean _disposed; - private readonly ILayerProvider _dataSource; + private readonly IProvider _dataSource; private Boolean _asyncQuery = false; private Boolean _handleFeaturesNotFoundEvent = true; #endregion @@ -138,7 +138,7 @@ public static PropertyDescriptor AreFeaturesSelectableProperty /// The which provides the data /// for the layer. /// - protected Layer(ILayerProvider dataSource) : + protected Layer(IProvider dataSource) : this(String.Empty, null, dataSource) { } @@ -154,7 +154,7 @@ protected Layer(ILayerProvider dataSource) : /// The which provides the data /// for the layer. /// - protected Layer(String layerName, ILayerProvider dataSource) : + protected Layer(String layerName, IProvider dataSource) : this(layerName, null, dataSource) { } @@ -175,7 +175,7 @@ protected Layer(String layerName, ILayerProvider dataSource) : /// The which provides the data /// for the layer. /// - protected Layer(String layerName, IStyle style, ILayerProvider dataSource) + protected Layer(String layerName, IStyle style, IProvider dataSource) { LayerName = layerName; _dataSource = dataSource; @@ -315,7 +315,7 @@ public virtual ICoordinateTransformation CoordinateTransformation /// /// Gets the data source used to create this layer. /// - public ILayerProvider DataSource + public IProvider DataSource { get { return _dataSource; } } diff --git a/SharpMap/Layers/LayerGroup.cs b/SharpMap/Layers/LayerGroup.cs index f7a05c8d..fd92c666 100644 --- a/SharpMap/Layers/LayerGroup.cs +++ b/SharpMap/Layers/LayerGroup.cs @@ -210,7 +210,7 @@ public ICoordinateTransformation CoordinateTransformation } } - public ILayerProvider DataSource + public IProvider DataSource { get { diff --git a/SharpMap/Layers/RasterLayer.cs b/SharpMap/Layers/RasterLayer.cs index 334cd79f..b4586fab 100644 --- a/SharpMap/Layers/RasterLayer.cs +++ b/SharpMap/Layers/RasterLayer.cs @@ -32,7 +32,7 @@ public class RasterLayer : Layer, IRasterLayer { private IGeometry _loadedRegion = null; - public RasterLayer(ILayerProvider dataSource) + public RasterLayer(IProvider dataSource) : base(dataSource) { } @@ -61,7 +61,7 @@ protected set #region IRasterLayer Members - public new IRasterLayerProvider DataSource + public new IRasterProvider DataSource { get { throw new NotImplementedException(); } } diff --git a/SharpMap/SharpMap.csproj b/SharpMap/SharpMap.csproj index 7d6a2048..5b7bfada 100644 --- a/SharpMap/SharpMap.csproj +++ b/SharpMap/SharpMap.csproj @@ -108,7 +108,8 @@ - + + @@ -116,7 +117,7 @@ - + @@ -145,9 +146,9 @@ Component - - - + + +