技术标签: GIS
3.2 地图布局
3.2.1 PageLayout对象
PageLayout用于显示地图数据,并通过对地图数据进行整饰以便对地图打印输出满足不同行业对GIS出图功能的需求。
PageLayout和Map这两个对象看起来非常相似,他们都是视图对象,可以显示地图;也都是图形元素的容器,可以容纳图形元素(Graphics Element)
区别:PageLayout除了保存图形元素外,还可以保存诸如MapFrame的框架元素(Frame Element)。
PageLayout控件上的Map对象被PageLayout的MapFrame对象所管理
PageLayout 类主要实现了IPageLayout接口,它定义了用于修改页面板式(layout)的方法和属性
IPageLayout的ZoomToWhole方法可以让PageLayout以最大尺寸显示;
IPageLayout 的ZoomToPercent方法可以按照输入的比例显示;
IPageLayout的ZoomToWidth方法可以让视图显示的范围匹配控件对象的宽度
IPageLayout的Page属性用以获取Page对象
IPageLayout的RulerSettings属性用以获取RulerSettings对象
IPageLayout的HorizontalSnapGuides和VerticalSnapGuides属性可以获取SnapGuides对象
3.2.2 Page对象
主要用来管理PageLayout对象中的页面,它用来加载地理数据,但不提供分析和查询功能。
Page类的主要接口是IPage,它除了用于管理Page的颜色、尺寸和方向,还可以管理边框类型和打印区域。FromID可以设置纸张大小类型
3.2.3 SnapGrid对象
是PageLayout上用于摆放元素而设置的辅助点。
以下代码片段演示 如何 设置PageLayout控件上的ISnapGrid
3.2.4 SnapGuides对象
SnapGuides对象,是为了更好的放置地图,而在PageLayout上设置的辅助线;同样分为 水平和垂直两种。
ISnapGuides 的AreVisible设定SnapGuides是否可见。
ISnapGuides 的GuideCount属性返回一个SnapGuides对象中的Guide的个数。
而使用ISnapGuides的Guide属性可以按索引值获得某个具体的Guide对象。
ISnapGuides的AdGuide方法将一个Guide放在指定位置上。
ISnapGuides的RemoveAllGuides和RemoveGuide方法分别可以清除所有的Guide和按索引值清除Guide。
以下代码片段演示如何为PageLayout对象添加辅助线:
3.2.5 RulerSettings 对象
标尺对象,它是为了辅助图形元素的放置位置而出现在Pagelayout对象上方和左方的辅助尺;通过IPageLayout的RulerSetting属性可以获得PageLayout上的RulerSetting对象;IRulerSetting接口的SmallestDivision属性用于设置标尺对象的最小刻度值属性。
3.2.6 Element 对象
在Map对象和Pagelayout对象显示的数据,除了地理数据外,还有 元素数据Element
Element 是一个非常庞大复杂的对象集合:a 图形元素(GraphicElement)和框架元素(FrameElement)
图形元素包括:LineElement,MarkerElement,TextElemet,GroupElement,FillshapElement,PictureElement,MultiPatchElement等
这些元素都是以图形的形式存在,在地图视图或者PageLayout视图上是可见的。
框架元素包括:MapFrameElement(地图框架元素),MapSurroundElement(地图环绕元素) 等,它们是作为不可见的容器存在的
Map对象或者Pagelayout对象可以通过IGraphicsContainer 接口来管理这些元素,
使用IGraphicsContainer接口可以添加、删除和更新位于Map或Pagelayout上的元素
使用GroupElement对象还可以将多个元素编组为单个实体来给用户使用
IElement是所有图形元素和框架元素都实现的接口,通过IElement接口可以确定Element对象的Geometry属性;
同时IElement接口也提供了用于查找和绘制元素的方法。
注意:IElement 与 ILineElement 以及 ITextElement等 不是父子关系,后者没有Geometry属性
3.2.7 MapGrid 对象
它是布局视图中的一系列参考线和参考点,用来帮助地图使用者快速的确定地图要素的位置。
公里格网,MapGridBorder,MapGridLabel,MapGrid等
MapGrid由MapGrids来管理,一个 MapGrids可以包含多个MapGrid
MapGrid是一个抽象类,它的子类有MeasuredGrid,IndexGrid,MgrsGrid,Graticule和CustomOverlayGrid五种;
这些子类的对象由MapGridFactory对象创建。
1 /// <summary>
2 /// 为Pagelayout对象添加格网对象
3 /// </summary>
4 /// <param name="pPageLayout"></param>
5 public void AddMeasuredGridToPageLayout(IPageLayout pPageLayout)
6 {
7 try
8 {
9 // 获取MapFrame对象
10 IActiveView pActiveView = pPageLayout as IActiveView;
11 IMap pMap = pActiveView.FocusMap;
12 // QI为IGraphicsContainer对象,来管理Pagelayout上的元素
13 IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer;
14 // 从IGraphicsContainer对象中找到指定地图的框架元素
15 IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
16 // 将框架元素QI为IMapGrids
17 IMapGrids pMapGrids = pMapFrame as IMapGrids;
18
19 // 自此,我们得到了Pagelayout对象的 参考(参考线和参考点),接下来就开始整它
20
21 // 创建一个MeasureGrid对象
22 IMeasuredGrid pMeasureGrid = new MeasuredGridClass();
23 IMapGrid pMapGrid = pMeasureGrid as IMapGrid;
24 pMeasureGrid.FixedOrigin = true;// 固定源
25 pMeasureGrid.Units = pMap.MapUnits;// 设置测量格网的单位为地图的单位
26 // 设置间隔尺寸
27 pMeasureGrid.XIntervalSize = 100;
28 pMeasureGrid.YIntervalSize = 100;
29 // 设置原点位置?
30 pMeasureGrid.XOrigin = -180;
31 pMeasureGrid.YOrigin = -90;
32 // 设置MeasuredGride投影属性
33 IProjectedGrid pProGrid = pMeasureGrid as IProjectedGrid;
34 pProGrid.SpatialReference = pMap.SpatialReference;
35 pMapGrid.Name = "Measured Grid";
36 // 创建一个CalibratedMapGridBorder对象(参考边界校准)并设置为pMapGrid的Border属性
37 ICalibratedMapGridBorder pCalibratedBorder = new CalibratedMapGridBorderClass();
38 pCalibratedBorder.BackgroundColor = GetRgbColor(255,255,255);
39 pCalibratedBorder.ForegroundColor = GetRgbColor(0, 0, 0);
40 pCalibratedBorder.BorderWidth = 0.1;
41 pCalibratedBorder.Interval = 72;
42 pCalibratedBorder.Alternating = true;
43 pMapGrid.Border = pCalibratedBorder as IMapGridBorder;
44
45 // 创建一个FormattedGridLabel对象(格式化参考标签)
46 IFormattedGridLabel pFormattedGridLabel = new FormattedGridLabelClass();
47 IGridLabel pGridLabel = pFormattedGridLabel as IGridLabel;
48
49 // 设置标签字体,需要引用类库
50 //stdole.StdFont pFont = new stdole.StdFont();
51 //pFont.Name = "Arial";
52 //pFont.Size = 6;
53 //pGridLabel.Font = pFont as stdole.IFontDisp;
54
55 pGridLabel.Color = GetRgbColor(0, 0, 0);
56 pGridLabel.LabelOffset = 4;
57 pGridLabel.set_LabelAlignment(esriGridAxisEnum.esriGridAxisLeft, false);
58 pGridLabel.set_LabelAlignment(esriGridAxisEnum.esriGridAxisRight, false);
59
60 INumericFormat pNumericFormat = new NumericFormatClass();// 数字格式
61 pNumericFormat.AlignmentOption = esriNumericAlignmentEnum.esriAlignRight;
62 pNumericFormat.RoundingOption = esriRoundingOptionEnum.esriRoundNumberOfSignificantDigits;
63 pNumericFormat.RoundingValue = 0;
64 pNumericFormat.ShowPlusSign = false;
65 pNumericFormat.ZeroPad = true;
66 pFormattedGridLabel.Format = pNumericFormat as INumberFormat;
67
68 // 设置pMapGrid的LabelFormat属性
69 pMapGrid.LabelFormat = pGridLabel;
70 // 添加格网
71 pMapGrids.AddMapGrid(pMapGrid);
72
73 }
74 catch (Exception)
75 {
76
77 throw;
78 }
79 }
3.2.8 MapSurround对象
MapSurround 对象是与一个地图对象关联的用于修饰地图的辅助图形元素对象。 比例尺,比例尺文本,图例,指北针。。
MapSurround对象由MapSurroundFrame对象管理,所有的MapSurround对象添加在布局视图上,每一个MapSurround对象可以
通过IMap接口的MapSurrounds属性的索引值所获取;也可以通过IMap接口的MapSurroundCount来遍历布局视图上的所有MapSurround对象
所有的MapSurround对象都实现了IMapSurround接口,使用该接口的Name属性可以获得MapSurround对象的名称,
通过IMapSurround的FitToBound方法可以设置一个MapSurround对象的大小。
同时,MapSurround类也实现了IMapSurroundEvents接口,可以用来触发MapSurround相关事件,如:AfterDraw,BeforeDraw,ContensChange
如下代码演示如何为PageLayout添加Legend:
1 /// <summary>
2 /// 为PageLayout对象添加图例对象
3 /// </summary>
4 /// <param name="pPageLayout"></param>
5 /// <param name="pEnvelop">图例添加的位置</param>
6 private void AddLegendToPageLayout(IPageLayout pPageLayout, IEnvelope pEnvelop)
7 {
8 try
9 {
10 IActiveView pActiveView = pPageLayout as IActiveView;
11 IMap pMap = pActiveView.FocusMap;
12 IGraphicsContainer pGraphicsContainer = pActiveView as IGraphicsContainer;
13 IMapFrame pMapFrame = pGraphicsContainer.FindFrame(pMap) as IMapFrame;
14 UID pUID = new UID();
15 pUID.Value = "{7A3F81E34-B9E3-11D1-8756-000F8751720}";
16 ISymbolBackground pSymbolBackground = new SymbolBackgroundClass();
17 IFillSymbol pFillSymbol = new SimpleFillSymbolClass();
18 ILineSymbol pLineSymbol = new SimpleLineSymbolClass();
19 pFillSymbol.Color = GetRgbColor(255, 255, 255);
20 pLineSymbol.Color = GetRgbColor(255, 255, 255);
21 pFillSymbol.Outline = pLineSymbol;
22 pSymbolBackground.FillSymbol = pFillSymbol;
23 IMapSurroundFrame pMapSurroundFrame = pMapFrame.CreateSurroundFrame(pUID, null);
24 pMapSurroundFrame.Background = pSymbolBackground;
25
26 IElement pElement = pMapSurroundFrame as IElement;
27 pElement.Geometry = pEnvelop;
28 IMapSurround pMapSurround = pMapSurroundFrame.MapSurround;
29 ILegend pLegend = pMapSurround as ILegend;
30 pLegend.ClearItems();
31 pLegend.Title = "图 ☆例";
32 ITextSymbol pTextSymbol = new TextSymbolClass();
33 pTextSymbol.Size = 10;
34 pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft;
35 ILegendItem pLegendItem = null;
36
37 for (int i = 0; i < pActiveView.FocusMap.LayerCount; i++)
38 {
39 ILayer pLayer = pActiveView.FocusMap.get_Layer(i);
40 if (pLayer is IFeatureLayer)
41 {
42 IFeatureLayer pFlayer = pLayer as IFeatureLayer;
43 IFeatureClass pFeatureClass = pFlayer.FeatureClass;
44 if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
45 {
46 continue;
47 }
48 else
49 {
50 pLegendItem = new HorizontalBarLegendItemClass();
51 pLegendItem.Layer = pLayer;
52 pLegendItem.Columns = 1;
53 pLegendItem.ShowDescriptions = false;
54 pLegendItem.ShowHeading = false;
55 pLegendItem.ShowLabels = true;
56 pLegendItem.LayerNameSymbol = pTextSymbol;
57 pLegend.AddItem(pLegendItem);
58 }
59 }
60 }
61 }
62 catch (Exception)
63 {
64
65 throw;
66 }
67 }
程序结果如下图所示:
第三章到此结束。这章的内容是地图和地图布局,所围绕的大都是图形布局对象的操作。
文章浏览阅读3.8k次,点赞9次,收藏28次。直接上一个工作中碰到的问题,另外一个系统开启多线程调用我这边的接口,然后我这边会开启多线程批量查询第三方接口并且返回给调用方。使用的是两三年前别人遗留下来的方法,放到线上后发现确实是可以正常取到结果,但是一旦调用,CPU占用就直接100%(部署环境是win server服务器)。因此查看了下相关的老代码并使用JProfiler查看发现是在某个while循环的时候有问题。具体项目代码就不贴了,类似于下面这段代码。while(flag) {//your code;}这里的flag._main函数使用while(1)循环cpu占用99
文章浏览阅读347次。idea shift f6 快捷键无效_idea shift +f6快捷键不生效
文章浏览阅读135次。Ecmacript 中没有DOM 和 BOM核心模块Node为JavaScript提供了很多服务器级别,这些API绝大多数都被包装到了一个具名和核心模块中了,例如文件操作的 fs 核心模块 ,http服务构建的http 模块 path 路径操作模块 os 操作系统信息模块// 用来获取机器信息的var os = require('os')// 用来操作路径的var path = require('path')// 获取当前机器的 CPU 信息console.log(os.cpus._node模块中有很多核心模块,以下不属于核心模块,使用时需下载的是
文章浏览阅读10w+次,点赞435次,收藏3.4k次。SPSS 22 下载安装过程7.6 方差分析与回归分析的SPSS实现7.6.1 SPSS软件概述1 SPSS版本与安装2 SPSS界面3 SPSS特点4 SPSS数据7.6.2 SPSS与方差分析1 单因素方差分析2 双因素方差分析7.6.3 SPSS与回归分析SPSS回归分析过程牙膏价格问题的回归分析_化工数学模型数据回归软件
文章浏览阅读7.5k次。如何利用hutool工具包实现邮件发送功能呢?1、首先引入hutool依赖<dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.7.19</version></dependency>2、编写邮件发送工具类package com.pc.c..._hutool发送邮件
文章浏览阅读867次,点赞2次,收藏2次。docker安装elasticsearch,elasticsearch-head,kibana,ik分词器安装方式基本有两种,一种是pull的方式,一种是Dockerfile的方式,由于pull的方式pull下来后还需配置许多东西且不便于复用,个人比较喜欢使用Dockerfile的方式所有docker支持的镜像基本都在https://hub.docker.com/docker的官网上能找到合..._docker安装kibana连接elasticsearch并且elasticsearch有密码
文章浏览阅读1.3w次,点赞57次,收藏92次。整理 | 郑丽媛出品 | CSDN(ID:CSDNnews)近年来,随着机器学习的兴起,有一门编程语言逐渐变得火热——Python。得益于其针对机器学习提供了大量开源框架和第三方模块,内置..._beeware
文章浏览阅读7.9k次。//// ViewController.swift// Day_10_Timer//// Created by dongqiangfei on 2018/10/15.// Copyright 2018年 飞飞. All rights reserved.//import UIKitclass ViewController: UIViewController { ..._swift timer 暂停
文章浏览阅读986次,点赞2次,收藏2次。1.硬性等待让当前线程暂停执行,应用场景:代码执行速度太快了,但是UI元素没有立马加载出来,造成两者不同步,这时候就可以让代码等待一下,再去执行找元素的动作线程休眠,强制等待 Thread.sleep(long mills)package com.example.demo;import org.junit.jupiter.api.Test;import org.openqa.selenium.By;import org.openqa.selenium.firefox.Firefox.._元素三大等待
文章浏览阅读3k次,点赞4次,收藏14次。Java软件工程师职位分析_java岗位分析
文章浏览阅读2k次。Java:Unreachable code的解决方法_java unreachable code
文章浏览阅读1w次。1、html中设置标签data-*的值 标题 11111 222222、点击获取当前标签的data-url的值$('dd').on('click', function() { var urlVal = $(this).data('ur_如何根据data-*属性获取对应的标签对象