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


C# SqlGeometry.STNumPoints方法代码示例

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


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

示例1: GetPoints

 private static IList<SMPoint> GetPoints(SqlGeometry geometry)
 {
     SMPoint[] pts = new SMPoint[(int)geometry.STNumPoints()];
     for (int i = 0; i < (int)geometry.STNumPoints(); i++)
     {
         SqlGeometry ptGeometry = geometry.STPointN(i);
         pts[i] = new SMPoint((double)ptGeometry.STX, (double)ptGeometry.STY);
     }
     return pts;
 }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:10,代码来源:SqlGeometryConverter.cs

示例2: ExpandEnv

        private static void ExpandEnv(Envelope env, SqlGeometry geom)
        {
            for (int i = 0, c = geom.STNumPoints().Value; i < c; i++)
            {
                SqlGeometry geomPoint = geom.STPointN(i + 1);

                env.ExpandToInclude(geomPoint.STX.Value, geomPoint.STY.Value);
            }
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:9,代码来源:Sql2Shape.cs

示例3: GetPoints

 private static Coordinate[] GetPoints(SqlGeometry geometry)
 {
     Coordinate[] pts = new Coordinate[geometry.STNumPoints().Value];
     for (int i = 1; i <= pts.Length; i++)
     {
         SqlGeometry ptGeometry = geometry.STPointN(i);
         pts[i - 1] = new Coordinate(ptGeometry.STX.Value, ptGeometry.STY.Value);
     }
     return pts;
 }
开发者ID:interworks,项目名称:FastShapefile,代码行数:10,代码来源:ConvertToGeometry.cs

示例4: ToPointList

        // Converts a geometry (ring or linestring) to list of points
        public static List<Point> ToPointList(SqlGeometry sqlGeometry)
        {
            List<Point> points = new List<Point>();

            for (int i = 1; i <= sqlGeometry.STNumPoints(); i++)
            {
                SqlGeometry p = sqlGeometry.STPointN(i);
                points.Add(new Point(p.STX.Value, p.STY.Value));
            }
            return points;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:12,代码来源:GeometryExtensions.cs

示例5: GetPoints

        private static IList<SMPoint> GetPoints(SqlGeometry geometry)
        {
            int pointsNum = (int)geometry.STNumPoints();
            SMPoint[] pts = new SMPoint[pointsNum];

            for (int i = 1; i <= pointsNum; i++)
            {
                SqlGeometry ptGeometry = geometry.STPointN(i);
                double z = ptGeometry.Z == SqlDouble.Null ? (double)ptGeometry.Z : 0;
                pts[i - 1] = new SMPoint((double)ptGeometry.STX, (double)ptGeometry.STY, z);
            }
            return pts;
        }
开发者ID:Giszpenc,项目名称:ProjNet,代码行数:13,代码来源:SpatialDataFactoryNew.cs

示例6: GetPoints

 private static Coordinate[] GetPoints(SqlGeometry geometry)
 {
     var pts = new Coordinate[(int)geometry.STNumPoints()];
     for (int i = 1; i <= (int)geometry.STNumPoints(); i++)
     {
         var ptGeometry = geometry.STPointN(i);
         pts[i-1] = new Coordinate((double)ptGeometry.STX, (double)ptGeometry.STY);
     }
     return pts;
 }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:10,代码来源:SqlGeometryConverter.cs

示例7: AddShortenedRingByBuilder

        /// <summary>
        /// Add points to single ring in polygon
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="ring"></param>
        /// <param name="shortestDistance"></param>
        private static void AddShortenedRingByBuilder(SqlGeometryBuilder builder, SqlGeometry ring,
                                                      SqlDouble shortestDistance)
        {
            var pointCount = ring.STNumPoints();
            //var area = GetGeography(ring).STArea();
            if (pointCount <= MinPointCountToProceed ) AddRingByBuilder(builder, ring);
            else
            {
                try
                {
                    var firstPoint = ring.STPointN(1);
                    var startPoint = firstPoint;
                    int resulPointCount = 0;
                    // Begin the polygon with the first point

                    builder.BeginFigure((double) firstPoint.STX, (double) firstPoint.STY);
                    // While there are still unchecked points in polygon
                    for (int i = 2; i <= pointCount; i++)
                    {

                        var secondPoint = ring.STPointN(i);
                        if (GetDistanceBetweenPoints(firstPoint, secondPoint) >= shortestDistance || (resulPointCount < MinPointCountInPolygon && i >= (pointCount - 1)))
                        {
                            resulPointCount++;
                            builder.AddLine((double) secondPoint.STX, (double) secondPoint.STY);
                            firstPoint = ring.STPointN(i);
                        }

                    }
                    // Add last point - the same as first
                    builder.AddLine((double) startPoint.STX, (double) startPoint.STY);
                    builder.EndFigure();
                }
                catch (System.Exception ex)
                {

                    throw new Exception(string.Format(" AddShortenedRingByBuilder: {0}  Точек в кольце:{1}", ex.Message,
                                                      pointCount));
                }
            }
        }
开发者ID:MoonDav,项目名称:TileRendering,代码行数:47,代码来源:ShortLineExcluding.cs

示例8: AddRingByBuilder

        private static void AddRingByBuilder(SqlGeometryBuilder builder, SqlGeometry ring)
        {
            try
            {

            var firstPoint = ring.STPointN(1);
            var startPoint = firstPoint;
            var pointCount = ring.STNumPoints();
            // Begin the polygon with the first point
            builder.BeginFigure((double) firstPoint.STX, (double) firstPoint.STY);
            // While there are still unchecked points in polygon
            for (int i = 2; i <= pointCount; i++)
            {
                var secondPoint = ring.STPointN(i);

                builder.AddLine((double) secondPoint.STX, (double) secondPoint.STY);

            }
            // Add last point - the same as first
            builder.AddLine((double) startPoint.STX, (double) startPoint.STY);
            builder.EndFigure();
            }
            catch (System.Exception ex)
            {

                throw new Exception(string.Format("  AddRingByBuilder: {0}", ex.Message));
            }
        }
开发者ID:MoonDav,项目名称:TileRendering,代码行数:28,代码来源:ShortLineExcluding.cs

示例9: GetSegmentLength

        /// <summary>
        /// Returns length of segment in polygon
        /// </summary>
        /// <param name="geometry"></param>
        /// <param name="firstPoint"></param>
        /// <param name="secondPoint"></param>
        /// <returns></returns>
        public static SqlDouble GetSegmentLength(SqlGeometry geometry, SqlInt32 firstPoint, SqlInt32 secondPoint)
        {
            SqlInt32 pointNums = geometry.STNumPoints();
            if (pointNums < firstPoint || pointNums < secondPoint) return 0;

            var firstCoords = geometry.STPointN((int) firstPoint);
            var secondCoords = geometry.STPointN((int) secondPoint);

            return GetDistanceBetweenPoints(firstCoords, secondCoords);
        }
开发者ID:MoonDav,项目名称:TileRendering,代码行数:17,代码来源:ShortLineExcluding.cs

示例10: GetPointsFromSqlGeometry

        private static Point[] GetPointsFromSqlGeometry(SqlGeometry sqlGeometry)
        {
            Point[] points = new Point[(Int32)(sqlGeometry.STNumPoints())];

            for (int i = 0; i < sqlGeometry.STNumPoints(); i++)
            {
                SqlGeometry pointGeometry = sqlGeometry.STPointN(i + 1);
                points[i] = new Point((float)pointGeometry.STX.Value, (float)pointGeometry.STY.Value);
            }
            return points;
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:11,代码来源:SqlGeometryHelper.cs

示例11: getBoundsFromPolygon

        void getBoundsFromPolygon(SqlGeometry pol, ref int MinX, ref int MinY, ref int MaxX, ref int MaxY)
        {
            for (int i = 1; i <= pol.STNumPoints(); i++)
            {

                int x = (int)pol.STPointN(i).STX.Value;
                int y = (int)pol.STPointN(i).STY.Value;

                if (x < MinX) { MinX = x; }
                if (y < MinX) { MinY = y; }
                if (x > MinX) { MaxX = x; }
                if (y > MinX) { MaxY = y; }

            }
        }
开发者ID:Yellowpages,项目名称:Production,代码行数:15,代码来源:Form1.cs

示例12: 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

示例13: ReprojectFigure

        private void ReprojectFigure(SqlGeometry geometry, SqlGeometryBuilder bldr)
        {
            SqlGeometry point;
            int numPoints = geometry.STNumPoints().Value;
            double[] pts = new double[numPoints * 2];

            for (int i = 0, idx = 0; i < numPoints; i++)
            {
                point = geometry.STPointN(i + 1);

                pts[idx++] = point.STX.Value;
                pts[idx++] = point.STY.Value;
            }

            if (numPoints > 0)
            {
                DotSpatial.Projections.Reproject.ReprojectPoints(pts, null, _proj_source, _proj_target, 0, numPoints);

                bldr.BeginFigure(pts[0], pts[1]);

                for (int i = 2; i < pts.Length; i += 2)
                    bldr.AddLine(pts[i], pts[i + 1]);

                bldr.EndFigure();
            }
        }
开发者ID:interworks,项目名称:FastShapefile,代码行数:26,代码来源:ReprojectSqlServer.cs


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