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


C# Feature.Area方法代码示例

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


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

示例1: SectionPolygonWithLine

        /// <summary>
        /// Sections a polygon into multiple parts depending on where line crosses it and if previous sectioning has occured.
        /// </summary>
        /// <param name="line">The line that splits the polygon. First and last points are intersect points.</param>
        /// <param name="polygon">The polygon that is to be split by the line.</param>
        /// <param name="polyStart">Index to polygon segment where the first intersect point is found.</param>
        /// <param name="polyEnd">Index to polygon segment where last intersect point is found.</param>
        /// <param name="resultFeatureSet">Reference to result shapefile where new polygon sections will be saved.</param>
        /// <returns>False if an error occurs, true otherwise.</returns>
        private static bool SectionPolygonWithLine(
            ref IFeature line, ref IFeature polygon, int polyStart, int polyEnd, ref IFeatureSet resultFeatureSet)
        {
            int numResults = resultFeatureSet.Features.Count;
            bool previousSplits = false;
            if (numResults != 0)
            {
                previousSplits = true;
            }

            // we can now make two new polygons by splitting the original one with the line segment
            IFeature poly1 = new Feature();
            IFeature poly2 = new Feature();

            SplitPolyInTwo(ref line, ref polygon, polyStart, polyEnd, ref poly1, ref poly2);
            if (previousSplits == false)
            {
                // if this split creates a sliver, we do not want to add either poly
                if (poly1.Area() > FindIntersectionTolerance && poly2.Area() > FindIntersectionTolerance)
                {
                    int shpIndex = 0;
                    resultFeatureSet.Features.Insert(shpIndex, poly1);
                    shpIndex = 1;
                    resultFeatureSet.Features.Insert(shpIndex, poly2);
                }
            }
            else
            {
                // this polygon underwent previous splittings, check
                // if the new results overlay the old ones before adding to resultSF
                IFeatureSet testFeatureSet = new FeatureSet(FeatureType.Polygon);
                IFeatureSet testFeatureSet2 = new FeatureSet(FeatureType.Polygon);

                if (ClipPolygonFeatureSetWithPolygon(resultFeatureSet, poly1, testFeatureSet, false) == false)
                {
                    return false;
                }

                if (ClipPolygonFeatureSetWithPolygon(resultFeatureSet, poly2, testFeatureSet2, false) == false)
                {
                    return false;
                }

                if (testFeatureSet.Features.Count > 0 || testFeatureSet2.Features.Count > 0)
                {
                    int numTestShapes = testFeatureSet.Features.Count;
                    const int insertIndex = 0;
                    IFeature insertShape;
                    for (int j = 0; j <= numTestShapes - 1; j++)
                    {
                        insertShape = testFeatureSet.Features[j];
                        resultFeatureSet.Features.Insert(insertIndex, insertShape);
                    }

                    numTestShapes = testFeatureSet2.Features.Count;
                    for (int j = 0; j <= numTestShapes - 1; j++)
                    {
                        insertShape = testFeatureSet2.Features[j];
                        resultFeatureSet.Features.Insert(insertIndex, insertShape);
                    }
                }
            }
            // end of checking against previous splits
            return true;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:74,代码来源:ClipPolygonWithLine.cs

示例2: addPolyFromPointsList

        private void addPolyFromPointsList(IFeatureSet polyOut, List<Point> lstPoints, double currVal, ICancelProgressHandler cancelProgressHandler)
        {

            List<ICoordinate> coordinates = new List<ICoordinate>();
            double area;

 //check           if (lstPoints.Count > 1)
            if (lstPoints.Count > 2)
            {
                foreach (Point tmpPoint in lstPoints)
                {
                    coordinates.Add(tmpPoint.Coordinate);
                }
                try
                {
                    IFeature tmpPoly = new Feature(FeatureTypes.Polygon, coordinates);
                    polyOut.Features.Add(tmpPoly);
                    area = tmpPoly.Area();
                }
                catch (Exception ex)
                {
                    throw new SystemException("Could not add new polygon to featureset in addPolyFromPointsList", ex);
                }



                polyOut.DataTable.Rows[polyOut.Features.Count - 1][2] = area;
                if (currVal == 1)
                {
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][0] = 1;
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][1] = "Initiation";
                }
                if (currVal == 3)
                {
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][0] = 3;
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][1] = "In-flow";
                }
                if (currVal > 3)
                {
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][0] = 2;
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][1] = "Out-flow";
                    polyOut.DataTable.Rows[polyOut.Features.Count - 1][3] = Convert.ToString(currVal);
                }


            }
        }
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:47,代码来源:mwSimpleRasterToPolygon.cs


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