本文整理汇总了C#中SqlGeometry.MakeValid方法的典型用法代码示例。如果您正苦于以下问题:C# SqlGeometry.MakeValid方法的具体用法?C# SqlGeometry.MakeValid怎么用?C# SqlGeometry.MakeValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlGeometry
的用法示例。
在下文中一共展示了SqlGeometry.MakeValid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetGeography
private static SqlGeography GetGeography(SqlGeometry ring)
{
if (ring.STIsValid()) ring = ring.MakeValid();
return SqlGeography.STGeomFromWKB(ring.STUnion(ring.STStartPoint()).STAsBinary(), 4326);
}
示例2: ToSharpMapGeometry
public static SMGeometry ToSharpMapGeometry(SqlGeometry geometry, Factory factory)
{
if (geometry == null) return null;
var fact = factory ?? Services.CreateGeometryFactory((int) geometry.STSrid);
if (geometry.STIsEmpty())
return fact.CreateGeometryCollection(null);
if (!geometry.STIsValid())
geometry.MakeValid();
OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), (string)geometry.STGeometryType());
switch (geometryType)
{
case OpenGisGeometryType.Point:
return SqlGeometryToSharpMapPoint(geometry, fact);
case OpenGisGeometryType.LineString:
return SqlGeometryToSharpMapLineString(geometry, fact);
case OpenGisGeometryType.Polygon:
return SqlGeometryToSharpMapPolygon(geometry, fact);
case OpenGisGeometryType.MultiPoint:
return SqlGeometryToSharpMapMultiPoint(geometry, fact);
case OpenGisGeometryType.MultiLineString:
return SqlGeometryToSharpMapMultiLineString(geometry, fact);
case OpenGisGeometryType.MultiPolygon:
return SqlGeometryToSharpMapMultiPolygon(geometry, fact);
case OpenGisGeometryType.GeometryCollection:
return SqlGeometryToSharpMapGeometryCollection(geometry, fact);
}
throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Sharpmap.Geometry", geometry.STGeometryType()), "geometry");
}
示例3: GetGeometryData
static protected SqlGeometry GetGeometryData(int bufferIndex, PipelineBuffer buffer)
{
if (buffer.IsNull(bufferIndex))
{
return null;
}
else
{
SqlGeometry geometry = new SqlGeometry();
byte[] blobData = buffer.GetBlobData(bufferIndex, 0, (int)buffer.GetBlobLength(bufferIndex));
try
{
geometry = SqlGeometry.STGeomFromWKB(new System.Data.SqlTypes.SqlBytes(blobData), 0);
}
catch (FormatException)
{
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream((byte[])blobData);
System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(memoryStream);
geometry.Read(binaryReader);
}
geometry = geometry.MakeValid();
return geometry;
}
}