Пример #1
0
        public static double GetRYPolygonArea(ESRI.ArcGIS.Geometry.IPolygon pXYPolygon, double dblcenter)
        {
            double RYPolygonArea = 0;

            if (pXYPolygon == null || pXYPolygon.IsEmpty)
            {
                return(RYPolygonArea);
            }
            //转换成经纬度
            IPolygon pLBPolygon = pXYPolygon;
            double   fMinL;
            int      nStartIndex;//最左边的点索引值

            if (GetMinLIndex(pLBPolygon, out fMinL, out nStartIndex) == false)
            {
                return(RYPolygonArea);
            }
            try
            {
                IPointCollection pPointCollection = pLBPolygon as IPointCollection;
                int    nPointCount = pPointCollection.PointCount;
                IPoint pPoint1, pPoint2;
                double fArea     = 0;
                int    nCurIndex = nStartIndex;
                fArea     = 0;
                dblcenter = 3600 / mdlPublic.RHO * dblcenter;
                for (int i = 0; i < nPointCount; i++)
                {
                    double dYushu1 = Math.IEEERemainder(nCurIndex, nPointCount);
                    double dYushu2 = Math.IEEERemainder(nCurIndex + 1, nPointCount);
                    if (dYushu1 < 0)
                    {
                        dYushu1 = dYushu1 + nPointCount;
                    }
                    if (dYushu2 < 0)
                    {
                        dYushu2 = dYushu2 + nPointCount;
                    }
                    pPoint1 = pPointCollection.get_Point(Convert.ToInt32(dYushu1));
                    pPoint2 = pPointCollection.get_Point(Convert.ToInt32(dYushu2));
                    double dblX1, dblX2, dblY1, dblY2;
                    modXY2LB.ComputeXYGeo(pPoint1.Y, pPoint1.X, out dblY1, out dblX1, dblcenter);
                    modXY2LB.ComputeXYGeo(pPoint2.Y, pPoint2.X, out dblY2, out dblX2, dblcenter);
                    double fTempArea;
                    //将所有的换算成弧度
                    //检查是否首先需要换算成整数
                    dblX1     = dblX1 / mdlPublic.RHO;
                    dblX2     = dblX2 / mdlPublic.RHO;
                    dblY1     = dblY1 / mdlPublic.RHO;
                    dblY2     = dblY2 / mdlPublic.RHO;
                    fTempArea = GetRYTXArea(ref dblX1, ref dblY1, ref dblX2, ref dblY2, m_pLLAreaPrama);
                    fArea     = fArea + fTempArea;
                    nCurIndex = nCurIndex + 1;
                }
                RYPolygonArea = fArea;
                return(RYPolygonArea);
            }
            catch { return(RYPolygonArea); }
        }
Пример #2
0
        /// <summary>
        /// 面的构造函数
        /// </summary>
        /// <param name="_layer">图层</param>
        /// <param name="kmlPolygon">图元(kml)</param>
        /// <param name="mapfac">地图工厂</param>
        public Polygon_ArcMap(AxMapControl _mapcontrol, KmlPolygon kmlPolygon, FactoryArcMap _mapFac)
        {
            this.mapControl = _mapcontrol;
            mapFactory      = _mapFac;

            Dosomething((Action)(delegate
            {
                lineSymbol = new SimpleLineSymbolClass();
                //轮廓颜色
                IColor outlineColor = new RgbColorClass()
                {
                    Red = kmlPolygon.OutLineColor.R,
                    Green = kmlPolygon.OutLineColor.G,
                    Blue = kmlPolygon.OutLineColor.B
                };
                lineSymbol.Color = outlineColor;
                lineSymbol.Width = kmlPolygon.OutLineSize;
                //存储颜色和宽度
                outLineColor = kmlPolygon.OutLineColor;
                outLineWidth = kmlPolygon.OutLineSize;

                fillSymbol = new SimpleFillSymbol();
                fillSymbol.Outline = lineSymbol;
                //填充色
                IColor c = new RgbColorClass()
                {
                    Red = kmlPolygon.FillColor.R,
                    Green = kmlPolygon.FillColor.G,
                    Blue = kmlPolygon.FillColor.B
                };
                fillSymbol.Color = c;
                this.fillColor = kmlPolygon.FillColor;

                base.Symbol = fillSymbol;
                polygon = new PolygonClass();
                pointCollection = polygon as IPointCollection;
                foreach (var lngLat in kmlPolygon.PositionList)
                {
                    pointCollection.AddPoint(new PointClass()
                    {
                        X = lngLat.Lng, Y = lngLat.Lat
                    });
                }
                base.Geometry = (IGeometry)pointCollection;

                pointList = new List <MapLngLat>();//坐标点集合
                pointList = kmlPolygon.PositionList;

                this.Description = kmlPolygon.Description;
            }), true);

            flashTimer          = new Timer();
            flashTimer.Elapsed += new ElapsedEventHandler(flashTimer_Elapsed);
        }
Пример #3
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            if (m_hookHelper.Hook == null)
            {
                return;
            }

            List <IGeometry> vTemp = GetDataGeometry(m_hookHelper.FocusMap);
            IMap             pMap  = m_hookHelper.FocusMap;

            if (vTemp == null)
            {
                return;
            }
            ESRI.ArcGIS.Geometry.IPolygon pGeometry = GetUnion(vTemp) as IPolygon;

            if (pGeometry == null)
            {
                return;
            }
            IArea  pArea = pGeometry as IArea;
            double area  = pArea.Area;

            GetArea(ref area, pMap);
            //ygc 2012-10-15 屏蔽面积判断
            //double dArea = SysCommon.ModSysSetting.GetExportAreaOfUser(Plugin.ModuleCommon.TmpWorkSpace, m_pAppForm.ConnUser);
            //if (dArea >= 0 && area > dArea)
            //{
            //    MessageBox.Show("超过提取最大面积", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            //    return;
            //}
            //end
            //ICommand pCmd = new ControlsClearSelectionCommandClass();
            //pCmd.OnCreate(m_hookHelper.Hook);
            //pCmd.OnClick();
            pMap.ClearSelection();
            m_pActiveView.Refresh();
            Application.DoEvents();
            drawgeometryXOR(pGeometry, m_pScreenDisplay);


            frm             = new frmExport(pMap, pGeometry);
            frm.WriteLog    = WriteLog;//ygc 2012-9-12 是否写日志
            frm.m_area      = area;
            frm.FormClosed += new FormClosedEventHandler(frm_FormClosed);
            frm.ShowDialog();
            Application.DoEvents();
        }
Пример #4
0
        public static double GetArea(ESRI.ArcGIS.Geometry.IPolygon pPolygon, double dblcenter)
        {
            double Area = 0;

            if (pPolygon == null)
            {
                return(Area);
            }
            try
            {
                if (m_pLLAreaPrama.m_A == 0)
                {
                    mdlPublic.SetLLAreaPrama(ref m_pLLAreaPrama, 1000);
                }
                ITopologicalOperator pTopologicalOperator = null;
                IGeometryCollection  pGeometryCollection  = pPolygon as IGeometryCollection;
                int nRingCount = pGeometryCollection.GeometryCount;
                if (nRingCount == 1)//单环的多边形
                {
                    Area = GetRYPolygonArea(pPolygon, dblcenter);
                }
                else//多环的多边形计算总面积
                {
                    double fArea     = 0;
                    double fTempArea = 0;
                    for (int i = 0; i < nRingCount; i++)
                    {
                        IRing    pRing        = pGeometryCollection.get_Geometry(i) as IRing;
                        IPolygon pTempPolygon = MakePolygonFromRing(pRing) as IPolygon;
                        if (pTempPolygon == null)
                        {
                            return(Area);
                        }
                        int nAreaSng;
                        //凌海峰 2008-0405:下面的代码是有些问题的,请以后修改,Polygon本身就有办法判断内外环的,这里暂时不修改了
                        SimplyPolygon(pTempPolygon, out nAreaSng);
                        fTempArea = GetRYPolygonArea(pTempPolygon, dblcenter);
                        fArea     = fArea + nAreaSng * Math.Abs(fTempArea);
                    }
                    Area = Math.Abs(fArea);
                }
                return(Area);
            }
            catch { return(Area); }
        }
Пример #5
0
 /// <summary>
 /// 释放资源
 /// </summary>
 public void Dispose()
 {
     if (flashTimer != null)
     {
         flashTimer.Stop();
         flashTimer.Dispose();
     }
     lineSymbol        = null;
     fillSymbol        = null;
     pointCollection   = null;
     polygon           = null;
     this.isHightLight = false;
     isVisible         = true;
     if (pointList != null)
     {
         pointList.Clear();
         pointList = null;
     }
 }
Пример #6
0
        //获得一个环的形状
        private static ESRI.ArcGIS.Geometry.Polygon MakePolygonFromRing(ESRI.ArcGIS.Geometry.IRing pRing)
        {
            ESRI.ArcGIS.Geometry.Polygon pResPolygon = null;

            ESRI.ArcGIS.Geometry.IPolygon pPolygon = null;
            try
            {
                pPolygon = new ESRI.ArcGIS.Geometry.PolygonClass();
                ESRI.ArcGIS.Geometry.IGeometryCollection pGeometryCollection;
                pGeometryCollection = pPolygon as ESRI.ArcGIS.Geometry.IGeometryCollection;
                object missing = Type.Missing;
                pGeometryCollection.AddGeometry(pRing, ref missing, ref missing);
                pResPolygon = pPolygon as ESRI.ArcGIS.Geometry.Polygon;
                return(pResPolygon);
            }
            catch (Exception err)
            {
                pResPolygon = null;
                pPolygon    = null;
            }
            return(null);
        }
Пример #7
0
        private void QueryBoundsFromGeom(int hDC, ref ESRI.ArcGIS.Display.IDisplayTransformation transform, ref ESRI.ArcGIS.Geometry.IPolygon boundary, ref ESRI.ArcGIS.Geometry.IPoint point)
        {
            // Calculate Size, XOffset and YOffset of the shape in Map units.
            double dMapXOffset = 0;
            double dMapSize = 0;
            double dMapYOffset = 0;

            dMapSize = PointsToMap(transform, m_dSize);
            if (m_dXOffset != 0)
                dMapXOffset = PointsToMap(transform, m_dXOffset);
            if (m_dYOffset != 0)
                dMapYOffset = PointsToMap(transform, m_dYOffset);
            point.PutCoords(point.X + dMapXOffset, point.Y + dMapYOffset);

            // Set up the device ratio.
            SetupDeviceRatio(hDC, transform);

            ESRI.ArcGIS.Geometry.IPointCollection ptColl = null;
            ESRI.ArcGIS.Geometry.ISegmentCollection segColl = null;
            double dVal = 0; // dVal is the measurement of the short side of a Triangles are based on.
            double dRad = 0;
            ptColl = (IPointCollection)boundary;
            segColl = (ISegmentCollection)boundary;
            dRad = dMapSize / 2;
            dVal = System.Math.Sqrt((dRad * dRad) / 2);
            object missing = System.Reflection.Missing.Value;
            ptColl.AddPoint(Utility.CreatePoint(point.X + dVal, point.Y - dVal), ref missing, ref missing);
            ptColl.AddPoint(Utility.CreatePoint(point.X - dVal, point.Y - dVal), ref missing, ref missing);
            ptColl.AddPoint(Utility.CreatePoint(point.X - dVal, point.Y + dVal), ref missing, ref missing);

            IPoint p = ptColl.get_Point(0);
            segColl.AddSegment((ISegment)Utility.CreateCircArc(point, ptColl.get_Point(2), ref p), ref missing, ref missing);

            //  Account for rotation also.
            ESRI.ArcGIS.Geometry.ITransform2D trans2D = null;
            if ((m_dAngle + m_dMapRotation) != 0)
            {
                trans2D = boundary as ITransform2D;
                trans2D.Rotate(point, Utility.Radians(m_dAngle + m_dMapRotation));
            }
        }
Пример #8
0
        void ESRI.ArcGIS.Display.IMarkerMask.QueryMarkerMask(int hDC, ESRI.ArcGIS.Geometry.ITransformation Transform, ESRI.ArcGIS.Geometry.IGeometry Geometry, ESRI.ArcGIS.Geometry.IPolygon Boundary)
        {
            //  Code QueryBoundary using same steps as Draw. But add a step where
            //  Points are converted to Map units, and then build an appropriate Polygon.
            if (Geometry == null | Boundary == null)
                return;
            if (!(Transform is ESRI.ArcGIS.Display.IDisplayTransformation))
                return;
            if (!(Geometry is ESRI.ArcGIS.Geometry.IPoint))
                return;
            Boundary.SetEmpty();

            IPoint point = Geometry as IPoint;
            IDisplayTransformation displayTrans = (IDisplayTransformation)Transform;
            QueryBoundsFromGeom(hDC, ref displayTrans, ref Boundary, ref point);

            // Unlike ISymbol.QueryBoundary, QueryMarkerMask requires a Simple geometry.
            ITopologicalOperator topo = Boundary as ITopologicalOperator;
            if (!topo.IsKnownSimple)
            {
                if (!topo.IsSimple)
                    topo.Simplify();
            }
        }
Пример #9
0
        void ESRI.ArcGIS.Display.ISymbol.QueryBoundary(int hDC, ESRI.ArcGIS.Geometry.ITransformation displayTransform, ESRI.ArcGIS.Geometry.IGeometry Geometry, ESRI.ArcGIS.Geometry.IPolygon Boundary)
        {
            // Check input parameters. Boundary may be a preexisting Polygon, so
            // make sure it's geometry is cleared.
            if (Geometry == null | Boundary == null)
                return;
            if (!(Geometry is ESRI.ArcGIS.Geometry.IPoint))
                return;
            Boundary.SetEmpty();

            IPoint point = (IPoint)Geometry;
            IDisplayTransformation displayTransformation = (IDisplayTransformation)displayTransform;

            QueryBoundsFromGeom(hDC, ref displayTransformation, ref Boundary, ref point);
        }