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


C# IGeometry.AsText方法代码示例

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


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

示例1: Write

        protected override byte[] Write(IGeometry gIn)
        {
            var geoWriter = new MsSql2008GeometryWriter();
            var b = geoWriter.WriteGeometry(gIn);
            var b2 = geoWriter.Write(gIn);
            using( var conn = new SqlConnection(ConnectionString))
            {
                conn.Open();
                using (var cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO [nts_io_geometry] VALUES(@P1, @P2, @P3);";
                    var p1 = new SqlParameter("P1", SqlDbType.Int) { SqlValue = Counter };
                    var p2 = new SqlParameter("P2", SqlDbType.Text) { SqlValue = gIn.AsText() };
                    var p3 = new SqlParameter("P3", SqlDbType.Udt) { UdtTypeName = "geometry", SqlValue = b };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();

                    /*
                    p1.SqlValue = 100000 + Counter;
                    cmd.Parameters.Remove(p3);
                    p3 = new SqlParameter("P3", SqlDbType.Image) { SqlValue = b };
                    cmd.Parameters.Add(p3);
                    p3.SqlValue = b2;
                    cmd.ExecuteNonQuery();
                     */
                }

            }
            return b2;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:30,代码来源:SqlGeometryFixture.cs

示例2: TestValid

 private static void TestValid(IGeometry geom)
 {
     if (!geom.IsValid)
     {
         var ivop = new NetTopologySuite.Operation.Valid.IsValidOp(geom);
         if (!ivop.IsValid)
         {
             Console.WriteLine(geom.AsText());
             Console.Write(ivop.ValidationError);
         }
         Assert.True(false);
     }
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:13,代码来源:WKTTest.cs

示例3: Write

        protected override byte[] Write(IGeometry gIn)
        {
            PostGisWriter pgWriter = new PostGisWriter();
            byte[] b = pgWriter.Write(gIn);
            using (NpgsqlConnection cn = new NpgsqlConnection(this.ConnectionString))
            {
                cn.Open();
                using (NpgsqlCommand cmd = cn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO \"nts_io_postgis_2d\" VALUES(@P1, @P2, @P3);";
                    NpgsqlParameter p1 = new NpgsqlParameter("P1", NpgsqlDbType.Integer) {NpgsqlValue = this.Counter};
                    NpgsqlParameter p2 = new NpgsqlParameter("P2", NpgsqlDbType.Text) { NpgsqlValue = gIn.AsText() };
                    NpgsqlParameter p3 = new NpgsqlParameter("P3", NpgsqlDbType.Bytea) { NpgsqlValue = b };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();
                }
            }

            return b;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:20,代码来源:PostgisFixture.cs

示例4: CheckEquality

        protected override void CheckEquality(IGeometry gIn, IGeometry gParsed, WKTWriter writer)
        {
            var res = gIn.EqualsExact(gParsed);
            if (res) return;

            if (Compressed)
            {
                var discreteHausdorffDistance =
                    Algorithm.Distance.DiscreteHausdorffDistance.Distance(gIn, gParsed);
                if (discreteHausdorffDistance > 0.05)
                {
                    Console.WriteLine();
                    Console.WriteLine(gIn.AsText());
                    Console.WriteLine(gParsed.AsText());
                    Console.WriteLine("DiscreteHausdorffDistance=" + discreteHausdorffDistance);
                }
                Assert.IsTrue(discreteHausdorffDistance < 0.001);
            }
            else
                Assert.IsTrue(false);
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:21,代码来源:SpatiaLiteFixture.cs

示例5: Write

        protected override byte[] Write(IGeometry gIn)
        {
            var writer = new GaiaGeoWriter();
            writer.HandleOrdinates = Ordinates;
            writer.UseCompressed = Compressed;

            var b = writer.Write(gIn);
            using (SQLiteConnection conn = new SQLiteConnection("Data Source=\"" + Name + "\""))
            {
                conn.Open();
                using (SQLiteCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = "INSERT INTO \"nts_io_spatialite\" VALUES(@P1, @P3, @P2);";
                    SQLiteParameter p1 = new SQLiteParameter("P1", DbType.Int32) { Value = this.Counter };
                    SQLiteParameter p2 = new SQLiteParameter("P2", DbType.String) { Value = gIn.AsText() };
                    SQLiteParameter p3 = new SQLiteParameter("P3", DbType.Binary) { Value = b };
                    cmd.Parameters.AddRange(new[] { p1, p2, p3 });
                    cmd.ExecuteNonQuery();
                }
            }
            return b;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:22,代码来源:SpatiaLiteFixture.cs

示例6: OnExecuteIntersectionQuery

       /// <summary>   
       /// Returns the features that intersects with 'geom'   
       /// </summary>   
       /// <param name="geom"></param>   
       /// <param name="ds">FeatureDataSet to fill data into</param>   
       protected override void OnExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)   
       {   
           //List<Geometry> features = new List<Geometry>();   
           using (var 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 = "SELECT g.* , g." + GeometryColumn + ".STAsBinary() As sharpmap_tempgeometry FROM " + Table + " g " + BuildTableHints() + " WHERE ";   
 
               if (!String.IsNullOrEmpty(_definitionQuery))   
                   strSQL += DefinitionQuery + " AND ";   
 
               strSQL += strGeom;

               string extraOptions = GetExtraOptions();
               if (!string.IsNullOrEmpty(extraOptions))
                   strSQL += " " + extraOptions;
 
 
               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 && col.ColumnName != "sharpmap_tempgeometry")   
                               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 && col.ColumnName != "sharpmap_tempgeometry")   
                                   fdr[col.ColumnName] = dr[col];
                           fdr.Geometry = Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"], Factory);   
                           fdt.AddRow(fdr);   
                       }   
                       ds.Tables.Add(fdt);   
                   }   
               }   
           }   
       }   
开发者ID:lishxi,项目名称:_SharpMap,代码行数:53,代码来源:SqlServer2008.cs

示例7: OnExecuteIntersectionQuery

        /// <summary>
        /// Returns the features that intersects with 'geom'
        /// </summary>
        /// <param name="geom"></param>
        /// <param name="fcs">FeatureCollectionSet to fill data into</param>
        protected override void OnExecuteIntersectionQuery(IGeometry geom, IFeatureCollectionSet fcs, CancellationToken? cancellationToken=null)
        {
            using (var conn = new OracleConnection(ConnectionString))
            {
                var strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";

                strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString(Map.NumberFormatEnUs) : "NULL");

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

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

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

                strSQL += strGeom;
                var ds = new FeatureDataSet();

                using (var adapter = new OracleDataAdapter(strSQL, conn))
                {
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count <= 0)
                    {
                        return;
                    }
                    
                    var 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)
                    {
                        var 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"], Factory);
                        fdt.AddRow(fdr);
                    }
                    fcs.Add(fdt);
                }
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:57,代码来源:Oracle.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 void ExecuteIntersectionQuery(IGeometry geom, FeatureDataSet ds)
        {
            //List<IGeometry> features = new List<IGeometry>();
            using (PgConnection conn = new PgConnection(_ConnectionString))
            {
                string strGeom = "GeomFromText('" + geom.AsText() + "')";
                if (this.SRID > 0)
                    strGeom = "setSRID(" + strGeom + "," + this.SRID.ToString() + ")";

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

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

                strSQL += this.GeometryColumn + " && " + strGeom + " AND distance(" + this.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 (System.Data.DataColumn col in ds.Tables[0].Columns)
                            if (col.ColumnName != this.GeometryColumn && 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 != "sharpmap_tempgeometry")
                                    fdr[col.ColumnName] = dr[col];
                            fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:46,代码来源:PostGIS2.cs

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

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

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

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

				if (!String.IsNullOrEmpty(_defintionQuery))
					strSQL += this.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 (System.Data.DataColumn col in ds.Tables[0].Columns)
							if (col.ColumnName != this.GeometryColumn && 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 != "sharpmap_tempgeometry")
									fdr[col.ColumnName] = dr[col];
							fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
							fdt.AddRow(fdr);
						}
						ds.Tables.Add(fdt);
					}
				}
			}
		}
开发者ID:lishxi,项目名称:_SharpMap,代码行数:53,代码来源:Oracle.cs

示例10: OnExecuteIntersectionQuery

        /// <summary>
        /// Returns the features that intersects with 'geom'
        /// </summary>
        /// <param name="geom"></param>
        /// <param name="ds">FeatureDataSet to fill data into</param>
        protected override void OnExecuteIntersectionQuery(IGeometry geom, IFeatureCollectionSet fcs, CancellationToken? cancellationToken=null)
        {
            using (var conn = new OracleConnection(ConnectionString))
            {
                string strGeom = "MDSYS.SDO_GEOMETRY('" + geom.AsText() + "', #SRID#)";

                strGeom = strGeom.Replace("#SRID#", SRID > 0 ? SRID.ToString(Map.NumberFormatEnUs) : "NULL");

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

                string strSql = "SELECT * FROM " +
                                Table + " g WHERE ";

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

                strSql += strGeom;

                var ds = (DataSet) new FeatureDataSet();
                using (var adapter = new OracleDataAdapter(strSql, conn))
                {
                    conn.Open();
                    adapter.Fill(ds);
                    conn.Close();
                    if (ds.Tables.Count > 0)
                    {
                        var fdt = new FeatureDataTable(ds.Tables[0]);
                        foreach (DataColumn col in ds.Tables[0].Columns)
                            if (string.Compare(col.ColumnName, GeometryColumn, CultureInfo.InvariantCulture, CompareOptions.OrdinalIgnoreCase) != 0)
                                fdt.Columns.Add(col.ColumnName, col.DataType, col.Expression);
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            var fdr = fdt.NewRow();
                            foreach (DataColumn col in ds.Tables[0].Columns)
                                if (string.Compare(col.ColumnName, GeometryColumn, CultureInfo.InvariantCulture, CompareOptions.OrdinalIgnoreCase) != 0)
                                    fdr[col.ColumnName] = dr[col];
                            var sdoGeometry = dr[GeometryColumn] as SdoGeometry;

                            if (sdoGeometry != null)
                            {
                                fdr.Geometry = sdoGeometry.AsGeometry();
                            }

                            fdt.AddRow(fdr);
                        }
                        ds.Tables.Add(fdt);
                    }
                }
            }
        }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:56,代码来源:OracleSpatial.cs

示例11: QueryFeatures

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

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

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

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

				using (Npgsql.NpgsqlDataAdapter adapter = new Npgsql.NpgsqlDataAdapter(strSQL, conn))
				{
					System.Data.DataSet ds = new System.Data.DataSet();
					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 != "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 != "sharpmap_tempgeometry")
									fdr[col.ColumnName] = dr[col];
							fdr.Geometry = SharpMap.Converters.WellKnownBinary.GeometryFromWKB.Parse((byte[])dr["sharpmap_tempgeometry"]);
							fdt.AddRow(fdr);								
						}
						return fdt;
					}
					else return null;
				}
			}
		}
开发者ID:diegowald,项目名称:intellitrack,代码行数:44,代码来源:PostGIS.cs


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