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


C# FeatureDataSet类代码示例

本文整理汇总了C#中FeatureDataSet的典型用法代码示例。如果您正苦于以下问题:C# FeatureDataSet类的具体用法?C# FeatureDataSet怎么用?C# FeatureDataSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: GetData

        /// <summary>
        /// Method to convert a <see cref="T:SharpMap.Data.FeatureDataSet"/> to a series of <see cref="GeoJSON"/> objects
        /// </summary>
        /// <param name="data">The feature dataset</param>
        /// <returns>A series of <see cref="GeoJSON"/> objects</returns>
        public static IEnumerable<GeoJSON> GetData(FeatureDataSet data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            using (data)
            {
                foreach (FeatureDataTable table in data.Tables)
                {
                    var columns = table.Columns;
                    var keys = new string[columns.Count];
                    for (var i = 0; i < columns.Count; i++)
                        keys[i] = columns[i].ColumnName;

                    var rows = table.Rows;
                    for (int i = 0; i < rows.Count; i++)
                    {
                        var row = (FeatureDataRow)rows[i];
                        var geometry = row.Geometry;
                        var values = new Dictionary<string, object>();
                        for (var j = 0; j < keys.Length; j++)
                            values.Add(keys[j], row[j]);
                        yield return new GeoJSON(geometry, values);
                    }
                }
            }
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:32,代码来源:GeoJSONHelper.cs

示例2: OnExecuteIntersectionQuery

        /// <summary>
        /// Method to perform the intersection query against the data source
        /// </summary>
        /// <param name="geom">The geometry to use as filter</param>
        /// <param name="ds">The feature data set to store the results in</param>
        protected override void OnExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
        {
            ExecuteIntersectionQuery(geom.EnvelopeInternal, ds);

            //index of last added feature data table
            var index = ds.Tables.Count - 1;
            if (index < 0) return;

            var res = CloneTableStructure(ds.Tables[index]);
            res.BeginLoadData();

            var fdt = ds.Tables[index];
            foreach (FeatureDataRow row in fdt.Rows)
            {
                if (PreparedGeometry.Intersects(row.Geometry))
                {
                    var fdr = (FeatureDataRow)res.LoadDataRow(row.ItemArray, true);
                    fdr.Geometry = row.Geometry;
                }
            }

            res.EndLoadData();

            ds.Tables.RemoveAt(index);
            ds.Tables.Add(res);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:31,代码来源:PreparedGeometryProvider.cs

示例3: ExecuteIntersectionQuery

        public override void ExecuteIntersectionQuery(BoundingBox box, FeatureDataSet ds)
        {
            var table = CreateTable();
            table.BeginLoadData();

            foreach (var kvp in Matrix)
            {
                var id = kvp.Key;
                if (box.Intersects(kvp.Value.EnvelopeInternal))
                {
                    var val = Matrix[kvp.Key, MatrixVector];
                    if (!Valid(val))
                        continue;

                    var row =
                        (FeatureDataRow)
                        table.LoadDataRow(new object[] { id, val }, LoadOption.Upsert);

                    var sval = Scale(val);
                    row.Geometry = CreateCircle(kvp.Value, sval);
                }
            }
            table.EndLoadData();

            ds.Tables.Add(table);
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:26,代码来源:MatrixODSumProvider.cs

示例4: TestMap

        public void TestMap()
        {
            var m = new Map(new Size(1024, 786)) {BackColor = Color.FloralWhite};
            const string samplePath = @"D:\GIS\FileGDB\samples\data\Topo.gdb";

            var p = new FileGdbProvider(samplePath);

            foreach (var fc in p.GetFeatureClasses("\\USA"))
            {
                if (fc.StartsWith("\\USA\\T"))
                    continue;

                Console.WriteLine(fc);
                var pUse = new FileGdbProvider(samplePath) { Table = fc };
                var vl = new VectorLayer("Layer:" + fc, pUse)
                             {
                                 SmoothingMode = SmoothingMode.HighQuality,
                                 Style = {Fill = RandomBrush(), Line = RandomPen()}
                             };
                m.Layers.Add(vl);

                var fds = new FeatureDataSet();
                vl.ExecuteIntersectionQuery(vl.Envelope, fds);
                fds.Tables[0].TableName = fc;
                var res = fds.Tables[0].Rows[0].ItemArray;
                foreach (DataColumn col in fds.Tables[0].Columns)
                    Console.Write(string.Format("{0} [{1}], ", col.ColumnName, col.DataType));
                Console.WriteLine();

                foreach (var item in res)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));
                Console.WriteLine();

                Console.WriteLine(pUse.GetGeometryByID(1));

                var r = pUse.GetFeature(1);
                foreach (var item in r.ItemArray)
                    Console.Write(string.Format(CultureInfo.InvariantCulture, "{0}, ", item));

                Console.WriteLine();
                Console.WriteLine();
            }
            Console.WriteLine();

            p.Dispose();

            m.ZoomToExtents();
            var b = m.GetMap();
            b.Save("fgdb-usa-states.bmp");

            //var fds = new FeatureDataSet();
            //lc.ExecuteIntersectionQuery(m.GetExtents().GetCentroid(), fds);
            //fds.Tables[0].TableName = lc.LayerName;
            //fds.Tables[0].WriteXml(Console.Out);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:55,代码来源:FileGdbProviderTest.cs

示例5: DataSetToFeatures

        public static IEnumerable<IFeature> DataSetToFeatures(FeatureDataSet dataSet)
        {
            var features = new Features();

            foreach (FeatureDataTable table in dataSet.Tables)
            {
                foreach (FeatureDataRow row in table)
                {
                    IFeature feature = features.New();
                    feature.Geometry = row.Geometry;
                    foreach (DataColumn column in table.Columns)
                        feature[column.ColumnName] = row[column.ColumnName];

                    features.Add(feature);
                }
            }
            return features;
        }
开发者ID:jdeksup,项目名称:Mapsui.Net4,代码行数:18,代码来源:Utilities.cs

示例6: ExecuteIntersectionQuery

        /// <summary>   
        /// Returns all features with the view box   
        /// </summary>   
        /// <param name="bbox">view box</param>   
        /// <param name="ds">FeatureDataSet to fill data into</param>   
        public override void ExecuteIntersectionQuery(BoundingBox bbox, FeatureDataSet ds)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                //Get bounding box string
                string strBbox = GetBoxFilterStr(bbox);

                string strSQL = String.Format(
                    "SELECT g.* FROM {0} g {1} WHERE ",
                    Table, BuildTableHints());

                if (!String.IsNullOrEmpty(DefinitionQuery))
                    strSQL += DefinitionQuery + " AND ";

                strSQL += strBbox;

                using (SqlDataAdapter adapter = new SqlDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    System.Data.DataSet ds2 = new System.Data.DataSet();
                    adapter.Fill(ds2);
                    conn.Close();
                    if (ds2.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds2.Tables[0]);
                        foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn)
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (System.Data.DataRow dr in ds2.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                                if (col.ColumnName != GeometryColumn)
                                    fdr[col.ColumnName] = dr[col];
                            fdr.Geometry = SqlGeometryConverter.ToSharpMapGeometry((Microsoft.SqlServer.Types.SqlGeometry)dr[GeometryColumn]);
                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:47,代码来源:SqlServer2008Ex.cs

示例7: ExecuteIntersectionQuery

        public override void ExecuteIntersectionQuery(Envelope bbox, FeatureDataSet ds)
        {
            var fdt = CreateTable();
            fdt.BeginLoadData();

            foreach (var relation in Matrix.Relations(RestrictId))
            {
                var origin = relation.Key;
                var destin = relation.Value;

                var box = origin.Value.EnvelopeInternal;
                box.ExpandToInclude(destin.Value.EnvelopeInternal);
                if (!bbox.Intersects(box))
                    continue;

                var val = Matrix[origin.Key, destin.Key];
                if (!Valid(val)) continue;

                var fdr = (FeatureDataRow)fdt.LoadDataRow(new object[] { CreateOid(origin.Key, destin.Key), val }, true);

                var sval = Scale(val);
                if (origin.Key == destin.Key)
                {
                    fdr.Geometry = CreateCircle(origin.Value, sval);
                }
                else
                {
                    fdr.Geometry = CreateLoad(origin.Value, destin.Value, sval);
                    val = Matrix[destin.Key, origin.Key];
                    if (Valid(val))
                    {
                        sval = Scale(val);
                        fdr = (FeatureDataRow)fdt.LoadDataRow(new object[] { CreateOid(destin.Key, origin.Key), val }, true);
                        fdr.Geometry = CreateLoad(destin.Value, origin.Value, sval);
                    }
                }
            }

            fdt.EndLoadData();
            ds.Tables.Add(fdt);
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:41,代码来源:MatrixRelationProvider.cs

示例8: ExecuteIntersectionQuery

        /// <summary>
        /// Returns the data associated with all the geometries that are intersected by 'geom'.
        /// </summary>
        /// <param name="geom">The geometry.</param>
        /// <param name="ds">The <see cref="FeatureDataSet"/> to fill data into.</param>
        public override void ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)
        {
            //Use the spatial index to get a list of features whose boundingbox intersects bbox
            var objectlist = GetObjectIDsInView(geom.GetBoundingBox());
			if (objectlist.Count == 0)
                return;

            var dt = DbaseFile.NewTable;
            var preparedGeometry = new NetTopologySuite.Geometries.Prepared.PreparedGeometryFactory()
                .Create(Converters.NTS.GeometryConverter.ToNTSGeometry(geom, _factory));
			for (int i = 0; i < objectlist.Count; i++)
			{
			    var testGeom = GetGeometryByID(objectlist[i]);
			    var testNtsGeom = Converters.NTS.GeometryConverter.ToNTSGeometry(testGeom, _factory);
                if (preparedGeometry.Intersects(testNtsGeom))
                {
                    var fdr = GetFeature(objectlist[i], dt);
                    if (fdr != null) dt.AddRow(fdr);
                }
			}

            if (dt.Rows.Count > 0)
                ds.Tables.Add(dt);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:29,代码来源:ShapeFileEx.cs

示例9: ExecuteIntersectionQuery

        /// <summary>
        /// Returns all features with the view box
        /// </summary>
        /// <param name="bbox">view box</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(SharpMap.Geometries.BoundingBox bbox, FeatureDataSet ds)
        {
            List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
            using (System.Data.OleDb.OleDbConnection conn = new OleDbConnection(_ConnectionString))
            {
                string strSQL = "Select * FROM " + this.Table + " WHERE ";
                if (_defintionQuery != null && _defintionQuery != "") //If a definition query has been specified, add this as a filter on the query
                    strSQL += _defintionQuery + " AND ";
                //Limit to the points within the boundingbox
                strSQL += this.XColumn + " BETWEEN " + bbox.Left.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.Right.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + this.YColumn +
                    " BETWEEN " + bbox.Bottom.ToString(SharpMap.Map.numberFormat_EnUS) + " AND " + bbox.Top.ToString(SharpMap.Map.numberFormat_EnUS);

                using (System.Data.OleDb.OleDbDataAdapter adapter = new OleDbDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    System.Data.DataSet ds2 = new System.Data.DataSet();
                    adapter.Fill(ds2);
                    conn.Close();
                    if (ds2.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds2.Tables[0]);
                        foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                            fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (System.Data.DataRow dr in ds2.Tables[0].Rows)
                        {
                            SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
                            foreach (System.Data.DataColumn col in ds2.Tables[0].Columns)
                                fdr[col.ColumnName] = dr[col];
                            if (dr[this.XColumn] != DBNull.Value && dr[this.YColumn] != DBNull.Value)
                                fdr.Geometry = new SharpMap.Geometries.Point((double)dr[this.XColumn], (double)dr[this.YColumn]);
                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:stophun,项目名称:fdotoolbox,代码行数:42,代码来源:OleDbPoint.cs

示例10: ExecuteIntersectionQuery

		/// <summary>
		/// Returns the features that intersects with 'geom'
		/// </summary>
		/// <param name="geom"></param>
		/// <param name="ds">FeatureDataSet to fill data into</param>
		public void ExecuteIntersectionQuery(SharpMap.Geometries.Geometry geom, FeatureDataSet ds)
		{
			List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
			using (SqlConnection conn = new SqlConnection(this.ConnectionString))
			{
				string strGeom;
				if (this.TargetSRID > 0 && this.SRID > 0 && this.SRID != this.TargetSRID)
					strGeom = "ST.Transform(ST.GeomFromText('" + geom.AsText() + "'," + this.TargetSRID.ToString() + ")," + this.SRID.ToString() + ")";
				else
					strGeom = "ST.GeomFromText('" + geom.AsText() + "', " + this.SRID.ToString() + ")";

				string strSQL = "SELECT " + this.FeatureColumns + ", ST.AsBinary(" + this.BuildGeometryExpression() + ") As sharpmap_tempgeometry ";
				strSQL += "FROM ST.RelateQuery" + this.BuildSpatialQuerySuffix() + "(" + strGeom + ", 'intersects')";

				if (!String.IsNullOrEmpty(this.DefinitionQuery))
					strSQL += " WHERE " + this.DefinitionQuery;

				if (!String.IsNullOrEmpty(this.OrderQuery))
					strSQL += " ORDER BY " + this.OrderQuery;

				using (SqlDataAdapter adapter = new SqlDataAdapter(strSQL, conn))
				{
					conn.Open();
					adapter.Fill(ds);
					conn.Close();
					if (ds.Tables.Count > 0)
					{
						FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
						foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
							if (col.ColumnName != this.GeometryColumn && !col.ColumnName.StartsWith(this.GeometryColumn + "_Envelope_") && col.ColumnName != "sharpmap_tempgeometry")
								fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
						foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
						{
							SharpMap.Data.FeatureDataRow fdr = fdt.NewRow();
							foreach (System.Data.DataColumn col in ds.Tables[0].Columns)
								if (col.ColumnName != this.GeometryColumn && !col.ColumnName.StartsWith(this.GeometryColumn + "_Envelope_") && col.ColumnName != "sharpmap_tempgeometry")
									fdr[col.ColumnName] = dr[col];
							if (dr["sharpmap_tempgeometry"] != DBNull.Value)
								fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
							fdt.AddRow(fdr);
						}
						ds.Tables.Add(fdt);
					}
				}
			}
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:51,代码来源:MsSqlSpatial.cs

示例11: GetFeaturesInView

 public void GetFeaturesInView(BoundingBox bbox, FeatureDataSet ds)
 {
     ExecuteIntersectionQuery(bbox, ds);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:4,代码来源:MsSqlSpatial.cs

示例12: ExecuteIntersectionQuery

        /// <summary>
        /// Returns all features with the view box
        /// </summary>
        /// <param name="bbox">view box</param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        public void ExecuteIntersectionQuery(BoundingBox bbox, FeatureDataSet ds)
        {
            List<Geometry> features = new List<Geometry>();
            using (OracleConnection conn = new OracleConnection(_ConnectionString))
            {
                //Get bounding box string
                string strBbox = GetBoxFilterStr(bbox);

                string strSQL = "SELECT g.*, g." + GeometryColumn + ".Get_WKB() AS sharpmap_tempgeometry ";
                strSQL += "FROM " + Table + " g WHERE ";

                if (!String.IsNullOrEmpty(_defintionQuery))
                    strSQL += DefinitionQuery + " AND ";

                strSQL += strBbox;

                using (OracleDataAdapter adapter = new OracleDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    DataSet ds2 = new DataSet();
                    adapter.Fill(ds2);
                    conn.Close();
                    if (ds2.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds2.Tables[0]);
                        foreach (DataColumn col in ds2.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds2.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds2.Tables[0].Columns)
                                if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                    fdr[col.ColumnName] = dr[col];
                            fdr.Geometry = GeometryFromWKB.Parse((byte[]) dr["sharpmap_tempgeometry"]);
                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:47,代码来源:Oracle.cs

示例13: GetFeaturesInView

 public void GetFeaturesInView(BoundingBox bbox, FeatureDataSet ds)
 {
     GetFeaturesInView(bbox, ds);
 }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:4,代码来源:Oracle.cs

示例14: ExecuteIntersectionQuery

        public override void ExecuteIntersectionQuery(Envelope box, FeatureDataSet ds)
        {
            GetNonSpatialColumns();
            using (var conn = GetConnection(ConnectionString))
            {
                var strSql = "SELECT " + _columns + ", \"" + GeometryColumn + "\" AS \"_smtmp_\" ";
                strSql += "FROM " + Table + " WHERE ";

                // Attribute constraint
                if (!String.IsNullOrEmpty(_definitionQuery))
                    strSql += DefinitionQuery + " AND ";
                
                // Spatial constraint
                strSql += GetBoxClause(box);

                using (var cmd = new SQLiteCommand(strSql, conn))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        var geomIndex = reader.FieldCount - 1;
                        var fdt = CreateTableFromReader(reader, geomIndex);

                        var dataTransfer = new object[geomIndex];
                        var geoReader = new GaiaGeoReader(Factory.CoordinateSequenceFactory, Factory.PrecisionModel,
                                                          _ordinates);
                        fdt.BeginLoadData();
                        while (reader.Read())
                        {
                            IGeometry g = null;
                            if (!reader.IsDBNull(geomIndex))
                                g = geoReader.Read((byte[])reader.GetValue(geomIndex));

                            //No geometry, no feature!
                            if (g == null)
                                continue;

                            //If not using RTree index we need to filter in code
                            if (_spatiaLiteIndex != SpatiaLiteIndex.RTree && !box.Intersects(g.EnvelopeInternal))
                                continue;

                            //Get all the attribute data
                            var count = reader.GetValues(dataTransfer);
                            System.Diagnostics.Debug.Assert(count == dataTransfer.Length);

                            var fdr = (FeatureDataRow)fdt.LoadDataRow(dataTransfer, true);
                            fdr.Geometry = g;
                        }
                        reader.Close();
                        fdt.EndLoadData();
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:54,代码来源:ManagedSpatiaLite.cs

示例15: ExecuteIntersectionQuery

        /// <summary>
        /// 
        /// </summary>
        /// <param name="box"></param>
        /// <param name="ds"></param>
		public void ExecuteIntersectionQuery(SharpMap.Geometries.BoundingBox box, FeatureDataSet ds)
		{
			// Identifies all the features within the given BoundingBox
			GisSharpBlog.NetTopologySuite.Geometries.Envelope envelope = GeometryConverter.ToNTSEnvelope(box);
			List<GisSharpBlog.NetTopologySuite.Features.Feature> results = new List<GisSharpBlog.NetTopologySuite.Features.Feature>(features.Count);
			foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in features)
				if (envelope.Intersects(feature.Geometry.EnvelopeInternal))
					results.Add(feature);

			// Fill DataSet
			SharpMap.Data.FeatureDataTable dataTable = CreateFeatureDataTable();
			foreach (GisSharpBlog.NetTopologySuite.Features.Feature feature in results)
				CreateNewRow(dataTable, feature);
			ds.Tables.Add(dataTable);
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:20,代码来源:NtsProvider.cs


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