首页 > 其他分享 >ArcGIS Pro2.8插入公里网

ArcGIS Pro2.8插入公里网

时间:2022-12-29 19:56:44浏览次数:45  
标签:Pro2.8 Offset ArcGIS GridLineOrientation Instance 插入 new using

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ArcGIS.Core.CIM;
using ArcGIS.Core.Data;
using ArcGIS.Core.Geometry;
using ArcGIS.Desktop.Catalog;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Editing;
using ArcGIS.Desktop.Extensions;
using ArcGIS.Desktop.Framework;
using ArcGIS.Desktop.Framework.Contracts;
using ArcGIS.Desktop.Framework.Dialogs;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Layouts;
using ArcGIS.Desktop.Mapping;

namespace test
{
    internal class addGrid : Button
    {
        
        protected override void OnClick()
        {
            //Given by UMA esri arcgis pro developer - better to customize accordingly
            var activeLayout = LayoutView.Active.Layout;
            QueuedTask.Run(() =>
            {
                var layoutDefn = activeLayout.GetDefinition();

                var gridLinesEastWest = new CIMGridLine
                {
                    Name = "GridLines",
                    ElementType = GridElementType.Line,
                    GridLineOrientation = GridLineOrientation.EastWest,
                    Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(),
                    Pattern = new CIMGridPattern {
                        Interval = 30, Start = 0, Stop = 1, Gap = 0
                    }
                };
                var gridLinesNorthSouth = new CIMGridLine
                {
                    Name = "GridLines",
                    ElementType = GridElementType.Line,
                    GridLineOrientation = GridLineOrientation.NorthSouth,
                    Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(),
                    Pattern = new CIMGridPattern { Interval = 30, Start = 0, Stop = 1, Gap = 0 }
                }; var gridTicksNorthSouth = new CIMGridLine
                {
                    Name = "Ticks",
                    ElementType = GridElementType.Tick,
                    GridLineOrientation = GridLineOrientation.NorthSouth,
                    Pattern = new CIMGridPattern { Interval = 30, Start = 0, Stop = 1, Gap = 0 },
                    FromTick = new CIMExteriorTick { Length = 0.0694, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                    ToTick = new CIMExteriorTick { Length = 0.0694, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                };
                var gridTicksEastWest = new CIMGridLine
                {
                    Name = "Ticks",
                    ElementType = GridElementType.Tick,
                    GridLineOrientation = GridLineOrientation.EastWest,
                    Pattern = new CIMGridPattern { Interval = 30, Start = 0, Stop = 1, Gap = 0 },
                    FromTick = new CIMExteriorTick { Length = 0.0694, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                    ToTick = new CIMExteriorTick { Length = 0.0694, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                };
                var gridTicksSmallEastWest = new CIMGridLine
                {
                    Name = "Ticks 1",
                    ElementType = GridElementType.Tick,
                    GridLineOrientation = GridLineOrientation.EastWest,
                    Pattern = new CIMGridPattern { Interval = 5, Start = 1, Stop = 6, Gap = 0 },
                    FromTick = new CIMExteriorTick { Length = 0.0277, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                    ToTick = new CIMExteriorTick { Length = 0.0277, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                };
                var gridTicksSmallNorthSouth = new CIMGridLine {
                    Name = "Ticks 1",
                    ElementType = GridElementType.Tick,
                    GridLineOrientation = GridLineOrientation.NorthSouth,
                    Pattern = new CIMGridPattern { Interval = 5, Start = 1, Stop = 6, Gap = 0 },
                    FromTick = new CIMExteriorTick { Length = 0.0277, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                    ToTick = new CIMExteriorTick { Length = 0.0277, Offset = 0, IsVisible = true, Symbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(), },
                };
                var gridLabelsEastWest = new CIMGridLine
                {
                    Name = "Labels",
                    ElementType = GridElementType.Label,
                    GridLineOrientation = GridLineOrientation.EastWest,
                    Pattern = new CIMGridPattern { Interval = 30, Start = 0, Stop = 1, Gap = 0 },
                    FromTick = new CIMExteriorTick
                    {
                        Length = 0.0694,
                        Offset = 0,
                        IsVisible = true,
                        GridEndpoint = new CIMGridEndpoint
                        {
                            GridLabelTemplate = new CIMSimpleGridLabelTemplate
                            {
                                DynamicStringTemplate = "<dyn type=\"grid\" units=\"dms\" decimalPlaces=\"0\" showDirections=\"True\" showZeroMinutes=\"False\" showZeroSeconds=\"False\"/>",
                                //TODO                                
                                Symbol = (SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 7, "Tahoma", "Regular")).MakeSymbolReference()
                            },
                            Offset = 0.083,
                            Position = 2,
                            LineSelection = 7
                        }
                    },
                    ToTick = new CIMExteriorTick
                    {
                        Length = 0.0694,
                        Offset = 0,
                        IsVisible = true,
                        GridEndpoint = new CIMGridEndpoint
                        {
                            GridLabelTemplate = new CIMSimpleGridLabelTemplate
                            {
                                DynamicStringTemplate = "", //TODO                               
                                Symbol = (SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 0.5, "Tahoma", "Regular")).MakeSymbolReference()
                            },
                            Offset = 0.083,
                            Position = 2,
                            LineSelection = 7
                        }
                    }
                };
                var gridLabelsNorthSouth = new CIMGridLine
                {
                    Name = "Labels",
                    ElementType = GridElementType.Label,
                    GridLineOrientation = GridLineOrientation.NorthSouth,
                    Pattern = new CIMGridPattern { Interval = 30, Start = 0, Stop = 1, Gap = 0 },
                    FromTick = new CIMExteriorTick
                    {
                        Length = 0.0694,
                        Offset = 0,
                        IsVisible = true,
                        GridEndpoint = new CIMGridEndpoint
                        {
                            GridLabelTemplate = new CIMSimpleGridLabelTemplate
                            {
                                DynamicStringTemplate = "<dyn type=\"grid\" units=\"dms\" decimalPlaces=\"0\" showDirections=\"True\" showZeroMinutes=\"False\" showZeroSeconds=\"False\"/>", //TODO                                
                                Symbol = (SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 7, "Tahoma", "Regular")).MakeSymbolReference()
                            },
                            Offset = 0.083,
                            Position = 2,
                            LineSelection = 7
                        }
                    },
                    ToTick = new CIMExteriorTick
                    {
                        Length = 0.0694,
                        Offset = 0,
                        IsVisible = true,
                        GridEndpoint = new CIMGridEndpoint
                        {
                            GridLabelTemplate = new CIMSimpleGridLabelTemplate
                            {
                                DynamicStringTemplate = "", //TODO                               
                                Symbol = (SymbolFactory.Instance.ConstructTextSymbol(ColorFactory.Instance.BlackRGB, 0.5, "Tahoma", "Regular")).MakeSymbolReference()
                            },
                            Offset = 0.083,
                            Position = 2,
                            LineSelection = 7
                        }
                    }
                };

                var layoutGrid = new List<CIMMapGrid>();
                var mapGrid = new CIMGraticule
                {
                    Name = "Black Horizontal Label Graticule",
                    IsVisible = true,
                    MaxInteriorAngle = 150,
                    EdgeMinimumLength = 1,
                    GridLines = new CIMGridLine[] { gridLinesEastWest, gridLinesNorthSouth, gridTicksEastWest, gridTicksNorthSouth, gridTicksSmallEastWest, gridTicksSmallNorthSouth, gridLabelsEastWest, gridLabelsNorthSouth },
                    NeatlineSymbol = (SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlackRGB, 0.5, SimpleLineStyle.Solid)).MakeSymbolReference(),                    //Internal                    
                    GeographicCoordinateSystem = new ArcGIS.Core.Internal.CIM.GeographicCoordinateSystem
                    {
                        WKT = "GEOGCS[\"GCS_North_American_1983\",DATUM[\"D_North_American_1983\",SPHEROID[\"GRS_1980\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433],AUTHORITY[\"EPSG\",4269]]",
                        XOrigin = -400,
                        YOrigin = -400,
                        XYScale = 11258999068426.238,
                        ZOrigin = -10000,
                        ZScale = 10000,
                        MOrigin = -10000,
                        MScale = 10000,
                        XYTolerance = 8.9831528411952133E-09,
                        ZTolerance = 0.001,
                        MTolerance = 0.001,
                        HighPrecision = true,
                        LeftLongitude = -180,
                        WKID = 4269,
                        LatestWKID = 4269
                    }
                };

                var mapFrameElement = layoutDefn.Elements[0] as CIMMapFrame; //My layout has only one element                
                mapFrameElement.Grids = new CIMMapGrid[]
                {
                    mapGrid
                };

                activeLayout.SetDefinition(layoutDefn);
            });
        }
    }
}

 

标签:Pro2.8,Offset,ArcGIS,GridLineOrientation,Instance,插入,new,using
From: https://www.cnblogs.com/gisoracle/p/17013391.html

相关文章

  • excel、word、PPT中插入PDF文件不显示图标问题
    插入PDF对象,不显示正确的PDF图标临时解决办法:手动修改对象图标具体位置,可在C:\Windows\Installer目录下搜索PDFFile_8.ico尝试如下操作:手动复制生成C:\Windows\SysW......
  • PE格式:手工给程序插入ShellCode
    PE格式是Windows下最常用的可执行文件格式,理解PE文件格式不仅可以了解操作系统的加载流程,还可以更好的理解操作系统对进程和内存相关的管理知识,而有些技术必须建立在了......
  • 排序-插入排序
    插入排序的代码实现虽然没有冒泡排序和选择排序那么简单粗暴,但它的原理应该是最容易理解的了,因为只要打过扑克牌的人都应该能够秒懂。插入排序是一种最简单直观的排序算法,......
  • 3任务创建-列表项插入函数&列表项末尾插入函数
    1.列表项插入函数 通过列表项项值xItemValue比对,查找插入位置1voidvListInsert(List_t*constpxList,ListItem_t*constpxNewListItem)2{3ListIt......
  • wps js 宏之插入页码
    在写插入wps文档的页码时,原以为简单的事情,随着录制宏变得有些扑朔迷离。为了插入奇偶页不同的页码,我尝试用录制宏的方式,看系统是怎么设置的。结果得到以下代码。/***......
  • mysql 用select 语句的查询结果当作 insert 语句需要插入的值
    背景在实际使用中会遇到这样的场景,需要根据一个表里的内容在其他表中添加关联的数据,这时候就会用到insertinto{table_name}selectx1,x2,x3...from{table_name2}wh......
  • 获取插入数据时的自增长值
    获取插入数据时的自增长值  (推荐,简单方便,但是不能使用DbUtils组件)​​prepareStatement(String​​  创建一个默认 ​​PreparedStatement​​ 对象,该对象能获......
  • #yyds干货盘点# LeetCode程序员面试金典:插入
    题目:给定两个整型数字 N​ 与 M​,以及表示比特位置的 i​ 与 j(i<=j,且从0位开始计算)。编写一种方法,使 M​ 对应的二进制数字插入 N​ 对应的二进制数字的第 i......
  • 插入滚动文字的<marquee>标签
    发现一个有意思的标签,一些比较老的网站上面经常会有一段文字在窗口内运动,触到边缘之后自动反弹,就是用这个标签实现的。 看了一下MDN,发现该标签已经废弃了,不过在我测的时......
  • python连接mysql数据库(2)——批量插入数据
      1、需要插入多条数据,一天一条,time的格式为yyyy-mm-dd00:00:00使用pandas插件包,取某一段时间的日粒度,然后进行日期格式化,使用strftime   2、每条开头有唯......