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


C# IFeatureSet.Close方法代码示例

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


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

示例1: Execute


//.........这里部分代码省略.........
            output.FeatureType = poly.FeatureType;
            foreach (IFeature f in poly.Features)
            {
                output.Features.Add(f);
            }

            output.DataTable.Columns.Add("FID", typeof(int));
            output.DataTable.Columns.Add(TextStrings.AveSlope, typeof(Double));

            IRaster slopeGrid = new Raster { DataType = ras.DataType, Bounds = ras.Bounds };

            // FeatureSet polyShape = new FeatureSet();
            int previous = 0;

            if (Slope(ref ras, zFactor, false, ref slopeGrid, cancelProgressHandler) == false)
            {
                return false;
            }

            int shapeCount = output.Features.Count;
            int[] areaCount = new int[shapeCount];
            double[] areaTotal = new double[shapeCount];
            double[] areaAve = new double[shapeCount];
            double dxHalf = slopeGrid.CellWidth / 2;
            double dyHalf = slopeGrid.CellHeight / 2;

            // check whether those two envelope are intersect
            if (ras.Extent.Intersects(output.Extent) == false)
            {
                return false;
            }

            RcIndex start = slopeGrid.ProjToCell(output.Extent.MinX, output.Extent.MaxY);
            RcIndex stop = slopeGrid.ProjToCell(output.Extent.MaxX, output.Extent.MinY);

            int rowStart = start.Row;
            int colStart = start.Column;
            int rowStop = stop.Row;
            int colStop = stop.Column;
            for (int row = rowStart - 1; row < rowStop + 1; row++)
            {
                int current = Convert.ToInt32((row - rowStart + 1) * 100.0 / (rowStop + 1 - rowStart + 1));

                // only update when increment in percentage
                if (current > previous + 5)
                {
                    cancelProgressHandler.Progress(string.Empty, current, current + TextStrings.progresscompleted);
                    previous = current;
                }

                for (int col = colStart - 1; col < colStop + 1; col++)
                {
                    Coordinate cent = slopeGrid.CellToProj(row, col);
                    double xCent = cent.X;
                    double yCent = cent.Y;
                    for (int shpindx = 0; shpindx < output.Features.Count; shpindx++)
                    {
                        IFeature tempFeat = output.Features[shpindx];
                        Point pt1 = new Point(xCent, yCent);
                        Point pt2 = new Point(xCent - dxHalf, yCent - dyHalf);
                        Point pt3 = new Point(xCent + dxHalf, yCent - dyHalf);
                        Point pt4 = new Point(xCent + dxHalf, yCent + dyHalf);
                        Point pt5 = new Point(xCent - dxHalf, yCent + dyHalf);
                        if ((((!tempFeat.Covers(pt1) && !tempFeat.Covers(pt2)) && !tempFeat.Covers(pt3))
                             && !tempFeat.Covers(pt4)) && !tempFeat.Covers(pt5))
                        {
                            continue;
                        }

                        areaCount[shpindx]++;
                        areaTotal[shpindx] += slopeGrid.Value[row, col] / 100;

                        if (cancelProgressHandler.Cancel)
                        {
                            return false;
                        }
                    }
                }
            }

            for (int shpindx = 0; shpindx < output.Features.Count; shpindx++)
            {
                if (areaCount[shpindx] == 0)
                {
                    areaAve[shpindx] = 0;
                }
                else
                {
                    areaAve[shpindx] = areaTotal[shpindx] / areaCount[shpindx];
                }

                output.Features[shpindx].DataRow["FID"] = shpindx;
                output.Features[shpindx].DataRow[TextStrings.AveSlope] = areaAve[shpindx];
            }

            poly.Close();
            slopeGrid.Close();
            output.SaveAs(output.Filename, true);
            return true;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:101,代码来源:FindAverageSlope.cs

示例2: Execute

        /// <summary>
        /// Finds the average slope in the given polygons.
        /// </summary>
        /// <param name="gridIn">The Polygon Raster(Grid file).</param>
        /// <param name="polyOut">The Polygon shapefile path.</param>
        /// <param name="progress">The progress handler.</param>
        public bool Execute(IRaster gridIn, IFeatureSet polyOut, ICancelProgressHandler cancelProgressHandler)
        {
            //Validates the input and output data
            if (gridIn == null || polyOut == null)
            {
                return false;
            }
            int maxX, maxY;
            int current = 0;
            int previous = 0;
            double noData, currVal, currTrack;
            string strTrackPath;
            IRaster gridTrack = new Raster();


            maxX = gridIn.NumRows - 1;
            maxY = gridIn.NumColumns - 1;
            noData = gridIn.NoDataValue;

            //strTrackPath = System.IO.Path.GetDirectoryName(strInRast) + "\\" + System.IO.Path.GetFileNameWithoutExtension(strInRast) + "_track.bgd";
            gridTrack = Raster.Create("gridTrack.bgd", "", gridIn.NumColumns, gridIn.NumRows, 1, gridIn.DataType, new string[] { "" });
            //gridTrack.CreateNew("gridTrack", "", gridIn.NumColumns, gridIn.NumRows, 1, gridIn.DataType, new string[] { "" });
            gridTrack.Bounds = gridIn.Bounds;
            gridTrack.NoDataValue = gridIn.NoDataValue;

            polyOut.DataTable.Columns.Add("Value", typeof(int));
            polyOut.DataTable.Columns.Add("Zone", typeof(string));
            polyOut.DataTable.Columns.Add("Area", typeof(double));
            polyOut.DataTable.Columns.Add("COMID", typeof(string));
            polyOut.DataTable.Columns.Add("AveSlope", typeof(double));

            for (int i = 0; i <= maxX; i++)
            {

                current = Convert.ToInt32(i * 100 / maxX);
                //only update when increment in percentage
                if (current > previous+5)
                {
                    cancelProgressHandler.Progress("", current, current.ToString() + "% progress completed");
                    previous = current;
                }
                    

                for (int j = 0; j <= maxY; j++)
                {
                    if (i > 0 && j > 0)
                    {
                        currVal = Convert.ToInt16(gridIn.Value[i, j]);
                        currTrack = Convert.ToInt16(gridTrack.Value[i, j]);
                        if (currVal == gridIn.NoDataValue)
                        {
                            gridTrack.Value[i, j] = 1;

                            if (cancelProgressHandler.Cancel == true)
                                return false;
                        }
                        else
                        {
                            if (currTrack == 1)
                            {
                            }
                            else
                            {
                                formPolyFromCell(gridIn, gridTrack, i, j, polyOut, cancelProgressHandler);

                                if (cancelProgressHandler.Cancel == true)
                                    return false;
                            }
                        }
                    }
                    else
                    {
                        gridTrack.Value[i, j] = gridIn.NoDataValue;
                    }

                    

                }
            }
            gridIn.Close();
            gridTrack.Close();
            polyOut.SaveAs(polyOut.Filename, true);
            polyOut.Close();
            return true;

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


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