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


C# PolylineClass.Project方法代码示例

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


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

示例1: CreatePolyline

		// Creates Route polyline
		private void CreatePolyline(ISMDirections objDirections)
		{
			// create polyline
			IPolyline objLine = null;
			objLine = new PolylineClass();

			// get points collection
			IPointCollection objPoints = null;
			objPoints = objLine as IPointCollection;

			// Adds Directions points to polyline
			AddPointsToPolyline(objDirections, ref objPoints);

			// Project points to Map projection
			IMxDocument objDoc = m_application.Document as IMxDocument;
			IMap objMap = objDoc.FocusMap;
			objLine.Project(objMap.SpatialReference);

			// create path graphics element
			IElement objElement = null;
			objElement = new LineElementClass();

			objElement.Geometry = objLine;

			// Set line color width and style
			SetLineProperties(objElement);

            // get Graphic container
			IGraphicsContainer objCont = objMap as IGraphicsContainer;

			// Add line to map
			objCont.AddElement(objElement, 0);
		}
开发者ID:Esri,项目名称:arcobjects-sdk-community-samples,代码行数:34,代码来源:RoutingForm.cs

示例2: OnDblClick

        public override void OnDblClick()
        {
            base.OnDblClick ();

            IPolygon thePoly = this._Feedback.Stop();
            this._Feedback = null;

            // Check that the polygon is okay
            bool bOK = false;
            if (thePoly != null && thePoly.IsEmpty == false)
            {
                thePoly.Close();

                thePoly.SimplifyPreserveFromTo();

                IArea theArea = (IArea)thePoly;
                if (theArea.Area > 0)
                {
                    bOK = true;
                }
            }

            if (!bOK)
            {
                MessageBox.Show("Resultant polygon was not valid. Please try again.");
                return;
            }

            // Select features based on the polygon
            IMxApplication theMxApp = (IMxApplication)this._App;
            IMap theMap = this.Extension.FocusMap;
            thePoly.Project(theMap.SpatialReference);

            // Hold onto the original method for selection so we can set it back afterwards
            esriSpatialRelEnum theOriginalAreaMethod = theMxApp.SelectionEnvironment.AreaSelectionMethod;
            esriSpatialRelEnum theOriginalLineMethod = theMxApp.SelectionEnvironment.LinearSelectionMethod;
            esriSpatialRelEnum theOriginalPointMethod = theMxApp.SelectionEnvironment.PointSelectionMethod;

            if (this._Form.SelectType == SelectByPolygonForm.selectByPolyType.selectInside)
            {
                theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains;
                theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelContains;
                theMap.SelectByShape(thePoly, theMxApp.SelectionEnvironment, false);
                theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod;
                theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod;
            }
            else if (this._Form.SelectType == SelectByPolygonForm.selectByPolyType.selectInsideOrIntersecting)
            {
                theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMap.SelectByShape(thePoly, theMxApp.SelectionEnvironment, false);
                theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod;
                theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod;
            }
            else
            {
                // This one is not straightforward and we need to manipulate the polygon shape
                // Take the rings and buffer them by the pixel tolerance and then pass to ArcMap
                double pixelTol = theMxApp.SelectionEnvironment.SearchTolerance;
                double theBufferDistance = this.CalculateMapDistance(theMap, Convert.ToInt32(pixelTol));

                IPolyline theOutline = new PolylineClass();
                ISegmentCollection theSColl = (ISegmentCollection)thePoly;
                for (int i = 0; i < theSColl.SegmentCount; i++)
                    ((ISegmentCollection)theOutline).AddSegment(theSColl.get_Segment(i), ref _missing, ref _missing);

                theOutline.Project(theMap.SpatialReference);
                IPolygon theBuffer = (IPolygon)((ITopologicalOperator)theOutline).Buffer(theBufferDistance);

                theMxApp.SelectionEnvironment.AreaSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMxApp.SelectionEnvironment.PointSelectionMethod = esriSpatialRelEnum.esriSpatialRelIntersects;
                theMap.SelectByShape(theBuffer, theMxApp.SelectionEnvironment, false);
                theMxApp.SelectionEnvironment.AreaSelectionMethod = theOriginalAreaMethod;
                theMxApp.SelectionEnvironment.LinearSelectionMethod = theOriginalLineMethod;
                theMxApp.SelectionEnvironment.PointSelectionMethod = theOriginalPointMethod;
            }

            // Refresh the map
            IActiveView theAV = (IActiveView)theMap;
            theAV.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, theAV.Extent);
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:86,代码来源:SelectByPolygonTool.cs

示例3: Execute

        public override int Execute(string logfileName)
        {
            this.InitLogging(logfileName);
            this.LogMessage(this.Name + " QA test execution started.");

            int currentOid = -1;

            try
            {
                this.LogMessage(this.Name + " Parameters:");
                for (int i = 0; i < this.ParameterCount; i++)
                    this.LogMessage(this.get_ParameterText(i) + ": " + this.get_ParameterValue(i));

                this.ClearErrors();

                // Check the search radius
                int idx = this.FindParameter("search-radius");
                DoubleParameterInfo theInfo = (DoubleParameterInfo)this._params[idx];
                double theSearchRadius = (double)theInfo.ParamValue;

                if (theSearchRadius <= 0)
                {
                    this.LogMessage("Zero or negative value passed as search radius for " + this.Name + ". Stopping.");
                    return -1;
                }

                // Check the cluster tolerance
                idx = this.FindParameter("cluster-tolerance");
                theInfo = (DoubleParameterInfo)this._params[idx];
                double theCluster = (double)theInfo.ParamValue;

                if (theCluster >= theSearchRadius)
                {
                    this.LogMessage("Cluster tolerance equal to or larger than search radius for " + this.Name + ". Stopping.");
                    return -1;
                }

                // Convert them to metres
                idx = this.FindParameter("search-units");
                UnitsParameterInfo theUnitsParam = (UnitsParameterInfo)this._params[idx];
                esriUnits theUnits = theUnitsParam.ParamValueInUnits;
                IUnitConverter theConverter = new UnitConverterClass();
                theSearchRadius = theConverter.ConvertUnits(theSearchRadius, theUnits, esriUnits.esriMeters);
                theCluster = theConverter.ConvertUnits(theCluster, theUnits, esriUnits.esriMeters);

                // Get the canDefer/canExcept params
                idx = this.FindParameter(ParameterInfo.PARAM_CANDEFER);
                bool canDefer = (bool)((ParameterInfo)this._params[idx]).ParamValue;
                idx = this.FindParameter(ParameterInfo.PARAM_CANEXCEPT);
                bool canExcept = (bool)((ParameterInfo)this._params[idx]).ParamValue;

                // Loop through the layers
                for (int i = 0; i < this.LayerCount - 1; i++)
                {
                    IFeatureLayer theLayer1 = this.get_Layer(i);
                    if (this.SupportsGeometryType(theLayer1.FeatureClass.ShapeType) == false)
                        continue;

                    // Index the points in theLayer1
                    IDataset theDataset1 = (IDataset)theLayer1.FeatureClass;
                    IGeoDataset theGeoDS = (IGeoDataset)theDataset1;
                    IEnvelope theAOI = theGeoDS.Extent;
                    if (theAOI == null || theAOI.IsEmpty)
                        continue;

                    theAOI.Project(SpatialReferenceHelper.BCAlbersSpatialReference);
                    double theCellsize = theAOI.Width / 100;
                    this.LogMessage("Indexing features in " + theDataset1.Name + ". Cellsize (m): " + theCellsize);
                    PointCollectionIndex theIndex = new PointCollectionIndex(theCellsize);

                    IFeatureCursor theFCursor1 = null;
                    if (this.ConstrainToSelection)
                    {
                        ICursor theCursor = null;
                        IFeatureSelection theFSel = (IFeatureSelection)theLayer1;
                        theFSel.SelectionSet.Search(null, true, out theCursor);
                        theFCursor1 = (IFeatureCursor)theCursor;
                    }
                    else
                    {
                        theFCursor1 = theLayer1.Search(null, true);
                    }

                    IFeature theFeature1 = theFCursor1.NextFeature();
                    while (theFeature1 != null)
                    {
                        if (theFeature1.Shape != null && theFeature1.Shape.IsEmpty == false)
                        {
                            IPointCollection thePtColl = (IPointCollection)theFeature1.Shape;
                            for (int k = 0; k < thePtColl.PointCount; k++)
                            {
                                theIndex.AddPoint(new IndexPoint(theFeature1.OID, k, thePtColl.get_Point(k)));
                            }
                        }

                        theFeature1 = theFCursor1.NextFeature();
                    }

                    // Release the cursor
                    Marshal.ReleaseComObject(theFCursor1);
//.........这里部分代码省略.........
开发者ID:EAWCS1,项目名称:SUITT,代码行数:101,代码来源:GeometryLinework.cs

示例4: 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

示例5: 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

示例6: _form_ErrorSelection

        private void _form_ErrorSelection(object sender, ErrorSelectionEventArgs e)
        {
            IMap theMap = this.Extension.FocusMap;
            try
            {
                this._selectedErrors = null;

                bool bNeedsRefesh = false;
                if (this._extraFeedback != null)
                {
                    bNeedsRefesh = true;
                    IGraphicsContainer theGCont = util.GraphicsHelper.get_GraphicsContainer(theMap);
                    theGCont.DeleteElement(this._extraFeedback);
                    this._extraFeedback = null;
                }

                if (e.SelectedIDs != null)
                {
                    this._selectedErrors = new dao.QAError[e.SelectedIDs.Length];
                    for (int i = 0; i < this._selectedErrors.Length; i++)
                    {
                        this._selectedErrors[i] = this.Extension.QAManager.FindQAError(e.SelectedIDs[i]);
                    }
                }

                // We're manipulating the map selection, stop listening to events for a moment
                try
                {
                    this._bIgnoreSelectionEvents = true;
                    IFeatureSelection theFSel = (IFeatureSelection)this.ErrorLayer;
                    if (this._selectedErrors != null && this._selectedErrors.Length > 0)
                    {
                        bNeedsRefesh = true;
                        IQueryFilter theQF = new QueryFilterClass();
                        theQF.WhereClause = "OBJECTID in (" + this._selectedErrors[0].ObjectID;
                        for (int i = 1; i < this._selectedErrors.Length && i < 100; i++)
                        {
                            theQF.WhereClause += ", " + this._selectedErrors[i].ObjectID;
                        }
                        theQF.WhereClause += ")";
                        theFSel.SelectFeatures(theQF, esriSelectionResultEnum.esriSelectionResultNew, false);
                        Application.DoEvents();
                    }
                    else if (theFSel.SelectionSet.Count > 0)
                    {
                        bNeedsRefesh = true;
                        IQueryFilter theQF = new QueryFilterClass();
                        theQF.WhereClause = "OBJECTID < 0";
                        theFSel.SelectFeatures(theQF, esriSelectionResultEnum.esriSelectionResultNew, false);
                        Application.DoEvents();
                    }
                }
                finally
                {
                    this._bIgnoreSelectionEvents = false;
                }

                if (this._selectedErrors != null && this._selectedErrors.Length == 1)
                {
                    this._form.SetDetailError(this._selectedErrors[0]);

                    // Put a graphic on the map
                    ExtendedInfo theInfo = new ExtendedInfo();
                    theInfo.ReadXML(this._selectedErrors[0].Error.ExtendedData);

                    double x1 = double.NaN; double y1 = double.NaN;
                    double x2 = double.NaN; double y2 = double.NaN;

                    Hashtable theProperties = theInfo.Properties;
                    foreach (object key in theProperties.Keys)
                    {
                        string strkey = key.ToString().ToUpper();
                        if (strkey.Equals("FROM POINT X"))
                            x1 = Convert.ToDouble(theProperties[key]);
                        else if (strkey.Equals("FROM POINT Y"))
                            y1 = Convert.ToDouble(theProperties[key]);
                        else if (strkey.Equals("TO POINT X"))
                            x2 = Convert.ToDouble(theProperties[key]);
                        else if (strkey.Equals("TO POINT Y"))
                            y2 = Convert.ToDouble(theProperties[key]);
                    }

                    if (!double.IsNaN(x1) && !double.IsNaN(y1) && !double.IsNaN(x2) && !double.IsNaN(y2))
                    {
                        bNeedsRefesh = true;

                        IPoint p1 = new PointClass();
                        p1.PutCoords(x1, y1);
                        p1.Project(this.GeographicReference);
                        IPoint p2 = new PointClass();
                        p2.PutCoords(x2, y2);
                        p2.Project(this.GeographicReference);

                        object theMissing = Type.Missing;
                        IPolyline thePolyline = new PolylineClass();
                        thePolyline.Project(this.GeographicReference);
                        ((IPointCollection)thePolyline).AddPoint(p1, ref theMissing, ref theMissing);
                        ((IPointCollection)thePolyline).AddPoint(p2, ref theMissing, ref theMissing);

                        thePolyline.Project(theMap.SpatialReference);
//.........这里部分代码省略.........
开发者ID:EAWCS1,项目名称:SUITT,代码行数:101,代码来源:ErrorManagerCmd.cs


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