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


C# Line.PutCoords方法代码示例

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


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

示例1: GetRelativeOrientation_org

        private RelativeOrientation GetRelativeOrientation_org(IPolycurve pFoundLineAsPolyCurve, IPolycurve inPolycurve)
        {
            //iRelativeOrientation == 1 --> closest points are original TO and found TO
            //iRelativeOrientation == 2 --> closest points are original TO and found FROM
            //iRelativeOrientation == 3 --> closest points are original FROM and found TO
            //iRelativeOrientation == 4 --> closest points are original FROM and found FROM

            Dictionary<int, double> dictSort2GetShortest = new Dictionary<int, double>();

            ILine pFoundTo_2_OriginalTo = new Line();
            pFoundTo_2_OriginalTo.PutCoords(pFoundLineAsPolyCurve.ToPoint, inPolycurve.ToPoint);
            dictSort2GetShortest.Add(1, pFoundTo_2_OriginalTo.Length);

            ILine pFoundFrom_2_OriginalTo = new Line();
            pFoundFrom_2_OriginalTo.PutCoords(pFoundLineAsPolyCurve.FromPoint, inPolycurve.ToPoint);
            dictSort2GetShortest.Add(2, pFoundFrom_2_OriginalTo.Length);

            ILine pFoundTo_2_OriginalFrom = new Line();
            pFoundTo_2_OriginalFrom.PutCoords(pFoundLineAsPolyCurve.ToPoint, inPolycurve.FromPoint);
            dictSort2GetShortest.Add(3, pFoundTo_2_OriginalFrom.Length);

            ILine pFoundFrom_2_OriginalFrom = new Line();
            pFoundFrom_2_OriginalFrom.PutCoords(pFoundLineAsPolyCurve.FromPoint, inPolycurve.FromPoint);
            dictSort2GetShortest.Add(4, pFoundFrom_2_OriginalFrom.Length);

            var sortedDict = from entry in dictSort2GetShortest orderby entry.Value ascending select entry;
            var pEnum = sortedDict.GetEnumerator();
            pEnum.MoveNext(); //get the first key for the shortest line
            var pair = pEnum.Current;
            int iOpt = pair.Key;
            return (RelativeOrientation)iOpt;
        }
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:32,代码来源:CurveByInference.cs

示例2: GetTangentCurveMatchFeatures

        public List<RelatedCurve> GetTangentCurveMatchFeatures(IFeatureClass FeatureClass, IFeature inFeature, IPolycurve inPolycurve, string WhereClause,
                                                int idxRadius, int idxCenterPointID,
                                                double SegementLength, out List<RelatedLine> tangentLines)
            //double AngleToleranceTangentCompareInDegrees, double StraightLinesBreakLessThanInDegrees, 
            //double MaximumDeltaInDegrees, double ExcludeTangentsShorterThan,
            //                                     out int outFoundTangentCurvesCount, ref List<RelatedCurve> CurveInfoFromNeighbours)
        {
            List<RelatedCurve> CurveInfoFromNeighbours = new List<RelatedCurve>();
            tangentLines = new List<RelatedLine>();

            ILine pOriginalChord = (ILine)new Line();
            pOriginalChord.PutCoords(inPolycurve.FromPoint, inPolycurve.ToPoint);
            IVector3D vecOriginalSelected = (IVector3D)new Vector3D();
            vecOriginalSelected.PolarSet(pOriginalChord.Angle, 0, 1);

            IGeometryBag pGeomBag = (IGeometryBag)new GeometryBag();
            IGeometryCollection pGeomColl = (IGeometryCollection)pGeomBag;

            IGeometry MultiPartPolyLine = (IGeometry)new Polyline(); //qi
            IGeoDataset pGeoDS = (IGeoDataset)FeatureClass;
            ISpatialReference spatialRef = pGeoDS.SpatialReference;
            MultiPartPolyLine.SpatialReference = spatialRef;

            IGeometryCollection geometryCollection2 = MultiPartPolyLine as IGeometryCollection;

            ILine inGeomTangentLineAtEnd = new Line(); //new
            ILine inGeomTangentLineAtStart = new Line(); //new
            object objMissing = Type.Missing;

            for (int i = 0; i < 2; i++)
            {
                ILine pThisLine = null;
                if (i == 0)
                {
                    //Add line tangent at end point
                    inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtTo, 1.0, true, CurveByInferenceSettings.Instance.TangentQueryLength, inGeomTangentLineAtEnd);
                    pThisLine = new Line();
                    pThisLine.PutCoords(inGeomTangentLineAtEnd.FromPoint, inGeomTangentLineAtEnd.ToPoint);
                    pGeomColl.AddGeometry(pThisLine);
                }
                else
                {
                    //Add line tangent at start point
                    inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0.0, true, CurveByInferenceSettings.Instance.TangentQueryLength, inGeomTangentLineAtStart);
                    pThisLine = new Line();
                    pThisLine.PutCoords(inGeomTangentLineAtStart.FromPoint, inGeomTangentLineAtStart.ToPoint);
                    pGeomColl.AddGeometry(pThisLine);
                }
                //Create a new path for each line.

                ISegmentCollection newPath = (ISegmentCollection)new Path();
                newPath.AddSegment((ISegment)pThisLine, ref objMissing, ref objMissing);
                //The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments.
                geometryCollection2.AddGeometry(newPath as IGeometry, ref objMissing, ref objMissing);
            }

            //now buffer the tangent lines
            IGeometryCollection outBufferedGeometryCol = (IGeometryCollection)new GeometryBag();
            for (int jj = 0; jj < geometryCollection2.GeometryCount; jj++)
            {
                IPath pPath = geometryCollection2.get_Geometry(jj) as IPath;
                IGeometryCollection pPolyL = (IGeometryCollection)new Polyline();
                pPolyL.AddGeometry((IGeometry)pPath);

                ITopologicalOperator topologicalOperator = (ITopologicalOperator)pPolyL;
                IPolygon pBuffer = topologicalOperator.Buffer(CurveByInferenceSettings.Instance.TangentQueryBuffer) as IPolygon;
                outBufferedGeometryCol.AddGeometry(pBuffer, ref objMissing, ref objMissing);
            }
            ITopologicalOperator pUnionedBuffers = null;
            pUnionedBuffers = new Polygon() as ITopologicalOperator;
            pUnionedBuffers.ConstructUnion((IEnumGeometry)outBufferedGeometryCol);

            ISpatialFilter pSpatFilt = new SpatialFilter();
            pSpatFilt.WhereClause = WhereClause;
            pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

            pSpatFilt.Geometry = (IGeometry)pUnionedBuffers;

            IFeatureCursor pFeatCursLines = null;
            try
            {
                pFeatCursLines = FeatureClass.Search(pSpatFilt, false);
            }
            catch (Exception ex)
            {
                messageBox.Show(ex.Message);
                return CurveInfoFromNeighbours;
            }
            IVector3D foundGeomVector = (IVector3D)new Vector3D();
            IFeature foundFeature = null;
            bool bHasTangentStraightLineAtJunction = false;

            //A list of relative orientation values that have large breaks
            List<RelativeOrientation> lstLargeBreak = new List<RelativeOrientation>();

            while ((foundFeature = pFeatCursLines.NextFeature()) != null)
            {
                if (inFeature.OID == foundFeature.OID)
                {
//.........这里部分代码省略.........
开发者ID:travisval,项目名称:ParcelFabricCurveByInference,代码行数:101,代码来源:CurveByInference.cs

示例3: HasParallelCurveMatchFeatures

        public bool HasParallelCurveMatchFeatures(IFeatureClass FeatureClass, IPolycurve inPolycurve, string WhereClause,
      double AngleToleranceTangentCompareInDegrees, double OrthogonalSearchDistance,
       out int outFoundLinesCount, out int outFoundParallelCurvesCount, ref List<string> CurveInfoFromNeighbours)
        {
            outFoundLinesCount = 0;
              outFoundParallelCurvesCount = 0;

              ILine pOriginalChord = new Line();
              pOriginalChord.PutCoords(inPolycurve.FromPoint, inPolycurve.ToPoint);
              IVector3D vecOriginalSelected = new Vector3DClass();
              vecOriginalSelected.PolarSet(pOriginalChord.Angle, 0, 1);

              int idxRadius = FeatureClass.FindField("RADIUS");
              if (idxRadius == -1)
            return false;

              int idxCenterPointID = FeatureClass.FindField("CENTERPOINTID");
              if (idxCenterPointID == -1)
            return false;

              object val = null;

              IGeometryBag pGeomBag = new GeometryBagClass();
              IGeometryCollection pGeomColl = (IGeometryCollection)pGeomBag;

              IGeometry MultiPartPolyLine = new PolylineClass(); //qi
              IGeoDataset pGeoDS = (IGeoDataset)FeatureClass;
              ISpatialReference spatialRef = pGeoDS.SpatialReference;
              MultiPartPolyLine.SpatialReference = spatialRef;

              IGeometryCollection geometryCollection2 = MultiPartPolyLine as IGeometryCollection;

              ILine pNormalLine = new Line(); //new
              for (int i = -1; i < 2; i = i + 2)
              {
            double dOffset = OrthogonalSearchDistance * i;

            inPolycurve.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, dOffset, pNormalLine);
            ILine pThisLine = new Line();

            pThisLine.PutCoords(pNormalLine.FromPoint, pNormalLine.ToPoint);
            pGeomColl.AddGeometry(pThisLine);

            //Although each line is connected to the other, create a new path for each line
            //this allows for future changes in case the input needs to be altered to separate paths.

            ISegmentCollection newPath = new PathClass();
            object obj = Type.Missing;
            newPath.AddSegment((ISegment)pThisLine, ref obj, ref obj);
            //The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments.
            geometryCollection2.AddGeometry(newPath as IGeometry, ref obj, ref obj);
              }

              ISpatialFilter pSpatFilt = new SpatialFilter();
              pSpatFilt.WhereClause = WhereClause;
              pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
              pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

              pSpatFilt.Geometry = pGeomBag;

              IFeatureCursor pFeatCursLines = null;
              try
              {
            pFeatCursLines = FeatureClass.Search(pSpatFilt, false);
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return false;
              }

              IFeature pFeat = pFeatCursLines.NextFeature();
              while (pFeat != null)
              {
            IGeometry pFoundLineGeom = pFeat.ShapeCopy;

            //if the feature has no radius attribute, skip.
            double dRadius = 0;
            int iCtrPoint = -1;
            val = pFeat.get_Value(idxRadius);
            if (val == DBNull.Value)
              dRadius = 0;
            else
              dRadius = (double)val;

            if (dRadius == 0)
            {//null or zero radius so skip.
              Marshal.ReleaseComObject(pFeat);
              pFeat = pFeatCursLines.NextFeature();
              continue;
            }

            val = pFeat.get_Value(idxCenterPointID);
            if (val == DBNull.Value)
            {//null centrpointID so skip.
              Marshal.ReleaseComObject(pFeat);
              pFeat = pFeatCursLines.NextFeature();
              continue;
            }

//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:Utilities.cs

示例4: HasTangentCurveMatchFeatures

        public bool HasTangentCurveMatchFeatures(IFeatureClass FeatureClass, IPolycurve inPolycurve, string WhereClause,
  double AngleToleranceTangentCompareInDegrees, double StraightLinesBreakLessThanInDegrees, double MaximumDeltaInDegrees, double ExcludeTangentsShorterThan, 
      out int outFoundTangentCurvesCount, ref List<string> CurveInfoFromNeighbours)
        {
            outFoundTangentCurvesCount = 0;

              ILine pOriginalChord = new Line();
              pOriginalChord.PutCoords(inPolycurve.FromPoint, inPolycurve.ToPoint);
              IVector3D vecOriginalSelected = new Vector3DClass();
              vecOriginalSelected.PolarSet(pOriginalChord.Angle, 0, 1);

              int idxRadius = FeatureClass.FindField("RADIUS");
              if (idxRadius == -1)
            return false;

              int idxCenterPointID = FeatureClass.FindField("CENTERPOINTID");
              if (idxCenterPointID == -1)
            return false;

              object val = null;

              IGeometryBag pGeomBag = new GeometryBagClass();
              IGeometryCollection pGeomColl = (IGeometryCollection)pGeomBag;

              IGeometry MultiPartPolyLine = new PolylineClass(); //qi
              IGeoDataset pGeoDS = (IGeoDataset)FeatureClass;
              ISpatialReference spatialRef = pGeoDS.SpatialReference;
              MultiPartPolyLine.SpatialReference = spatialRef;

              IGeometryCollection geometryCollection2 = MultiPartPolyLine as IGeometryCollection;

              ILine pTangentLineAtEnd = new Line(); //new
              ILine pTangentLineAtStart = new Line(); //new
              object objMissing = Type.Missing;

              for (int i = 0; i < 2; i++)
              {
            ILine pThisLine = null;
            if (i == 0)
            {
              inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtTo, 1.0, true, 0.2, pTangentLineAtEnd);
              pThisLine = new Line();
              pThisLine.PutCoords(pTangentLineAtEnd.FromPoint, pTangentLineAtEnd.ToPoint);
              pGeomColl.AddGeometry(pThisLine);
            }
            else
            {
              inPolycurve.QueryTangent(esriSegmentExtension.esriExtendAtFrom, 0.0, true, 0.2, pTangentLineAtStart);
              pThisLine = new Line();
              pThisLine.PutCoords(pTangentLineAtStart.FromPoint, pTangentLineAtStart.ToPoint);
              pGeomColl.AddGeometry(pThisLine);
            }
            //Create a new path for each line.

            ISegmentCollection newPath = new PathClass();
            newPath.AddSegment((ISegment)pThisLine, ref objMissing, ref objMissing);
            //The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments.
            geometryCollection2.AddGeometry(newPath as IGeometry, ref objMissing, ref objMissing);
              }

              //now buffer the lines
              IGeometryCollection outBufferedGeometryCol = new GeometryBagClass();
              for (int jj = 0; jj < geometryCollection2.GeometryCount; jj++)
              {
            IPath pPath = geometryCollection2.get_Geometry(jj) as IPath;
            IGeometryCollection pPolyL = new PolylineClass();
            pPolyL.AddGeometry((IGeometry)pPath);

            ITopologicalOperator topologicalOperator = (ITopologicalOperator)pPolyL;
            IPolygon pBuffer = topologicalOperator.Buffer(0.1) as IPolygon;
            outBufferedGeometryCol.AddGeometry(pBuffer, ref objMissing, ref objMissing);
              }
              ITopologicalOperator pUnionedBuffers = null;
              pUnionedBuffers = new PolygonClass() as ITopologicalOperator;
              pUnionedBuffers.ConstructUnion((IEnumGeometry)outBufferedGeometryCol);

              ISpatialFilter pSpatFilt = new SpatialFilter();
              pSpatFilt.WhereClause = WhereClause;
              pSpatFilt.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
              pSpatFilt.SearchOrder = esriSearchOrder.esriSearchOrderSpatial;

              pSpatFilt.Geometry = (IGeometry)pUnionedBuffers;

              IFeatureCursor pFeatCursLines = null;
              try
              {
            pFeatCursLines = FeatureClass.Search(pSpatFilt, false);
              }
              catch (Exception ex)
              {
            MessageBox.Show(ex.Message);
            return false;
              }
              IVector3D vecFoundGeom = new Vector3DClass();
              IFeature pFeat = pFeatCursLines.NextFeature();
              bool bHasTangentStraightLineAtJunction = false;
              List<int> lstLargeBreak = new List<int>();

              while (pFeat != null)
              {
//.........这里部分代码省略.........
开发者ID:Esri,项目名称:parcel-fabric-desktop-addins,代码行数:101,代码来源:Utilities.cs

示例5: drawLineGraphic

        private void drawLineGraphic(double Size, bool bHor = true)
        {
            IMxDocument pMxDoc = m_pDoc;
            IActiveView pActiveView;
            IScreenDisplay pScreenDisplay;

            IEnvelope pEnv;
            IPoint pCenterPoint;
            IDisplayTransformation pTransform;

            pActiveView = pMxDoc.FocusMap as IActiveView;
            pScreenDisplay = pActiveView.ScreenDisplay;

            pTransform = pScreenDisplay.DisplayTransformation;
            pEnv = pTransform.FittedBounds;
            pCenterPoint = new Point();
            pCenterPoint.PutCoords((pEnv.XMax + pEnv.XMin) / 2, (pEnv.YMax + pEnv.YMin) / 2);

            ILine pLine;
            IPolyline pPolyline;
            IGeometryCollection pGeomColl;
            ISegmentCollection pSegColl;

            Size /= 2;

            IPoint pPointFrom;
            IPoint pPointTo;

            pSegColl = new Path() as ISegmentCollection;
            pGeomColl = new Polyline() as IGeometryCollection;

            // UN
            pPointFrom = new Point();
            if (bHor) { pPointFrom.PutCoords(pCenterPoint.X - Size, pCenterPoint.Y); }
            else { pPointFrom.PutCoords(pCenterPoint.X, pCenterPoint.Y - Size); }

            pPointTo = new Point();
            if (bHor) { pPointTo.PutCoords(pCenterPoint.X + Size, pCenterPoint.Y); }
            else { pPointTo.PutCoords(pCenterPoint.X, pCenterPoint.Y + Size); }

            pLine = new Line();
            pLine.PutCoords(pPointFrom, pPointTo);
            pSegColl.AddSegment(pLine as ISegment);

            // Add to final
            pGeomColl.AddGeometry(pSegColl as IGeometry);
            pPolyline = pGeomColl as IPolyline;

            IRgbColor pLineColor = new RgbColor();
            pLineColor.Red = 255; // A CHANGER!!!

            addGraphicToMap(pMxDoc.FocusMap, pPolyline, pLineColor, pLineColor);

            pPointFrom = null;
            pPointTo = null;
            pLine = null;
            pPolyline = null;
            pGeomColl = null;
            pSegColl = null;
        }
开发者ID:GroupeDDM,项目名称:saisieforestiere10,代码行数:60,代码来源:SF10_extMain.cs


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