Engine中旋转地图后如何指定范围输出为图片?

Engine中旋转地图后如何指定范围输出为图片?
已邀请:

刘峥 - ArcGIS多面手

赞同来自: lordum

【解决办法】:
需要先将输出范围的几何也旋转一下再输出,否则范围会比指定的大,参考代码:


//rotation为地图旋转角度(单位为角度)
​private void Do_Export(object sender, EventArgs e)
        {
            IMap map = axMapControl1.Map;
            IActiveView actView = axMapControl1.ActiveView;
            IGraphicsContainer GC = map.BasicGraphicsLayer as IGraphicsContainer;
            IEnumElement enumElement = GC.LocateElementsByEnvelope(axMapControl1.ActiveView.Extent);
            enumElement.Reset();
            IElement element = enumElement.Next();
            geo = element.Geometry;

//旋转输出范围几何
            ITransform2D trans2D = geo as ITransform2D;
            trans2D.Rotate(((IArea)geo).Centroid, rotation*Math.PI/180); 
            IEnvelope aftRot = geo.Envelope as IEnvelope;

            ExportImage(m_mapControl.ActiveView, crtPath + \\output.jpg, aftRot, (int)aftRot.Width, (int)aftRot.Height);
        }

        public static void ExportImage(IActiveView pActiveView, string sFilePath, IEnvelope outputExtent, int width, int height)
        {
            IExport pExporter = new ExportJPEGClass();
            IEnvelope pEnvelope = new EnvelopeClass();

            int pResolution = width * (int)(pActiveView.ScreenDisplay.DisplayTransformation.Resolution) / pActiveView.ExportFrame.right;

            tagRECT ptagRECT;
            ptagRECT.left = 0;
            ptagRECT.top = 0;
            ptagRECT.right = width;
            ptagRECT.bottom = height;

            pEnvelope.PutCoords(ptagRECT.left, ptagRECT.bottom, ptagRECT.right, ptagRECT.top);
            pExporter.Resolution = pResolution;
            pExporter.ExportFileName = sFilePath;
            pExporter.PixelBounds = pEnvelope;

//指定输出范围
            pActiveView.Output(pExporter.StartExporting(), (System.Int16)pExporter.Resolution, ref ptagRECT, outputExtent, null);

            pExporter.FinishExporting();
            pExporter.Cleanup();
        }

要回复问题请先登录注册