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


C# Geometry.AsText方法代码示例

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


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

示例1: QueryFeatures

        public FeatureDataTable QueryFeatures(Geometry geom, double distance)
        {
            //List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
            using (OracleConnection conn = new OracleConnection(_ConnectionString))
            {
                string strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";

                if (SRID > 0)
                {
                    strGeom = strGeom.Replace("#SRID#", SRID.ToString(Map.NumberFormatEnUs));
                }
                else
                {
                    strGeom = strGeom.Replace("#SRID#", "NULL");
                }

                strGeom = "SDO_WITHIN_DISTANCE(g." + GeometryColumn + ", " + strGeom + ", 'distance = " +
                          distance.ToString(Map.NumberFormatEnUs) + "') = 'TRUE'";

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

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

                strSQL += strGeom;

                using (OracleDataAdapter adapter = new OracleDataAdapter(strSQL, conn))
                {
                    DataSet ds = new DataSet();
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.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);
                        }
                        return fdt;
                    }
                    else return null;
                }
            }
        }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:54,代码来源:Oracle.cs

示例2: QueryFeatures

        public FeatureDataTable QueryFeatures(Geometry geom, double distance)
        {
            //List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string strGeom;
                if (TargetSRID > 0 && SRID > 0 && SRID != TargetSRID)
                    strGeom = "ST.Transform(ST.GeomFromText('" + geom.AsText() + "'," + TargetSRID.ToString() + ")," +
                              SRID.ToString() + ")";
                else
                    strGeom = "ST.GeomFromText('" + geom.AsText() + "', " + SRID.ToString() + ")";

                string strSQL = "SELECT " + FeatureColumns + ", ST.AsBinary(" + BuildGeometryExpression() +
                                ") As sharpmap_tempgeometry ";
                strSQL += "FROM ST.IsWithinDistanceQuery" + BuildSpatialQuerySuffix() + "(" + strGeom + ", " +
                          distance.ToString(Map.NumberFormatEnUs) + ")";

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

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

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

示例3: 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(Geometry geom, FeatureDataSet ds)
        {
            List<Geometry> features = new List<Geometry>();
            using (OracleConnection conn = new OracleConnection(_ConnectionString))
            {
                string strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";

                if (SRID > 0)
                {
                    strGeom = strGeom.Replace("#SRID#", SRID.ToString(Map.NumberFormatEnUs));
                }
                else
                {
                    strGeom = strGeom.Replace("#SRID#", "NULL");
                }

                strGeom = "SDO_RELATE(g." + GeometryColumn + ", " + strGeom +
                          ", 'mask=ANYINTERACT querytype=WINDOW') = 'TRUE'";

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

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

                strSQL += strGeom;

                using (OracleDataAdapter adapter = new OracleDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.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,代码行数:57,代码来源:Oracle.cs

示例4: 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(Geometry geom, FeatureDataSet ds)   
       {   
           //List<Geometry> features = new List<Geometry>();   
           using (SqlConnection conn = new SqlConnection(_connectionString))   
           {   
               //TODO: Convert to SQL Server   
               string strGeom = _spatialObject + "::STGeomFromText('" + geom.AsText() + "', #SRID#)";

               strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString() : "0");
               strGeom = GeometryColumn + ".STIntersects(" + strGeom + ") = 1";

               string strSQL = string.Format("SELECT g.* , g.{0}{1}.STAsBinary() As sharpmap_tempgeometry FROM {2} g WHERE ",
                   GeometryColumn, MakeValidString, Table);
 
               if (!String.IsNullOrEmpty(_defintionQuery))   
                   strSQL += DefinitionQuery + " AND ";   
 
               strSQL += strGeom;   
 
               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 && col.ColumnName != "sharpmap_tempgeometry")
                               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 && col.ColumnName != "sharpmap_tempgeometry")
                                   fdr[col.ColumnName] = dr[col];
                           fdr.Geometry = Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
                           fdt.AddRow(fdr);
                       }
                       ds.Tables.Add(fdt);
                   }   
               }   
           }   
       }   
开发者ID:lishxi,项目名称:_SharpMap,代码行数:50,代码来源:SqlServer2008.cs

示例5: QueryFeatures

        public FeatureDataTable QueryFeatures(Geometry geom, double distance)
        {
            //Collection<Geometries.Geometry> features = new Collection<SharpMap.Geometries.Geometry>();
            using (NpgsqlConnection conn = new NpgsqlConnection(_ConnectionString))
            {
                string strGeom = "GeomFromText('" + geom.AsText() + "')";
                if (SRID > 0)
                    strGeom = "setSRID(" + strGeom + "," + SRID + ")";

                string strSQL = "SELECT * , AsBinary(\"" + GeometryColumn + "\") As sharpmap_tempgeometry FROM " +
                                QualifiedTable + " WHERE ";

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

                strSQL += "\"" + GeometryColumn + "\" && " + "buffer(" + strGeom + "," +
                          distance.ToString(Map.NumberFormatEnUs) + ")";
                strSQL += " AND distance(\"" + GeometryColumn + "\", " + strGeom + ")<" +
                          distance.ToString(Map.NumberFormatEnUs);

                using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(strSQL, conn))
                {
                    DataSet ds = new DataSet();
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.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);
                        }
                        return fdt;
                    }
                    else return null;
                }
            }
        }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:47,代码来源:PostGIS.cs

示例6: 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(Geometry geom, FeatureDataSet ds)
        {
            List<Geometry> features = new List<Geometry>();
            using (NpgsqlConnection conn = new NpgsqlConnection(_ConnectionString))
            {
                string strGeom = "GeomFromText('" + geom.AsText() + "')";
                if (SRID > 0)
                    strGeom = "setSRID(" + strGeom + "," + SRID + ")";

                string strSQL = "SELECT * , AsBinary(\"" + GeometryColumn + "\") As sharpmap_tempgeometry FROM " +
                                QualifiedTable + " WHERE ";

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

                strSQL += "\"" + GeometryColumn + "\" && " + strGeom + " AND distance(\"" + GeometryColumn + "\", " +
                          strGeom + ")<0";

            #if DEBUG
                Debug.WriteLine(string.Format("{0}\n{1}", "ExecuteIntersectionQuery: executing sql:", strSQL));
            #endif

                using (NpgsqlDataAdapter adapter = new NpgsqlDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.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,代码行数:52,代码来源:PostGIS.cs

示例7: 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(Geometry geom, FeatureDataSet ds)
        {
            //List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
            using (PgConnection conn = new PgConnection(_ConnectionString))
            {
                string strGeom = "GeomFromText('" + geom.AsText() + "')";
                if (SRID > 0)
                    strGeom = "setSRID(" + strGeom + "," + SRID.ToString() + ")";

                string strSQL = "SELECT * , AsBinary(" + GeometryColumn + ") As sharpmap_tempgeometry FROM " + Table +
                                " WHERE ";

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

                strSQL += GeometryColumn + " && " + strGeom + " AND distance(" + GeometryColumn + ", " + strGeom + ")<0";

                using (PgDataAdapter adapter = new PgDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        FeatureDataTable fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != GeometryColumn && col.ColumnName != "sharpmap_tempgeometry")
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.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:lishxi,项目名称:_SharpMap,代码行数:47,代码来源:PostGIS2.cs

示例8: ExecuteIntersectionQuery

        /// <summary>   
        /// Returns the features that intersects with 'geom'   
        /// </summary>   
        /// <param name="geom"></param>   
        /// <param name="ds">FeatureDataSet to fill data into</param>   
        public override void ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)
        {
            using (SqlConnection conn = new SqlConnection(ConnectionString))
            {
                string strGeom = _spatialObject + "::STGeomFromText('" + geom.AsText() + "', #SRID#)";

                strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString() : "0");
                strGeom = GeometryColumn + ".STIntersects(" + strGeom + ") = 1";

                string strSQL = "SELECT g.* FROM " + Table + " g " + BuildTableHints() + " WHERE ";

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

                strSQL += strGeom;

                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 != GeometryColumn)
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (System.Data.DataRow dr in ds.Tables[0].Rows)
                        {
                            FeatureDataRow fdr = fdt.NewRow();
                            foreach (System.Data.DataColumn col in ds.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:lishxi,项目名称:_SharpMap,代码行数:46,代码来源:SqlServer2008Ex.cs


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