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


C# Feature.Intersects方法代码示例

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


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

示例1: RandomPoints

 /// <summary>
 /// Creates a specified number of random point features inside a single polygon feature. 
 /// </summary>
 /// <param name="ConstrainingFeature">Random points will be generated inside this polygon feature.</param>
 /// <param name="NumberOfPoints">The number of points to be randomly generated.</param>
 /// <returns>A point feature set with the randomly created features.</returns>
 public static FeatureSet RandomPoints(Feature ConstrainingFeature, int NumberOfPoints)
 {
     //This function generates random points within the boundaries of one polygon feature
     FeatureSet fsOut = new FeatureSet();
     fsOut.FeatureType = FeatureType.Point;
     Coordinate c = new Coordinate();
     Random r = new Random();
     int i = 0;
     while (i < NumberOfPoints)
     {
         c = new Coordinate();
         //make a random point somewhere in the rectangular extents of the feature
         double rndx = r.Next(0, 100000) / 100000.0;
         double rndy = r.Next(0, 100000) / 100000.0;
         c.X = rndx * (ConstrainingFeature.Envelope.Right() - ConstrainingFeature.Envelope.Left()) + ConstrainingFeature.Envelope.Left();
         c.Y = rndy * (ConstrainingFeature.Envelope.Top() - ConstrainingFeature.Envelope.Bottom()) + ConstrainingFeature.Envelope.Bottom();
         //check if the point falls within the polygon featureset
         if (ConstrainingFeature.Intersects(c))
         {
             fsOut.AddFeature(new Feature(c));
             i++;
         }
     }
     return fsOut;
 }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:31,代码来源:RandomGeometry.cs

示例2: InterceptLine

        private void InterceptLine(Feature fea)
        {

            Extent exf = fea.Envelope.ToExtent();

            if (currentExtent.Contains(exf))
            {
                #region   exteny
                int endRow = vector.GetCell(exf.MinX, exf.MinY)[1];
                int iniRow = vector.GetCell(exf.MaxX, exf.MaxY)[1];

                if (endRow == -1 || iniRow == -1) return;


                for (int it = iniRow; it <= endRow; it++)
                {
                    Coordinate ini = new Coordinate();
                    Coordinate end = new Coordinate();
                    double[] i = vector.GetCoordenatesByCell(1, it);
                    double[] e = vector.GetCoordenatesByCell(vector.Get_area().NumColumns, it);
                    ini.X = i[0] - cellsize;
                    ini.Y = i[1];
                    end.X = e[0] + cellsize;
                    end.Y = e[1];
                    LinearRing line = new LinearRing(new List<Coordinate>() { ini, end });

                    if (fea.Intersects(line))
                    {
                        IFeature rfea = fea.Intersection(line);
                        IList<Coordinate> cor = rfea.Coordinates;
                        if (cor.Count == 1) break;
                        Filldata(rfea, cor);
                    }
                }


                #endregion
            }
            else
            {
                for (int it = 0; it < vector.Get_area().NumRows; it++)
                {
                    Coordinate ini = new Coordinate();
                    Coordinate end = new Coordinate();
                    double[] i = vector.GetCoordenatesByCell(1, it);
                    double[] e = vector.GetCoordenatesByCell(vector.Get_area().NumColumns, it);
                    ini.X = i[0] - cellsize;
                    ini.Y = i[1];
                    end.X = e[0] + cellsize;
                    end.Y = e[1];


                    LinearRing line = new LinearRing(new List<Coordinate>() { ini, end });
                   

                    if (fea.Intersects(line))
                    {
                        IFeature rfea = fea.Intersection(line);
                        IList<Coordinate> cor = rfea.Coordinates;
                        if (cor.Count == 1) break;
                        Filldata(rfea, cor);
                        if (test)
                        {
                            IFeature fd = li.AddFeature((IBasicGeometry)rfea);
                            fd.DataRow["id"] = "c";
                        }

                    }

                }


            }
        }
开发者ID:shoaib-ijaz,项目名称:geosoft,代码行数:74,代码来源:Clip2.cs


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