Exemplo n.º 1
0
        private void method_9(IActiveView pView, IPoint point, double num, bool flag, IRgbColor color)
        {
            this.method_8(point, num, flag);
            ISegmentCollection segmentCollection = new Polygon() as ISegmentCollection;
            ICircularArc       circularArc       = this.method_8(point, num, flag);
            object             missing           = Type.Missing;

            segmentCollection.AddSegment(circularArc as ISegment, ref missing, ref missing);
            ICircleElement circleElement = new CircleElement() as ICircleElement;
            IElement       element       = (IElement)circleElement;

            element.Geometry = (segmentCollection as IGeometry);
            IFillShapeElement fillShapeElement = (IFillShapeElement)circleElement;
            ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();
            ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol();

            simpleLineSymbol.Color   = (color);
            simpleLineSymbol.Width   = (2.0);
            simpleLineSymbol.Style   = (0);
            simpleFillSymbol.Color   = (color);
            simpleFillSymbol.Style   = (esriSimpleFillStyle)(1);
            simpleFillSymbol.Outline = (simpleLineSymbol);
            fillShapeElement.Symbol  = (simpleFillSymbol);
            IGraphicsContainer graphicsContainer = (IGraphicsContainer)pView;

            graphicsContainer.AddElement((IElement)circleElement, 0);
        }
Exemplo n.º 2
0
        private int CheckCircularArc([NotNull] ICircularArc circularArc,
                                     [NotNull] IRow row)
        {
            IPoint centerPoint = circularArc.CenterPoint;

            if (centerPoint == null || centerPoint.IsEmpty)
            {
                return(ReportError("Circular arc has no center point",
                                   GetErrorGeometry((ISegment)circularArc),
                                   Codes[Code.CicularArc_NoCenterPoint],
                                   TestUtils.GetShapeFieldName(row),
                                   row));
            }

            if (circularArc.ChordHeight < _minimumChordHeight)
            {
                return(ReportError(
                           string.Format("Chord height of circular arc is too small ({0})",
                                         FormatLengthComparison(circularArc.ChordHeight, "<",
                                                                _minimumChordHeight,
                                                                _spatialReference)),
                           GetErrorGeometry((ISegment)circularArc),
                           Codes[Code.CircularArc_ChordHeightTooSmall],
                           TestUtils.GetShapeFieldName(row),
                           row));
            }

            // add checks as needed
            return(NoError);
        }
Exemplo n.º 3
0
 public override void OnMouseDown(int Button, int int_1, int int_2, int int_3)
 {
     if (Button == 1)
     {
         IActiveView activeView = (IActiveView)this._context.FocusMap;
         IPoint      point      = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3);
         if (this.idisplayFeedback_0 == null)
         {
             this.idisplayFeedback_0         = new NewCircleFeedback();
             this.idisplayFeedback_0.Display = activeView.ScreenDisplay;
             (this.idisplayFeedback_0 as INewCircleFeedback).Start(point);
         }
         else
         {
             try
             {
                 ICircularArc circularArc = (this.idisplayFeedback_0 as INewCircleFeedback).Stop();
                 this.idisplayFeedback_0 = null;
                 ISegmentCollection segmentCollection = new Polygon() as ISegmentCollection;
                 object             value             = Missing.Value;
                 segmentCollection.AddSegment(circularArc as ISegment, ref value, ref value);
                 (segmentCollection as IGeometry).SpatialReference = this._context.FocusMap.SpatialReference;
                 this._context.FocusMap.ClipGeometry            = (segmentCollection as IGeometry);
                 (this._context.FocusMap as IActiveView).Extent = (segmentCollection as IGeometry).Envelope;
                 this._context.ActiveView.Refresh();
             }
             catch (Exception)
             {
             }
         }
     }
 }
Exemplo n.º 4
0
 public override void OnMouseUp(int button, int shift, int x, int y)
 {
     if (this._circleFeedback != null)
     {
         try
         {
             ICircularArc circularArc = this._circleFeedback.Stop();
             if (circularArc == null || circularArc.IsEmpty)
             {
                 this._circleFeedback = null;
                 return;
             }
             this._circleFeedback = null;
             IPolygon polygon = new Polygon() as IPolygon;
             object   value   = Missing.Value;
             (polygon as ISegmentCollection).AddSegment(circularArc as ISegment, ref value, ref value);
             _plugin.FireFenceAdded(new FenceAddedArgs((IGeometry)polygon));
             IActiveView activeView = this._context.FocusMap as IActiveView;
             activeView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, polygon.Envelope);
         }
         catch (Exception exception_)
         {
             //CErrorLog.writeErrorLog(this, exception_, "");
         }
     }
 }
Exemplo n.º 5
0
        private void DrawCircleByCenterAndRadius(ILayer pLayer, ICircularArc pCircularArc, IScreenDisplay pScreenDisplay)
        {
            object o = Type.Missing;

            if (pLayer != null)
            {
                ISegmentCollection pSegmentCollection = null;
                pSegmentCollection = new PathClass();
                if (pLayer is IFeatureLayer)
                {
                    IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                    if (pFeatureClass != null)
                    {
                        ISegment pSegment = pCircularArc as ISegment;
                        pSegmentCollection.AddSegment(pSegment, ref o, ref o);
                        IGeometryCollection pPolyline = new PolylineClass();
                        //通过IGeometryCollection为Polyline对象添加Path对象
                        pPolyline.AddGeometry(pSegmentCollection as IGeometry, ref o, ref o);
                        IFeature pCircleFeature = pFeatureClass.CreateFeature();
                        pCircleFeature.Shape = pPolyline as PolylineClass;
                        pCircleFeature.Store();

                        //局部刷新
                        IInvalidArea pInvalidArea = new InvalidAreaClass();
                        pInvalidArea.Add(pCircularArc);
                        pInvalidArea.Display = pScreenDisplay;
                        pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);

                        //20140410 lyf
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 绘制圆弧
        /// </summary>
        /// <params name="pCircleArc"></params>
        private void DrawArc(ICircularArc pCircleArc)
        {
            if (pCircleArc == null)
            {
                return;
            }

            ISegmentCollection pSegColl;
            IPolyline          pPolyline;

            pSegColl = new PolylineClass();
            pSegColl.AddSegment(pCircleArc as ISegment);
            pPolyline = pSegColl as IPolyline;

            IRgbColor pColor = new RgbColor();

            pColor.Red   = 0;
            pColor.Green = 0;
            pColor.Blue  = 0;

            m_LineSym       = new SimpleLineSymbol();
            m_LineSym.Color = pColor;
            m_LineSym.Width = 1;
            m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

            ISymbol pSym = m_LineSym as ISymbol;

            pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            m_pLineFeedback.Symbol = pSym;

            m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
            m_hookHelper.ActiveView.ScreenDisplay.DrawPolyline(pPolyline);
            m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();
        }
Exemplo n.º 7
0
        public static ICircularArc CreateCircArc(IPoint pCenter, IPoint pFrom, ref IPoint pTo)
        {
            ICircularArc circularArcClass = null;

            circularArcClass = new CircularArc();
            circularArcClass.PutCoords(pCenter, pFrom, pTo, esriArcOrientation.esriArcClockwise);
            return(circularArcClass);
        }
Exemplo n.º 8
0
        private IPointCollection IntersectPointColl(ICircularArc circularArc, IPolyline coastline)
        {
            IPolyline            circlePolyline = Arc2Polyline(circularArc);
            ITopologicalOperator topOperator    = (ITopologicalOperator)circlePolyline;
            IGeometry            interGeometry  = (IGeometry)topOperator.Intersect(coastline, esriGeometryDimension.esriGeometry0Dimension);
            IPointCollection     interPointColl = (IPointCollection)interGeometry;

            return(interPointColl);
        }
Exemplo n.º 9
0
        public static List <int> getSelectedBuildings(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));
            double angle             = (toAngle - fromAngle + 360) % 360;
            bool   isCCW             = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            else if (angle == 0)
            {
                angle = 360;
            }

            double arcDistance = radius * GeometricUtilities.GetRadians(angle);

            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance); //逆时针
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);
            IPolygon            pPolygon     = polygon as IPolygon;

            IGeometry pGeometry = GeometryUtilities.ConvertProjToGeo(pPolygon as IGeometry);

            IFeatureLayer pFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.Projecton) as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;

            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry      = pGeometry;
            spatialFilter.GeometryField = pFeatureClass.ShapeFieldName;
            spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;

            //Execute the spatialfilter
            IFeatureCursor featureCursor = pFeatureClass.Search(spatialFilter, false);

            IFeature   pFeature = null;
            List <int> bids     = new List <int>();

            while ((pFeature = featureCursor.NextFeature()) != null)
            {
                bids.Add(pFeature.OID);
            }

            return(bids);
        }
        //圆弧(线)转圆几何
        public static IGeometry GetCircleGeometry(ICircularArc pCircularArc)
        {
            ISegmentCollection pSegmentCollection = new PolygonClass();
            object missing1 = System.Type.Missing;
            object missing2 = System.Type.Missing;
            pSegmentCollection.AddSegment(pCircularArc as ISegment, ref missing1, ref missing2);


            IGeometry pGeometry = pSegmentCollection as IGeometry;
            return pGeometry;
        }
        //圆弧(线)转多边形(圆)
        public static IPolygon CircularArcToPolygon(ICircularArc pCircularArc)
        {
            ISegmentCollection pSegmentCollection = new PolygonClass();
            object missing1 = System.Type.Missing;
            object missing2 = System.Type.Missing;
            pSegmentCollection.AddSegment(pCircularArc as ISegment, ref missing1, ref missing2);


            IPolygon pPolygon = pSegmentCollection as IPolygon;
            return pPolygon;
        }
Exemplo n.º 12
0
        private IPolyline Arc2Polyline(ICircularArc Arc)
        {
            object             obj  = Type.Missing;
            ISegmentCollection segC = new PolylineClass();

            segC.AddSegment((ISegment)Arc, ref obj, ref obj);
            IPolyline circlePolyline = (IPolyline)segC;
            // mirror spatial referrence
            ISpatialReference spr = Arc.SpatialReference;

            circlePolyline.SpatialReference = spr;
            return(circlePolyline);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 根据绘制的圆形创建要素
        /// </summary>
        /// <params name="pLayer"></params>
        /// <params name="pCircuArc"></params>
        /// <params name="pScreenDisplay"></params>
        private void DrawCircleFeature(ILayer pLayer, ICircularArc pCircuArc, IScreenDisplay pScreenDisplay)
        {
            if (pLayer == null)
            {
                return;
            }
            ISegmentCollection pSegmentCollection = null;

            if (pLayer is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                if (pFeatureClass != null)
                {
                    IPolyline pPolyline = null;
                    IPolygon  pPolygon  = null;

                    if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        pSegmentCollection = new PolylineClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolyline = pSegmentCollection as IPolyline;
                    }
                    else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        pSegmentCollection = new PolygonClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolygon = pSegmentCollection as IPolygon;
                    }
                    else
                    {
                        return;
                    }
                    IFeature pFeature = null;
                    if (pPolyline != null)
                    {
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolyline);
                    }
                    else if (pPolygon != null)
                    {
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolygon);
                    }
                    else
                    {
                        return;
                    }
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }
            }
        }
Exemplo n.º 14
0
        private IPoint ComputeCenterPointFromRadius(IPolyline ThePolyline, double NewRadius, bool IsMinorCurve)
        {
            IConstructCircularArc pCircArcConst = new CircularArc() as IConstructCircularArc;

            pCircArcConst.ConstructEndPointsRadius(ThePolyline.FromPoint, ThePolyline.ToPoint,
                                                   (NewRadius < 0), Math.Abs(NewRadius), IsMinorCurve);
            ICircularArc pCircArc  = pCircArcConst as ICircularArc;
            IPoint       pCtrPoint = pCircArc.CenterPoint;
            IZAware      pZAw      = pCtrPoint as IZAware;

            pZAw.ZAware = true;
            pCtrPoint.Z = 0;
            return(pCtrPoint);
        }
Exemplo n.º 15
0
 public override void OnMouseDown(int int_0, int Shift, int int_2, int int_3)
 {
     if (int_0 == 1)
     {
         IActiveView activeView = _context.FocusMap as IActiveView;
         IPoint      mapPoint   = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(int_2, int_3);
         if (SketchToolAssist.Feedback != null)
         {
             try
             {
                 ICircularArc       circularArc   = (SketchToolAssist.Feedback as INewCircleFeedback).Stop();
                 ISegmentCollection polylineClass = null;
                 IFeatureLayer      featureLayer  = Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer;
                 if (featureLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                 {
                     polylineClass = new Polyline() as ISegmentCollection;
                 }
                 else if (featureLayer.FeatureClass.ShapeType != esriGeometryType.esriGeometryPolygon)
                 {
                     return;
                 }
                 else
                 {
                     polylineClass = new Polygon() as ISegmentCollection;
                 }
                 object value = Missing.Value;
                 polylineClass.AddSegment(circularArc as ISegment, ref value, ref value);
                 CreateFeatureTool.CreateFeature(polylineClass as IGeometry, _context.FocusMap as IActiveView,
                                                 Yutai.ArcGIS.Common.Editor.Editor.CurrentEditTemplate.FeatureLayer);
             }
             catch (Exception exception)
             {
                 //CErrorLog.writeErrorLog(this, exception, "");
             }
             SketchShareEx.m_bInUse           = false;
             SketchShareEx.LastPoint          = null;
             SketchShareEx.PointCount         = 0;
             SketchToolAssist.Feedback        = null;
             SketchShareEx.m_LastPartGeometry = null;
         }
         else
         {
             SketchShareEx.m_bInUse            = true;
             SketchToolAssist.Feedback         = new NewCircleFeedback();
             SketchToolAssist.Feedback.Display = activeView.ScreenDisplay;
             (SketchToolAssist.Feedback as INewCircleFeedback).Start(mapPoint);
         }
     }
 }
Exemplo n.º 16
0
 public override void OnMouseUp(int button, int shift, int x, int y)
 {
     if (this._circleFeedback != null)
     {
         try
         {
             ICircularArc circularArc = this._circleFeedback.Stop();
             this._circleFeedback = null;
             IPolygon polygon = new Polygon() as IPolygon;
             object   value   = Missing.Value;
             (polygon as ISegmentCollection).AddSegment(circularArc as ISegment, ref value, ref value);
             IElement element = new CircleElement
             {
                 Geometry = polygon
             };
             INewElementOperation operation = new NewElementOperation
             {
                 ActiveView  = this._context.ActiveView,
                 ContainHook = this.GetActiveView(),
                 Element     = element
             };
             this._context.OperationStack.Do(operation);
             //if (this._context.Hook is IApplication)
             //{
             //    if ((this._context.Hook as IApplication).ContainerHook != null)
             //    {
             //        DocumentManager.DocumentChanged((this._context.Hook as IApplication).ContainerHook);
             //    }
             //    else
             //    {
             //        DocumentManager.DocumentChanged((this._context.Hook as IApplication).Hook);
             //    }
             //}
             //else
             //{
             //    DocumentManager.DocumentChanged(this._context.Hook);
             //}
         }
         catch (Exception exception_)
         {
             //CErrorLog.writeErrorLog(this, exception_, "");
         }
     }
 }
Exemplo n.º 17
0
        public override void OnMouseUp(int Button, int Shift, int X, int Y)
        {
            IPoint    point    = this.m_mapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            IGeometry geometry = null;
            IElement  element  = null;

            switch (this.DrawType)
            {
            case EnumDrawType.circle:
                if (this.m_circleFeedback != null)
                {
                    ICircularArc circularArc = this.m_circleFeedback.Stop();
                    this.m_circleFeedback = null;
                    if (circularArc == null || circularArc.IsPoint)
                    {
                        return;
                    }
                    geometry = MapAPI.ConvertCircularArcToPolygon(circularArc);
                    element  = new CircleElementClass();
                }
                break;

            case EnumDrawType.square:
                if (this.m_rectangleFeedback != null)
                {
                    geometry = this.m_rectangleFeedback.Stop(point);
                    if ((geometry as IPointCollection).PointCount == 2)
                    {
                        this.m_rectangleFeedback = null;
                        return;
                    }
                    this.m_rectangleFeedback = null;
                    element = new PolygonElementClass();
                }
                break;
            }
            if (geometry != null)
            {
                element.Geometry = geometry;
                this.AppendNodeToTreeList(element);
            }
        }
Exemplo n.º 18
0
        /// <summary>
        /// Converts the ICircularArc to polygon.
        /// </summary>
        /// <param name="circularArc">The circulararc.</param>
        /// <returns>IPolygon.</returns>
        public static IPolygon ConvertCircularArcToPolygon(ICircularArc circularArc)
        {
            ISegmentCollection segmentCollection = new RingClass();
            ISegmentCollection arg_2B_0          = segmentCollection;
            ISegment           arg_2B_1          = circularArc as ISegment;
            object             value             = Missing.Value;
            object             value2            = Missing.Value;

            arg_2B_0.AddSegment(arg_2B_1, ref value, ref value2);
            IRing ring = segmentCollection as IRing;

            ring.Close();
            IGeometryCollection geometryCollection = new PolygonClass();
            IGeometryCollection arg_5D_0           = geometryCollection;
            IGeometry           arg_5D_1           = ring;

            value  = Missing.Value;
            value2 = Missing.Value;
            arg_5D_0.AddGeometry(arg_5D_1, ref value, ref value2);
            return(geometryCollection as IPolygon);
        }
Exemplo n.º 19
0
        private IPolygon Arc2Polygon(ICircularArc Arc)
        {
            ISegmentCollection pSegCol = new RingClass();
            object             obj     = Type.Missing;

            pSegCol.AddSegment((ISegment)Arc, ref obj, ref obj);
            //enclose ring make it valid
            IRing pRing;

            pRing = pSegCol as IRing;
            pRing.Close();
            IGeometryCollection pPolygonCol = new PolygonClass();

            pPolygonCol.AddGeometry(pRing, ref obj, ref obj);
            IPolygon circlePolygon = (IPolygon)pPolygonCol;
            // mirror spatial referrence
            ISpatialReference spr = Arc.SpatialReference;

            circlePolygon.SpatialReference = spr;
            return(circlePolygon);
        }
Exemplo n.º 20
0
        private void method_0(int int_0)
        {
            object value;

            this.isymbol_0.SetupDC(int_0, this.iscreenDisplay_0.DisplayTransformation);
            if (this.ipointCollection_0.PointCount == 1)
            {
                value = Missing.Value;
                IPointCollection polylineClass = new Polyline();
                polylineClass.AddPoint(this.ipointCollection_0.Point[0], ref value, ref value);
                try
                {
                    if (this.ipoint_0 != null)
                    {
                        polylineClass.AddPoint(this.ipoint_0, ref value, ref value);
                        this.isymbol_0.Draw(polylineClass as IGeometry);
                    }
                }
                catch (Exception exception)
                {
                    exception.ToString();
                }
            }
            else if (this.ipointCollection_0.PointCount == 2)
            {
                ISegmentCollection segmentCollection = new Polyline() as ISegmentCollection;
                ICircularArc       circularArc       = null;
                value = Missing.Value;
                if (this.ipoint_0 != null)
                {
                    circularArc = this.method_1(this.ipointCollection_0.Point[0], this.ipointCollection_0.Point[1],
                                                this.ipoint_0);
                    segmentCollection.AddSegment(circularArc as ISegment, ref value, ref value);
                    this.isymbol_0.Draw(segmentCollection as IGeometry);
                }
            }
            this.isymbol_0.ResetDC();
        }
Exemplo n.º 21
0
        public static void drawSector(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));

            double angle = (toAngle - fromAngle) % 360;
            bool   isCCW = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            if (angle == 0)
            {
                angle = 360;
            }
            double arcDistance = radius * GeometricUtilities.GetRadians(angle);

            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance);
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);

            //画扇形
            IGraphicsContainer3D graphicsContainer3D = GISMapApplication.Instance.GetLayer(LayerNames.Rays) as IGraphicsContainer3D;
            IPolygonElement      polygonElement      = new PolygonElementClass();
            IElement             element             = polygonElement as IElement;

            element.Geometry = polygon as IGeometry;
            graphicsContainer3D.AddElement(element);
        }
Exemplo n.º 22
0
        private IPoint CreateNewCenterPoint(IPoint presentCP, IPoint lastCP)
        {
            initialCoastLine();
            IPoint    newCP = new PointClass();
            IPolyline line  = new PolylineClass();

            line = Coastline;
            ICircularArc     presentCA       = CreateCircleArc(presentCP, radius, false);
            IPointCollection intersectPtColl = IntersectPointColl(presentCA, line);
            List <IPoint>    intersectPtlist = new List <IPoint>();
            List <IPoint>    splitResult     = new List <IPoint>();
            List <IPoint>    correctPtlist   = new List <IPoint>();

            for (int i = 0; i < intersectPtColl.PointCount; i++)
            {
                intersectPtlist.Add(intersectPtColl.get_Point(i));
            }
            if (intersectPtlist.Count == 2)
            {
                correctPtlist = GetCorrectPoint(intersectPtlist, lastCP);
            }
            else
            {
                splitResult = SplitPolyline(line, intersectPtColl, presentCP);
                //MessageBox.Show(splitResult.Count.ToString());
                correctPtlist = GetCorrectPoint(splitResult, lastCP);
            }

            if (correctPtlist.Count == 1)
            {
                newCP = correctPtlist[0];
            }
            else
            {
                MessageBox.Show("Wrong result");
            }
            return(newCP);
        }
Exemplo n.º 23
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            IPoint pMovePt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);

            pMovePt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pMovePt);
            if (m_lMouseDownCount == 1)
            {
                m_pLineFeedback.MoveTo(pMovePt);
            }
            else if (m_lMouseDownCount == 2)
            {
                m_bCreated = false;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.UpperLeft  = m_pFirstPoint;
                pEnv.LowerRight = m_pSecondPoint;

                IConstructCircularArc pEllipArc = new CircularArcClass();
                pEllipArc.ConstructThreePoints(m_pFirstPoint, m_pSecondPoint, pMovePt, true);
                m_pCircleArc = pEllipArc as ICircularArc;
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            }
            DataEditCommon.g_pAxMapControl.Focus();
        }
        private ICircularArc ConstructCurveFromString(string inString, ISegment ExitTangentFromPreviousCourse,
                                                      esriDirectionType inDirectionType, esriDirectionUnits inDirectionUnits,
                                                      out double outChordLength, out double outChordBearing)
        {//
            IConstructCircularArc pConstArc = new CircularArcClass();
            ICircularArc          pArc      = (ICircularArc)pConstArc;
            IPoint pPt = new PointClass();

            pPt.PutCoords(1000, 1000);
            //initialize the curve params
            bool bHasRadius = false; double dRadius = -1;
            bool bHasChord = false; double dChord = -1;
            bool bHasArc = false; double dArcLength = -1;
            bool bHasDelta = false; double dDelta = -1;
            bool bCCW = false; //assume curve to right unless proven otherwise
            //now initialize bearing types for non-tangent curves
            bool     bHasRadialBearing = false; double dRadialBearing = -1;
            bool     bHasChordBearing = false; double dChordBearing = -1;
            bool     bHasTangentBearing = false; double dTangentBearing = -1;
            ISegment EntryTangentSegment = null;

            int iItemPosition = 0;

            string[] sCourse         = inString.Split(' ');
            int      UpperBound      = sCourse.GetUpperBound(0);
            bool     bIsTangentCurve = (((string)sCourse.GetValue(0)).ToLower() == "tc");

            foreach (string item in sCourse)
            {
                if (item == null)
                {
                    break;
                }
                if ((item.ToLower() == "r") && (!bHasRadius) && (iItemPosition <= 3))
                {                      // this r is for radius
                    dRadius    = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasRadius = true; //found a radius
                }
                if ((item.ToLower()) == "c" && (!bHasChord) && (iItemPosition <= 3))
                {                     // this c is for chord length
                    dChord    = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasChord = true; //found a chord length
                }
                if ((item.ToLower()) == "a" && (!bHasArc) && (iItemPosition <= 3))
                {                      // this a is for arc length
                    dArcLength = Convert.ToDouble(sCourse.GetValue(iItemPosition + 1));
                    bHasArc    = true; //found an arc length
                }
                if ((item.ToLower()) == "d" && (!bHasDelta) && (iItemPosition <= 3))
                {                     // this d is for delta or central angle
                    dDelta    = Angle_2_Radians((string)sCourse.GetValue(iItemPosition + 1), inDirectionUnits);
                    bHasDelta = true; //found a central angle
                }
                if ((item.ToLower()) == "r" && (!bHasRadialBearing) && (iItemPosition > 3) && (UpperBound > 5))
                {// this r is for radial bearing
                    try
                    {
                        dRadialBearing = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                        if (!(dRadialBearing == -999))
                        {
                            bHasRadialBearing = true;
                        }                                                //found a radial bearing
                    }
                    catch { }//this will catch case of final R meaning a curve right and not radial bearing
                }
                if ((item.ToLower()) == "c" && (!bHasChordBearing) && (iItemPosition > 3))
                {                            // this c is for chord bearing
                    dChordBearing    = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                    bHasChordBearing = true; //found a chord bearing
                }
                if ((item.ToLower()) == "t" && (!bHasTangentBearing) && (iItemPosition > 3))
                {                              // this t is for tangent bearing
                    dTangentBearing    = DirectionString_2_PolarRadians((string)sCourse.GetValue(iItemPosition + 1), inDirectionType, inDirectionUnits);
                    bHasTangentBearing = true; //found a tangent bearing
                    IConstructPoint2 pToPt = new PointClass();
                    pToPt.ConstructAngleDistance(pPt, dTangentBearing, 100);
                    ILine EntryTangentLine = new LineClass();
                    EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
                    EntryTangentSegment = (ISegment)EntryTangentLine;
                }

                if ((item.ToLower()) == "l")
                {
                    // this l is for defining a curve to the left
                    bCCW = true;
                }
                iItemPosition += 1;
            }

            if (!(bIsTangentCurve)) //non-tangent curve
            {                       //chord bearing
                if (bHasRadius && bHasChord && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusChord(pPt, dChordBearing, bCCW, dRadius, dChord, true);
                    }
                    catch { };
                }

                if (bHasRadius && bHasArc && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusArc(pPt, dChordBearing, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }

                if (bHasRadius && bHasDelta && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingRadiusAngle(pPt, dChordBearing, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }

                if (bHasChord && bHasDelta && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingAngleChord(pPt, dChordBearing, bCCW, dDelta, dChord);
                    }
                    catch { };
                }

                if (bHasChord && bHasArc && bHasChordBearing)
                {
                    try
                    {
                        pConstArc.ConstructBearingChordArc(pPt, dChordBearing, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }

                //tangent bearing
                if (bHasRadius && bHasChord && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }

                if (bHasRadius && bHasArc && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }

                if (bHasChord && bHasDelta && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc && bHasTangentBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }

                //radial bearing
                if (bHasRadialBearing)
                {
                    //need to convert radial bearing to tangent bearing by adding/subtracting 90 degrees
                    double dTanBear = 0;
                    if (bCCW)
                    {
                        dTanBear = dRadialBearing - (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
                    }
                    else
                    {
                        dTanBear = dRadialBearing + (Angle_2_Radians("90", esriDirectionUnits.esriDUDecimalDegrees));
                    }
                    IConstructPoint2 pToPt = new PointClass();
                    pToPt.ConstructAngleDistance(pPt, dTanBear, 100);
                    ILine EntryTangentLine = new LineClass();
                    EntryTangentLine.PutCoords(pPt, (IPoint)pToPt);
                    EntryTangentSegment = (ISegment)EntryTangentLine;
                }

                if (bHasRadius && bHasChord && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(EntryTangentSegment, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }
                if (bHasRadius && bHasArc && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(EntryTangentSegment, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(EntryTangentSegment, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }
                if (bHasChord && bHasDelta && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(EntryTangentSegment, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc && bHasRadialBearing)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(EntryTangentSegment, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }
            }
            else
            { //tangent curve
                if (bHasRadius && bHasChord)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusChord(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dChord);
                    }
                    catch { };
                }
                if (bHasRadius && bHasArc)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusArc(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dArcLength);
                    }
                    catch { };
                }
                if (bHasRadius && bHasDelta)
                {
                    try
                    {
                        pConstArc.ConstructTangentRadiusAngle(ExitTangentFromPreviousCourse, false, bCCW, dRadius, dDelta);
                    }
                    catch { };
                }
                if (bHasChord && bHasDelta)
                {
                    try
                    {
                        pConstArc.ConstructTangentAngleChord(ExitTangentFromPreviousCourse, false, bCCW, dDelta, dChord);
                    }
                    catch { };
                }
                if (bHasChord && bHasArc)
                {
                    try
                    {
                        pConstArc.ConstructTangentChordArc(ExitTangentFromPreviousCourse, false, bCCW, dChord, dArcLength);
                    }
                    catch { };
                }
            }
            ILine pLine = new LineClass();

            try
            {
                pLine.PutCoords(pArc.FromPoint, pArc.ToPoint);
            }
            catch
            {
                outChordLength = -1; outChordBearing = -1;
                return(null);
            }
            outChordLength  = pLine.Length;
            outChordBearing = pLine.Angle;
            return(pArc);
        }
Exemplo n.º 25
0
        //几何图形坐标转换
        private void GeometryCoordConvert(ref IGeometry pConvertGeometry, double A1, double B1, double C1, double A2, double B2, double C2, double A3, double C3)
        {
            object a      = System.Reflection.Missing.Value;
            object b      = System.Reflection.Missing.Value;
            bool   isRing = false;

            if (pConvertGeometry.GeometryType != esriGeometryType.esriGeometryPoint)//如果为线要素或面要素
            {
                IArray pArrayPoint    = new ArrayClass();
                IArray pGeometryArray = new ArrayClass();
                IGeometryCollection pGeometryCollection = pConvertGeometry as IGeometryCollection;
                for (int i = 0; i < pGeometryCollection.GeometryCount; i++)
                {
                    IGeometry pGeometry = pGeometryCollection.get_Geometry(i);
                    if (pGeometry.GeometryType != esriGeometryType.esriGeometryPoint)//
                    {
                        #region
                        if (pGeometry.GeometryType == esriGeometryType.esriGeometryRing)
                        {
                            isRing = true;
                        }

                        if (pGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                        {
                            pGeometry = CommonFunction.GetPolygonBoundary((IPolygon)pGeometry);
                        }

                        ISegmentCollection pSegmentCol    = (ISegmentCollection)pGeometry;
                        ISegmentCollection pNewSegmentCol = new PolylineClass();
                        for (int k = 0; k < pSegmentCol.SegmentCount; k++)//遍历几何形体的每个节(片断)
                        {
                            //该节为直线段
                            if (pSegmentCol.get_Segment(k).GeometryType == esriGeometryType.esriGeometryLine)
                            {
                                IPointCollection pPointCol1 = new MultipointClass();
                                ILine            pLine      = (ILine)pSegmentCol.get_Segment(k);

                                IPoint pFromPoint = pLine.FromPoint;
                                pPointCol1.AddPoint((IPoint)pFromPoint, ref a, ref b);
                                IPoint pToPoint = pLine.ToPoint;
                                pPointCol1.AddPoint((IPoint)pToPoint, ref a, ref b);

                                PointCollCoordConvert(A1, B1, C1, A2, B2, C2, A3, C3, ref pPointCol1);//对点集做镜像

                                //修改线段的端点坐标
                                pLine.FromPoint = pPointCol1.get_Point(0);
                                pLine.ToPoint   = pPointCol1.get_Point(1);

                                pNewSegmentCol.AddSegment((ISegment)pLine, ref a, ref b);
                            }
                            //该节为圆弧
                            else if (pSegmentCol.get_Segment(k).GeometryType == esriGeometryType.esriGeometryCircularArc)
                            {
                                IPointCollection pPointCol2 = new MultipointClass();

                                ICircularArc pCircularArc = (ICircularArc)pSegmentCol.get_Segment(k);

                                try
                                {
                                    IPoint pCenterPoint = pCircularArc.CenterPoint;
                                    pPointCol2.AddPoint((IPoint)pCenterPoint, ref a, ref b);
                                    IPoint pFromPoint = pCircularArc.FromPoint;
                                    pPointCol2.AddPoint((IPoint)pFromPoint, ref a, ref b);
                                    IPoint pToPoint = pCircularArc.ToPoint;
                                    pPointCol2.AddPoint((IPoint)pToPoint, ref a, ref b);

                                    PointCollCoordConvert(A1, B1, C1, A2, B2, C2, A3, C3, ref pPointCol2);//对点集做镜像

                                    //构造新的圆弧
                                    ICircularArc pArc = new CircularArcClass();
                                    pArc.PutCoords(pPointCol2.get_Point(0), pPointCol2.get_Point(1), pPointCol2.get_Point(2),
                                                   (pCircularArc.IsCounterClockwise ? esriArcOrientation.esriArcCounterClockwise : esriArcOrientation.esriArcClockwise));

                                    pNewSegmentCol.AddSegment((ISegment)pArc, ref a, ref b);
                                }
                                catch { }
                            }
                            //该节为贝塞尔曲线
                            else if (pSegmentCol.get_Segment(k).GeometryType == esriGeometryType.esriGeometryBezier3Curve)
                            {
                                IPointCollection pPointCol3   = new MultipointClass();
                                IBezierCurve     pBezierCurve = (IBezierCurve)pSegmentCol.get_Segment(k);

                                //记录该节贝塞尔曲线的4个控制点
                                IPoint pFromPoint = new PointClass();
                                pBezierCurve.QueryCoord(0, pFromPoint);
                                pPointCol3.AddPoint(pFromPoint, ref a, ref b);
                                IPoint pFromTangentPoint = new PointClass();
                                pBezierCurve.QueryCoord(1, pFromTangentPoint);
                                pPointCol3.AddPoint(pFromTangentPoint, ref a, ref b);
                                IPoint pToTangentPoint = new PointClass();
                                pBezierCurve.QueryCoord(2, pToTangentPoint);
                                pPointCol3.AddPoint(pToTangentPoint, ref a, ref b);
                                IPoint pToPoint = new PointClass();
                                pBezierCurve.QueryCoord(3, pToPoint);
                                pPointCol3.AddPoint(pToPoint, ref a, ref b);

                                PointCollCoordConvert(A1, B1, C1, A2, B2, C2, A3, C3, ref pPointCol3);//对点集做镜像

                                //修改该节贝塞尔曲线的4个控制点
                                pBezierCurve.PutCoord(0, pPointCol3.get_Point(0));
                                pBezierCurve.PutCoord(1, pPointCol3.get_Point(1));
                                pBezierCurve.PutCoord(2, pPointCol3.get_Point(2));
                                pBezierCurve.PutCoord(3, pPointCol3.get_Point(3));

                                pNewSegmentCol.AddSegment((ISegment)pBezierCurve, ref a, ref b);
                            }
                        }//end for 遍历几何形体的每个节(片断)

                        CommonFunction.GeometryToArray(pNewSegmentCol as IGeometry, pArrayPoint);

                        IPolycurve2 pPolycurve2 = CommonFunction.BuildPolyLineFromSegmentCollection(pNewSegmentCol);

                        pGeometry = (IGeometry)pPolycurve2;

                        #endregion
                    }
                    if (pConvertGeometry.GeometryType == esriGeometryType.esriGeometryPolygon)//由线构成面
                    {
                        pGeometry = CommonFunction.PolylineToPolygon(pGeometry as IPolyline);
                    }
                    pGeometryArray.Add(pGeometry);
                }
                if (pGeometryArray.Count > 1)
                {
                    pConvertGeometry = pGeometryArray.get_Element(0) as IGeometry;
                    if (isRing == true)
                    {
                        for (int i = 1; i < pGeometryArray.Count; i++)
                        {
                            pConvertGeometry = CommonFunction.DiffenceGeometry(pConvertGeometry, pGeometryArray.get_Element(i) as IGeometry);
                        }
                    }
                    else
                    {
                        for (int i = 1; i < pGeometryArray.Count; i++)
                        {
                            pConvertGeometry = CommonFunction.UnionGeometry(pConvertGeometry, pGeometryArray.get_Element(i) as IGeometry);
                        }
                    }
                }
                else
                {
                    pConvertGeometry = pGeometryArray.get_Element(0) as IGeometry;
                }

                CommonFunction.AddZMValueForGeometry(ref pConvertGeometry, pArrayPoint);
            }
            else
            {
                PointCoordConvert(ref pConvertGeometry, A1, B1, C1, A2, B2, C2, A3, C3);
            }
        }
Exemplo n.º 26
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            // TODO:  Add ToolCreateCircle.OnMouseDown implementation
            if ((m_pMapCtl = ClsGlobal.GetMapControl(m_hookHelper)) == null)
            {
                return;
            }
            IPoint pPoint = m_pMapCtl.ToMapPoint(X, Y);

            if (Button == 1)
            {
                if (m_NewCircleFeedback == null)
                {
                    m_NewCircleFeedback         = new NewCircleFeedbackClass();
                    m_NewCircleFeedback.Display = m_pMapCtl.ActiveView.ScreenDisplay;

                    m_NewCircleFeedback.Start(pPoint);
                    m_CenterPoint = pPoint;
                }
                else
                {
                    try
                    {
                        object       Miss = Type.Missing;
                        ICircularArc pArc = m_NewCircleFeedback.Stop();
                        //IGeometry geometry = new PolygonClass();
                        //geometry = m_pMapCtl.TrackCircle();
                        IPolygon           pPolygon = new PolygonClass();
                        ISegment           pArcC    = pArc as ISegment;
                        ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                        pArcP.AddSegment(pArcC, ref Miss, ref Miss);
                        pPolygon.Close();
                        IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                        pFeature.Shape = pPolygon;
                        pFeature.Store();
                        m_pMapCtl.Refresh();
                        m_NewCircleFeedback = null;
                    }
                    catch (System.Exception ex)
                    {
                    }
                }
            }
            if (Button == 2)
            {
                double                radius        = Math.Sqrt((pPoint.X - m_CenterPoint.X) * (pPoint.X - m_CenterPoint.X) + (pPoint.Y - m_CenterPoint.Y) * (pPoint.Y - m_CenterPoint.Y));
                FrmDrawCircle         frm           = new FrmDrawCircle(radius);
                IConstructCircularArc pArcConstruct = null;
                if (m_NewCircleFeedback == null)
                {
                    return;
                }

                if (frm.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        pArcConstruct = new CircularArcClass();
                        pArcConstruct.ConstructCircle(m_CenterPoint, frm.m_radius, false);
                        if (pArcConstruct != null)
                        {
                            IPolygon           pPolygon = new PolygonClass();
                            ISegment           pArcC    = pArcConstruct as ISegment;
                            ISegmentCollection pArcP    = pPolygon as ISegmentCollection;
                            pArcP.AddSegment(pArcC);
                            pPolygon.Close();
                            IFeature pFeature = m_FLayer.FeatureClass.CreateFeature();
                            pFeature.Shape = pPolygon;
                            pFeature.Store();
                            m_pMapCtl.Refresh();
                            m_NewCircleFeedback.Stop();
                            m_NewCircleFeedback = null;
                        }
                    }
                    catch (System.Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        if (m_NewCircleFeedback != null)
                        {
                            m_NewCircleFeedback.Stop();
                        }
                        m_NewCircleFeedback = null;
                    }
                }
            }
        }
Exemplo n.º 27
0
        private ISegmentCollection createSegments(Cell cell, BoostVoronoi bv, ArcConstructionMethods method, ISpatialReference spatialReference)
        {
            List <Cell>   cells    = bv.Cells;
            List <Edge>   edges    = bv.Edges;
            List <Vertex> vertices = bv.Vertices;

            IPoint previousEndPoint = null;

            ISegmentCollection segmentCollection = new PolygonClass()
            {
                SpatialReference = spatialReference
            };

            // As per boost documentation, edges are returned in counter clockwise (CCW) rotation.
            //  voronoi_edge_type* next()	Returns the pointer to the CCW next edge within the corresponding Voronoi cell.  Edges not necessarily share a common vertex (e.g. infinite edges).
            for (int i = cell.EdgesIndex.Count - 1; i >= 0; i--)
            {
                Edge edge = edges[cell.EdgesIndex[i]];


                //If the vertex index equals -1, it means the edge is infinite. It is impossible to print the coordinates.
                if (!edge.IsFinite && edge.End < 0)
                {
                    // this is the ending portion of a pair of infinite edges, file the previous edge with Start >= 0
                    Edge previous = null;
                    for (int k = i + 1; k < cell.EdgesIndex.Count; k++)
                    {
                        previous = edges[cell.EdgesIndex[k]];
                        if (previous.End >= 0)
                        {
                            break;
                        }
                        previous = null;
                    }
                    if (previous == null)
                    {
                        for (int k = 0; k < i; k++)
                        {
                            previous = edges[cell.EdgesIndex[k]];
                            if (previous.End >= 0)
                            {
                                break;
                            }
                            previous = null;
                        }
                    }
                    if (previous == null)
                    {
                        throw new Exception("No outbound infinite edge could be found");
                    }

                    //Add a straight line segment
                    Vertex start     = vertices[previous.End];
                    IPoint FromPoint = new PointClass()
                    {
                        X = start.X, Y = start.Y, SpatialReference = spatialReference
                    };
                    Vertex end     = vertices[edge.Start];
                    IPoint ToPoint = new PointClass()
                    {
                        X = end.X, Y = end.Y, SpatialReference = spatialReference
                    };

                    segmentCollection.AddSegment(new LineClass()
                    {
                        FromPoint = FromPoint, ToPoint = ToPoint, SpatialReference = spatialReference
                    });
                    previousEndPoint = ToPoint;
                }
                else if (edge.IsFinite)
                {
                    Vertex start     = vertices[edge.End];
                    IPoint FromPoint = new PointClass()
                    {
                        X = start.X, Y = start.Y, SpatialReference = spatialReference
                    };
                    if (previousEndPoint != null)
                    {
                        if ((Math.Abs(previousEndPoint.X - FromPoint.X) > 0.05 || Math.Abs(previousEndPoint.X - FromPoint.X) > 0.05))
                        {
                            throw new Exception("Significant change between last end point and current start point");
                        }
                        else
                        {
                            FromPoint = previousEndPoint;
                        }
                    }
                    Vertex end     = vertices[edge.Start];
                    IPoint ToPoint = new PointClass()
                    {
                        X = end.X, Y = end.Y, SpatialReference = spatialReference
                    };

                    if (method == ArcConstructionMethods.Straight || edge.IsLinear)
                    {
                        segmentCollection.AddSegment(new LineClass()
                        {
                            FromPoint = FromPoint, ToPoint = ToPoint, SpatialReference = spatialReference
                        });
                        previousEndPoint = ToPoint;
                    }
                    else
                    {
                        // We need three points, use start, end, mid-point between focus and directrix
                        Cell twinCell = cells[edges[edge.Twin].Cell];


                        VPoint pointSite; VSegment lineSite;
                        if (cell.ContainsPoint && twinCell.ContainsSegment)
                        {
                            pointSite = bv.RetrieveInputPoint(cell);
                            lineSite  = bv.RetrieveInputSegment(twinCell);
                        }
                        else if (cell.ContainsSegment && twinCell.ContainsPoint)
                        {
                            pointSite = bv.RetrieveInputPoint(twinCell);
                            lineSite  = bv.RetrieveInputSegment(cell);
                        }

                        else
                        {
                            throw new Exception("Invalid edge, curves should only be present between a point and a line");
                        }

                        double scaleFactor = Convert.ToDouble(bv.ScaleFactor);
                        IPoint aoPointSite = new Point()
                        {
                            X = Convert.ToDouble(pointSite.X) / scaleFactor,
                            Y = Convert.ToDouble(pointSite.Y) / scaleFactor,
                            SpatialReference = spatialReference
                        };

                        ISegment aoLineSite = new LineClass()
                        {
                            FromPoint = new PointClass()
                            {
                                X = Convert.ToDouble(lineSite.Start.X) / scaleFactor,
                                Y = Convert.ToDouble(lineSite.Start.Y) / scaleFactor,
                                SpatialReference = spatialReference
                            },
                            ToPoint = new PointClass()
                            {
                                X = Convert.ToDouble(lineSite.End.X) / scaleFactor,
                                Y = Convert.ToDouble(lineSite.End.Y) / scaleFactor,
                                SpatialReference = spatialReference
                            },
                            SpatialReference = spatialReference
                        };


                        if (method == ArcConstructionMethods.Approximate)
                        {
                            List <Vertex> sampledVerticed = null;
                            try
                            {
                                sampledVerticed = bv.SampleCurvedEdge(edge, aoLineSite.Length / 10);
                            }
                            catch (FocusOnDirectixException e)
                            {
                                //Log any exception here is required
                                sampledVerticed = new List <Vertex>()
                                {
                                    start, end
                                };
                            }
                            catch (UnsolvableVertexException e)
                            {
                                sampledVerticed = new List <Vertex>()
                                {
                                    start, end
                                };
                            }

                            sampledVerticed.Reverse();
                            List <IPoint> discretizedEdge = sampledVerticed.Select(
                                p => new Point()
                            {
                                X = p.X, Y = p.Y
                            }
                                ).ToList <IPoint>();

                            IPoint prev = discretizedEdge[0];
                            foreach (IPoint v in discretizedEdge.Skip(1))
                            {
                                segmentCollection.AddSegment(new LineClass()
                                {
                                    FromPoint = new Point()
                                    {
                                        X = prev.X, Y = prev.Y, SpatialReference = spatialReference
                                    },
                                    ToPoint = new Point()
                                    {
                                        X = v.X, Y = v.Y, SpatialReference = spatialReference
                                    },
                                    SpatialReference = spatialReference
                                });
                                prev = v;
                            }
                            previousEndPoint = discretizedEdge.Last();
                        }
                        else if (method == ArcConstructionMethods.Circular)
                        {
                            IPoint nearPoint = ((IProximityOperator)aoLineSite).ReturnNearestPoint(aoPointSite, esriSegmentExtension.esriNoExtension);
                            IPoint midpoint  = new PointClass()
                            {
                                X = (nearPoint.X + aoPointSite.X) / 2,
                                Y = (nearPoint.Y + aoPointSite.Y) / 2,
                                SpatialReference = spatialReference
                            };

                            IConstructCircularArc constArc = new CircularArcClass()
                            {
                                SpatialReference = spatialReference
                            };
                            constArc.ConstructThreePoints(FromPoint, midpoint, ToPoint, false);
                            ICircularArc arc = (ICircularArc)constArc;

                            if (!arc.IsMinor)
                            {
                                constArc = new CircularArcClass()
                                {
                                    SpatialReference = spatialReference
                                };
                                constArc.ConstructEndPointsRadius(FromPoint, ToPoint, !arc.IsCounterClockwise, arc.Radius, true);
                                arc = (ICircularArc)constArc;
                            }
                            segmentCollection.AddSegment((ISegment)arc);
                            previousEndPoint = arc.ToPoint;
                        }
                        else if (method == ArcConstructionMethods.Ellipse)
                        {
                            IPoint nearPoint = ((IProximityOperator)aoLineSite).ReturnNearestPoint(aoPointSite, esriSegmentExtension.esriExtendTangents);
                            nearPoint.SpatialReference = spatialReference;

                            ILine lineToFocus = new LineClass()
                            {
                                FromPoint = nearPoint, ToPoint = aoPointSite, SpatialReference = spatialReference
                            };
                            ILine semiMajor = new LineClass()
                            {
                                SpatialReference = spatialReference
                            };
                            lineToFocus.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, 100 * lineToFocus.Length, semiMajor);

                            IPoint center = new PointClass()
                            {
                                X = (semiMajor.FromPoint.X + semiMajor.ToPoint.X) / 2,
                                Y = (semiMajor.FromPoint.Y + semiMajor.ToPoint.Y) / 2,
                                SpatialReference = spatialReference
                            };

                            double minor_length = Math.Sqrt(
                                Math.Pow(distance(semiMajor.FromPoint, ToPoint) + distance(semiMajor.ToPoint, ToPoint), 2)
                                - Math.Pow(semiMajor.Length, 2));

                            IEllipticArc arc = new EllipticArcClass()
                            {
                                SpatialReference = spatialReference
                            };
                            double rotation = lineToFocus.Angle;
                            double from     = GetAngle(center, FromPoint);

                            arc.PutCoords(false, center, FromPoint, ToPoint, rotation, minor_length / semiMajor.Length, esriArcOrientation.esriArcMinor);

                            segmentCollection.AddSegment((ISegment)arc);
                            previousEndPoint = arc.ToPoint;
                        }
                    }
                }
            }
            return(segmentCollection);
        }
Exemplo n.º 28
0
        /// <summary>
        /// ���ݻ��Ƶ�Բ�δ���Ҫ��
        /// </summary>
        /// <params name="pLayer"></params>
        /// <params name="pCircuArc"></params>
        /// <params name="pScreenDisplay"></params>
        private void DrawCircleFeature(ILayer pLayer, ICircularArc pCircuArc, IScreenDisplay pScreenDisplay)
        {
            if (pLayer == null) return;
            ISegmentCollection pSegmentCollection = null;
            if (pLayer is IFeatureLayer)
            {
                IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                if (pFeatureClass != null)
                {
                    IPolyline pPolyline = null;
                    IPolygon pPolygon = null;

                    if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        pSegmentCollection = new PolylineClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolyline = pSegmentCollection as IPolyline;
                    }
                    else if (pFeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                    {
                        pSegmentCollection = new PolygonClass();
                        pSegmentCollection.AddSegment(pCircuArc as ISegment);
                        pPolygon = pSegmentCollection as IPolygon;
                    }
                    else
                        return;
                    IFeature pFeature = null;
                    if (pPolyline != null)
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolyline);
                    else if (pPolygon != null)
                        pFeature = DataEditCommon.CreateUndoRedoFeature(pFeatureLayer, pPolygon);
                    else
                        return;
                    m_hookHelper.FocusMap.SelectFeature(m_pCurrentLayer, pFeature);
                    m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics | esriViewDrawPhase.esriViewGeoSelection | esriViewDrawPhase.esriViewBackground, null, null);
                }
            }
        }
Exemplo n.º 29
0
        /// <summary>
        /// 获取扇形与地面网格相交的网格中心点
        /// </summary>
        /// <param name="p"></param>
        /// <param name="fromAngle"></param>
        /// <param name="toAngle"></param>
        /// <param name="radius"></param>
        /// <returns></returns>
        public static List <LTE.Geometric.Point> getSelectedGridsCenterPoints(LTE.Geometric.Point p, double fromAngle, double toAngle, double radius)
        {
            IPoint centralPoint = GeometryUtilities.ConstructPoint2D(p.X, p.Y);

            double arithmeticToAngle = GeometricUtilities.GetRadians(GeometricUtilities.ConvertGeometricArithmeticAngle(toAngle));

            double angle = (toAngle - fromAngle) % 360;
            bool   isCCW = true;

            if (angle > 180)
            {
                angle = 360 - angle;
                isCCW = false;
            }
            if (angle == 0)
            {
                angle = 360;
            }
            double arcDistance = radius * GeometricUtilities.GetRadians(angle);


            IPoint       fromPoint   = GeometryUtilities.ConstructPoint_AngleDistance(centralPoint, arithmeticToAngle, radius);
            ICircularArc circularArc = GeometryUtilities.ConstructCircularArc(centralPoint, fromPoint, isCCW, arcDistance);
            IPoint       toPoint     = circularArc.ToPoint;

            ISegment fromSegment = GeometryUtilities.ConstructLine(centralPoint, fromPoint) as ISegment;
            ISegment toSegment   = GeometryUtilities.ConstructLine(toPoint, centralPoint) as ISegment;

            ISegment[]          segmentArray = new ISegment[] { fromSegment, circularArc as ISegment, toSegment };
            IGeometryCollection polygon      = GeometryUtilities.ConstructPolygon(segmentArray);

            //画扇形
            //IGraphicsContainer3D graphicsContainer3D = GISMapApplication.Instance.GetLayer(LayerNames.Rays) as IGraphicsContainer3D;
            //IPolygonElement polygonElement = new PolygonElementClass();
            //IElement element = polygonElement as IElement;
            //element.Geometry = polygon as IGeometry;
            //graphicsContainer3D.AddElement(element);

            IGeometry pGeometry = GeometryUtilities.ConvertProjToGeo(polygon as IGeometry);
            //地面网格图层是经纬度
            IFeatureLayer groundFeatureLayer = GISMapApplication.Instance.GetLayer(LayerNames.GroundGrids) as IFeatureLayer;
            IFeatureClass groundFeatureClass = groundFeatureLayer.FeatureClass;

            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry = pGeometry;
            //spatialFilter.Geometry = pPolygon as IGeometry;
            spatialFilter.GeometryField = groundFeatureClass.ShapeFieldName;
            spatialFilter.SpatialRel    = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor featureCursor = groundFeatureClass.Search(spatialFilter, false);

            int CenterXIndex = groundFeatureClass.Fields.FindField("CenterX");
            int CenterYIndex = groundFeatureClass.Fields.FindField("CenterY");
            int xindex       = groundFeatureClass.Fields.FindField("GXID");
            int yindex       = groundFeatureClass.Fields.FindField("GYID");

            IFeature pFeature;
            List <LTE.Geometric.Point> centerPoints = new List <LTE.Geometric.Point>();

            while ((pFeature = featureCursor.NextFeature()) != null)
            {
                int    gxid    = (int)pFeature.get_Value(xindex);
                int    gyid    = (int)pFeature.get_Value(yindex);
                double centerX = double.Parse(pFeature.get_Value(CenterXIndex).ToString());
                double centerY = double.Parse(pFeature.get_Value(CenterYIndex).ToString());

                IPoint crossWithGround = GeometryUtilities.ConstructPoint3D(centerX, centerY, 0);
                double lng = crossWithGround.X, lat = crossWithGround.Y;
                crossWithGround = (IPoint)GeometryUtilities.ConvertGeoToProj(crossWithGround as IGeometry);

                centerPoints.Add(new LTE.Geometric.Point(crossWithGround.X, crossWithGround.Y, crossWithGround.Z));
            }

            System.Runtime.InteropServices.Marshal.ReleaseComObject(featureCursor);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(groundFeatureLayer);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(groundFeatureClass);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(spatialFilter);
            System.Runtime.InteropServices.Marshal.ReleaseThreadCache();

            return(centerPoints);
        }
        private void CreateParcelFromSegmentCollection(ISegmentCollection Segments, string PlanName)
        {
            int iCnt = Segments.SegmentCount;

            ISegment[] pSegmentArr = new ISegment[iCnt];
            for (int j = 0; j < iCnt; j++)
            {
                pSegmentArr[j] = Segments.get_Segment(j);
            }

            ICadastralEditor   pCadEd         = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            IParcelEditManager pParcEditorMan = (IParcelEditManager)pCadEd;

            try
            {
                ICadastralPacketManager pCadPacketMan = (ICadastralPacketManager)pCadEd;
                bool bStartedWithPacketOpen           = pCadPacketMan.PacketOpen;
                if (!bStartedWithPacketOpen)
                {
                    m_editor.StartOperation();
                }

                //1. Start map edit session
                ICadastralMapEdit pCadMapEdit = (ICadastralMapEdit)pCadEd;
                pCadMapEdit.StartMapEdit(esriMapEditType.esriMEEmpty, "NewParcel", false);

                //2.	Get job packet
                ICadastralPacket pCadaPacket = pCadPacketMan.JobPacket;

                //3.	Create Plan (new)
                string sPlanName = PlanName;
                //first check to ensure plan is not already in the database.
                IGSPlan pGSPlan = FindFabricPlanByName(sPlanName, pCadEd);

                if (pGSPlan == null)
                {
                    //if plan is null, it was not found and can be created
                    pGSPlan = new GSPlanClass();
                    // 3.a set values
                    pGSPlan.Accuracy = 4;
                    pGSPlan.Name     = sPlanName;
                }

                //3.b Add the plan to the job packet
                ICadastralPlan pCadaPlan = (ICadastralPlan)pCadaPacket;
                pCadaPlan.AddPlan(pGSPlan);

                //4.	Create Parcel
                ICadastralParcel pCadaParcel  = (ICadastralParcel)pCadaPacket;
                IGSParcel        pNewGSParcel = new GSParcelClass();
                //Make sure that any extended attributes on the parcel have their default values set
                IGSAttributes pGSAttributes = (IGSAttributes)pNewGSParcel;
                if (pGSAttributes != null)
                {
                    ICadastralObjectSetup pCadaObjSetup = (ICadastralObjectSetup)pParcEditorMan;
                    pCadaObjSetup.AddExtendedAttributes(pGSAttributes);
                    pCadaObjSetup.SetDefaultValues(pGSAttributes);
                }

                //4a.	Add the parcel to the packet. (do this before addlines)
                // - This will enable us to Acquire the parcel ID,
                // - Having the parcel attached to the packet allows InsertLine to function.
                pCadaParcel.AddParcel(pNewGSParcel);
                pNewGSParcel.Lot  = "NewParcel";
                pNewGSParcel.Type = 7;
                //4b.	Set Plan (created above)
                IGSPlan thePlan = pCadaPlan.GetPlan(sPlanName);
                pNewGSParcel.Plan = thePlan;
                //4c.	Insert GSLines (from new) into GSParcel
                //4d. To bypass join, you can create GSPoints and assign those point IDs to the GSLines.
                ICadastralPoints     pCadaPoints     = (ICadastralPoints)pCadaPacket;
                IMetricUnitConverter pMetricUnitConv = (IMetricUnitConverter)pCadEd;

                //Set up the initial start point, POB

                IPoint pPt1 = Segments.get_Segment(0).FromPoint;

                IZAware pZAw = (IZAware)pPt1;
                pZAw.ZAware = true;
                pPt1.Z      = 0; //defaulting to 0

                //Convert the point into metric units, and get a new (in-mem) point id
                IGSPoint pGSPointFrom = pMetricUnitConv.SetGSPoint(pPt1);
                pCadaPoints.AddPoint(pGSPointFrom);
                int iID1      = pGSPointFrom.Id;
                int iID1_Orig = iID1;

                int     index   = 0;
                IGSLine pGSLine = null;
                //++++++++++++ Add Courses ++++++++++++++
                int  iID2    = -1;
                bool bIsLoop = (Math.Abs(pPt1.X - Segments.get_Segment(iCnt - 1).ToPoint.X)) < 0.01 &&
                               (Math.Abs(pPt1.Y - Segments.get_Segment(iCnt - 1).ToPoint.Y)) < 0.01;

                IAngularConverter pAngConv = new AngularConverterClass();

                for (int j = 0; j < iCnt; j++)
                {
                    pSegmentArr[j] = Segments.get_Segment(j);

                    double dDir         = 0; //radians north azimuth
                    ILine  pLineOrChord = new LineClass();
                    pLineOrChord.PutCoords(pSegmentArr[j].FromPoint, pSegmentArr[j].ToPoint);

                    if (pAngConv.SetAngle(pLineOrChord.Angle, esriDirectionType.esriDTPolar, esriDirectionUnits.esriDURadians))
                    {
                        dDir = pAngConv.GetAngle(esriDirectionType.esriDTNorthAzimuth, esriDirectionUnits.esriDURadians);
                    }

                    double dDist         = pLineOrChord.Length;
                    double dRadius       = 0;
                    int    iAccuracy     = -1;
                    int    iUserLineType = -1;
                    int    iCategory     = -1;

                    if (pSegmentArr[j] is ICircularArc)
                    {
                        ICircularArc pCircArc = pSegmentArr[j] as ICircularArc;
                        dRadius = pCircArc.Radius;
                        if (pCircArc.IsCounterClockwise)
                        {
                            dRadius = dRadius * -1;
                        }
                    }
                    bool bComputeToPoint = (bIsLoop && (j < iCnt - 1)) || !bIsLoop;
                    //From, Direction (NAz Radians), Distance (map's projection units), Radius
                    pGSLine = CreateGSLine(pMetricUnitConv, pCadaPoints, ref pPt1,
                                           iID1, dDir, dDist, dRadius, iAccuracy, iUserLineType, iCategory, bComputeToPoint, out iID2);

                    if (j < iCnt - 1 || !bIsLoop)
                    {
                        iID1 = iID2;
                    }
                    else if ((j == iCnt - 1) && bIsLoop)
                    {
                        pGSLine.ToPoint = iID1_Orig; //closing the traverse back to the POB
                    }
                    iID2 = -1;

                    //Add the line to the new parcel
                    if (pGSLine != null)
                    {
                        pNewGSParcel.InsertLine(++index, pGSLine);
                    }
                }


                //Add radial lines for circular curves
                pNewGSParcel.AddRadialLines();

                // 4.e then set join=true on the parcel.
                pNewGSParcel.Joined = true;

                //let the packet know that a change has been made
                pCadPacketMan.SetPacketModified(true);

                //save the new parcel
                try
                {
                    pCadMapEdit.StopMapEdit(true);
                }
                catch
                {
                    if (!bStartedWithPacketOpen)
                    {
                        m_editor.AbortOperation();
                    }
                    return;
                }
                if (!bStartedWithPacketOpen)
                {
                    m_editor.StopOperation("New Parcel");
                }
                pCadPacketMan.PartialRefresh();
            }
            catch (Exception ex)
            {
                m_editor.AbortOperation();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// ����Բ��
        /// </summary>
        /// <params name="pCircleArc"></params>
        private void DrawArc(ICircularArc pCircleArc)
        {
            if (pCircleArc == null) return;

            ISegmentCollection pSegColl;
            IPolyline pPolyline;
            pSegColl = new PolylineClass();
            pSegColl.AddSegment(pCircleArc as ISegment);
            pPolyline = pSegColl as IPolyline;

            IRgbColor pColor = new RgbColor();
            pColor.Red = 0;
            pColor.Green = 0;
            pColor.Blue = 0;

            m_LineSym = new SimpleLineSymbol();
            m_LineSym.Color = pColor;
            m_LineSym.Width = 1;
            m_LineSym.Style = esriSimpleLineStyle.esriSLSSolid;

            ISymbol pSym = m_LineSym as ISymbol;
            pSym.ROP2 = esriRasterOpCode.esriROPNotXOrPen;
            m_pLineFeedback.Symbol = pSym;

            m_hookHelper.ActiveView.ScreenDisplay.StartDrawing(m_hookHelper.ActiveView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
            m_hookHelper.ActiveView.ScreenDisplay.SetSymbol(pSym);
            m_hookHelper.ActiveView.ScreenDisplay.DrawPolyline(pPolyline);
            m_hookHelper.ActiveView.ScreenDisplay.FinishDrawing();
        }
Exemplo n.º 32
0
        private void DrawCircleByCenterAndRadius(ILayer pLayer, ICircularArc pCircularArc, IScreenDisplay pScreenDisplay)
        {
            object o = Type.Missing;
            if (pLayer != null)
            {
                ISegmentCollection pSegmentCollection = null;
                pSegmentCollection = new PathClass();
                if (pLayer is IFeatureLayer)
                {
                    IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
                    IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
                    if (pFeatureClass != null)
                    {

                        ISegment pSegment = pCircularArc as ISegment;
                        pSegmentCollection.AddSegment(pSegment, ref o, ref o);
                        IGeometryCollection pPolyline = new PolylineClass();
                        //ͨ��IGeometryCollectionΪPolyline�������Path����
                        pPolyline.AddGeometry(pSegmentCollection as IGeometry, ref o, ref o);
                        IFeature pCircleFeature = pFeatureClass.CreateFeature();
                        pCircleFeature.Shape = pPolyline as PolylineClass;
                        pCircleFeature.Store();

                        //�ֲ�ˢ��
                        IInvalidArea pInvalidArea = new InvalidAreaClass();
                        pInvalidArea.Add(pCircularArc);
                        pInvalidArea.Display = pScreenDisplay;
                        pInvalidArea.Invalidate((short)esriScreenCache.esriAllScreenCaches);

                        //20140410 lyf
                        m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null);
                    }
                }
            }
        }
        protected override void OnClick()
        {
            FileType ft = FileType.COGOToolbarTraverse; //start out assuming it is a cogo traverse file

            m_count = 1;
            ICadastralEditor            pCadEd         = (ICadastralEditor)ArcMap.Application.FindExtensionByName("esriCadastralUI.CadastralEditorExtension");
            ICadastralFabric            pCadFabric     = pCadEd.CadastralFabric;
            ICadastralExtensionManager2 pCadExtMan     = (ICadastralExtensionManager2)pCadEd;
            IParcelEditManager          pParcEditorMan = (IParcelEditManager)pCadEd;
            IParcelConstruction         pTrav          = pParcEditorMan.ParcelConstruction;

            if (!(pParcEditorMan.InTraverseEditMode) && !(pParcEditorMan.InConstructionEditMode))
            {//if this is not a construction or a new parcel, then get out.
                MessageBox.Show("Please create a new parcel or new construction first, and then try again.");
                return;
            }

            //Make sure the lines grid is selected
            Utilities UTILS = new Utilities();

            UTILS.SelectCadastralPropertyPage((ICadastralExtensionManager)pCadExtMan, "lines");

            IParcelConstruction3 pTrav3  = (IParcelConstruction3)pTrav;
            IGSParcel            pParcel = null;

            try
            {
                pParcel = pTrav.Parcel;
            }
            catch (COMException error)
            {
                MessageBox.Show(error.Message.ToString());
                return;
            }
            //go get a traverse file
            // Display .Net dialog for File selection.
            OpenFileDialog openFileDialog = new OpenFileDialog();

            // Set File Filter
            openFileDialog.Filter = "Traverse file (*.txt)|*.txt|Comma-delimited(*.csv)|*.csv|All Files|*.*";
            // Disable multi-select
            openFileDialog.Multiselect = false;
            // Don't need to Show Help
            openFileDialog.ShowHelp = false;
            // Set Dialog Title
            openFileDialog.Title       = "Load file";
            openFileDialog.FilterIndex = 2;
            // Display Open File Dialog
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                openFileDialog = null;
                return;
            }

            TextReader tr = null;

            try
            {
                tr = new StreamReader(openFileDialog.FileName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            string sCourse = "";
            int    iCount  = 0;

            string[] sFileLine = new string[0]; //define as dynamic array
            //initialize direction units and format
            esriDirectionType  enumDirectionType  = esriDirectionType.esriDTQuadrantBearing;
            esriDirectionUnits enumDirectionUnits = esriDirectionUnits.esriDUDegreesMinutesSeconds;

            //initialize start and end points
            IPoint StartPoint     = new PointClass();
            IPoint EndPoint       = new PointClass();
            bool   IsLoopTraverse = false;

            //fill the array with the lines from the file
            while (sCourse != null)
            {
                sCourse = tr.ReadLine();
                try
                {
                    if (sCourse.Trim().Length >= 1) //test for empty lines
                    {
                        RedimPreserveString(ref sFileLine, 1);
                        sFileLine[iCount] = sCourse;
                    }
                    iCount++;
                    sCourse = sCourse.ToLower();
                    if (sCourse.Contains("dt"))
                    {
                        if (sCourse.Contains("qb"))
                        {
                            enumDirectionType = esriDirectionType.esriDTQuadrantBearing;
                        }
                        else if (sCourse.Contains("na"))
                        {
                            enumDirectionType = esriDirectionType.esriDTNorthAzimuth;
                        }
                        else if (sCourse.Contains("sa"))
                        {
                            enumDirectionType = esriDirectionType.esriDTSouthAzimuth;
                        }
                        else if (sCourse.Contains("p"))
                        {
                            enumDirectionType = esriDirectionType.esriDTPolar;
                        }
                    }
                    if (sCourse.Contains("du"))
                    {
                        if (sCourse.Contains("dms"))
                        {
                            enumDirectionUnits = esriDirectionUnits.esriDUDegreesMinutesSeconds;
                        }
                        else if (sCourse.Contains("dd"))
                        {
                            enumDirectionUnits = esriDirectionUnits.esriDUDecimalDegrees;
                        }
                        else if (sCourse.Contains("g"))
                        {
                            enumDirectionUnits = esriDirectionUnits.esriDUGons;
                        }
                        else if (sCourse.Contains("r"))
                        {
                            enumDirectionUnits = esriDirectionUnits.esriDURadians;
                        }
                    }
                    if (sCourse.Contains("sp"))
                    {//start point
                        string[] XY = sCourse.Split(' ');
                        double   x  = Convert.ToDouble(XY[1]);
                        double   y  = Convert.ToDouble(XY[2]);
                        StartPoint.PutCoords(x, y);
                    }

                    if (sCourse.Contains("ep"))
                    {//end point
                        string[] XY = sCourse.Split(' ');
                        double   x  = Convert.ToDouble(XY[1]);
                        double   y  = Convert.ToDouble(XY[2]);
                        EndPoint.PutCoords(x, y);
                    }

                    if (sCourse.Contains("tometricfactor"))
                    {//this handles the comma-separated file case
                        string[] sScaleFactor = sCourse.Split(',');
                        m_dScaleFactor = Convert.ToDouble(sScaleFactor[1]);
                    }
                }
                catch { }
            }
            tr.Close(); //close the file and release resources
            string sFileExt = System.IO.Path.GetExtension(openFileDialog.FileName.TrimEnd());

            if ((sFileExt.ToLower() == ".csv") && (sFileLine[0].Contains(",")))
            {//if it's a comma-delimited file
                ft = FileType.CommaDelimited;
            }

            //Test for loop traverse
            if (!(EndPoint.IsEmpty))
            {
                if (EndPoint.Compare(StartPoint) == 0)
                {
                    IsLoopTraverse = true;
                }
                else
                {
                    IsLoopTraverse = false;
                }
            }

            //get highest point id number in grid, and get the to point id on the last line.
            IGSLine pParcelLine     = null;
            int     iFirstToNode    = -1;
            int     iLastToNode     = -1;
            int     iHighestPointID = -1;

            for (int i = 0; i < pTrav.LineCount; i++)
            {
                if (pTrav.GetLine(i, ref pParcelLine))
                {
                    if (iFirstToNode < 0)
                    {
                        iFirstToNode = pParcelLine.ToPoint;
                    }
                    iLastToNode     = pParcelLine.ToPoint;
                    iHighestPointID = iHighestPointID < pParcelLine.ToPoint ? pParcelLine.ToPoint : iHighestPointID;
                    iHighestPointID = iHighestPointID < pParcelLine.FromPoint ? pParcelLine.FromPoint : iHighestPointID;
                }
            }

            ICadastralUndoRedo pCadUndoRedo = pTrav as ICadastralUndoRedo;

            pCadUndoRedo.StartUndoRedoSession("Load Lines From File");
            try
            {
                IGSLine  pLine        = null;
                int      iLinecount   = iCount - 1;
                ISegment pExitTangent = null;
                for (iCount = 0; iCount <= iLinecount; iCount++)
                {
                    if (ft == FileType.COGOToolbarTraverse)
                    {
                        {
                            pLine = null;

                            ICircularArc pCircArc;//need to use this in the test to handle curves greater than 180
                            pLine = CreateGSLine(sFileLine[iCount], enumDirectionUnits, enumDirectionType,
                                                 pExitTangent, out pExitTangent, out pCircArc);
                            //exit tangent from the previous course is the new entry tangent for the next course

                            if (pLine != null)
                            {
                                if (pCircArc == null)
                                {// straight line
                                    //if this is the last course then set the to point to 1
                                    if ((iCount == iLinecount) && IsLoopTraverse)
                                    {
                                        pLine.ToPoint = 1;
                                    }
                                    pTrav.InsertGridRow(-1, pLine);
                                }
                                else
                                {                                                               //some post-processing needed to figure out if a 180 curve needs to be split
                                    if (Math.Abs(pCircArc.CentralAngle) < (Math.PI - 0.000001)) //some tolerance for being close to 180
                                    {                                                           //this curve is OK
                                      //if this is the last course then set the to point to 1
                                        if ((iCount == iLinecount) && IsLoopTraverse)
                                        {
                                            pLine.ToPoint = 1;
                                        }
                                        pTrav.InsertGridRow(-1, pLine);
                                    }
                                    else
                                    {//curve is greater than or equal to 180, special treatment for GSE needed to split curve into 2 parts
                                        //first decrement the count
                                        m_count -= 1;
                                        ISegment pFullSegment = (ISegment)pCircArc; ISegment pFirstHalf; ISegment pSecondHalf;
                                        pFullSegment.SplitAtDistance(0.5, true, out pFirstHalf, out pSecondHalf);
                                        IConstructCircularArc2 pCircArcConstr1 = new CircularArcClass();
                                        ICircularArc           pCircArc1       = (ICircularArc)pCircArcConstr1;
                                        pCircArcConstr1.ConstructEndPointsRadius(pFirstHalf.FromPoint,
                                                                                 pFirstHalf.ToPoint, pCircArc.IsCounterClockwise, pCircArc.Radius, true);
                                        ILine2 pTangentLine = new LineClass();
                                        pCircArc1.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 0, false, 100, pTangentLine);
                                        string sTangentBearing = PolarRadians_2_DirectionString(pTangentLine.Angle,
                                                                                                enumDirectionType, enumDirectionUnits);
                                        sTangentBearing = sTangentBearing.Replace(" ", "");
                                        string sHalfDelta = Radians_2_Angle(Math.Abs(pCircArc1.CentralAngle), enumDirectionUnits);
                                        string sSide      = pCircArc.IsCounterClockwise ? " L " : " R ";

                                        ISegment EntryTangent = (ISegment)pTangentLine;

                                        //construct the string for the first piece
                                        // looks similar to this: NC R 500 D 181-59-59 T N59-59-59W L
                                        string sFirstCurve = "NC R " + Convert.ToString(pCircArc.Radius)
                                                             + " D " + sHalfDelta + " T " + sTangentBearing + sSide;

                                        IGSLine pLineFirstCurve = CreateGSLine(sFirstCurve, enumDirectionUnits, enumDirectionType, pExitTangent,
                                                                               out pExitTangent, out pCircArc);
                                        pTrav.InsertGridRow(-1, pLineFirstCurve);

                                        ICircularArc pCircArc2 = (ICircularArc)pCircArcConstr1;
                                        pCircArcConstr1.ConstructEndPointsRadius(pSecondHalf.FromPoint,
                                                                                 pSecondHalf.ToPoint, pCircArc.IsCounterClockwise, pCircArc.Radius, true);
                                        pCircArc2.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 0, false, 100, pTangentLine);
                                        sTangentBearing = PolarRadians_2_DirectionString(pTangentLine.Angle, enumDirectionType, enumDirectionUnits);
                                        sTangentBearing = sTangentBearing.Replace(" ", "");
                                        //construct the string for the second piece
                                        // looks similar to this: NC R 500 D 181-59-59 T N59-59-59W L
                                        string sSecondCurve = "NC R " + Convert.ToString(pCircArc.Radius)
                                                              + " D " + sHalfDelta + " T " + sTangentBearing + sSide;

                                        IGSLine pLineSecondCurve = CreateGSLine(sSecondCurve, enumDirectionUnits, enumDirectionType, pExitTangent,
                                                                                out pExitTangent, out pCircArc);
                                        //if this is the last course then set the to point to 1
                                        if ((iCount == iLinecount) && IsLoopTraverse)
                                        {
                                            pLine.ToPoint = 1;
                                        }
                                        pTrav.InsertGridRow(-1, pLineSecondCurve);
                                    }
                                }
                            }
                        }
                    }
                    else//this is comma-separated version of the grid, so do the following
                    {
                        pLine = null;
                        //apply a point id number offset if there are existing lines in the grid.
                        if (iHighestPointID > -1 && iCount >= 3)
                        {
                            string[] sTraverseCourse = sFileLine[iCount].Split(',');
                            if (iCount == 3)
                            {
                                sTraverseCourse[0] = iLastToNode.ToString();
                                sTraverseCourse[5] = (Convert.ToInt32(sTraverseCourse[5]) + iHighestPointID).ToString();
                            }
                            else if (iCount > 3)
                            {
                                sTraverseCourse[0] = (Convert.ToInt32(sTraverseCourse[0]) + iHighestPointID).ToString();
                                sTraverseCourse[5] = (Convert.ToInt32(sTraverseCourse[5]) + iHighestPointID).ToString();
                            }

                            sFileLine[iCount] = sTraverseCourse[0];
                            int iAttCount = sTraverseCourse.GetLength(0);
                            for (int j = 1; j < iAttCount; j++)
                            {
                                sFileLine[iCount] += "," + sTraverseCourse[j];
                            }
                        }

                        pLine = CreateGSLineFromCommaSeparatedString(sFileLine[iCount], enumDirectionUnits, enumDirectionType);

                        if (pLine != null)
                        {
                            pTrav.InsertGridRow(-1, pLine);
                        }
                    }
                }
                pTrav3.UpdateGridFromGSLines(false);
                IParcelConstruction2 pConstr2 = (IParcelConstruction2)pTrav3; //hidden interface
                pConstr2.RecalculatePoints();                                 //explicit recalculate needed on a construction
                pParcel.Modified();
                pParcEditorMan.Refresh();
                pCadUndoRedo.WriteUndoRedoSession(true);
                sFileLine      = null;
                openFileDialog = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Load Lines From File");
                pCadUndoRedo.WriteUndoRedoSession(false);
            }
        }
Exemplo n.º 34
0
        public int GetSelectSegment(IFeature pFeature, IPoint pPoint, ref ISegment pSegment)
        {
            int index = -1;

            pSegment = null;

            if (pFeature == null || pPoint == null)
            {
                return(index);
            }

            ISegmentCollection pSegCol = pFeature.ShapeCopy as ISegmentCollection;
            ISegment           pSeg;
            double             dDistance = 0;
            double             dTempDist = 0;

            IPoint pPt1;
            IPoint pPt2;
            ILine  tmpLine = null;
            IPoint pProjectPt;

            for (int i = 0; i < pSegCol.SegmentCount; i++)
            {
                pSeg = pSegCol.Segment[i];
                if (pSeg.GeometryType == esriGeometryType.esriGeometryLine)
                {
                    if (dDistance == 0 && pSegment == null)
                    {
                        tmpLine = new LineClass();
                        tmpLine.PutCoords(pSeg.FromPoint, pSeg.ToPoint);
                        //点到直线的距离
                        dDistance = Math.Abs(GetPointToLineDistance(pPoint, tmpLine));
                        pSegment  = pSeg;
                        index     = i;
                    }
                    else
                    {
                        tmpLine.PutCoords(pSeg.FromPoint, pSeg.ToPoint);
                        if (pSeg.FromPoint.X < pSeg.ToPoint.X)
                        {
                            pPt1 = pSeg.FromPoint;
                            pPt2 = pSeg.ToPoint;
                        }
                        else
                        {
                            pPt2 = pSeg.FromPoint;
                            pPt1 = pSeg.ToPoint;
                        }

                        //如果投影点不在直线上,刚此条直线不能够算离点最近
                        pProjectPt = GetProjectionPoint(pPoint, tmpLine);
                        dTempDist  = Math.Abs(GetPointToLineDistance(pPoint, tmpLine));
                        if (dDistance > dTempDist)
                        {
                            dDistance = dTempDist;
                            pSegment  = pSeg;
                            index     = i;
                        }
                    }
                }
                else if (pSeg.GeometryType == esriGeometryType.esriGeometryCircularArc)
                {
                    ICircularArc tmpArc = pSeg as ICircularArc;
                    if (dDistance == 0 && pSegment == null)
                    {
                        dDistance = Math.Abs(Math.Sqrt(Math.Pow(pPoint.X - tmpArc.CenterPoint.X, 2) + Math.Pow(pPoint.Y - tmpArc.CenterPoint.Y, 2)));
                        pSegment  = pSeg;
                        index     = i;
                    }
                    else
                    {
                        dTempDist = Math.Abs(Math.Sqrt(Math.Pow(pPoint.X - tmpArc.CenterPoint.X, 2) + Math.Pow(pPoint.Y - tmpArc.CenterPoint.Y, 2)));
                        if (dDistance > dTempDist)
                        {
                            pSegment = pSeg;
                            index    = i;
                        }
                    }
                }
            }
            return(index);
        }
        private IGSLine CreateGSLine(String inCourse, esriDirectionUnits inDirectionUnits,
            esriDirectionType inDirectionType, ISegment EntryTangent,
            out ISegment ExitTangent, out ICircularArc outCircularArc)
        {
            //
              string[] sCourse = inCourse.Split(' ');
              Utilities UTILS = new Utilities();
              double dToMeterUnitConversion = UTILS.ToMeterUnitConversion();
              // ISegment ExitTangent = null;
              string item = (string)sCourse.GetValue(0);
              if (item.ToLower() == "dd")
              {//Direction distance -- straight line course
            IGSLine pLine = new GSLineClass();
            double dBear = DirectionString_2_NorthAzimuth((string)sCourse.GetValue(1), inDirectionType, inDirectionUnits);
            pLine.Bearing = dBear;
            pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
            pLine.FromPoint = m_count;
            m_count += 1;
            pLine.ToPoint = m_count;
            //Now define the tangent exit segment
            //in case it's needed for the next course (TC tangent curve, or Angle deflection)
            double dPolar = DirectionString_2_PolarRadians((string)sCourse.GetValue(1),
                inDirectionType, inDirectionUnits);
            IPoint pFromPt = new PointClass();
            pFromPt.PutCoords(1000, 1000);
            IConstructPoint2 pToPt = new PointClass();
            pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
            ILine ExitTangentLine = new LineClass();
            ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
            ExitTangent = (ISegment)ExitTangentLine;
            outCircularArc = null;
            Marshal.ReleaseComObject(pFromPt);
            Marshal.ReleaseComObject(pToPt);
            return pLine;
              }
              if (item.ToLower() == "ad")
              {//Angle deflection distance
            IGSLine pLine = new GSLineClass();
            double dDeflAngle = Angle_2_Radians((string)sCourse.GetValue(1), inDirectionUnits);
            //now need to take the previous tangent segment, reverse its orientation and
            //add +ve clockwise to get the bearing
            ILine calcLine = (ILine)EntryTangent;
            double dBear = PolarRAD_2_SouthAzimuthRAD(calcLine.Angle) + dDeflAngle;
            pLine.Bearing = dBear;
            pLine.Distance = Convert.ToDouble(sCourse.GetValue(2)) * dToMeterUnitConversion;
            pLine.FromPoint = m_count;
            m_count += 1;
            pLine.ToPoint = m_count;
            //Now define the tangent exit segment
            //in case it's needed for the next course (TC tangent curve, or Angle deflection)
            IPoint pFromPt = new PointClass();
            pFromPt.PutCoords(1000, 1000);
            IConstructPoint2 pToPt = new PointClass();
            double dPolar = NorthAzimuthRAD_2_PolarRAD(dBear);
            pToPt.ConstructAngleDistance(pFromPt, dPolar, 100);
            ILine ExitTangentLine = new LineClass();
            ExitTangentLine.PutCoords(pFromPt, (IPoint)pToPt);
            ExitTangent = (ISegment)ExitTangentLine;
            outCircularArc = null;
            Marshal.ReleaseComObject(pFromPt);
            Marshal.ReleaseComObject(pToPt);

            return pLine;
              }
              else if ((item.ToLower() == "nc") || (item.ToLower() == "tc"))
              {
            double dChordlength;
            double dChordBearing;
            ICircularArc pArc = ConstructCurveFromString(inCourse, EntryTangent,
                inDirectionType, inDirectionUnits, out dChordlength, out dChordBearing);
            try
            {
              IGSLine pLine = new GSLineClass();
              pLine.Bearing = PolarRAD_2_NorthAzimuthRAD(dChordBearing);
              pLine.Radius = pArc.Radius * dToMeterUnitConversion;//convert to meters
              if (pArc.IsCounterClockwise) { pLine.Radius = pLine.Radius * -1; }
              pLine.Distance = dChordlength * dToMeterUnitConversion; //convert to meters
              pLine.FromPoint = m_count;
              m_count += 1;
              pLine.ToPoint = m_count;
              ILine pTangentLine = new LineClass();
              pArc.QueryTangent(esriSegmentExtension.esriExtendTangentAtTo, 1, true, 100, pTangentLine);
              //pass the exit tangent back out for use as next entry tangent
              ExitTangent = (ISegment)pTangentLine;
              outCircularArc = pArc;
              return pLine;
            }
            catch { }
              }
              outCircularArc = null;
              ExitTangent = null;
              return null;
        }
        private IGSLine CreateGSLine(IMetricUnitConverter MetricConversion, ICadastralPoints CadastralPoints,
                                     ref IPoint FromPointInToPointOut, int FromPointID, double Direction, double Distance,
                                     double Radius, int Accuracy, int UserLineType, int Category, bool ComputeToPoint, out int ToPointID)
        {
            //In this function, Radius == 0 means a straight line
            //If the radius is >0 or <0 then the line is a circular curve with Distance as the chord length
            //for curves Bearing means chord bearing
            //negative radius means a curve to the left, positive radius curve to the right
            //for no Accuracy, no Type, or no Category pass in -1
            //Bearing is in north azimuth radians

            IGSLine pLine = new GSLineClass();

            pLine.Bearing = Direction; //direction is in radians north azimuth
            double dConvertedDistance = 0;

            MetricConversion.ConvertDistance(esriCadastralUnitConversionType.esriCUCToMetric, Distance, ref dConvertedDistance);
            pLine.Distance = dConvertedDistance; //needs to be in meters;

            if (Math.Abs(Radius) > 0)
            {
                MetricConversion.ConvertDistance(esriCadastralUnitConversionType.esriCUCToMetric, Radius, ref dConvertedDistance);
                pLine.Radius = dConvertedDistance; //needs to be in meters;
            }

            pLine.FromPoint = FromPointID;
            pLine.ToPoint   = -1;

            if (Accuracy > -1)
            {
                pLine.Accuracy = Accuracy;
            }
            if (UserLineType > -1)
            {
                pLine.LineType = UserLineType;
            }
            if (Category > -1)
            {
                pLine.Category = (esriCadastralLineCategory)Category;
            }

            //Make sure that any extended attributes on the line have their default values set
            IGSAttributes pGSAttributes = (IGSAttributes)pLine;

            if (pGSAttributes != null)
            {
                ICadastralObjectSetup pCadaObjSetup = (ICadastralObjectSetup)MetricConversion; //QI
                pCadaObjSetup.AddExtendedAttributes(pGSAttributes);
                pCadaObjSetup.SetDefaultValues(pGSAttributes);
            }

            //Compute the new end point for the line.
            //FromPointInToPointOut is in units of the map projection.
            ICurve pCurv = MetricConversion.GetSurveyedLine(pLine, CadastralPoints, false, FromPointInToPointOut);

            //pCurv is also in the units of the map projection. Convert the end point to metric units.

            FromPointInToPointOut   = pCurv.ToPoint;//pass the new To point back out
            FromPointInToPointOut.Z = 0;
            IGSPoint pGSPointTo = MetricConversion.SetGSPoint(FromPointInToPointOut);

            if (ComputeToPoint)
            {
                CadastralPoints.AddPoint(pGSPointTo);
                pLine.ToPoint = pGSPointTo.Id;
                ToPointID     = pLine.ToPoint;
            }
            else
            {
                ToPointID = -1;
            }

            if (pCurv is ICircularArc)
            {
                ICircularArc pCircArc = (ICircularArc)pCurv;
                IPoint       pCtrPt   = pCircArc.CenterPoint;
                IZAware      pZAw     = (IZAware)pCtrPt;
                pZAw.ZAware = true;
                pCtrPt.Z    = 0;
                IGSPoint pGSCtrPt = MetricConversion.SetGSPoint(pCtrPt);
                CadastralPoints.AddPoint(pGSCtrPt);
                pLine.CenterPoint = pGSCtrPt.Id;
            }

            return(pLine);
        }
Exemplo n.º 37
0
        public override void OnMouseMove(int Button, int Shift, int X, int Y)
        {
            IPoint pMovePt = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            pMovePt = GIS.GraphicEdit.SnapSetting.getSnapPoint(pMovePt);
            if (m_lMouseDownCount == 1)
            {
                m_pLineFeedback.MoveTo(pMovePt);
            }
            else if (m_lMouseDownCount == 2)
            {
                m_bCreated = false;

                IEnvelope pEnv = new EnvelopeClass();
                pEnv.UpperLeft = m_pFirstPoint;
                pEnv.LowerRight = m_pSecondPoint;

                IConstructCircularArc pEllipArc = new CircularArcClass();
                pEllipArc.ConstructThreePoints(m_pFirstPoint, m_pSecondPoint, pMovePt, true);
                m_pCircleArc = pEllipArc as ICircularArc;
                m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewForeground, null, null);
            }
            DataEditCommon.g_pAxMapControl.Focus();
        }