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


C# PolylineClass.QueryPoint方法代码示例

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


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

示例1: ProcessFeature

        private ArrayList ProcessFeature(IFeature test, SegmentCollectionIndex index,
			double searchRadius, double aspectRatio, bool canDefer, bool canExcept)
        {
            if (test == null || test.Shape == null || test.Shape.IsEmpty)
                return null;

            ArrayList theReturn = new ArrayList();

            IDataset theDataset = (IDataset)test.Table;

            IGeometry theTestShape = test.ShapeCopy;
            theTestShape.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
            ISegmentCollection theSegColl = (ISegmentCollection)theTestShape;
            ISegment theSegment;

            for (int i = 0; i < theSegColl.SegmentCount; i++)
            {
                theSegment = theSegColl.get_Segment(i);
                int theNeatlineOID;
                double dist1 = index.get_MinimumDistance(theSegment.FromPoint, out theNeatlineOID);
                if (dist1 <= searchRadius)
                {
                    double dist2 = index.get_MinimumDistance(theSegment.ToPoint, out theNeatlineOID);
                    if (dist2 <= searchRadius)
                    {
                        if (Math.Abs(dist1 - dist2) < theSegment.Length / aspectRatio)
                        {
                            // Error point will be 1/2 way along segment
                            IPolyline thePolyline = new PolylineClass();
                            thePolyline.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                            ((ISegmentCollection)thePolyline).AddSegment(theSegment, ref this._missing, ref this._missing);
                            thePolyline.Project(SpatialReferenceHelper.GeographicReference);

                            IPoint theErrorPoint = new PointClass();
                            thePolyline.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, theErrorPoint);

                            DataQualityError theError = new DataQualityError(this.Name, canDefer, canExcept);
                            theError.Location = theErrorPoint;

                            // If it's in the smallest 10% of the search radius, mark high severity
                            // 50%, medium
                            double avgDist = (dist1 + dist2) / 2;
                            if (avgDist <= searchRadius / 10)
                                theError.Severity = 1;
                            else if (avgDist <= searchRadius / 2)
                                theError.Severity = 2;
                            else
                                theError.Severity = 3;

                            theError.Description = "Line segment co-linear with neatline";

                            ExtendedInfo theInfo = new ExtendedInfo();

                            theInfo.AddProperty("Feature class", theDataset.Name);
                            if (test.HasOID)
                                theInfo.AddProperty("Feature ID", test.OID.ToString());
                            theInfo.AddProperty("Neatline Feature ID", theNeatlineOID.ToString());
                            theInfo.AddProperty("Distance", String.Format("{0:0.## metres}", avgDist));
                            theInfo.AddProperty("From point x", thePolyline.FromPoint.X.ToString());
                            theInfo.AddProperty("From point y", thePolyline.FromPoint.Y.ToString());
                            theInfo.AddProperty("To point x", thePolyline.ToPoint.X.ToString());
                            theInfo.AddProperty("To point y", thePolyline.ToPoint.Y.ToString());

                            theError.ExtendedData = theInfo.WriteXML();
                            //this.LogMessage(theError.ExtendedData);
                            theReturn.Add(theError);
                        }
                    }
                }
            }
            return theReturn;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:72,代码来源:GeometryNeatline.cs

示例2: Execute


//.........这里部分代码省略.........
                            }

                            IFeature theFeature2 = theFCursor2.NextFeature();
                            while (theFeature2 != null)
                            {
                                if (theFeature2.Shape != null && theFeature2.Shape.IsEmpty == false)
                                {
                                    IGeometry theCopy = theFeature2.ShapeCopy;
                                    theCopy.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                                    IPointCollection thePtColl = (IPointCollection)theCopy;
                                    for (int k = 0; k < thePtColl.PointCount; k++)
                                    {
                                        // Find the closest point in the index. If it's less than
                                        // the search radius and larger than the cluster tolerance,
                                        // log as an error
                                        IPoint thePoint = thePtColl.get_Point(k);
                                        IndexPoint theIdxPoint = theIndex.get_ClosestPointWithinLimits(
                                            thePoint.X,
                                            thePoint.Y,
                                            theCluster,
                                            theSearchRadius);

                                        if (theIdxPoint != null)
                                        {
                                            // Build a straight line between the offending points
                                            IPolyline thePolyline = new PolylineClass();
                                            thePolyline.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                                            ((IPointCollection)thePolyline).AddPoint(thePoint, ref this._missing, ref this._missing);
                                            IPoint theOtherPoint = new PointClass();
                                            theOtherPoint.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                                            theOtherPoint.PutCoords(theIdxPoint.X, theIdxPoint.Y);
                                            ((IPointCollection)thePolyline).AddPoint(theOtherPoint, ref this._missing, ref this._missing);

                                            // Get the distance
                                            double dist = PointCollectionIndex.get_Distance(thePoint.X, thePoint.Y, theOtherPoint.X, theOtherPoint.Y);

                                            // Project to geographics for error reporting
                                            thePolyline.Project(SpatialReferenceHelper.GeographicReference);

                                            // Error point will be 1/2 way along line between points
                                            IPoint theErrorPoint = new PointClass();
                                            thePolyline.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, theErrorPoint);

                                            DataQualityError theError = new DataQualityError(this.Name, canDefer, canExcept);
                                            theError.Location = theErrorPoint;

                                            // If it's in the smallest 10% of the search radius, mark high severity
                                            // 50%, medium
                                            if (dist <= theSearchRadius / 10)
                                                theError.Severity = 1;
                                            else if (dist <= theSearchRadius / 2)
                                                theError.Severity = 2;
                                            else
                                                theError.Severity = 3;

                                            theError.Description = "Points almost but not quite co-located";

                                            ExtendedInfo theExtInfo = new ExtendedInfo();

                                            theExtInfo.AddProperty("Feature class 1", theDataset1.Name);
                                            theExtInfo.AddProperty("Feature class 2", theDataset2.Name);
                                            if (theLayer1.FeatureClass.HasOID)
                                                theExtInfo.AddProperty("Feature ID 1", theIdxPoint.SourceFeatureID.ToString());
                                            if (theLayer2.FeatureClass.HasOID)
                                                theExtInfo.AddProperty("Feature ID 2", theFeature2.OID.ToString());
                                            theExtInfo.AddProperty("Distance", String.Format("{0:0.## metres}", dist));
                                            theExtInfo.AddProperty("From point x", thePolyline.FromPoint.X.ToString());
                                            theExtInfo.AddProperty("From point y", thePolyline.FromPoint.Y.ToString());
                                            theExtInfo.AddProperty("To point x", thePolyline.ToPoint.X.ToString());
                                            theExtInfo.AddProperty("To point y", thePolyline.ToPoint.Y.ToString());

                                            theError.ExtendedData = theExtInfo.WriteXML();
                                            //this.LogMessage(theError.ExtendedData);
                                            this._errors.Add(theError);
                                        }
                                    }
                                }

                                theFeature2 = theFCursor2.NextFeature();
                            }
                        }
                    }
                }

                this.LogMessage("Number of errors found: " + this.ErrorCount);
                this.LogMessage("Test " + this.Name + " successful.");
            }
            catch (Exception ex)
            {
                this.LogMessage("Exception caught: \n" + ex.Message + "\n" + ex.StackTrace.ToString());
                this.LogMessage("id of the current polygon: " + currentOid);
                return -1;
            }
            finally
            {
                this.StopLogging();
            }

            return this.ErrorCount;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:101,代码来源:GeometryLinework.cs

示例3: ProcessPotentialGapErrors

        private ArrayList ProcessPotentialGapErrors(ArrayList pointPairs, ITopology topology, IFeatureClass sourceFC,
			double limitRadians, bool allowPinches)
        {
            ArrayList theReturn = new ArrayList();

            // We have a list of pairs of points on opposite sides of a gap which are
            // within the tolerance distances. We need to calculate the angles
            /*
             * Format of the "pair" is IndexPoint[6]
             * [0] - thePoint
             * [1] - theOtherPoint
             * [2] - point preceding thePoint in source feature shape
             * [3] - point following thePoint in source feature shape
             * [4] - point preceding theOtherPoint in source feature shape
             * [5] - point following theOtherPoint in source feature shape
             */
            int count = 0;
            IScratchWorkspaceFactory theFactory = new ScratchWorkspaceFactoryClass();

            for (int i = 0; i < pointPairs.Count; i++)
            {
                IndexPoint[] thePair = (IndexPoint[])pointPairs[i];

                // Construct line segments and compare angles
                ILine[] theLines = new ILine[2];
                ILine[] theOtherLines = new ILine[2];
                if (thePair[2] != null) theLines[0] = this.ConstructLine(thePair[2].X, thePair[2].Y, thePair[0].X, thePair[0].Y);
                if (thePair[3] != null) theLines[1] = this.ConstructLine(thePair[0].X, thePair[0].Y, thePair[3].X, thePair[3].Y);
                if (thePair[4] != null) theOtherLines[0] = this.ConstructLine(thePair[4].X, thePair[4].Y, thePair[1].X, thePair[1].Y);
                if (thePair[5] != null) theOtherLines[1] = this.ConstructLine(thePair[1].X, thePair[1].Y, thePair[5].X, thePair[5].Y);

                bool bFoundError = false;

                for (int j = 0; j < theLines.Length; j++)
                {
                    for (int k = 0; k < theOtherLines.Length; k++)
                    {
                        // Eval angle. If it is less than the limit, Create an error and add it to the collection
                        double angleRadians = this.EvalAngle(theLines[j], theOtherLines[k]);
                        if (double.IsNaN(angleRadians) == false)
                        {
                            if (angleRadians >= 0 && angleRadians < limitRadians)
                            {
                                // Error point will be 1/2 way between points
                                ILine theGap = this.ConstructLine(thePair[0].X, thePair[0].Y, thePair[1].X, thePair[1].Y);
                                double theGapSize = theGap.Length;

                                IPolyline theGapPolyline = new PolylineClass();
                                theGapPolyline.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                                ((ISegmentCollection)theGapPolyline).AddSegment((ISegment)theGap, ref this._missing, ref this._missing);
                                theGapPolyline.Project(SpatialReferenceHelper.GeographicReference);

                                IPoint theErrorPoint = new PointClass();
                                theGapPolyline.QueryPoint(esriSegmentExtension.esriNoExtension, 0.5, true, theErrorPoint);

                                if (allowPinches || this.IsPinch(
                                    theErrorPoint,
                                    theGapPolyline,
                                    sourceFC,
                                    theFactory.DefaultScratchWorkspace
                                    ) == false)
                                {
                                    IDataset theDataset = (IDataset)sourceFC;

                                    PotentialError thePError = new PotentialError();
                                    thePError.AngleDegrees = angleRadians * 180 / Math.PI;
                                    thePError.ErrorPoint = theErrorPoint;
                                    thePError.FeatureClassName = theDataset.Name;
                                    thePError.FromPoint = theGapPolyline.FromPoint;
                                    thePError.GapSize = theGapSize;
                                    thePError.OtherOID = thePair[1].SourceFeatureID;
                                    thePError.OtherPointIndex = thePair[1].SourcePointIndex;
                                    thePError.SourceOID = thePair[0].SourceFeatureID;
                                    thePError.SourcePointIndex = thePair[0].SourcePointIndex;
                                    thePError.ToPoint = theGapPolyline.ToPoint;

                                    theReturn.Add(thePError);
                                }

                                bFoundError = true;
                            }
                        }
                        if (bFoundError)
                            break;
                    }
                    if (bFoundError)
                        break;
                }

                if (++count % 500 == 0)
                    this.LogMessage("Processed gap " + count + " of " + pointPairs.Count);
            }

            return theReturn;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:95,代码来源:GeometryGap.cs


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