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


C# IFeatureSet.Select方法代码示例

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


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

示例1: Execute

        /// <summary>
        /// Executes the Union Opaeration tool programaticaly
        /// </summary>
        /// <param name="self">The input are feature set</param>
        /// <param name="other">The second input feature set</param>
        /// <param name="output">The output feature set</param>
        /// <param name="cancelProgressHandler">The progress handler</param>
        /// <returns></returns>
        public bool Execute(
            IFeatureSet self, IFeatureSet other, IFeatureSet output, ICancelProgressHandler cancelProgressHandler)
        {
            // Validates the input and output data
            if (self == null || other == null || output == null)
            {
                return false;
            }

            IFeatureSet tempOutput = self.Intersection(other, FieldJoinType.All, null);
            IFeatureSet tempFeatureSet = self.CombinedFields(other);

            int previous = 0;
            int max = self.Features.Count;

            // Take (Self-Intersect Featureset)
            List<IFeature> intersectList;
            for (int i = 0; i < self.Features.Count; i++)
            {
                intersectList = other.Select(self.Features[i].Envelope.ToExtent());
                foreach (IFeature feat in intersectList)
                {
                    if (cancelProgressHandler.Cancel)
                    {
                        return false;
                    }

                    self.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly);
                }

                if (Math.Round(i * 40D / max) <= previous)
                {
                    continue;
                }

                previous = Convert.ToInt32(Math.Round(i * 40D / max));
                cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted);
            }

            max = other.Features.Count;

            // Take (Other-Intersect Featureset)
            for (int i = 0; i < other.Features.Count; i++)
            {
                intersectList = self.Select(other.Features[i].Envelope.ToExtent());
                foreach (IFeature feat in intersectList)
                {
                    if (cancelProgressHandler.Cancel)
                    {
                        return false;
                    }

                    other.Features[i].Difference(feat, tempFeatureSet, FieldJoinType.LocalOnly);
                }

                if (Math.Round((i * 40D / max) + 40D) <= previous)
                {
                    continue;
                }

                previous = Convert.ToInt32(Math.Round((i * 40D / max) + 40D));
                cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted);
            }

            max = tempFeatureSet.Features.Count;
            output.CopyTableSchema(tempFeatureSet);

            // Add the individual feature to output
            for (int i = 0; i < tempFeatureSet.Features.Count; i++)
            {
                output.Features.Add(tempFeatureSet.Features[i]);
                if (Math.Round((i * 10D / max) + 80D) <= previous)
                {
                    continue;
                }

                previous = Convert.ToInt32(Math.Round((i * 10D / max) + 80D));
                if (cancelProgressHandler.Cancel)
                {
                    return false;
                }

                cancelProgressHandler.Progress(string.Empty, previous, previous + TextStrings.progresscompleted);
            }

            max = tempOutput.Features.Count;

            // Add the Intersect feature to output
            for (int i = 0; i < tempOutput.Features.Count; i++)
            {
                output.Features.Add(tempOutput.Features[i]);
                if (cancelProgressHandler.Cancel)
//.........这里部分代码省略.........
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:101,代码来源:Union.cs

示例2: Intersection

        /// <summary>
        /// This tests each feature of the input
        /// </summary>
        /// <param name="self">This featureSet</param>
        /// <param name="other">The featureSet to perform intersection with</param>
        /// <param name="joinType">The attribute join type</param>
        /// <param name="progHandler">A progress handler for status messages</param>
        /// <returns>An IFeatureSet with the intersecting features, broken down based on the join Type</returns>
        public static IFeatureSet Intersection(this IFeatureSet self, IFeatureSet other, FieldJoinType joinType, IProgressHandler progHandler)
        {
            IFeatureSet result = null;
            ProgressMeter pm = new ProgressMeter(progHandler, "Calculating Intersection", self.Features.Count);
            if (joinType == FieldJoinType.All)
            {
                result = CombinedFields(self, other);
                // Intersection is symmetric, so only consider I X J where J <= I
                if (!self.AttributesPopulated) self.FillAttributes();
                if (!other.AttributesPopulated) other.FillAttributes();
                int i = 0;
                foreach (IFeature selfFeature in self.Features)
                {
                    List<IFeature> potentialOthers = other.Select(selfFeature.Envelope.ToExtent());
                    foreach (IFeature otherFeature in potentialOthers)
                    {
                        selfFeature.Intersection(otherFeature, result, joinType);
                    }
                    pm.CurrentValue = i;
                    i++;
                }
                pm.Reset();
            }
            if (joinType == FieldJoinType.LocalOnly)
            {
                if (!self.AttributesPopulated) self.FillAttributes();

                result = new FeatureSet();
                result.CopyTableSchema(self);
                result.FeatureType = self.FeatureType;
                IFeature union;
                pm = new ProgressMeter(progHandler, "Calculating Union", other.Features.Count);
                if (other.Features != null && other.Features.Count > 0)
                {
                    union = other.Features[0];
                    for (int i = 1; i < other.Features.Count; i++)
                    {
                        union = union.Union(other.Features[i]);
                        pm.CurrentValue = i;
                    }
                    pm.Reset();
                    pm = new ProgressMeter(progHandler, "Calculating Intersections", self.NumRows());
                    Extent otherEnvelope = new Extent(union.Envelope);
                    for (int shp = 0; shp < self.ShapeIndices.Count; shp++)
                    {
                        if (!self.ShapeIndices[shp].Extent.Intersects(otherEnvelope)) continue;
                        IFeature selfFeature = self.GetFeature(shp);
                        selfFeature.Intersection(union, result, joinType);
                        pm.CurrentValue = shp;
                    }
                    pm.Reset();
                }
            }
            if (joinType == FieldJoinType.ForeignOnly)
            {
                if (!other.AttributesPopulated) other.FillAttributes();
                result = new FeatureSet();
                result.CopyTableSchema(other);
                IFeature union;
                if (self.Features != null && self.Features.Count > 0)
                {
                    pm = new ProgressMeter(progHandler, "Calculating Union", self.Features.Count);
                    union = self.Features[0];
                    for (int i = 1; i < self.Features.Count; i++)
                    {
                        union = union.Union(self.Features[i]);
                        pm.CurrentValue = i;
                    }
                    pm.Reset();
                    if (other.Features != null)
                    {
                        pm = new ProgressMeter(progHandler, "Calculating Intersection", other.Features.Count);
                        int j = 0;
                        foreach (IFeature otherFeature in other.Features)
                        {
                            IFeature test = otherFeature.Intersection(union, result, joinType);
                            if (test.BasicGeometry != null)
                            {
                                result.Features.Add(test);
                            }
                            pm.CurrentValue = j;
                            j++;
                        }
                    }
                    pm.Reset();
                }
            }
            return result;
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:97,代码来源:FeatureSetExt.cs


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