热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

在AE中高效添加地图指北针以提升地理信息准确性

在AdobeAfterEffects中,通过高效添加地图指北针,可以显著提升地理信息的准确性和视觉效果。本文介绍了一种方法,利用代码函数`publicstaticvoidExportMapEx(stringfilepath,intresolution,AxMapControlcurMapControl)`,实现地图导出时自动添加指北针,确保地理数据的精确性和一致性。此外,还详细探讨了如何优化指北针的位置和样式,以增强地图的可读性和专业性。

  public static void ExportMapEx(string filepath, int resolution, AxMapControl curMapControl)
        {
            try
            {
                // 从Style文件中获取指定的指北针
                string stylefilePath Application.StartupPath @"\style\testArrow.ServerStyle";
                INorthArrow pNorthArrow GetSymbol(stylefilePath, "North Arrows", "ESRI North 2") as INorthArrow;
                if (pNorthArrow == null) return;
                // 设置指北针的位置及大小
                ESRI.ArcGIS.Geometry.IEnvelope envelope3 new ESRI.ArcGIS.Geometry.EnvelopeClass();
                envelope3.PutCoords(2, 2, 5, 5);

                // 设置当前活动视图,m_MapDocument为当前打开的地图文档
                IActiveView pCurActiveView MyGIS.Forms.MainForm.m_MapDocument.PageLayout as IActiveView;
                MyGIS.Forms.MainForm.m_MapDocument.SetActiveView(pCurActiveView);
                IGraphicsContainer pGraphicContainer (IGraphicsContainer)MyGIS.Forms.MainForm.m_MapDocument.PageLayout;

                IMapFrame mapFrame pGraphicContainer.FindFrame(pCurActiveView.FocusMap) as IMapFrame ;
                IMapSurroundFrame mapSurroundFrame new MapSurroundFrameClass();
                mapSurroundFrame.MapFrame mapFrame;
                mapSurroundFrame.MapSurround pNorthArrow as IMapSurround;
                IElement element (IElement)mapSurroundFrame;
                element.Geometry envelope3;

                // 添加元素
                element.Activate(pCurActiveView.ScreenDisplay);
                pGraphicContainer.AddElement(element, 0);
                //pCurActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, mapSurroundFrame, null);

                // 这里分辨率分两种情况:96dpi和300dpi
                string extension System.IO.Path.GetExtension(filepath);
                IExport pExporter null;
                if (extension == ".bmp")
                {
                    pExporter new ExportBMPClass();
                }
                else if (extension == ".jpg")
                {
                    pExporter new ExportJPEGClass();
                }
                else if (extension == ".png")
                {
                    pExporter new ExportPNGClass();
                }
                else if (extension == ".gif")
                {
                    pExporter new ExportGIFClass();
                }
                else if (extension == ".pdf")
                {
                    pExporter new ExportPDFClass();
                }
                else if (extension == ".tif")
                {
                    pExporter new ExportTIFFClass();
                }

                pExporter.ExportFileName filepath;
                tagRECT deviceRECT default(tagRECT);
                if (resolution 96)
                {
                    return;
                }
                // 区分设置分辨率
                if (resolution == 96)
                {
                    pExporter.Resolution resolution;
                    deviceRECT pCurActiveView.ExportFrame;
                    IEnvelope pDriverBounds new EnvelopeClass();
                    pDriverBounds.PutCoords(deviceRECT.left, deviceRECT.bottom, deviceRECT.right, deviceRECT.top);
                    pExporter.PixelBounds pDriverBounds;
                }
                else
                {
                    System.Int32 screenResolution 96;
                    pExporter.Resolution resolution;
                    deviceRECT.left 0;
                    deviceRECT.top 0;
                    deviceRECT.right (int)(pCurActiveView.ExportFrame.right (resolution screenResolution));
                    deviceRECT.bottom (int)(pCurActiveView.ExportFrame.bottom (resolution screenResolution));

                    ESRI.ArcGIS.Geometry.IEnvelope envelope new ESRI.ArcGIS.Geometry.EnvelopeClass();
                    envelope.PutCoords(deviceRECT.left, deviceRECT.top, deviceRECT.right, deviceRECT.bottom);
                    pExporter.PixelBounds envelope;
                }

                //ITrackCancel pCancel new CancelTrackerClass();
                //curMapControl.ActiveView.Output(pExporter.StartExporting(), Convert.ToInt32(lScreenResolution), ref deviceRECT, curMapControl.ActiveView.Extent, pCancel);
                pCurActiveView.Output(pExporter.StartExporting(), Convert.ToInt32(resolution), ref deviceRECT, null, null);
                pExporter.FinishExporting();
                pExporter.Cleanup();
                MessageBox.Show("导出图像成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show("导出异常: \n" ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }

 

#ae开发

推荐阅读
author-avatar
白堤柳帘佳_688
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有