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


C# IFeature.GetBasicGeometryN方法代码示例

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


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

示例1: SeparateParts

        /// <summary>
        /// Separate Parts
        /// </summary>
        /// <param name="poly"></param>
        /// <param name="polyParts"></param>
        public static void SeparateParts(ref IFeature poly, ref IFeature[] polyParts)
        {
            int numParts = poly.NumGeometries;
            if (numParts == 0)
            {
                numParts = 1;
            }

            IFeature[] parts = new IFeature[numParts];

            if (numParts > 1)
            {
                for (int i = 0; i <= numParts - 1; i++)
                {
                    int countPoints = poly.GetBasicGeometryN(i).Coordinates.Count;
                    List<Coordinate> partsList = new List<Coordinate>();
                    for (int j = 0; j <= countPoints - 1; j++)
                    {
                        partsList.Insert(j, poly.Coordinates[j]);
                    }

                    parts[i] = new Feature(FeatureType.Polygon, partsList);
                }

                polyParts = parts;
            }
            else
            {
                parts[0] = new Feature();
                parts[0] = poly;
                polyParts = parts;
            }
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:38,代码来源:ClipPolygonWithLine.cs

示例2: ConvertPolyToVertexArray

        /// <summary>
        /// Takes a MapWinGIS polygon shape and stores all x/y coordinates into a vertex array.
        /// </summary>
        /// <param name="poly">The polygon to be converted.</param>
        /// <param name="polyVertArray">The array[numParts][] that will contain the polygon vertices.</param>
        public static void ConvertPolyToVertexArray(ref IFeature poly, ref Coordinate[][] polyVertArray)
        {
            int numParts = poly.NumGeometries;
            if (numParts == 0)
            {
                numParts = 1;
            }

            int numPoints = poly.NumPoints;
            Coordinate[][] vertArray = new Coordinate[numParts][];
            if (numParts > 1)
            {
                // separate parts of polygon
                for (int i = 0; i <= numParts - 1; i++)
                {
                    int numPtsInPart = poly.GetBasicGeometryN(i).Coordinates.Count;
                    vertArray[i] = new Coordinate[numPtsInPart];
                    for (int j = 0; j <= numPtsInPart - 2; j++)
                    {
                        vertArray[i][j] = poly.GetBasicGeometryN(i).Coordinates[j];
                    }

                    // be sure to 'close' the polygon in the vertex array!
                    vertArray[i][numPtsInPart - 1] = vertArray[i][0];
                }
            }
            else
            {
                // all points in polygon go into same vertex array
                vertArray[0] = new Coordinate[numPoints];
                for (int i = 0; i <= numPoints - 1; i++)
                {
                    vertArray[0][i] = poly.Coordinates[i];
                }
            }

            polyVertArray = vertArray;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:43,代码来源:ClipPolygonWithLine.cs

示例3: DrawPolygonFeature

        /// <summary>
        /// Draws a label on a polygon with various different methods
        /// </summary>
        /// <param name="e"></param>
        /// <param name="g"></param>
        /// <param name="f"></param>
        /// <param name="category"></param>
        /// <param name="selected"></param>
        /// <param name="existingLabels"></param>
        public static void DrawPolygonFeature(MapArgs e, Graphics g, IFeature f, ILabelCategory category, bool selected, List<RectangleF> existingLabels)
        {
            ILabelSymbolizer symb = category.Symbolizer;
            if (selected) symb = category.SelectionSymbolizer;

            //Gets the features text and calculate the label size
            string txt = GetLabelText(f, category);
            if (txt == null) return;
            SizeF labelSize = g.MeasureString(txt, symb.GetFont());

            if (f.NumGeometries == 1)
            {
                RectangleF labelBounds = PlacePolygonLabel(f.BasicGeometry, e, labelSize, symb);
                CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
            }
            else
            {
                if (symb.PartsLabelingMethod == PartLabelingMethod.LabelAllParts)
                {
                    for (int n = 0; n < f.NumGeometries; n++)
                    {
                        RectangleF labelBounds = PlacePolygonLabel(f.GetBasicGeometryN(n), e, labelSize, symb);
                        CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
                    }
                }
                else
                {
                    double largestArea = 0;
                    IPolygon largest = null;
                    for (int n = 0; n < f.NumGeometries; n++)
                    {
                        IPolygon pg = Geometry.FromBasicGeometry(f.GetBasicGeometryN(n)) as IPolygon;
                        if (pg == null) continue;
                        double tempArea = pg.Area;
                        if (largestArea < tempArea)
                        {
                            largestArea = tempArea;
                            largest = pg;
                        }
                    }
                    RectangleF labelBounds = PlacePolygonLabel(largest, e, labelSize, symb);
                    CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
                }
            }

            //Depending on the labeling strategy we do diff things
        }
开发者ID:nikson898,项目名称:dot-spatial,代码行数:56,代码来源:MapLabelLayer.cs

示例4: DrawLineFeature

        /// <summary>
        /// Draws a label on a line with various different methods
        /// </summary>
        /// <param name="e"></param>
        /// <param name="g"></param>
        /// <param name="f"></param>
        /// <param name="category"></param>
        /// <param name="selected"></param>
        /// <param name="existingLabels"></param>
        public static void DrawLineFeature(MapArgs e, Graphics g, IFeature f, ILabelCategory category, bool selected, List<RectangleF> existingLabels)
        {
            if (f == null) return;
            ILabelSymbolizer symb = category.Symbolizer;
            if (selected) symb = category.SelectionSymbolizer;

            //Gets the features text and calculate the label size
            string txt = GetLabelText(f, category);
            if (txt == null) return;
            SizeF labelSize = g.MeasureString(txt, symb.GetFont());

            if (f.NumGeometries == 1)
            {
                RectangleF labelBounds = PlaceLineLabel(f.BasicGeometry, labelSize, e, symb);
                CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
            }
            else
            {
                //Depending on the labeling strategy we do diff things
                if (symb.PartsLabelingMethod == PartLabelingMethod.LabelAllParts)
                {
                    for (int n = 0; n < f.NumGeometries; n++)
                    {
                        RectangleF labelBounds = PlaceLineLabel(f.GetBasicGeometryN(n), labelSize, e, symb);
                        CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
                    }
                }
                else
                {
                    double longestLine = 0;
                    int longestIndex = 0;
                    for (int n = 0; n < f.NumGeometries; n++)
                    {
                        ILineString ls = f.GetBasicGeometryN(n) as ILineString;
                        double tempLength = 0;
                        if (ls != null) tempLength = ls.Length;
                        if (longestLine < tempLength)
                        {
                            longestLine = tempLength;
                            longestIndex = n;
                        }
                    }
                    RectangleF labelBounds = PlaceLineLabel(f.GetBasicGeometryN(longestIndex), labelSize, e, symb);
                    CollisionDraw(txt, g, symb, f, e, labelBounds, existingLabels);
                }
            }
        }
开发者ID:nikson898,项目名称:dot-spatial,代码行数:56,代码来源:MapLabelLayer.cs

示例5: Shape

 /// <summary>
 /// Creates a shape based on the specified feature.  This shape will be standing alone,
 /// all by itself.  The fieldnames and field types will be null.
 /// </summary>
 /// <param name="feature"></param>
 public Shape(IFeature feature)
 {
     _shapeRange = new ShapeRange(feature.FeatureType);
     _attributes = feature.DataRow.ItemArray;
     IList<Coordinate> coords = feature.Coordinates;
     _vertices = new double[feature.NumPoints*2];
     _z = new double[feature.NumPoints];
     _m = new double[feature.NumPoints];
     for (int i = 0; i < coords.Count; i++)
     {
         Coordinate c = coords[i];
         _vertices[i*2] = c.X;
         _vertices[i*2 + 1] = c.Y;
         _z[i] = c.Z;
         _m[i] = c.M;
     }
     int offset = 0;
     for(int ig = 0; ig < feature.NumGeometries; ig++)
     {
         IBasicGeometry g = feature.GetBasicGeometryN(ig);
         PartRange prt = new PartRange(_vertices, 0, offset, feature.FeatureType);
         _shapeRange.Parts.Add(prt);
         offset += g.NumPoints;
     }
 }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:30,代码来源:Shape.cs


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