Open() public method

Opens the datasource
public Open ( ) : void
return void
Beispiel #1
0
 public void TestTwoOpenClose()
 {
     ///Simulates two threads using the same provider at the same time..
     var provider = new ShapeFile(TestDataPath, false, true);
     provider.Open();
     provider.Open();
     provider.GetGeometriesInView(GetRandomEnvelope());
     provider.Close();
     provider.GetGeometriesInView(GetRandomEnvelope());
     provider.Close();
 }
        /// <summary>
        /// Open a TileIndex shapefile
        /// 
        /// A tileindex is a shapefile that ties together several datasets into a single layer. Therefore, you don’t need to create separate layers for each piece of imagery or each county’s road data; make a tileindex and let SharpMap piece the mosaic together on the fly.
        /// Making a tileindex is easy using gdaltindex for GDAL data sources (rasters). You just run the tool, specifying the index file to create and the list of data sources to add to the index.
        ///
        /// For example, to make a mosaic of several TIFFs:
        ///
        /// gdaltindex imagery.shp imagery/*.tif

        /// See: http://mapserver.org/optimization/tileindex.html
        /// </summary>
        /// <param name="layerName">Name of the layer</param>
        /// <param name="fileName">Path to the ShapeFile containing tile-indexes</param>
        /// <param name="fieldName">FieldName in the shapefile storing full or relative path-names to the datasets</param>
        public GdalTileIndexRasterLayer(string layerName, string fileName, string fieldName) : base(layerName)
        {
            _fileName = fileName;
            _shapeFile = new ShapeFile(fileName, true);
            _shapeFile.Open();
            _extents = _shapeFile.GetExtents();
            _shapeFile.Close();
            _fieldName = fieldName;
        }
        /// <summary>
        /// Open a TileIndex shapefile
        /// 
        /// A tileindex is a shapefile that ties together several datasets into a single layer. Therefore, you don’t need to create separate layers for each piece of imagery or each county’s road data; make a tileindex and let SharpMap piece the mosaic together on the fly.
        /// Making a tileindex is easy using gdaltindex for GDAL data sources (rasters). You just run the tool, specifying the index file to create and the list of data sources to add to the index.
        ///
        /// For example, to make a mosaic of several TIFFs:
        ///
        /// gdaltindex imagery.shp imagery/*.tif

        /// See: http://mapserver.org/optimization/tileindex.html
        /// </summary>
        /// <param name="layerName">Name of the layer</param>
        /// <param name="fileName">Path to the ShapeFile containing tile-indexes</param>
        /// <param name="fieldName">FieldName in the shapefile storing full or relative path-names to the datasets</param>
        public GdalTileIndexRasterLayer(string layerName, string fileName, string fieldName) : base(layerName)
        {
            _fileName = fileName;
            _shapeFile = new ShapeFile(fileName, true);
            _shapeFile.Open();
            _extents = _shapeFile.GetExtents();
            _shapeFile.Close();
            _fieldName = fieldName;
            _openDatasets = new Dictionary<string, CacheHolder>();
        }
Beispiel #4
0
 public void TestTwoThreadsUsingDifferentProviders()
 {
     var provider1 = new ShapeFile(TestDataPath, false, true);
     var provider2 = new ShapeFile(TestDataPath, false, true);
     provider1.Open();
     provider2.Open();
     provider1.GetGeometriesInView(GetRandomEnvelope());
     provider1.Close();
     provider2.GetGeometriesInView(GetRandomEnvelope());
     provider2.Close();
 }
        public JsonResult GetData(float w, float n, float e, float s, int z)
        {
            string format = String.Format("~/App_Data/berlin/{0}", "osmbuildings.shp");
            string path = this.HttpContext.Server.MapPath(format);
            if (!System.IO.File.Exists(path))
                throw new FileNotFoundException("file not found", path);

            Point start = this.GeoToPixel(n, w, z);
            var meta = new { n, w, s, e, x = start.X, y = start.Y, z };

            Envelope bbox = new Envelope();
            bbox.ExpandToInclude(new Coordinate(n, w));
            bbox.ExpandToInclude(new Coordinate(s, e));

            FeatureDataSet ds = new FeatureDataSet();
            using (ShapeFile provider = new ShapeFile(path))
            {
                provider.DoTrueIntersectionQuery = true;
                provider.Open();
                provider.ExecuteIntersectionQuery(bbox, ds);
                provider.Close();
            }

            int zz = MaxZoom - z;
            List<object> data = new List<object>();
            FeatureDataTable table = ds.Tables[0];
            foreach (FeatureDataRow row in table)
            {
                int c = (short)(row["height"]);
                if (c == 0)
                    c = 5; // default value for "null" (zero) heights
                int h = c * ScaleZ >> zz;
                if (h <= 1)
                    h = 1;

                IGeometry geometry = row.Geometry;
                Coordinate[] coords = geometry.Coordinates;
                int total = coords.Length;
                double[] values = new double[total * 2];
                int i = 0;
                foreach (Coordinate curr in coords)
                {
                    Point p = this.GeoToPixel(curr.X, curr.Y, z);
                    values[i++] = p.X - start.X;
                    values[i++] = p.Y - start.Y;
                }
                data.Add(new object[] { h, values });
            }

            return this.Json(new { meta, data }, JsonRequestBehavior.AllowGet);
        }
        private Collection<IGeometry> GetBorders()
        {
            Collection<IGeometry> stateBorders;
            using (ShapeFile shapefile = new ShapeFile (ShpFileName)) {
                shapefile.Open ();

                // Get extents, assign to svg "viewbox" attribute.
                Envelope bbox = shapefile.GetExtents ();
                stateBorders = shapefile.GetGeometriesInView (bbox);

                shapefile.Close ();
            }
            return stateBorders;
        }
        public Envelope GetExtents()
        {
            if (BBox == null) {

                using (ShapeFile shapefile = new ShapeFile (ShpFileName)) {
                    shapefile.Open ();

                    // Get extents, assign to svg "viewbox" attribute.
                    BBox = shapefile.GetExtents ();
                    shapefile.Close ();
                }
            }
            return BBox;
        }
        /// <summary>
        /// This method returns a FeatureDataTable containing all the rows from the shapefile that intersect the testGeometry.
        /// The ShapeFile.ExecuteIntersectionQuery method only tests bounding boxes so we use the FilterDelegate property to add a true 
        /// intersection test using NetTopologySuite
        /// </summary>
        /// <param name="pathToShapefile">The path to the shapefile</param>
        /// <param name="testGeometry">The geometry that we want to test against</param>
        /// <returns></returns>
        public FeatureDataTable GetIntersectingFeaturesUsingFilterDelegate(string pathToShapefile, Geometry testGeometry)
        {
            //create a new shapefile provider 
            using (ShapeFile shapefile = new ShapeFile(pathToShapefile))
            {
                //create an nts GeometryFactory
                GeometryFactory geometryFactory = new GeometryFactory();

                //convert the testGeometry into the equivalent NTS geometry
                GeoAPI.Geometries.IGeometry testGeometryAsNtsGeom = GeometryConverter.ToNTSGeometry(testGeometry, geometryFactory);

                Geometry check = GeometryConverter.ToSharpMapGeometry(testGeometryAsNtsGeom);
                if (!check.Equals(testGeometry))
                    throw new ApplicationException("conversion error");

                //set the shapefile providers' FilterDelegate property to a new anonymous method
                //this delegate method will be called for each potential row
                shapefile.FilterDelegate = delegate(FeatureDataRow featureDataRow)
                                               {
                                                   //get the geometry from the featureDataRow
                                                   Geometry rowGeometry = featureDataRow.Geometry;
                                                   //convert it to the equivalent NTS geometry
                                                   GeoAPI.Geometries.IGeometry compareGeometryAsNtsGeometry =
                                                           GeometryConverter.ToNTSGeometry(rowGeometry, geometryFactory);
                                                   //do the test. Note that the testGeometryAsNtsGeometry is available here because it is 
                                                   //declared in the same scope as the anonymous method.
                                                   bool intersects =
                                                       testGeometryAsNtsGeom.Intersects(compareGeometryAsNtsGeometry);
                                                   //return the result
                                                   return intersects;
                                               };


                //create a new FeatureDataSet
                FeatureDataSet featureDataSet = new FeatureDataSet();
                //open the shapefile
                shapefile.Open();
                //call ExecuteIntersectionQuery. The FilterDelegate will be used to limit the result set
                shapefile.ExecuteIntersectionQuery(testGeometry, featureDataSet);
                //close the shapefile
                shapefile.Close();
                //return the populated FeatureDataTable
                return featureDataSet.Tables[0];
            }
        }
Beispiel #9
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlgOpen = new OpenFileDialog();

            dlgOpen.Filter = "ESRI Shapefiles (*.shp)|*.shp";
            if (dlgOpen.ShowDialog() == DialogResult.OK)
            {
                //lbAssetFields.Items.Clear();
                lbFieldNames.Items.Clear();
                String strFilePath    = dlgOpen.FileName;
                int    iParseFileName = dlgOpen.FileName.LastIndexOf('\\');
                String strFileName    = dlgOpen.FileName.Substring(iParseFileName + 1);
                m_strShapeFilePath   = strFilePath;
                strFilePath          = strFilePath.Substring(0, iParseFileName + 1);
                tbShapeFilePath.Text = m_strShapeFilePath;

                // Set the DBF database connection string
                m_connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strFilePath + ";Extended Properties=dBASE IV;User ID=Admin;Password=;";

                // Open the shapefile at the given path
                ShapeFile shapefile = null;
                try
                {
                    shapefile = new SharpMap.Data.Providers.ShapeFile(m_strShapeFilePath);
                    shapefile.Open();
                }
                catch (Exception exc)
                {
                    Global.WriteOutput("Error: Couldn't open shapefile." + exc.Message);
                    return;
                }
                FeatureDataRow fdr = shapefile.GetFeature(0);
                lbFieldNames.Items.Add("GEOMETRY");
                m_htShapefileFields.Clear();
                for (int i = 0; i < fdr.Table.Columns.Count; i++)
                {
                    lbFieldNames.Items.Add(fdr.Table.Columns[i].ColumnName.ToUpper());
                    m_htShapefileFields.Add(fdr.Table.Columns[i].ColumnName.ToUpper(), fdr.Table.Columns[i].DataType.ToString());
                }
                shapefile.Close();
            }
        }
Beispiel #10
0
        /// <summary> Event handler for MouseDown event.  </summary>
        /// <param name="sender"> The sender of the MouseDown event. </param>
        /// <param name="e"> The event parameters. </param>
        #region doc:map_MouseDown handler
        private void map_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!(e.ChangedButton == MouseButton.Left && e.ButtonState == MouseButtonState.Pressed))
            {
                return;
            }

            var canvasPoint = e.GetPosition(this);

            System.Windows.Point wgsPoint = CanvasToGeo(canvasPoint);
            var ds = new FeatureDataSet();

            geometries.Clear();
            using (var shpFile = new SharpMap.Data.Providers.ShapeFile(shapeFilePath))
            {
                shpFile.Open();
                shpFile.ExecuteIntersectionQuery(new BoundingBox(wgsPoint.X, wgsPoint.Y, wgsPoint.X, wgsPoint.Y), ds);

                //if selected any object
                if (ds.Tables[0].Rows.Count <= 0)
                {
                    return;
                }

                using (var geomProvider = new GeometryProvider(ds.Tables[0]))
                {
                    geomProvider.Open();
                    foreach (var geoItem in geomProvider.Geometries)
                    {
                        var geometry = WkbToWpf.Parse(geoItem.AsBinary(), GeoToCanvas);
                        if (geometry.FillContains(canvasPoint))
                        {
                            geometries.Add(geometry);
                        }
                    }
                }
            }
        }
Beispiel #11
0
        public void TestShapeFile(SqlServerSpatialObjectType spatialType)
        {
            using (var p = new SharpMap.Data.Providers.ShapeFile(GetTestFile(), true))
            {
                p.Open();

                var env = p.GetExtents();
                if (spatialType == SqlServerSpatialObjectType.Geography && (env.MaxY > 90 || env.MaxY < -90))
                {
                    Assert.Ignore("Test file Y values exceed valid latitudes");
                }

                for (uint i = 0; i < p.GetFeatureCount(); i++)
                {
                    var fdr = p.GetFeature(i);
                    if (fdr.Geometry == null)
                    {
                        continue;
                    }

                    try
                    {
                        fdr.Geometry.SRID = 4326;
                        var res = ToSqlServerAndBack(fdr.Geometry, spatialType);
                        Assert.AreEqual(fdr.Geometry, res);
                        System.Diagnostics.Trace.WriteLine(string.Format("Feature {0} ({1}) converted!", i, fdr[0]));
                    }
                    catch (SqlGeometryConverterException)
                    {
                        System.Diagnostics.Trace.WriteLine(string.Format("Feature {0} ({1}) conversion failed!", i, fdr[0]));
                    }
                    catch (SqlGeographyConverterException)
                    {
                        System.Diagnostics.Trace.WriteLine(string.Format("Feature {0} ({1}) conversion failed!", i, fdr[0]));
                    }
                }
            }
        }
        public void SetupFixture()
        {
            SqlConnectionStringBuilder connStrBuilder = new SqlConnectionStringBuilder(UnitTests.Properties.Settings.Default.SqlServer2008);

            if (string.IsNullOrEmpty(connStrBuilder.DataSource) || string.IsNullOrEmpty(connStrBuilder.InitialCatalog))
            {
                Assert.Ignore("Requires SQL Server connectionstring");
            }

            GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
            //SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

            // Set up sample tables (Geometry + Geography)
            using (SqlConnection conn = new SqlConnection(UnitTests.Properties.Settings.Default.SqlServer2008))
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "CREATE TABLE roads_ugl_geom(ID int identity(1,1) PRIMARY KEY, NAME nvarchar(100), GEOM geometry)";
                    cmd.ExecuteNonQuery();
                }

                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "CREATE TABLE roads_ugl_geog(ID int identity(1,1) PRIMARY KEY, NAME nvarchar(100), GEOG geography)";
                    cmd.ExecuteNonQuery();
                }

                // Load data
                using (SharpMap.Data.Providers.ShapeFile shapeFile = new SharpMap.Data.Providers.ShapeFile(GetTestFile()))
                {
                    shapeFile.Open();
                    _geometrySrid = shapeFile.SRID;

                    IEnumerable <uint> indexes = shapeFile.GetObjectIDsInView(shapeFile.GetExtents());

                    // Note that spatial indexes may only kick in at certain number of records
                    // so for thorough testing comment out next line and load all features (approx 3500)
                    indexes = indexes.Take(100);

                    var cmdGeom = new SqlCommand("INSERT INTO roads_ugl_geom(NAME, GEOM) VALUES (@Name, geometry::STGeomFromText(@Geom, @Srid))", conn);
                    var cmdGeog = new SqlCommand("INSERT INTO roads_ugl_geog(NAME, GEOG) VALUES (@Name, geography::STGeomFromText(@Geog, @Srid))", conn);

                    foreach (uint idx in indexes)
                    {
                        SharpMap.Data.FeatureDataRow feature = shapeFile.GetFeature(idx);

                        string wkt;

                        if (feature.Geometry == null || feature.Geometry.IsEmpty)
                        {
                            wkt = "LINESTRING EMPTY";
                        }
                        else
                        {
                            wkt = feature.Geometry.AsText();
                        }

                        if (cmdGeom.Parameters.Count == 0)
                        {
                            cmdGeom.Parameters.AddWithValue("@Geom", wkt);
                            cmdGeom.Parameters.AddWithValue("@Name", feature["NAME"]);
                            cmdGeom.Parameters.AddWithValue("@Srid", _geometrySrid);
                        }
                        else
                        {
                            cmdGeom.Parameters[0].Value = wkt;
                            cmdGeom.Parameters[1].Value = feature["NAME"];
                        }
                        cmdGeom.ExecuteNonQuery();

                        if (cmdGeog.Parameters.Count == 0)
                        {
                            cmdGeog.Parameters.AddWithValue("@Geog", wkt);
                            cmdGeog.Parameters.AddWithValue("@Name", feature["NAME"]);
                            cmdGeog.Parameters.AddWithValue("@Srid", GeographySrid);
                        }
                        else
                        {
                            cmdGeog.Parameters[0].Value = wkt;
                            cmdGeog.Parameters[1].Value = feature["NAME"];
                        }
                        cmdGeog.ExecuteNonQuery();
                    }

                    cmdGeom.Dispose();
                    cmdGeog.Dispose();
                }

                // ensure we have some features with NULL and EMPTY geometries
                using (var cmd = conn.CreateCommand())
                {
                    // To find invalid geometries:
                    // SELECT {OidColumn}, {GeometryColumn}.STIsValid() AS STIsValid, {GeometryColumn}.IsValidDetailed() AS IsValidDetailed FROM {QualifiedTableName}

                    // NULL
                    cmd.CommandText = "INSERT INTO roads_ugl_geom(NAME, GEOM) VALUES ('Test null wkt', NULL)";
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = "INSERT INTO roads_ugl_geog(NAME, GEOG) VALUES ('Test null wkt', NULL)";
                    cmd.ExecuteNonQuery();

                    // EMPTY
                    cmd.CommandText = "INSERT INTO roads_ugl_geom(NAME, GEOM) VALUES ('Test empty wkt', 'LINESTRING EMPTY')";
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = "INSERT INTO roads_ugl_geog(NAME, GEOG) VALUES ('Test empty wkt', 'LINESTRING EMPTY')";
                    cmd.ExecuteNonQuery();

                    // INVALID (ID 144 from shape file; see also ID 2055)
                    cmd.CommandText = $"INSERT INTO roads_ugl_geom(NAME, GEOM) VALUES ('Test invalid wkt', geometry::STGeomFromText('LINESTRING (-84.652756071629071 42.676743004284312, -84.652924071615374 42.676624004283632, -84.652756071629071 42.676743004284312, -84.652512071649028 42.676922004285323, -84.641022072594438 42.685478004332808, -84.638779072781034 42.687271004342172, -84.636932072941363 42.689831004350026, -84.634491073153043 42.693100004360424, -84.62387107404335 42.701092004405112, -84.603256075794022 42.715752004493233, -84.603142075803831 42.715832004493734, -84.599823076091937 42.718651004508146, -84.588676077031693 42.722431004556235, -84.586021077270672 42.725533004568049)', {_geometrySrid}))";
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = $"INSERT INTO roads_ugl_geog(NAME, GEOG) VALUES ('Test invalid wkt', geography::STGeomFromText('LINESTRING (-84.652756071629071 42.676743004284312, -84.652924071615374 42.676624004283632, -84.652756071629071 42.676743004284312, -84.652512071649028 42.676922004285323, -84.641022072594438 42.685478004332808, -84.638779072781034 42.687271004342172, -84.636932072941363 42.689831004350026, -84.634491073153043 42.693100004360424, -84.62387107404335 42.701092004405112, -84.603256075794022 42.715752004493233, -84.603142075803831 42.715832004493734, -84.599823076091937 42.718651004508146, -84.588676077031693 42.722431004556235, -84.586021077270672 42.725533004568049)', {GeographySrid}))";
                    cmd.ExecuteNonQuery();
                }

                // Create GEOM spatial index
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText    = $"CREATE SPATIAL INDEX [{GeometrySpatialIndex}] ON [dbo].[roads_ugl_geom](GEOM) USING GEOMETRY_GRID WITH (BOUNDING_BOX =(-98, 40, -82, 50), GRIDS =(LEVEL_1 = MEDIUM,LEVEL_2 = MEDIUM,LEVEL_3 = MEDIUM,LEVEL_4 = MEDIUM))";
                    cmd.CommandTimeout = 300;
                    cmd.ExecuteNonQuery();
                }

                // Create GEOG spatial index
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText    = $"CREATE SPATIAL INDEX [{GeographySpatialIndex}] ON [dbo].[roads_ugl_geog](GEOG)";
                    cmd.CommandTimeout = 300;
                    cmd.ExecuteNonQuery();
                }

                // initialise counts and test IDs
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = $"SELECT COUNT(ID) FROM roads_ugl_geom WHERE Geom.STIsEmpty() = 0 AND Geom.STIsValid() = 1";
                    _numValidGeoms  = (int)cmd.ExecuteScalar();

                    cmd.CommandText  = $"SELECT COUNT(ID) FROM roads_ugl_geom WHERE GEOM IS NOT NULL AND Geom.STIsEmpty() = 0 AND Geom.STIsValid() = 0";
                    _numInvalidGeoms = (int)cmd.ExecuteScalar();

                    _numValidatedGeoms = _numValidGeoms + _numInvalidGeoms;

                    cmd.CommandText = $"SELECT COUNT(ID) FROM roads_ugl_geom";
                    _numFeatures    = (int)cmd.ExecuteScalar();

                    _idNullGeom    = (uint)(_numFeatures - 2);
                    _idEmptyGeom   = (uint)(_numFeatures - 1);
                    _idInvalidGeom = (uint)(_numFeatures);
                }
            }
        }
Beispiel #13
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            MogreApp.setLocations(prj.getMogreLocations());
            SetupMogre();
            Mogre.SceneManager sm = app.SceneManager;

            foreach (MogreGis.FilterGraph graph in prj.getFilterGraphs())
            {

                foreach (osgGISProjects.Source source in prj.getSources())
                {
                    if (Path.GetExtension(source.getURI()) != ".shp")
                    {
                        throw new NotImplementedException();
                    }

                    if (source.getName() == graph.getName())
                    {
                        MogreGis.FilterEnv env = null;
                        MogreGis.FeatureList featureList = null;

                        FeatureDataSet ds = new FeatureDataSet();
                        source.DataSource.Open();
                        source.DataSource.ExecuteIntersectionQuery(source.DataSource.GetExtents(), ds);
                        source.DataSource.Close();
                        FeatureDataTable features = (FeatureDataTable)ds.Tables[0];
                        featureList = MogreGis.Feature.DataTableToList(features);

                        foreach (Script script in prj.getScripts())
                        {
                            Registry.instance().GetEngine("Python").run(script);
                        }

                        foreach (Feature feature in featureList)
                        {
                            SharpMapSpatialReferenceFactory smsrf = new SharpMapSpatialReferenceFactory();
                            ShapeFile shp = new ShapeFile(source.getURI());
                            shp.Open();
                            SharpMapSpatialReference sr;
                            sr = (SharpMapSpatialReference)smsrf.createSRSfromWKT(shp.CoordinateSystem.WKT);
                            feature.getGeometry().SpatialReference = sr;
                        }

                        env = new MogreGis.FilterEnv(sm, "env" + graph.getName());
                        env.setScriptEngine(Registry.instance().GetEngine("Python"));
                        foreach (MogreGis.Filter filter in graph.getFilters())
                        {
                            if (filter is MogreGis.FragmentFilter)
                            {
                                (filter as MogreGis.FragmentFilter).process(featureList, env);
                            }
                            if (filter is MogreGis.FeatureFilter)
                            {
                                featureList = (filter as MogreGis.FeatureFilter).process(featureList, env);
                            }
                        }
                    }
                }
            }
            app.getRoot().StartRendering();
        }
        public FeatureDataTable GetFeatureTableFromShapefile(string shapeFilePath)
        {
            GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();
            int cd;
            if (!int.TryParse(_enconding.Text, out cd))
            {
                _status.Text = "Bad code page";
            }

            ShapeFile sf = new ShapeFile(shapeFilePath);
            sf.Encoding = Encoding.GetEncoding(int.Parse(_enconding.Text));
            sf.Open();
            Envelope ext = sf.GetExtents();
            FeatureDataSet ds = new FeatureDataSet();
            sf.ExecuteIntersectionQuery(ext, ds);
            //ds.Tables[0].Columns.Remove("Oid");
            return ds.Tables[0];
        }