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


C# SqlGeometry.ToString方法代码示例

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


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

示例1: AppendGeometryToSQLSource

		private void AppendGeometryToSQLSource(SqlGeometry geom, string label)
		{
			if (_ACTIVATE_CLIPBOARD == false) return;

			if (_geomSqlSrcBuilder == null)
			{
				ResetSQLSource();
				_geomSqlSrcBuilder = new StringBuilder();
				_geomSqlSrcBuilderSELECT = new StringBuilder();
			}
			else
			{
				_geomSqlSrcBuilder.AppendLine();
				_geomSqlSrcBuilderSELECT.AppendLine();
				_geomSqlSrcBuilderSELECT.Append("UNION ALL ");
			}


			_geomSqlSrcBuilder.AppendFormat("DECLARE @g{0} geometry = geometry::STGeomFromText('{1}',{2})", ++_geomSqlSourceCount, geom.ToString(), geom.STSrid.Value);

			// TODO: Prevent SQL injection with the label param
			//SqlCommand com = new SqlCommand(string.Format("SELECT @g{0} AS geom, @Label AS Label", _geomSqlSourceCount));
			//label = label ?? "Geom 'cool' " + _geomSqlSourceCount.ToString();
			//com.Parameters.AddWithValue("@Label", label);

			label = label ?? "Geometry " + _geomSqlSourceCount.ToString();
			_geomSqlSrcBuilderSELECT.AppendFormat("SELECT @g{0} AS geom, '{1}' AS Label", _geomSqlSourceCount, label.Replace("'", "''"));
		}
开发者ID:xfischer,项目名称:SqlServerSpatial.Toolkit,代码行数:28,代码来源:SpatialClipboard.cs

示例2: ShouldSerializeToWkt

        public void ShouldSerializeToWkt(string input, string expected)
        {
            var g=new SqlGeometry(SqlTypes.SqlGeometry.STGeomFromText(new SqlChars(new SqlString(input)), 4326));

            Assert.Equal<string>(expected, g.ToString());
        }
开发者ID:mcartoixa,项目名称:GeoSIK,代码行数:6,代码来源:SqlGeometry.cs

示例3: PolygonFromRings

		public static SqlGeometry PolygonFromRings(SqlGeometry outerRing, List<SqlGeometry> holes)
		{
			// Check si les parametres sont des LINESTRING
			#region Check params
			if (outerRing == null || outerRing.IsNull)
				throw new ArgumentException("La boucle extérieure est null", "outerRing");

			if (outerRing.STGeometryType().Value != OpenGisGeometryType.LineString.ToString())
				throw new ArgumentException("La boucle extérieure doit être un LINESTRING", "outerRing");
			if (holes != null)
			{
				foreach (var hole in holes)
				{
					if (hole.STGeometryType().Value != OpenGisGeometryType.LineString.ToString())
						throw new ArgumentException("Les boucles intérieures doivent être un LINESTRING", "holes");
				}
			}
			#endregion


			StringBuilder sb = new StringBuilder();
			sb.Append("POLYGON (");
			sb.Append(outerRing.ToString().Replace("LINESTRING ", ""));

			if (holes != null)
			{
				foreach (SqlGeometry hole in holes)
				{

					SqlGeometry polyFromHole = PolygonFromRings(hole, null);

					if (SqlTypesExtensions.GetAireEnMetres(polyFromHole) < AIRE_MINI_SCORIES)
						continue;

					//Debug.WriteLine(polyFromHole.STArea().Value);

					sb.Append(",");
					sb.Append(hole.ToString().Replace("LINESTRING ", ""));
				}
			}

			sb.Append(")");

			SqlGeometry ret = SqlTypesExtensions.STGeomFromText(sb.ToString(), outerRing.STSrid.Value);
			ret = ret.MakeValidIfInvalid(2);

			return ret;
		}
开发者ID:xfischer,项目名称:SqlServerSpatial.Toolkit,代码行数:48,代码来源:SqlTypesExtensions.cs


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