本文整理汇总了C#中SqlGeometry.STGeometryType方法的典型用法代码示例。如果您正苦于以下问题:C# SqlGeometry.STGeometryType方法的具体用法?C# SqlGeometry.STGeometryType怎么用?C# SqlGeometry.STGeometryType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SqlGeometry
的用法示例。
在下文中一共展示了SqlGeometry.STGeometryType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SqlGeometryToGeometry
public static IGeometry SqlGeometryToGeometry(SqlGeometry geom, GeometryFactory factory)
{
if (geom.STIsEmpty())
return factory.CreateGeometryCollection(null);
OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);
switch (geometryType)
{
case OpenGisGeometryType.Point:
return SqlGeometryToGeometryPoint(geom, factory);
case OpenGisGeometryType.LineString:
return SqlGeometryToGeometryLineString(geom, factory);
case OpenGisGeometryType.Polygon:
return SqlGeometryToGeometryPolygon(geom, factory);
case OpenGisGeometryType.MultiPoint:
return SqlGeometryToGeometryMultiPoint(geom, factory);
case OpenGisGeometryType.MultiLineString:
return SqlGeometryToGeometryMultiLineString(geom, factory);
case OpenGisGeometryType.MultiPolygon:
return SqlGeometryToGeometryMultiPolygon(geom, factory);
case OpenGisGeometryType.GeometryCollection:
return SqlGeometryToGeometryGeometryCollection(geom, factory);
}
throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Geometry", geom.STGeometryType()), "geom");
}
示例2: ToSharpMapGeometry
public static SMGeometry ToSharpMapGeometry(SqlGeometry geometry)
{
OpenGisGeometryType geometryType =
(OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), (string)geometry.STGeometryType());
switch (geometryType)
{
case OpenGisGeometryType.Point:
return SqlGeometryToSharpMapPoint(geometry);
case OpenGisGeometryType.LineString:
return SqlGeometryToSharpMapLineString(geometry);
case OpenGisGeometryType.Polygon:
return SqlGeometryToSharpMapPolygon(geometry);
case OpenGisGeometryType.MultiPoint:
return SqlGeometryToSharpMapMultiPoint(geometry);
case OpenGisGeometryType.MultiLineString:
return SqlGeometryToSharpMapMultiLineString(geometry);
case OpenGisGeometryType.MultiPolygon:
return SqlGeometryToSharpMapMultiPolygon(geometry);
case OpenGisGeometryType.GeometryCollection:
return SqlGeometryToSharpMapGeometryCollection(geometry);
}
throw new ArgumentException(string.Format("Cannot convert SqlServer '{0}' to Sharpmap.Geometry", geometry.STGeometryType()), "geometry");
}
示例3: 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");
}
示例4: GetOpenGisGeometryType
private OpenGisGeometryType GetOpenGisGeometryType(SqlGeometry geom)
{
return (OpenGisGeometryType) Enum.Parse(typeof (OpenGisGeometryType), (string) geom.STGeometryType());
}
示例5: GetGeometryInfo
/// <summary>
/// Преобразует в списки координат с инфрмацией о типе геометрии
/// </summary>
/// <param name="shape"></param>
/// <returns></returns>
private GeometryInstanceInfo GetGeometryInfo(SqlGeometry shape)
{
var result = new GeometryInstanceInfo();
var type = (OpenGisGeometryType) Enum.Parse(typeof (OpenGisGeometryType), (string) shape.STGeometryType());
result.ShapeType = type;
//List<PointF> points = new List<PointF>();
PointF[] points;
List<GeometryPointSequence> pointSequenceList;
var shapesPointsCollection = new List<List<GeometryPointSequence>>();
switch (type)
{
case OpenGisGeometryType.Point:
points = new PointF[1];
SqlGeometry firstpoint = shape.STStartPoint();
points[0] = new PointF((float) firstpoint.STX, (float) firstpoint.STY);
pointSequenceList = new List<GeometryPointSequence>
{
new GeometryPointSequence {PointList = points, InnerRing = false}
};
shapesPointsCollection.Add(pointSequenceList);
break;
case OpenGisGeometryType.LineString:
points = shape.ToPointsFArray();
pointSequenceList = new List<GeometryPointSequence> { new GeometryPointSequence { PointList = points, InnerRing = false } };
shapesPointsCollection.Add(pointSequenceList);
break;
case OpenGisGeometryType.Polygon:
shapesPointsCollection = shape.ToGeometryPointsOfPolygon();
break;
case OpenGisGeometryType.MultiPoint:
case OpenGisGeometryType.MultiLineString:
shapesPointsCollection = shape.ToGeometryPointsOfMultiPointLineString();
break;
case OpenGisGeometryType.MultiPolygon:
shapesPointsCollection = shape.ToGeometryPointsOfMultiPolygon();
break;
case OpenGisGeometryType.GeometryCollection:
var geomNum = (int) shape.STNumGeometries();
var geometryList = new GeometryInstanceInfo[geomNum];
int i;
for ( i = 0; i < geomNum; i++)
geometryList[i] = GetGeometryInfo(shape.STGeometryN(i));
result.GeometryInstanceInfoCollection = geometryList;
break;
}
result.Points = shapesPointsCollection;
return result;
}
示例6: ConvertSimpleGeometry
private static Geometry ConvertSimpleGeometry(SqlGeometry geom, Vector unitVector = default(Vector))
{
Geometry ret = null;
try
{
switch (geom.STGeometryType().ToString())
{
case "Polygon":
ret = ConvertPolygon(geom);
break;
case "LineString":
ret = ConvertLineString(geom);
break;
case "Point":
ret = ConvertPoint(geom, unitVector);
break;
default:
throw new NotSupportedException(string.Format("ConvertSimpleGeometry: Geometry type {0} not supported", geom.STGeometryType()));
}
}
catch (Exception)
{
throw;
}
return ret;
}
示例7: Decode
private Geometry Decode(SqlGeometry g)
{
PathGeometry result = new PathGeometry();
switch (g.STGeometryType().Value.ToLower())
{
case "point":
PathFigure pointFig = new PathFigure();
pointFig.StartPoint = new Point(g.STX.Value - 2, g.STY.Value - 2);
LineSegment pointLs = new LineSegment(new Point(g.STX.Value + 2, g.STY.Value + 2), true);
pointFig.Segments.Add(pointLs);
result.Figures.Add(pointFig);
pointFig = new PathFigure();
pointFig.StartPoint = new Point(g.STX.Value - 2, g.STY.Value + 2);
pointLs = new LineSegment(new Point(g.STX.Value + 2, g.STY.Value - 2), true);
pointFig.Segments.Add(pointLs);
result.Figures.Add(pointFig);
return result;
case "polygon":
string cmd = new string(g.STAsText().Value).Trim().Substring(8);
string[] polyArray = (cmd.Substring(1, cmd.Length - 2) + ", ").Split('(');
var polys = from s in polyArray
where s.Length > 0
select s.Trim().Substring(0, s.Length - 3);
PathFigure fig;
foreach (var item in polys)
{
fig = new PathFigure();
var polyPoints = from p in item.Split(',')
select p.Trim().Replace(" ", ",");
fig.StartPoint = Point.Parse(polyPoints.ElementAt(0));
for (int i = 1; i < polyPoints.Count(); i++)
{
LineSegment ls = new LineSegment(Point.Parse(polyPoints.ElementAt(i)), true);
fig.Segments.Add(ls);
}
result.Figures.Add(fig);
}
return result;
case "linestring":
PathFigure lsfig = new PathFigure();
lsfig.StartPoint = new Point(g.STPointN(1).STX.Value, g.STPointN(1).STY.Value);
for (int i = 1; i <= g.STNumPoints(); i++)
{
LineSegment ls = new LineSegment();
ls.Point = new Point(g.STPointN(i).STX.Value, g.STPointN(i).STY.Value);
lsfig.Segments.Add(ls);
}
result.Figures.Add(lsfig);
return result;
case "multipoint":
case "multilinestring":
case "multipolygon":
case "geometrycollection":
GeometryGroup mpG = new GeometryGroup();
for (int i = 1; i <= g.STNumGeometries().Value; i++)
mpG.Children.Add(Decode(g.STGeometryN(i)));
return mpG;
default:
return Geometry.Empty;
}
}
示例8: ReprojectGeometry
private void ReprojectGeometry(SqlGeometry geom, SqlGeometryBuilder bldr)
{
if (geom.STIsEmpty())
{
bldr.BeginGeometry(OpenGisGeometryType.GeometryCollection);
bldr.EndGeometry();
}
else
{
OpenGisGeometryType geometryType = (OpenGisGeometryType)Enum.Parse(typeof(OpenGisGeometryType), geom.STGeometryType().Value);
switch (geometryType)
{
case OpenGisGeometryType.Point:
ReprojectPoint(geom, bldr);
break;
case OpenGisGeometryType.LineString:
ReprojectLineString(geom, bldr);
break;
case OpenGisGeometryType.Polygon:
ReprojectPolygon(geom, bldr);
break;
case OpenGisGeometryType.MultiPoint:
ReprojectMultiPoint(geom, bldr);
break;
case OpenGisGeometryType.MultiLineString:
ReprojectMultiLineString(geom, bldr);
break;
case OpenGisGeometryType.MultiPolygon:
ReprojectMultiPolygon(geom, bldr);
break;
case OpenGisGeometryType.GeometryCollection:
ReprojectGeometryCollection(geom, bldr);
break;
default:
throw new ArgumentException(string.Format("Cannot reproject SqlServer Type '{0}'", geom.STGeometryType()), "geom");
}
}
}
示例9: 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;
}