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


C# SqlGeometry.STAsText方法代码示例

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


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

示例1: GetPoints

 private PointF[] GetPoints(SqlGeometry geom)
 {
     var size = 76;
     string cmd = new string(geom.STAsText().Value).Trim().Substring(8).Trim(')', '(');
     return cmd.Split(new [] {','}, StringSplitOptions.RemoveEmptyEntries).Select(x =>
     {
         var splited = x.Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries);
         var a = splited[0].Replace('.', ',');
         var b = splited[1].Replace('.', ',');
         return new PointF(float.Parse(a) * size + 32, float.Parse(b) * size + 12);
     }).ToArray();
 }
开发者ID:FoKycHuK,项目名称:kgg,代码行数:12,代码来源:FourthHandler.cs

示例2: 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;
            }
        }
开发者ID:rupeshkumar399,项目名称:seemapcell,代码行数:72,代码来源:GeometryInfo.cs


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