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


C# PolylineClass.ConstructUnion方法代码示例

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


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

示例1: get_GraphicShape

        private static IGeometry get_GraphicShape(IEnumElement theElements, int a_Dimensionality, bool multipart, ref IElementCollection elemCollection)
        {
            IGeometry theReturn = null;
            IGeometryCollection theGeomColl = null;
            object missing = Type.Missing;

            try
            {
                elemCollection.Clear();

                if (theElements != null)
                {
                    theElements.Reset();
                    IElement theElement = theElements.Next();
                    while (theElement != null)
                    {
                        if (theGeomColl == null)
                            theGeomColl = new GeometryBagClass();

                        IGeometry theShape = null;
                        if (theElement is IGroupElement)
                        {
                            theShape = get_GraphicShape(((IGroupElement)theElement).Elements, a_Dimensionality, multipart,ref elemCollection);
                        }
                        else if (theElement is ICircleElement
                            || theElement is IPolygonElement
                            || theElement is IRectangleElement
                            || theElement is IEllipseElement
                            || theElement is ILineElement
                            || theElement is IMarkerElement)
                            theShape = theElement.Geometry;

                        if (theShape != null)
                            theGeomColl.AddGeometry(theShape, ref missing, ref missing);

                        elemCollection.Add(theElement,-1);

                        theElement = theElements.Next();
                    }
                }

                if (theGeomColl != null && theGeomColl.GeometryCount > 0)
                {
                    ITopologicalOperator theTopoOp = null;

                    switch (a_Dimensionality)
                    {
                        case 0:
                            if (multipart)
                            {
                                theTopoOp = new MultipointClass();
                                theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            }
                            else
                                theTopoOp = theGeomColl.get_Geometry(0) as ITopologicalOperator;
                            break;
                        case 1:
                            theTopoOp = new PolylineClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            break;
                        case 2:
                            theTopoOp = new PolygonClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                            break;
                    }

                    theReturn = theTopoOp as IGeometry;
                }
            }
            catch(Exception ex)
            {
                util.Logger.Write(" Descrip  : Finding elements with a specific dimensionality. " +
                    "\n Message  : " + ex.Message +
                    "\n StackTrc : " + ex.StackTrace,util.Logger.LogLevel.Debug);

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

示例2: get_GraphicShape

        public static IGeometry get_GraphicShape(IEnumElement theElements, int a_Dimensionality, bool multipart)
        {
            IGeometry theReturn = null;
            IGeometryCollection theGeomColl = null;
            object missing = Type.Missing;

            if (theElements != null)
            {
                theElements.Reset();
                IElement theElement = theElements.Next();
                while (theElement != null)
                {
                    if (theGeomColl == null)
                        theGeomColl = new GeometryBagClass();

                    IGeometry theShape = null;
                    if (theElement is IGroupElement)
                    {
                        theShape = get_GraphicShape(((IGroupElement)theElement).Elements, a_Dimensionality, multipart);
                    }
                    else if (theElement is ICircleElement
                        || theElement is IPolygonElement
                        || theElement is IRectangleElement
                        || theElement is IEllipseElement
                        || theElement is ILineElement
                        || theElement is IMarkerElement)
                        theShape = theElement.Geometry;

                    if (theShape != null)
                        theGeomColl.AddGeometry(theShape, ref missing, ref missing);

                    theElement = theElements.Next();
                }
            }

            if (theGeomColl != null && theGeomColl.GeometryCount > 0)
            {
                ITopologicalOperator theTopoOp = null;

                switch (a_Dimensionality)
                {
                    case 0:
                        if (multipart)
                        {
                            theTopoOp = new MultipointClass();
                            theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        }
                        else
                            theTopoOp = theGeomColl.get_Geometry(0) as ITopologicalOperator;
                        break;
                    case 1:
                        theTopoOp = new PolylineClass();
                        theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        break;
                    case 2:
                        theTopoOp = new PolygonClass();
                        theTopoOp.ConstructUnion((IEnumGeometry)theGeomColl);
                        break;
                }

                theReturn = theTopoOp as IGeometry;
            }
            return theReturn;
        }
开发者ID:EAWCS1,项目名称:SUITT,代码行数:64,代码来源:GraphicToFeatureCmd.cs

示例3: btnOK_Click


//.........这里部分代码省略.........
                        IFeature trailFromPrevSection = trailFC.GetFeature(Convert.ToInt32(oid));
                        if (waypointOID == "")
                        {
                            geomCol.AddGeometry(trailFromPrevSection.ShapeCopy);
                        }
                        else
                        {
                            IFeature startKMPost = waypointFC.GetFeature(startKmOID);
                            IPoint startKMPoint = startKMPost.ShapeCopy as IPoint;
                            IPoint endPointOnFirstLine = waypointFC.GetFeature(Convert.ToInt32(waypointOID)).ShapeCopy as IPoint;
                            ICurve curve = trailFromPrevSection.ShapeCopy as ICurve;
                            bool brs = true; double dfc = 0; double dacToKMPoint = -1; double dacToWayPointOnPath = -1;
                            IPoint outStartPoint = new PointClass();
                            curve.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, startKMPoint, false, outStartPoint, ref dacToKMPoint, ref dfc, ref brs);
                            curve.QueryPointAndDistance(esriSegmentExtension.esriNoExtension, endPointOnFirstLine, false, outStartPoint, ref dacToWayPointOnPath, ref dfc, ref brs);
                            ICurve outCurve = new PolylineClass();
                            double fromDistance = dacToKMPoint;
                            double toDistance = dacToWayPointOnPath;
                            if (dacToWayPointOnPath < dacToKMPoint)
                            {
                                fromDistance = dacToWayPointOnPath;
                                toDistance = dacToKMPoint;
                            }
                            curve.GetSubcurve(fromDistance, toDistance, false, out outCurve);
                            geomCol.AddGeometry(outCurve);

                        }
                    }
                }

                //Total segments is the number of segments in the section, but does NOT include all the segments that might be used to build the km post.
                double averageCosineValue = 1.0 / (totalCosValues / totalSegments);
                ITopologicalOperator unionedPolyline = new PolylineClass();
                unionedPolyline.ConstructUnion(geomCol as IEnumGeometry);
                IPolyline fullTrail = unionedPolyline as IPolyline;
                IPoint fromPoint2 = fullTrail.FromPoint;
                IPoint toPoint2 = fullTrail.ToPoint;
                List<IPoint> endPoints = new List<IPoint>() { fromPoint2, toPoint2 };
                foreach (IPoint pnt in endPoints)
                {
                    ISpatialFilter spatFilter = new SpatialFilterClass();
                    spatFilter.Geometry = pnt;
                    spatFilter.GeometryField = "SHAPE";
                    spatFilter.WhereClause = "OBJECTID = " + startKmOID;
                    spatFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
                    feCur = waypointFC.Search(spatFilter, false);
                    IFeature wayPointFe = feCur.NextFeature();

                    if (wayPointFe != null)
                    {
                        if (wayPointFe.OID != startKmOID)
                        {
                            //The from point of the unioned polyline doesn't match, so we have to reverse direction.
                            fullTrail.ReverseOrientation();
                        }
                        int splitIndex = 1;
                        int kmAlongTrail = startKmPost;
                        while (true)
                        {
                            double splitDistance = splitIndex * 1000 * averageCosineValue;
                            if (splitDistance > fullTrail.Length)
                            {
                                break;
                            }
                            IPoint outPoint = new PointClass();
                            fullTrail.QueryPoint(esriSegmentExtension.esriNoExtension, splitDistance, false, outPoint);
开发者ID:RiverTaig,项目名称:GDT,代码行数:67,代码来源:Form1.cs


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