Developing GIS Applications with Arc Objects using C
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET GIS应用开发 Developing GIS Applications with Arc. Objects using C#. NET 江西省研究生��� 程 主讲:兰小机 GIS博士、教授 Email : landcom 8835@163. com QQ : 305333315 课程网站:
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1 Overview of Arc. GIS Engine editing 1. Arc. GIS Engine 编辑与Arc. Map编辑 2. 编辑流程 3. 编辑目标图层(Editing target layer) 4. 编辑任务(Edit tasks) 5. 编辑绘制(Edit sketch) 6. 使用操作栈(Working with the operation stack) 7. 使用捕捉环境 8. 编辑事件 9. 要素查看器(Feature inspectors) 10. 使用要素模板
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 要素的复制、剪切、粘贴和删除 Control. Tools. Editing {2 D 7 BD 886 -7531 -4198 -820 D-551 A 5 A 14569 E} _Copy esri. Controls. Editing. Copy. Command Control. Tools. Editing {C 03 E 7512 -CA 4 E-4197 -8386 -57830425 D 13 A} _Cut esri. Controls. Editing. Cut. Command Control. Tools. Editing {99 FADFFD-A 788 -4 F 1 F-A 1 B 3 -04909 B 06735 A} _Paste esri. Controls. Editing. Paste. Command Control. Tools. Editing {C 4 CB 4830 -8 C 2 E-49 AE-9 D 12 -73 E 822 BCA 90 E} _Clear esri. Controls. Editing. Clear. Command
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Arc. GIS Engine环境下的Editor. Toolbar、 Editor Menu and Edit Task:
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Control. Tools. Editing _Start {5 CAF 45 CD-E 3 B 1 -4 FFD-96 C 4 -BCDD 2289 C 1 EB} esri. Controls. Editing. Start. Command Control. Tools. Editing _Stop {8 D 03 C 271 -BB 00 -4 A 36 -9 B 84 -AD 2 E 1 DE 0 DE 11} esri. Controls. Editing. Stop. Command Control. Tools. Editing _Save {0 BB 6 A 923 -6 AAF-4 B 7 A-B 8 A 8 -A 7225065 A 0 C 8} esri. Controls. Editing. Save. Command Control. Tools. Editing _Edit {6 F 922 BD 8 -EF 26 -4852 -BAED-45 CFF 3 A 97121} esri. Controls. Editing. Edit. Tool Control. Tools. Editing _Sketch {13 B 234 E 8 -3 B 30 -49 CA-9967 -4 C 76 F 7231 AD 6} esri. Controls. Editing. Sketch. Tool Control. Tools. Editing_T arget. Tool. Control {5 D 815 B 27 -6 A 93 -42 DB-B 2 C 6 -1 CC 58 B 416 E 9 F} esri. Controls. Editing. Target. Tool. Control. Tools. Editing _Attribute {A 554 ADBC-D 0 DD-469 A-8 A 95 -B 4 CEED 0794 C 3} esri. Controls. Editing. Attribute. Command {506 ACF 9 B-B 4 B 4 -4 A 4 A-A 5 FA-5215 E 4 A 240 B 2} Control. Tools. Editing esri. Controls. Editing. Sketch. Properties. Co _Sketch. Properties mmand
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 撤销(undo) / 重复(redo) Control. Tools. Generic _Redo {B 0675372 -0271 -4680 -9 A 2 C-269 B 3 F 0 C 01 E 8} esri. Controls. Redo. Command Control. Tools. Generic _Undo {380 FB 31 E-6 C 24 -4 F 5 C-B 1 DF 47 F 33586 B 885} esri. Controls. Undo. Command
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Arc. GIS Engine的“Sketch Tool Context Menu”
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Control. Tools. Editing_ {3 E 28536 E-66 EB-4812 -BD 8 C-7 AE 6 EA 5 CCB 17} Snap. To. Feature. Menu esri. Controls. Editing. Snap. To. Feature. Menu Control. Tools. Editing_ Snap. Endpoint {B 473 F 50 B-3 D 6 B-4718 -8 DE 3 -75 D 7 ECACED 58} Control. Tools. Editing_ Snap. Vertex {78 FF 7 F 24 -E 5 E 6 -4 CA 4 -993 E-6 FAA 81684441} esri. Controls. Editing. Snap. Vertex. Command Control. Tools. Editing_ Snap. Midpoint {250219 D 8 -7 A 0 B-4017 -93 EF-1 E 893 D 16 F 742} esri. Controls. Editing. Snap. Midpoint. Command Control. Tools. Editing_ Snap. Edge {5 D 67 D 843 -E 10 C-4 D 0 B-A 69 C-2 DFA 82 B 25450} esri. Controls. Editing. Snap. Edge. Command esri. Controls. Editing. Snap. Endpoint. Command
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Control. Tools. Editing {4 E 6 E 4 BB 5 -4 B 2 E-4 E 1 F-8 E 08 -18 E 24 FF 80 A 13} esri. Controls. Editing. Sketch. Direction. Command _Sketch. Direction Control. Tools. Editing_ Sketch. Deflection {3 ECE 8 CAB-3 DAD-4 B 04 -B 586 -D 9 B 6369885 C 3} esri. Controls. Editing. Sketch. Deflection. Command Control. Tools. Editing {FAF 9 D 507 -97 DF-4 F 2 E-835 A-35 A 3 DECF 90 B 9} esri. Controls. Editing. Sketch. Length. Command _Sketch. Length Control. Tools. Editing_Ske tch. Change. Length {6 EF 1 BE 13 -4 FF 4 -4529 -958 D-46 A 418 C 99 DD 8} esri. Controls. Editing. Sketch. Change. Length. Command Control. Tools. Editing {B 368783 B-9 BDE-46 A 6 -A 712 -2969 C 1 F 21 FA 2} _Sketch. Absolute. XY esri. Controls. Editing. Sketch. Absolute. XYCommand Control. Tools. Editing {061 BD 3 E 1 -4245 -4699 -863 C-DE 478647 FBE 3} esri. Controls. Editing. Sketch. Delta. XYCommand _Sketch. Delta. XY Control. Tools. Editing_Ske tch. Direction. Length {9 DB 473 E 5 -BF 90 -465 B-8758 -74 C 656 F 136 EB} esri. Controls. Editing. Sketch. Direction. Length. Command Control. Tools. Editing {798 FED 0 C-978 D-4 DFA-A 658 -D 3 DADF 9 D 414 D} esri. Controls. Editing. Sketch. Parallel. Command _Sketch. Parallel Control. Tools. Editing_ Sketch. Perpendicular {A 9 F 4 EAD 1 -622 C-4 BC 7 -857 B-55 ABA 51 D 5359} esri. Controls. Editing. Sketch. Perpendicular. Com mand
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Control. Tools. Editing_Sket ch. Segment. Deflection {A 1 D 97 BFF-5 B 08 -4852 -8223 -5714 EC 5811 DB} esri. Controls. Editing. Sketch. Segment. Deflection. Command Control. Tools. Editing _Sketch. Replace {C 9 DFFED 3 -57 CC-485 A-A 5 A 1 -CC 510 CE 9 DC 97} esri. Controls. Editing. Sketch. Replace. Command Control. Tools. Editing _Sketch. Streaming {4 E 8 F 7 A 0 A-C 3 F 3 -462 B-9632 -D 9981941 A 18 E} Control. Tools. Editing _Sketch. Delete {E 5 D 330 C 9 -8 E 98 -4148 -818 F-7128 D 152 DFD 5} esri. Controls. Editing. Sketch. Delete. Command Control. Tools. Editing _Sketch. Finish {2 A 876779 -8 A 6 A-4 B 73 -9 B 89 -AE 0099 B 0571 A} esri. Controls. Editing. Sketch. Finish. Command Control. Tools. Editing_S ketch. Finish. Square {73883500 -776 E-4 E 99 -92 B 2 -6 ED 6332558 DD} Control. Tools. Editing _Sketch. Finish. Part {D 69 E 981 F-4 FDE-4077 -B 224 -0 C 58 A 35 AF 668} Control. Tools. Editing _Task. Tool. Control {BEB 77 C 7 B-4257 -41 DC-9447 -C 3 C 5 C 4 C 8 F 7 C 7} esri. Controls. Editing. Task. Tool. Control esri. Controls. Editing. Sketch. Streaming. Command esri. Controls. Editing. Sketch. Finish. Square. Command esri. Controls. Editing. Sketch. Finish. Part. Command
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 在Arc. GIS 桌面环境中的主要编辑对象是Editor ,而在 Arc. GIS Engine开发中则是Engine. Editor (单实例对象 ) ;在相应的应用程序中,它们负责管理编辑绘制(edit sketch)、当前任务(current task)、当前目标图层 (current target layer)、编辑 作空间(edit workspace)、编辑选择(edit selection)、编辑会话属 性(edit session properties)以及捕捉环境(snap environment)。 l Engine. Editor主要接口有:IEngine. Editor、 IEngine. Edit. Layers、IEngine. Edit. Properties、 IEngine. Edit. Properties 2、IEngine. Edit. Sketch、 IEngine. Snap. Environment、 IEngine. Edit. Events 、 IExtension (System).
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 表 10 -1 Arc. GIS Engine与Arc. GIS Desktop编辑的主要接口比 较 Arc. GIS Engine Arc. GIS Desktop Editing environment IEngine. Editor (New in 9. 3) IEditor Edit tasks IEngine. Edit. Task (New in 9. 3) IEdit. Task Edit sketch IEngine. Edit. Sketch (New in 9. 3) IEdit. Sketch Edit layers IEngine. Edit. Layers (New in 9. 3) IEdit. Layers Edit properties IEngine. Edit. Properties Edit events IEngine. Edit. Events (New in 9. 3) IEdit. Events IEdit. Properties
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Interfaces l Arc. Map Editor主要接口: IEdit. Annotation. Properties IEdit. Attribute. Properties IEdit. Layers IEditor 3 IEditor. Z IEdit. Properties 2 IEdit. Properties 3 IEdit. Properties 4 IEdit. Sketch 3 IEdit. Task. Search IExtension (esri. System) IExtension. Accelerators (esri. System) IExtension. Manager (esri. System) ISnap. Environment 3
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEngine. Edit. Sketch IEngine. Editor IEngine. Edit. Layers
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEngine. Edit. Properties 2
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEngine. Edit. Events (New in 9. 3)
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEngine. Edit. Task ( new at Arc. GIS 9. 3 ) l 编辑任务使用编辑绘制几何对象(from IEngine. Edit. Sketch. Geometry )完成 某项操作; Engine. Editor 一次只能 有一个活动的编辑任务,使用 IEngine. Editor. Current. Task 设置当 前的编辑任务. l 所有的 Engine 编辑任务都实现了IEngine. Edit. Task 接口. Engine 编辑任务必须注册到‘ESRI Engine Edit Tasks’组件类目中,以便显示在 Controls. Editing. Task. Tool. Control中.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 启动编辑会话: private IEngine. Editor m_engine. Editor = new Engine. Editor. Class(); private void Start. Editing (IMap map, IFeature. Layer feature. Layer) { if (m_engine. Editor. Edit. State != esri. Engine. Edit. State. esri. Engine. State. Not. Editing) return; IDataset dataset = feature. Layer. Feature. Class as IDataset; IWorkspace workspace = dataset. Workspace; m_engine. Editor. Start. Editing(workspace, map); ((IEngine. Edit. Layers) m_engine. Editor). Set. Target. Layer(feature. Layer, -1); public void Set. Target. Layer ( } IFeature. Layer, int Sub. Type );
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET �行��操作 l IEngine. Editor接口提供了一系列方法用于编辑操作,如 Start. Operation 、Abort. Operation 及Stop. Operation。 Ø IEngine. Editor. Start. Operation --启动编辑操作 • public void Start. Operation ( ); Ø IEngine. Editor. Abort. Operation --取消编辑操作,不保 存编辑 • public void Abort. Operation ( ); Ø IEngine. Editor. Stop. Operation --结束编辑操作 • public void Stop. Operation ( string operation. Name ); • operation. Name allows the operation to be identified on the operaton stack.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void cmd. Edit. Operation() { m_engine. Editor. Start. Operation(); try { //Perform feature edits here. if (some. Edit. Validation. Checks. Method == true) m_engine. Editor. Stop. Operation(“Test edit operation”); else m_engine. Editor. Abort. Operation(); } catch (Exception ex) { m_engine. Editor. Abort. Operation(); //Add code to handle exception.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 保存���束��会� l通过执行Controls. Editing. Save. Command命令, 可以保存编辑会话中的编辑变化;也可以调用 IEngine. Editor. Stop. Editing(save. Changes参数 设置为true)方法保存编辑变化,该方法的语法如 下: public void Stop. Editing ( bool save. Changes ); Ø 若save. Changes参数为false,则不保存编辑 变化结束编辑会话。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void btn. Stop. Editing_Click(object sender, Event. Args e) { if (m_engine. Editor. Has. Edits() == false) m_engine. Editor. Stop. Editing(false); else { if (Message. Box. Show("Save Edits? ", "Save Prompt", Message. Box. Buttons. Yes. No) == Dialog. Result. Yes) m_engine. Editor. Stop. Editing(true); else m_engine. Editor. Stop. Editing(false); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IWorkspace. Edit接口 l IWorkspace. Edit接口是Arc. Objects 实现空间数据编辑功能的另一接口. Ø 它可以启动或停止一个编辑流程, 适用于不需要用户交互的编辑操 作。 l 使用Start. Editing方法启动一个编辑流 程 Ø public void Start. Editing (bool with. Undo. Redo ); Ø with. Undo. Redo参数用来确定是否 支持“undo /redo ”功能。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Start. Editing (IFeature. Layer feature. Layer) { IFeature. Class feature. Class = feature. Layer. Feature. Class; IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; workspace. Edit. Start. Editing(true); workspace. Edit. Start. Edit. Operation(); IFeature p. Feature = feature. Class. Get. Feature(1); p. Feature. Delete(); workspace. Edit. Stop. Edit. Operation(); bool b. Has. Edits = true;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Dialog. Result i. Response = Message. Box. Show("Edit Operation", "Undo operation? ", Message. Box. Buttons. Yes. No); if (i. Response == Dialog. Result. Yes) workspace. Edit. Undo. Edit. Operation(); workspace. Edit. Has. Edits(ref b. Has. Edits); if (b. Has. Edits) { i. Response = Message. Box. Show("Edit Operation", "Save edits? ", Message. Box. Buttons. Yes. No); if (i. Response == Dialog. Result. Yes) { workspace. Edit. Stop. Editing(true); } else { workspace. Edit. Stop. Editing(false); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEngine. Edit. Layers 10. 1. 3 编辑目标图层 l 使用IEngine. Edit. Layers. Set. Target. Layer 或 Controls. Editing. Target. Tool. Control设置要编辑的 目标图层 。 l 使用IEngine. Edit. Layers. Target. Layer 获得目前编 辑的图层。 l 使用 IEngine. Edit. Events. On. Target. Layer. Changed 事 件来监听编辑目标图层的变化。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1. 4 编辑任务 l 编辑任务使用编辑绘制中的几何对象 (IEngine. Edit. Sketch. Geometry)完成某一特定的编辑操作; Engine. Editor一次只能有一个活动的编辑任务,使用 IEngine. Editor. Current. Task设置当前的编辑任务。所有的 Engine编辑任务都实现了IEngine. Edit. Task 接口。Engine 编辑任务必须注册到“ESRI Engine Edit Tasks”组件类目 中,以便显示在 Controls. Editing. Task. Tool. Control中。 l Engine. Editor提供了两个内置的编辑任务:Create New Feature和Modify Feature.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 可以通过实现IEngine. Edit. Task接口创 建自定义的编辑任务。 IEngine. Edit. Task. Group. Name 属性允 许编辑任务在 Controls. Editing. Task. Tool. Control 中 逻辑分组。使用 IEngine. Edit. Events. On. Current. Task. C hanged 事件监听编辑任务的改变。 l 使用Arc. GIS添加类向导(Arc. GIS Add Class Wizard)来快速创建实现 IEngine. Edit. Task接口的类, 创建定制 的编辑任务.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l Samples: ØEditing. Cut. Polygons. Edit. Task ØEditing. Reshape. Polyline. Edit. Task
IEngine. Edit. Sketch 江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1. 5 ���制 - Edit sketch l IEngine. Edit. Sketch 中的geometry 用于完成当前的编辑任务,如当前编 辑任务为“Create New Feature” 时,使用该geometry来创建一个要 素; geometry 由当前编辑任务设置, 其类型可以是: a multipoint, a polyline, or a polygon , 与目标编辑 图层的几何类型相同。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l AE提供了2个快捷菜单帮助完 成edit sketch geometry. Ø Controls. Editing. Sketch. Contex t. Menu Ø Controls. Editing. Vertex. Contex t. Menu
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Creating a sketch operation l IEngine. Sketch. Operation. Start 启 动一绘制操作(sketch operation), 使用 IEngine. Sketch. Operation. Set. Men u. String 方法命名该操作,以便操作 栈( operation stack )能够识别该操 作,并用作Undo / Redo 的Tool. Tip . l IEngine. Sketch. Operation. Finish结 束一绘制操作,并将该操作放入操 作栈中。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Øpublic void Start (IEngine. Editor editor ); Øpublic void Set. Menu. String (string Menu. String ); Øpublic void Finish ( IEnvelope inval. Env, esri. Engine. Sketch. Operation. Type op. Type, object Data ); Constant esri. Engine. Sketch. Operation. General esri. Engine. Sketch. Operation. Vertex. Added esri. Engine. Sketch. Operation. Vertex. Deleted esri. Engine. Sketch. Operation. Vertex. Moved Value 0 1 2 3
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Engine. Sketch. Operation() { IEngine. Sketch. Operation sketch. Op = new Engine. Sketch. Operation. Class(); IEngine. Editor engine. Editor = new Engine. Editor. Class(); IEngine. Edit. Sketch edit. Sketch = (IEngine. Edit. Sketch) engine. Editor; IEnvelope invalidate. Env = ((IClone) edit. Sketch. Geometry. Envelope). Clone() as IEnvelope; sketch. Op. Start(engine. Editor); sketch. Op. Set. Menu. String("Delete Vertex"); IPoint. Collection point. Col = (IPoint. Collection) edit. Sketch. Geometry; IClone vertex. To. Remove = (IClone) point. Col. get_Point(point. Col. Point. Count - 1); vertex. To. Remove. Clone(); point. Col. Remove. Points(point. Col. Point. Count - 1, 1); edit. Sketch. Geometry = (IGeometry) point. Col; edit. Sketch. Refresh. Sketch();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 对于单个绘制操作,使用IEngine. Sketch. Operation. Undo 和Redo来实现撤销和重做; Ø IEngine. Sketch. Operation. Undo (derived from IOperation. Stack. Undo) Ø IEngine. Sketch. Operation. Redo (derived from IOperation. Stack. Redo) l 对于多个绘制操作,则需要先使用 IToolbar. Control 2. Operation. Stack访问操作栈,然后再 使用IOperation. Stack. Undo或IOperation. Stack. Redo来 实现撤销和重做。 l 绘制操作的事件: Ø IEngine. Edit. Events. On. Vertex. Added Ø IEngine. Edit. Events. On. Vertex. Deleted Ø IEngine. Edit. Events. On. Vertex. Moved Ø IEngine. Edit. Events. On. Sketch. Modified
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1. 6 使用操作栈 l 由Engine. Editor 管理的编辑会话,如果需要undo / redo功能,那么应用程序中必须包含 Toolbar. Control. l IToolbar. Control. Operation. Stack 属性提供了对 操作栈的访问。IOperation. Stack. Undo和 IOperation. Stack. Redo方法则分别用于撤销和重 复操作。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l将编辑和绘制操作添加至操作栈的步骤: 1. 在应用程序中添加Toolbar. Control ,并设置其伙伴控 件; 2. 实例化Controls. Operation. Stack ,并将其与 Toolbar. Control相关联; 3. 连接Engine. Editor 到Toolbar. Control ,使得操作栈 包含编辑与绘制操作;可以有2种方式实现该功能: • 将一编辑命令添加到Toolbar. Control上; • 在Form_Load 事件中,通过编程连接Engine. Editor 与Toolbar. Control 4. 启动编辑会话,并设置 IEngine. Editor. Enable. Undo. Redo为true,使编辑会话
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 2: IOperation. Stack operation. Stack = new Controls. Operation. Stack. Class(); ax. Toolbar. Control 1. Operation. Stack = operation. Stack; ax. Toolbar. Control 2. Operation. Stack = operation. Stack; 3: (a)直接将编辑命令添加到Toolbar. Control上 (b)连接Engine. Editor 与Toolbar. Control object tbr = (object)ax. Toolbar. Control 1. Object; IExtension engine. Editor. Ext = m_engine. Editor as IExtension;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IOperation. Stack operation. Stack = m_Toolbar. Control. Operation. Stack; //Do the following to undo the previous operation on the stack. operation. Stack. Undo(); //Do the following to redo the next operation on the stack. operation. Stack. Redo();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1. 7 使用捕捉环境 l 捕捉有助于精确定位要素及编辑绘制的顶点。 l Arc. GIS提供了两种类型捕捉环境: Ø Arc. GIS snapping environment (New in Arc. GIS 10): 为捕捉提供了最通用框架,对Arc. GIS桌面和Arc. GIS Engine都可用,并使用相同的组件。 Ø Editing snapping environment:提供了更精细的捕 捉,但只在编辑会话中可用,且对Arc. GIS桌面和 Arc. GIS Engine使用不同的组件和接口 (ISnap. Environment for Desktop and IEngine. Snap. Environment for Engine)。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 两种捕捉�境的比� Desktop support Engine support Configuration of snapping agents Available outside an edit session Requires management of cache Respects definition queries on layers Supports customization of snap tips Supports filtering of individual layers Supports custom snapping types Access to snap result via the application programming interface (API) Arc. GIS snapping environment Yes Yes No Editing snapping environment Yes Yes No No Yes Yes No
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Arc. GIS snapping environment (New in Arc. GIS 10) l Arc. GIS 捕捉环境可用于所有的自定义 具,而不 仅仅限于编辑器中的 具。在Arc. Map 和Arc. GIS Engine中, Arc. GIS 捕捉环境是作为应用程序扩 展来访问的。 l ISnapping. Environment 是Arc. GIS 捕捉环境的主 要接口,这个接口 用于控制捕捉是否激活、使用 哪些类型的捕捉及设置捕捉容差、定义捕捉符号。 Arc. GIS 捕捉环境还提供了IPoint. Snapper、 ISnapping. Result 和ISnapping. Feedback 接口。
ISnapping. Environment 江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IPoint. Snapper
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET ØISnapping. Feedback
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET ØISnapping. Result
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 从Arc. Map中访问Arc. GIS 捕捉环境 在 具类中声明以下变量: IPoint m_Current. Mouse. Coords; ISnapping. Environment m_Snapping. Env; IPoint. Snapper m_Snapper; ISnapping. Feedback m_Snapping. Feedback; 在 具类中的On. Click 方法中插入以下代码: m_Snapping. Env = m_application. Find. Extension. By. Name(“ESRI Snapping”) as ISnapping. Environment; m_Snapper = m_Snapping. Env. Point. Snapper; m_Snapping. Feedback = new Snapping. Feedback. Class(); m_Snapping. Feedback. Initialize (hook, m_Snapping. Env, true); public void Initialize ( object Hook, ISnapping. Environment snap. Env, bool auto. Erase);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 从Arc. GIS Engine中访问Arc. GIS 捕捉环境 在 具类中声明以下变量: IHook. Helper m_hook. Helper;IHook. Helper 2 m_hook. Helper 2; ISnapping. Environment m_Snapping. Env;IPoint m_Current. Mouse. Coords; IPoint. Snapper m_Snapper; ISnapping. Feedback m_Snapping. Feedback; On. Create m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; m_hook. Helper 2 = m_hook. Helper as IHook. Helper 2; On. Click IExtension. Manager extension. Manager = m_hook. Helper 2. Extension. Manager; UID guid = new UIDClass(); guid. Value = "{E 07 B 4 C 52 -C 894 -4558 -B 8 D 4 -D 4050018 D 1 DA}"; IExtension extension = extension. Manager. Find. Extension(guid); m_Snapping. Env = extension as ISnapping. Environment;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET esri. Snapping. Type Constant esri. Snapping. Type. None esri. Snapping. Type. Point esri. Snapping. Type. Endpoint esri. Snapping. Type. Vertex esri. Snapping. Type. Edge esri. Snapping. Type. Midpoint esri. Snapping. Type. Intersection 32 esri. Snapping. Type. Tangent 64 Description No snap. Snap to point. Snap to endpoint. Snap to vertex. Snap to edge. Snap to midpoint. Intersection snapping. Tangent snapping. X 1 4 X 1 2 X 1 64 X 1 32 X 1 16 Value 0 1 2 4 8 16 X 1 8 X 1 1
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 配置捕捉环境 //Specify combination of esri. Snapping. Type enumerations. m_Snapping. Environment. Snapping. Type = (esri. Snapping. Type) ((int)esri. Snapping. Type. Edge + (int)esri. Snapping. Type. Endpoint); //Specify bitwise combination for edge and endpoint snapping. m_Snapping. Environment. Snapping. Type = (esri. Snapping. Type)63;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 捕捉的优先级 Ø 按下列顺序计算捕捉类型: 1. esri. Snapping. Type. Point 2. esri. Snapping. Type. Intersection 3. esri. Snapping. Type. Endpoint 4. esri. Snapping. Type. Vertex 5. esri. Snapping. Type. Midpoint 6. esri. Snapping. Type. Tangent 7. esri. Snapping. Type. Edge Ø Snapping. Type is an application-level setting.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET (2)在 具的On. Mouse. Move事件中, IPoint. Snapper. Snap方法捕捉鼠标的当前位置; 如果返回Snap. Result,则调用Update方法更新 鼠标位置;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET public override void On. Mouse. Move(int Button, int Shift, int X, int Y) { m_Current. Mouse. Coords = m_Active. View. Screen. Display. Transformation. To. Map Point(X, Y); ISnapping. Result snap. Result = m_Snapper. Snap(m_Current. Mouse. Coords); m_Snapping. Feedback. Update(snap. Result, 0); if (snap. Result != null) m_Current. Mouse. Coords = snap. Result. Location; if (p. Envelope. Feedback != null) p. Envelope. Feedback. Move. To(m_Current. Mouse. Coords); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET (3)在 具的Refresh方法中,刷新捕捉反馈。 – public override void Refresh( int h. DC) { //Refresh the previous location of the snap tip. if (m_Snapping. Feedback != null) m_Snapping. Feedback. Refresh( h. DC); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Editing snapping environment in Arc. GIS Engine l 可以使用Controls. Editing. Snapping. Command 或IEngine. Snap. Environment 接口来访问捕捉设 置. l 通过实现IEngine. Snap. Agent 接口来创建定制的 捕捉设置。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l Arc. GIS Engine的编辑捕捉环境 (IEngine. Snap. Environment) 控制每一个捕捉代 理IEngine. Snap. Agent, 捕捉类型(hit type)设置, 及捕捉容差. Ø每个捕捉代理的捕捉类型由 IEngine. Feature. Snap. Agent 管理. Ø所有的设置均可以在捕捉设置对话框中修改或 确认。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public void Snap. Envir. Settings (IEngine. Editor editor) { IEngine. Snap. Environment snap. Environment = editor as IEngine. Snap. Environment; if (snap. Environment. Snap. Agent. Count == 0) { System. Windows. Forms. Message. Box. Show( "You need to turn on at least one snapping agent!!!"); return; } double tolerance = snap. Environment. Snap. Tolerance; Message. Box. Show(Convert. To. String(tolerance)); snap. Environment. Snap. Tolerance. Units = esri. Engine. Snap. Tolerance. Units. esri. Engine. Snap. Tolerance. Map Units; snap. Environment. Snap. Tolerance = 15; ((IEngine. Edit. Properties 2)editor). Snap. Tips = true;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Edit. Snap (IMap. Control 3 m. Map) { IEngine. Editor m_engine. Editor = new Engine. Editor. Class(); if (m_engine. Editor. Edit. State == esri. Engine. Edit. State. esri. Engine. State. Not. Editing) { ILayer current. Layer = m. Map. get_Layer(0); if (current. Layer is IFeature. Layer) { IFeature. Layer feature. Layer = current. Layer as IFeature. Layer; IDataset dataset = feature. Layer. Feature. Class as IDataset; IWorkspace workspace = dataset. Workspace; m_engine. Editor. Start. Editing (workspace, m. Map); ((IEngine. Edit. Layers)
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET if (m. Map. Layer. Count != 0) { IEngine. Edit. Layers edit. Layers = editor as IEngine. Edit. Layers; IEngine. Snap. Environment snap. Environment = editor as IEngine. Snap. Environment; IEngine. Feature. Snap. Agent feature. Snap. Agent = new Engine. Feature. Snap(); feature. Snap. Agent. Feature. Class = ((IFeature. Layer) m. Map. get_Layer(0)). Feature. Class; feature. Snap. Agent. Hit. Type = esri. Geometry. Hit. Part. Type. esri. Geometry. Part. Vertex | esri. Geometry. Hit. Part. Type. esri. Geometry. Part. Boundary | esri. Geometry. Hit. Part. Type. esri. Geometry. Part. Endpoint; snap. Environment. Add. Snap. Agent(feature. Snap. Agent);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Editing snapping environment in Arc. Map l Arc. Map中的编辑捕捉环境,主要通过以下 接口进行管理和使用: ØISnap. Environment 3 ØISnap. Agent ØIFeature. Snap. Agent 2 ØISnap. Agent. Feedback
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 1. 8 Edit events l 在一个编辑会话中的事件由 IEngine. Edit. Events接口来管理, 如通过监听 IEngine. Edit. Events. On. Sketch. Fin ished以在完成编辑绘制后检测编 辑绘制是否有效。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Event order l 一个编辑操作可以触发IEngine. Edit. Events中的多个事件. 如: Ø 当IEngine. Editor. Start. Editing()或执行 Controls. Editing. Start. Command时 • 触发On. Start. Editing, On. Selection. Changed, 及 On. Sketch. Modified 事件. Ø 当通过IEngine. Editor. Current. Task 或 Controls. Editing. Task. Tool. Control改变当前任务时 • 触发On. Sketch. Modified, On. After. Draw. Sketch, 及 On. Current. Task. Changed 事件 Ø 当IEngine. Editor. Stop. Editing()或执行 Controls. Editing. Stop. Command 时, • 触发On. Target. Layer. Changed 和On. Stop. Editing事件.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 可以按下列方式使用编辑事件: private IEngine. Editor m_Engine. Editor = new Engine. Editor. Class(); private IEngine. Edit. Events_Event m_Engine. Edit. Events; …… m_Engine. Edit. Events. On. Start. Editing += new IEngine. Edit. Events_On. Start. Editing. Event. Handler(O n. Start. Editing. Method); …… private void On. Start. Editing. Method() { …… }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l IEdit. Template. Factory仅定义了Create方法,用来创建编 辑模板。Use IEditor 3. Add. Templates to add the template to the editor. Ø public IEdit. Template Create ( string Name, ILayer);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Create. Feature. Template( IMx. Document m_doc, IEditor 3 m_editor) { //Create a single template for the selected layer. ILayer edit. Layer = m_doc. Selected. Layer; IEdit. Template. Factory edit. Template. Fact = new Edit. Template. Factory. Class(); IEdit. Template new. Edit. Template = edit. Template. Fact. Create("Building", edit. Layer); //Add the template. IArray template. Array = new Array. Class(); template. Array. Add(new. Edit. Template); m_editor. Add. Templates(template. Array); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Accessing feature templates l 使用IEdit. Template. Manager来访问要素模板对象: l public void Get. Edit. Template. Manager( ILayer layer) { ILayer. Extensions layer. Extensions = layer as ILayer. Extensions; IEdit. Template. Manager edit. Template. Mgr; for (int j = 0; j < layer. Extensions. Extension. Count; j++) { object extension = layer. Extensions. get_Extension(j); if (extension is IEdit. Template. Manager) { edit. Template. Mgr = extension as IEdit. Template. Manager; IEdit. Template edit. Template = edit. Template. Mgr. get_Edit. Template(0); edit. Template. Set. Default. Value("Name", "Venice", true);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public void m_edit. Events_On. Sketch. Finished( IEditor 3 m_editor) { IEdit. Sketch 3 m_ed. Sketch = m_editor as IEdit. Sketch 3; m_editor. Start. Operation(); IPoint point = m_ed. Sketch. Last. Point; IEdit. Template edit. Template = m_editor. Current. Template; IFeature. Layer feat. Layer = edit. Template. Layer as IFeature. Layer; IFeature. Class feat. Class = feat. Layer. Feature. Class; IFeature new. Feature = feat. Class. Create. Feature(); new. Feature. Shape = point; edit. Template. Set. Default. Values(new. Feature); new. Feature. Store(); m_editor. Stop. Operation("Create Point"); m_editor. Display. Invalidate(new. Feature. Extent, true,
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET �除要素模板 l IEditor 3. Remove. Template Ø public void Remove. Template ( IEdit. Template edit. Template); l IEditor 3. Remove. All. Templates. In. Map Ø public void Remove. All. Templates. In. Map ( IMap map); l IEditor 3. Remove. All. Templates. In. Layer Ø public void Remove. All. Templates. In. Layer ( ILayer layer);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 2. 1 版本化��的主要接口 l 版本管理(基本) l 事件接口: Ø IVersion,IVersion 2 Ø IVersion. Events_Eve Ø IVersion 3 nt l 版本化编辑 Ø IVersion. Events 2_Ev ent Ø IVersion. Edit,IVersion. Edit 2 Ø IVersion. Edit 3, IVersion. Edit 4 l 版本管理(高级) Ø IVersioned. Workspace 2 Ø IVersioned. Workspace 3
江西理 大学 – Developing GIS Applications. IVersion 2 with Arc. Objects using C#. NET IVersion public IVersion Create. Child ( string Name, IVersion p. Initial. State. Version); l IVersion 3 inherits from IVersion, IVersion 2 Ø IVersion 3. Delete. With. Children l IVersion 2 inherits from IVersion, the IVersion interface has been
江西理 大学 – Developing GIS has Applications with Arc. Objects using C#. NET Note: the IVersion. Edit interface been superseded by IVersion. Edit 4. IVersion. Edit l IVersion. Edit Ø public bool Reconcile ( string Version. Name); l IVersion. Edit 2增加: Ø public bool Reconcile 2 ( string Version. Name, bool acquire. Lock ); l IVersion. Edit 3增加: Ø public bool Reconcile 3 ( string Version. Name, bool acquire. Lock, bool abort. If. Conflicts); l IVersion. Edit 4增加: Ø public bool Reconcile 4 ( string Version. Name, bool acquire. Lock, bool abort. If. Conflicts, bool
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Note: the IVersioned. Workspace interface has been superseded by IVersioned. Workspace 3. l IVersioned. Worksp ace l IVersioned. Workspace 2增加: Ø public IEnum. Version. Info Recommended. Reconcile. Order {get; } l IVersioned. Workspace 3增加: Ø public IEnum. BSTR Recommended. Sync. Order {get; } Ø An ordered list of replicas that need to be synchronized.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 2. 2 获取当前编辑会话中的编辑变化 esri. Edit. Data. Changes. Type Constant Value Description esri. Edit. Data. Changes. Within. Sessio Changes since the start of 0 n the edit session. esri. Edit. Data. Changes. Within. Opera Changes since the start of 1 tion the edit operation l IWorkspace. Edit 2 Ø public IData. Changes. Ex get_Edit. Data. Changes ( esri. Edit. Data. Changes. Type edit. Change. Type); Ø public bool Is. In. Edit. Operation {get; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l IData. Changes. Ex public IFIDSet get_Changed. IDs ( string class. Name, esri. Difference. Type diff. Type); public IDifference. Cursor Extract ( string class. Name, esri. Difference. Type diff. Type); public IDifference. Cursor. Ex Extract. Ex ( string class. Name, esri. Difference. Type diff. Type); public IEnum. BSTR Modified. Classes {get; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET esri. Difference. Type Constant Value Description esri. Difference. Type. Insert 0 esri. Difference. Type. Delete. No. Change 1 esri. Difference. Type. Update. No. Change 2 esri. Difference. Type. Update 3 esri. Difference. Type. Update. Delete 4 esri. Difference. Type. Delete. Update 5 Row was inserted in this version. Row has been deleted in this version and not changed in the difference version. Row has been updated in both versions. Row has been updated in this version but deleted in the difference version. Row has been deleted in this version but updated in the difference version.
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public IEnum. BSTR Get. Modified. Classes (IWorkspace workspace) { IWorkspace. Edit 2 workspace. Edit 2 = (IWorkspace. Edit 2) workspace; IData. Changes. Ex data. Changes = workspace. Edit 2. get_Edit. Data. Changes (esri. Edit. Data. Changes. Type. esri. Edit. Data. Changes. Withi n. Session); return data. Changes. Modified. Classes; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public IFIDSet Inserted. And. Deleted. IDs (IData. Changes. Ex data. Changes. Ex, String class. Name) { // Get the IDs of inserted rows. IFIDSet insert. Fid. Set = data. Changes. Ex. get_Changed. IDs (class. Name, esri. Difference. Type. Insert); // Get the IDs of deleted rows. IFIDSet delete. No. Change. Fid. Set = data. Changes. Ex. get_Changed. IDs(class. Name, esri. Difference. Type. Delete. No. Change); // Join the two ID sets and return the result. IFIDSet. Operator fid. Set. Operator = (IFIDSet. Operator) insert. Fid. Set; return fid. Set. Operator. Union(delete. No. Change. Fid. Set); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public void Display. Modified. Values (IData. Changes. Ex data. Changes. Ex, String class. Name) { // Get a cursor over the updated rows. IDifference. Cursor. Ex difference. Cursor. Ex = data. Changes. Extract. Ex (class. Name, esri. Difference. Type. Update. No. Change); int feature. ID = -1; IRow source. Row = null; IRow difference. Row = null; ILong. Array field. Indexes = null; // Iterate through the cursor. difference. Cursor. Ex. Next (out feature. ID, out source. Row, out difference. Row, out field. Indexes); while (feature. ID != -1) { Console. Write. Line("Changes for feature {0}: ", feature. ID); // Go to each changed field and display the old and new values. for (int i = 0; i < field. Indexes. Count; i++) { Console. Write. Line("Previous value: {0}", source. Row. get_Value(i)); Console. Write. Line(“Current value: {0}”, difference. Row. get_Value(i)); } difference. Cursor. Ex. Next (out feature. ID, out source. Row, out difference. Row, out field. Indexes);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 2. 3 �找版本之�的差异 l Establishing references to the versions public IFIDSet Find. Version. Differences (IWorkspace workspace, String child. Version. Name, String parent. Version. Name, String table. Name, esri. Difference. Type difference. Type) { // Get references to the child and parent versions. IVersioned. Workspace versioned. Workspace = (IVersioned. Workspace) workspace; IVersion child. Version = versioned. Workspace. Find. Version(child. Version. Name); IVersion parent. Version = versioned. Workspace. Find. Version(parent. Version. Name);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l Detecting the differences // Cast to the IVersion 2 interface to find the common ancestor. IVersion 2 child. Version 2 = (IVersion 2) child. Version; IVersion common. Ancestor. Version = child. Version 2. Get. Common. Ancestor(parent. Version); // Cast the child version to IFeature. Workspace and open the table. IFeature. Workspace child. FWS = (IFeature. Workspace) child. Version; ITable child. Table = child. FWS. Open. Table(table. Name); // Cast the common ancestor version to IFeature. Workspace and open the table. IFeature. Workspace common. Ancestor. FWS = (IFeature. Workspace) common. Ancestor. Version; ITable common. Ancestor. Table = common. Ancestor. FWS. Open. Table(table. Name);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET // Cast to the IVersioned. Table interface to create a difference cursor. IVersioned. Table versioned. Table = (IVersioned. Table) child. Table; IDifference. Cursor difference. Cursor = versioned. Table. Differences (common. Ancestor. Table, difference. Type, null); // Create output variables for the IDifference. Cursor. Next method and a FID set. IFIDSet fid. Set = new FIDSet. Class(); IRow difference. Row = null; int object. ID = -1; // Step through the cursor, showing the ID of each modified row. difference. Cursor. Next(out object. ID, out difference. Row); while (object. ID != -1) { fid. Set. Add(object. ID);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l Obtaining differences between historical versions public IFIDSet Find. Historical. Differences (IWorkspace workspace, String historical. Marker. Name, String table. Name, esri. Difference. Type difference. Type) { // Cast to the IHistorical. Workspace interface and get the 2004 and default versions. IHistorical. Workspace historical. Workspace = (IHistorical. Workspace) workspace; IHistorical. Version default. Version = historical. Workspace. Find. Historical. Version. By. Name(historical Workspace. Default. Marker. Name); IHistorical. Version historical. Version = historical. Workspace. Find. Historical. Version. By. Name(historical Marker. Name); // Cast both versions to IFeature. Workspace and open the table from each. IFeature. Workspace default. FWS = (IFeature. Workspace) default. Version;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET // Create a difference cursor. IVersioned. Table versioned. Table = (IVersioned. Table) default. Table; IDifference. Cursor difference. Cursor = versioned. Table. Differences(historical. Table, difference. Type, null); // Create output variables for the IDifference. Cursor. Next method and a FID set. IFIDSet fid. Set = new FIDSet. Class(); IRow difference. Row = null; int object. ID = -1; // Step through the cursor, showing the ID of each modified row. difference. Cursor. Next(out object. ID, out difference. Row); while (object. ID != -1) { fid. Set. Add(object. ID); difference. Cursor. Next(out object. ID, out difference. Row); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET public void Reconcileand. Post (IVersion edit. Version, IVersion target. Version) { IMultiuser. Workspace. Edit mu. Workspace. Edit = (IMultiuser. Workspace. Edit) edit. Version; IWorkspace. Edit workspace. Edit = (IWorkspace. Edit) edit. Version; IVersion. Edit 4 version. Edit = (IVersion. Edit 4) edit. Version; if (mu. Workspace. Edit. Supports. Multiuser. Edit. Session. Mode( esri. Multiuser. Edit. Session. Mode. esri. MESMVersioned)) { mu. Workspace. Edit. Start. Multiuser. Editing(esri. Multiuser. Edi t. Session. Mode. esri. MESMVersioned); //Reconcile with the target version. bool conflicts = version. Edit. Reconcile 4(target. Version. Name, true, false, false);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET if (conflicts) Message. Box. Show(" Conflicts Detected "); Else Message. Box. Show(" No Conflicts Detected "); workspace. Edit. Start. Edit. Operation(); //Post to the target version. if (version. Edit. Can. Post()) version. Edit. Post(target. Version. Name); workspace. Edit. Stop. Edit. Operation(); workspace. Edit. Stop. Editing(true); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 2. 5 �听版本化��事件 l IVersion. Events_Event publishes the following events: Ø On. Conflicts. Detected Ø On. Reconcile Ø On. Redefine. Version Ø On. Refresh. Version l IVersion. Events 2_Event publishes the following events: Ø On. Archive. Updated Ø On. Begin. Reconcile Ø On. Delete. Version Ø On. Post
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public void Set. Version. Event (IVersion version) { // Cast the version to the event interface. IVersion. Events_Event version. Event = (IVersion. Events_Event) version; // Instantiate the delegate type and add it to the event. version. Event. On. Reconcile += new IVersion. Events_On. Reconcile. Event. Handler(On. Reconcile); } l public void On. Reconcile (String target. Version. Name, Boolean has. Conflicts) { // TODO: Implement the event handling. }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 3 Display. Feedback对象 l Display. Feedback是让用户能够使用鼠标与 控件进行可视化交互的对象集,主要用于创 建、修改几何对象。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l 所有的Display. Feedback类都实现了 IDisplay. Feedback接口,这个接口定义了 它们的公共方法和属性,如Display、 Symbol属性和Move. To、Refresh方法。 l 一般地,当Display. Feedback对象初始化的 时候,程序员需要给它们设置Display和 Symbol属性,然后才让它们开始Move. To。 如果不明确设置一个Symbol属性,系统将 会给Display. Feedback一个缺省的Symbol
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 3. 1 产生新Geometry的Feedback对 象 l New. Line. Feedback、 New. Polygon. Feedback、 New. Bezier. Curve. Feedback l 绘制圆形和Envelope对象
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET (1 ) New. Line. Feedback、New. Polygon. Feedback、 New. Bezier. Curve. Feedback l New. Line. Feedback,New. Polygon. Feedback, New. Bezier. Curve. Feedback分别用于创建Polyline、 Polygon和Bezier. Curve(贝塞尔曲线)对象。创建这三类 Feedback对象使用的鼠标事件都是Mouse. Down、 Mouse. Move和Mouse. Dbl. Click。 l 三个对象尽管产生的几何形体对象不一样,但是它们使用的 方法都是大同小异的,如在Mouse. Down事件中使用Start 方法添加一个起始点或者使用Add. Point添加点;在 Mouse. Move事件中使用Move. To方法来移动鼠标到一个新 的点;在Mouse. Dbl. Click事件中Stop方法将返回产生的几 何形体对象。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Create Polyline By Feedback l public sealed class Create. Polyline. Tool : Base. Tool { IHook. Helper m_hook. Helper = null; IMap m_Map; IActive. View m_Active. View; INew. Line. Feedback p. Line. Feedback; IFeature. Layer m_p. Current. Layer; IPoint m_p. Point; public Create. Polyline. Tool( IFeature. Layer feature. Layer) { base. m_category = "高��� "; base. m_caption = "� 建�要素 "; base. m_message = "�建�要素 "; base. m_tool. Tip = "� 建�要素 "; base. m_name = "Create. Polyline. Tool"; string bitmap. Resource. Name = Get. Type(). Name + ". bmp"; base. m_bitmap = new Bitmap(Get. Type(), bitmap. Resource. Name);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; m_Active. View = m_hook. Helper. Active. View; m_Map = m_hook. Helper. Focus. Map; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { //�得鼠�在控件上点�的位置,�生一个点�象 IPoint p. Pt = m_Active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); if (p. Line. Feedback == null) { p. Line. Feedback = new New. Line. Feedback. Class(); p. Line. Feedback. Display = m_Active. View. Screen. Display; p. Line. Feedback. Start(p. Pt); } else { p. Line. Feedback. Add. Point(p. Pt); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Move(int Button, int Shift, int X, int Y) { IPoint p. Pt = m_Active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); //Move. To方法�承自 IDisplay. Feedback接口的定 � if (p. Line. Feedback != null) p. Line. Feedback. Move. To(p. Pt); m_p. Point = m_Active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Dbl. Click() { IGeometry p. Geom = null; IPoint. Collection p. Point. Collection = null; p. Line. Feedback. Add. Point(m_p. Point); IPolyline p. Poly. Line = p. Line. Feedback. Stop(); if (p. Poly. Line != null) p. Point. Collection = (IPoint. Collection) p. Poly. Line; if (p. Point. Collection. Point. Count < 2) Message. Box. Show("You must have at least two vertices in a line. ", "Bad Line Geometry", Message. Box. Buttons. OK, Message. Box. Icon. Exclamation); else p. Geom = (IGeometry) p. Point. Collection; p. Line. Feedback = null; Create. Feature(p. Geom); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Create. Feature( IGeometry p. Geom) { if (p. Geom == null || m_p. Current. Layer == null) return; IWorkspace. Edit p. Workspace. Edit = Get. Workspace. Edit(); IFeature. Layer p. Feature. Layer = (IFeature. Layer)m_p. Current. Layer; IFeature. Class p. Feature. Class = p. Feature. Layer. Feature. Class; p. Workspace. Edit. Start. Edit. Operation(); IFeature p. Feature = p. Feature. Class. Create. Feature(); try { p. Feature. Shape = p. Geom; } catch (Exception ex) { Message. Box. Show("�建要素 ", ex. Message); } p. Feature. Store(); p. Workspace. Edit. Stop. Edit. Operation(); m_Active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Ge ography, m_p. Current. Layer, p. Geom. Envelope);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private IWorkspace. Edit Get. Workspace. Edit() { if (m_p. Current. Layer == null) return null; IFeature. Layer p. Feature. Layer = (IFeature. Layer)m_p. Current. Layer; IFeature. Class p. Feature. Class = p. Feature. Layer. Feature. Class; IDataset p. Dataset = (IDataset) p. Feature. Class; if (p. Dataset == null) return null; return (IWorkspace. Edit) p. Dataset. Workspace; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Create Circle by Feedback l public sealed class Create. Circle. Tool : Base. Tool { IHook. Helper m_hook. Helper = new Hook. Helper. Class(); IMap m_Map; IActive. View m_Active. View; INew. Circle. Feedback p. Circle. Feedback; IFeature. Layer m_p. Current. Layer; public Create. Circle. Tool( IFeature. Layer feature. Layer) { …… m_p. Current. Layer = feature. Layer; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper. Hook = hook; m_Active. View = m_hook. Helper. Active. View; m_Map = m_hook. Helper. Focus. Map; } public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { //�得鼠�在控件上点�的位置,�生一个点�象 IPoint p. Pt = m_Active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); if (p. Circle. Feedback == null) { p. Circle. Feedback = new New. Circle. Feedback. Class(); p. Circle. Feedback. Display = m_Active. View. Screen. Display; p. Circle. Feedback. Start(p. Pt); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Move(int Button, int Shift, int X, int Y) { IPoint p. Pt = m_Active. View. Screen. Display. Transformation. To. Map Point(X, Y); //Move. To方法�承自 IDisplay. Feedback接口的定� if (p. Circle. Feedback != null) p. Circle. Feedback. Move. To(p. Pt); } public override void On. Mouse. Up(int Button, int Shift, int X, int Y) { IGeometry p. Geo = null; p. Geo = p. Circle. Feedback. Stop(); p. Circle. Feedback = null; Create. Feature(p. Geo);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Create. Feature(IGeometry p. Geom) { IWorkspace. Edit p. Workspace. Edit = Get. Workspace. Edit(); IFeature. Layer p. Feature. Layer = (IFeature. Layer) m_p. Current. Layer; IFeature. Class p. Feature. Class = p. Feature. Layer. Feature. Class; IConstruct. Circular. Arc p. Construct. Arc = p. Geom as IConstruct. Circular. Arc; IPolygon p. Polygon = new Polygon. Class(); ISegment. Collection p. Segment. Collection = p. Polygon as ISegment. Collection; ISegment p. Segment = p. Construct. Arc as ISegment; object missing = Type. Missing; p. Segment. Collection. Add. Segment(p. Segment, ref missing); p. Workspace. Edit. Start. Edit. Operation(); IFeature p. Feature = p. Feature. Class. Create. Feature(); p. Feature. Shape = p. Polygon; p. Feature. Store(); p. Workspace. Edit. Stop. Edit. Operation();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 3. 2 移动几何对象上的节点 l Line. Move. Point. Feedback、 Bezier. Move. Point. Feedback和 Polygon. Move. Point. Feedback三个对象移动节点 的方法是一样的,且使用的鼠标事件也都是 Mouse. Down、Mouse. Move和 Mouse. Up。 l Line. Move. Point. Feedback、 Bezier. Move. Point. Feedback类都实现了 ILine. Move. Point. Feedback接口。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l ILine. Move. Point. Feedback和 IPolygon. Move. Point. Feedback接口中定义的 Start方法 Ø public void Start ( IPolyline polyline, int point. Index, IPoint ); Ø public void Start ( IPolygon polygon, int point. Index, IPoint); • 要求传入三个参数,即需要移动节点的几何形体对象,移 动的点索引号和鼠标点击位置。 • 为了获得点索引号这个参数,需要使用IHit. Test接口定义 的方法来实现。 Ø 实现了IHit. Test接口的对象有 Envelope、Point、 Multipoint、Polyline和 Polygon,这个接口只有一个
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public bool Hit. Test ( IPoint Query. Point, double search. Radius, esri. Geometry. Hit. Part. Type geometry. Part, IPoint hit. Point, ref double hit. Distance, ref int hit. Part. Index, ref int hit. Segment. Index, ref bool b. Right. Side );
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET Move. Polyline. And. Bezier. Point实例
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 3. 4 其他Display. Feedback l Move. Geometry. Feedback Ø 如果打算同时移动多个几何对象,可以使用 Move. Geometry. Feedback来实现。 IMove. Geometry. Feedback: : Add. Geometry方法用于添加要移动 的对象;IMove. Geometry. Feedback: : Clear. Geometry可以清除 Display. Feedback中所有要移动的几何对象。Start方法用于设置 移动的起始点。 l Reshape. Feedback对象 Ø Reshape. Feedback对象可以用于对一个实现了 IPath 接口的对象 进行整形的任务,实现IPath接口的对象包括Path和Ring,分别用 来表达Polyline、Polygon的一部分。IReshape. Feedback: : Start 的Stretch参数则决定了变形的方式。
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public sealed class Polygons. Difference : Base. Tool { IApplication m_application = null; IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IEngine. Edit. Properties m_engine. Editor = null; public Polygons. Difference() { base. m_category = "空�数据�� "; base. m_caption = "多�形挖空�理 "; base. m_message = "多�形挖空�理 "; base. m_tool. Tip = "多�形挖空�理 "; base. m_name = "Polygons. Difference"; string bitmap. Resource. Name = Get. Type(). Name + ". bmp"; base. m_bitmap = new Bitmap(Get. Type(), bitmap. Resource. Name); base. m_cursor = new System. Windows. Forms. Cursor(Get. Type(), Get. Type(). Name + ". cur");
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; } public override void On. Click() { ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���!! ", "信 息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show(……); return; } m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; IPoint p. Point = m_active. View. Screen. Display. Transformation. To. Map. Poi nt(X, Y); ISelection. Environment p. Selection. Environment = new Selection. Environment. Class(); p. Selection. Environment. Point. Selection. Method = esri. Spatial. Rel. Enum. esri. Spatial. Rel. Within; m_map. Select. By. Shape(p. Point as IGeometry, p. Selection. Environment, false); if (m_map. Selection. Count != 2) { Message. Box. Show(……); return; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IEnum. Feature p. Enum. Feature = m_map. Feature. Selection as IEnum. Feature; IFeature first. Feature = p. Enum. Feature. Next(); IFeature second. Feature = p. Enum. Feature. Next(); bool first. Polygon. Is. Large = false; IGeometry p. Geometry = null; IRelational. Operator p. Rel. Op 1 = first. Feature. Shape as IRelational. Operator; IRelational. Operator p. Rel. Op 2 = second. Feature. Shape as IRelational. Operator; ITopological. Operator p. Topological. Operator = null; if (p. Rel. Op 1. Contains(second. Feature. Shape)) { p. Topological. Operator = first. Feature. Shape as ITopological. Operator; p. Geometry = p. Topological. Operator. Difference(second. Feature. Shape); first. Polygon. Is. Large = true; } else if (p. Rel. Op 2. Contains(first. Feature. Shape))
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET bool delete. Interior. Polygon = false; Dialog. Result p. Dialog. Result = Message. Box. Show("是 否要�除内多�形? ", "操作提示", Message. Box. Buttons. Yes. No); if (p. Dialog. Result == Dialog. Result. Yes) { delete. Interior. Polygon = true; } IFeature. Class feature. Class = first. Feature. Class as IFeature. Class; IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; if (!(workspace. Edit. Is. Being. Edited())) return; workspace. Edit. Start. Edit. Operation();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET if (first. Polygon. Is. Large) { first. Feature. Shape = p. Geometry; first. Feature. Store(); if (delete. Interior. Polygon) second. Feature. Delete(); } else { second. Feature. Shape = p. Geometry; second. Feature. Store(); if (delete. Interior. Polygon) first. Feature. Delete(); } workspace. Edit. Stop. Edit. Operation(); m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo graphy, null, m_active. View. Extent); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 5 分割线要素
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public sealed class Split 2 Lines. At 1 Intersect. Tool : Base. Tool { IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IEngine. Edit. Properties m_engine. Editor = null; IPoint m_first. Point = null; IPoint m_second. Point = null; IPoint m_active. Point = null; IFeature m_first. Feature = null; IFeature m_second. Feature = null; enum Tool. Phase { Select. First. Feature, Select. Second. Feature, Split } Tool. Phase m_tool. Phase; IMultipoint intersect. Points = null;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public Split 2 Lines. At 1 Intersect. Tool() { base. m_category = "空�数据�� "; base. m_caption = "在交点�分割�要素 "; base. m_message = "在交点�分割�要素 "; base. m_tool. Tip = "在交点�分割�要素 "; base. m_name = "Split 2 Lines. At 1 Intersect. Tool"; base. m_bitmap = new Bitmap(Get. Type(), "Split. At 1 Intersect. bmp"); base. m_cursor = new System. Windows. Forms. Cursor(Get. Type(), Get. Type(). Name + ". cur"); m_engine. Editor = new Engine. Editor. Class(); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; if (m_hook. Helper == null) base. m_enabled = false; else base. m_enabled = true; m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; m_first. Point = new Point. Class(); m_second. Point = new Point. Class(); m_active. Point = new Point. Class(); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Click() { m_tool. Phase = Tool. Phase. Select. First. Feature; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���!! ", "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; } } public override bool Deactivate() { m_first. Feature = null; m_second. Feature = null; m_first. Point = null; m_second. Point = null; m_active. Point = null; return true; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Key. Down (int key. Code, int Shift) {// If the Escape key is used, throw away the calculated point. if (key. Code == (int)Keys. Escape) { m_tool. Phase = Tool. Phase. Select. First. Feature; m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down (int Button, int Shift, int X, int Y) { if (Button != (int)Keys. LButton) return; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���! !", "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; } m_active. Point = m_active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); switch (m_tool. Phase) { case (Tool. Phase. Select. First. Feature): Get. First. Feature(); break; case (Tool. Phase. Select. Second. Feature): Get. Second. Feafeature(); break; case (Tool. Phase. Split):
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Move (int Button, int Shift, int X, int Y) { if (m_tool. Phase != Tool. Phase. Split) return; IPoint point = m_active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); nearest. Intersect. Point = Find. Nearest. Intersect. Point(intersect. Points as IPoint. Collection, point); if (nearest. Intersect. Point != null) { Flash. Geometry(nearest. Intersect. Point, 5, 10); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. Vie w. Foreground, null, m_active. View. Extent); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Get. First. Feature() { m_first. Point = m_active. Point; m_first. Feature = Selct. Feature. Based. Mouse. Point(m_first. Point); if (m_first. Feature != null) m_tool. Phase = Tool. Phase. Select. Second. Feature; } private void Get. Second. Feafeature() { if (m_first. Feature == null) { m_tool. Phase = Tool. Phase. Select. First. Feature; return; } m_second. Point = m_active. Point; m_second. Feature = Selct. Feature. Based. Mouse. Point(m_second. Point); if (m_second. Feature == null) { m_tool. Phase = Tool. Phase. Select. Second. Feature; return; } intersect. Points = Getintersect. Points(m_second. Feature, m_first. Feature); if (intersect. Points == null) { m_tool. Phase = Tool. Phase. Select. Second. Feature; } else { m_tool. Phase = Tool. Phase. Split; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private IMultipoint Getintersect. Points( IFeature m_second. Feature, IFeature m_first. Feature) { IGeometry geometry 1 = m_first. Feature. Shape. Copy; IGeometry geometry 2 = m_second. Feature. Shape. Copy; ITopological. Operator 2 topo 1 = geometry 1 as ITopological. Operator 2; topo 1. Is. Known. Simple_2 = false; topo 1. Simplify(); ITopological. Operator 2 topo 2 = geometry 2 as ITopological. Operator 2; topo 2. Is. Known. Simple_2 = false; topo 2. Simplify(); IMultipoint intersect. Points = topo 2. Intersect(geometry 1, esri. Geometry. Dimension. esri. Geometry 0 Dimension) as IMultipoint;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Split. Feafeatures( IFeature m_first. Feature, IFeature m_second. Feature) { if (intersect. Points == null) return; if (nearest. Intersect. Point == null) return; Split. One. Feature(m_first. Feature); Split. One. Feature(m_second. Feature); m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geography | esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); m_tool. Phase = Tool. Phase. Select. First. Feature; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Split. One. Feature( IFeature split. Feature ) { IPolycurve. To. Split = split. Feature. Shape. Copy as IPolycurve; double distance. On. Curve = 0; double nearest. Distance = 0; bool is. Right. Side = false; IPoint out. Point = new Point. Class(); bool Split. Happened; int new. Part. Index; int new. Segment. Index; ISegment. Collection polyline = null; IFeature new. Feature = null; IFeature. Class split. Feature. Class = split. Feature. Class as IFeature. Class; IDataset dataset = split. Feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET public void Split. At. Point ( IPoint split. Point, try { curve. To. Split. Query. Point. And. Distance(esri. Segment. Extension. es bool project. Onto, ri. No. Extension, nearest. Intersect. Point, false, out. Point, ref bool create. Part, distance. On. Curve, ref nearest. Distance, ref is. Right. Side); ref bool public void curve. To. Split. At. Point(out. Point, true, out Split. Happened, Query. Point. And. Distance ( Split. Happened, out new. Part. Index, out new. Segment. Index); ref int new. Part. Index, esri. Segment. Extension IGeometry. Collection geometry. Collection = curve. To. Split as ref int IGeometry. Collection; extension, new. Segment. Index); workspace. Edit. Start. Edit. Operation(); IPoint in. Point, • Adds a new vertex for (int i = 0; i < geometry. Collection. Geometry. Count; i++) bool as. Ratio, along the curve as the { ISegment. Collection part. Geom = IPoint out. Point, specified input point, refgeometry. Collection. get_Geometry(i) as ISegment. Collection; double or the projection onto object missing = Type. Missing; Distance. Along. Curve, the curve of the polyline = new Polyline. Class(); ref double specified input point. for (int k = 0; k < part. Geom. Segment. Count; k++) distance. From. Curve, { polyline. Add. Segment(part. Geom. get_Segment(k), ref bool b. Right. Side); missing, ref missing); } • Finds the point on the
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET new. Feature = split. Feature. Class. Create. Feature(); for (int j = 0; j < split. Feature. Fields. Field. Count; j++) { if (split. Feature. Fields. get_Field(j). Editable) { new. Feature. set_Value(j, split. Feature. get_Value(j)); } } Flash. Geometry(polyline as IGeometry, 3, 50); new. Feature. Shape = polyline as IGeometry; new. Feature. Store(); part. Geom = null; } split. Feature. Delete(); workspace. Edit. Stop. Edit. Operation(); } catch (Exception ex) { workspace. Edit. Abort. Edit. Operation(); Message. Box. Show("分割�要素失�!! " + ex. Message, "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private IPoint Find. Nearest. Intersect. Point (IPoint. Collection intersect. Points, IPoint second. Point) { IPoint point = null; double min. Distance = 0. 0; double distance = 0. 0; int min. Distance. Point. Idx = -1; for (int i = 0; i < intersect. Points. Point. Count; i++) { point = intersect. Points. get_Point(i); distance = (point. X - second. Point. X) * (point. X - second. Point. X) + (point. Y - second. Point. Y) * (point. Y - second. Point. Y); if (i == 0) { min. Distance = distance; min. Distance. Point. Idx = 0; } else { if (distance < min. Distance) { min. Distance = distance; min. Distance. Point. Idx = i; } } if (min. Distance. Point. Idx != -1) return intersect. Points. get_Point(min. Distance. Point. Idx); else return null; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public sealed class Reshape. Tool : Base. Tool { IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IEngine. Edit. Properties m_engine. Editor = null; IPoint m_active. Point = null; IFeature m_selected. Feature = null; enum Tool. Phase { Select. Feature, Draw. Sketch. And. Reshape } Tool. Phase m_tool. Phase;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public Reshape. Tool() { …… m_engine. Editor = new Engine. Editor. Class(); } public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Click() { m_tool. Phase = Tool. Phase. Select. Feature; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���!! ", "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; } } public override bool Deactivate() { m_selected. Feature = null; m_active. Point = null; return true; } public override void On. Key. Down(int key. Code, int Shift) { if (key. Code == (int)Keys. Escape) { m_tool. Phase = Tool. Phase. Select. Feature; m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo Selection, null, m_active. View. Extent); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; if (m_map == null || m_active. View == null) return; m_active. Point = m_active. View. Screen. Display. Transformation. To. Map. Point(X, Y); switch (m_tool. Phase) { case (Tool. Phase. Select. Feature): base. m_cursor = new Cursor(Get. Type(), "arrow_l. cur"); Get. Selected. Feature(); base. m_cursor = new Cursor(Get. Type(), "pen. cur"); break; case (Tool. Phase. Draw. Sketch. And. Reshape): base. m_cursor = new Cursor(Get. Type(), "pen. cur"); Draw. And. Reshape(); base. m_cursor = new Cursor(Get. Type(), "arrow_l. cur"); break;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Get. Selected. Feature() { if (m_active. Point == null) return; IPoint mouse. Point = m_active. Point; m_selected. Feature = Selct. Feature. Based. Mouse. Point(mouse. Point); if (m_selected. Feature != null) m_tool. Phase = Tool. Phase. Draw. Sketch. And. Reshape; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Draw. And. Reshape() { //在屏幕上�制用于整形的�要素 IScreen. Display screen. Display = m_active. View. Screen. Display; ISimple. Line. Symbol sym = new Simple. Line. Symbol. Class(); IRgb. Color color = new Rgb. Color. Class(); color. Red = 255; color. Green = 0; color. Blue = 0; sym. Color = color; sym. Style = esri. Simple. Line. Style. esri. SLSSolid; sym. Width = 2; IRubber. Band reshape. Band = new Rubber. Line. Class(); IGeometry reshape. Geom = reshape. Band. Track. New(screen. Display, sym as ISymbol); screen. Display. Start. Drawing(screen. Display. h. DC, (short)esri. Screen. Cache. esri. No. Screen. Cache); screen. Display. Set. Symbol(sym as ISymbol);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IGeometry edit. Shape = m_selected. Feature. Shape. Copy; IFeature. Class feature. Class = m_selected. Feature. Class as IFeature. Class; IPoint. Collection reshape. Path = new Path. Class(); reshape. Path. Add. Point. Collection(reshape. Geom as IPoint. Collection); //reshape the selected feature if (feature. Class. Shape. Type == esri. Geometry. Type. esri. Geometry. Polyline) { IPolyline polyline = edit. Shape as IPolyline; polyline. Reshape(reshape. Path as IPath); } if (feature. Class. Shape. Type == esri. Geometry. Type. esri. Geometry. Polygon) { IGeometry. Collection geometry. Collection = edit. Shape as IGeometry. Collection; IRing ring = null; for (int i = 0; i < geometry. Collection. Geometry. Count; i++) { ring = geometry. Collection. get_Geometry(i) as IRing;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; try { workspace. Edit. Start. Edit. Operation(); m_selected. Feature. Shape = edit. Shape; m_selected. Feature. Store(); workspace. Edit. Stop. Edit. Operation(); } catch (Exception ex) { workspace. Edit. Abort. Edit. Operation(); Message. Box. Show("要素整形失�!! " + ex. Message, "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); } m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. G eography | esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); m_tool. Phase = Tool. Phase. Select. Feature;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private IFeature Selct. Feature. Based. Mouse. Point(IPoint p. Point) { ITopological. Operator p. Topo = p. Point as ITopological. Operator; IGeometry p. Buffer = p. Topo. Buffer(0. 5); IGeometry p. Geometry = p. Buffer. Envelope; Set. All. Polyline. Polygon. Layers. Selectable(); ISelection. Environment sel. Environment = new Selection. Environment. Class(); sel. Environment. Combination. Method = esri. Selection. Result. Enum. esri. Selection. Result. New; m_map. Select. By. Shape(p. Geometry, sel. Environment, true); IEnum. Feature Selected. Features = m_map. Feature. Selection as IEnum. Feature; Selected. Features. Reset(); IFeature sel. Feature = Selected. Features. Next(); Set. All. Layers. Selectable(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); return sel. Feature ; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 要素合并(Union) l public sealed class Union. Features. Cmd : Base. Command { IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IFeature. Layer current. Layer = null; IEngine. Edit. Properties m_engine. Editor = null; public Union. Features. Cmd() { …… m_engine. Editor = new Engine. Editor. Class(); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { if (hook == null) return; m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; } public override void On. Click() { ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show(); return; } m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; IEnum. Feature selected. Features = Get. Selected. Features(); if (selected. Features == null) return; Union. Features(selected. Features); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. G eography | esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private IEnum. Feature Get. Selected. Features() { if (m_map. Selection. Count < 2) { Message. Box. Show(); return null; } ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) return null; if (!(layer is IFeature. Layer)) return null; current. Layer = layer as IFeature. Layer; if (current. Layer. Feature. Class. Shape. Type == esri. Geometry. Type. esri. Geometry. Point) { Message. Box. Show(); return null; } IEnum. Feature Selected. Features = m_map. Feature. Selection as IEnum. Feature; if (Selected. Features == null) return null; //判断Selected. Features是否�相同的几何�型,且是否与 m_engine. Editor. Target. Layer几何�型相同 bool same. Geometry. Type = Judge. Geometry. Type(Selected. Features);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private bool Judge. Geometry. Type(IEnum. Feature Selected. Features) { Selected. Features. Reset(); IFeature feature = Selected. Features. Next(); if (feature == null) return false; esri. Geometry. Type geometry. Type = feature. Shape. Copy. Geometry. Type; while ((feature = Selected. Features. Next()) != null) { if (geometry. Type != feature. Shape. Copy. Geometry. Type) { return false; } if (geometry. Type == current. Layer. Feature. Class. Shape. Type) return true; return false;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Union. Features( IEnum. Feature selected. Features) { IFeature feature = null; IGeometry geometry = null; object missing = Type. Missing; selected. Features. Reset(); feature = selected. Features. Next(); if (feature == null) return; IFeature. Class feature. Class = feature. Class as IFeature. Class; IGeometry. Collection geometries = new Geometry. Bag. Class(); while (feature != null) { geometry = feature. Shape. Copy; geometries. Add. Geometry(geometry, ref missing); feature = selected. Features. Next();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET switch (feature. Class. Shape. Type) { case esri. Geometry. Type. esri. Geometry. Multipoint: unioned. Geometry = new Multipoint. Class(); break; case esri. Geometry. Type. esri. Geometry. Polyline: unioned. Geometry = new Polyline. Class(); break; case esri. Geometry. Type. esri. Geometry. Polygon: unioned. Geometry = new Polygon. Class(); break;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET ITopological. Operator 2 topo = unioned. Geometry as ITopological. Operator 2; topo. Is. Known. Simple_2 = false; topo. Simplify(); IFeature. Class target. Feature. Class = current. Layer. Feature. Class; IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; if (!(workspace. Edit. Is. Being. Edited())) return; try { workspace. Edit. Start. Edit. Operation(); IFeature unioned. Feature = target. Feature. Class. Create. Feature(); unioned. Feature. Shape = unioned. Geometry as IGeometry; unioned. Feature. Store(); workspace. Edit. Stop. Edit. Operation(); } catch (Exception ex) { workspace. Edit. Abort. Edit. Operation();
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 将部分转换为要素 l public sealed class Convert. Part 2 Feature. Tool : Base. Tool { IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IFeature. Layer current. Layer = null; IEngine. Edit. Properties m_engine. Editor = null; IPoint m_active. Point = null; IFeature m_selected. Feature = null; enum Tool. Phase { Selecting. Feature, Selecting. Part } Tool. Phase m_tool. Phase; public Convert. Part 2 Feature. Tool() { …… m_engine. Editor = new Engine. Editor. Class(); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; m_active. Point = new Point. Class(); } public override void On. Click() { m_tool. Phase = Tool. Phase. Selecting. Feature; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���!! ", "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override bool Deactivate() { m_selected. Feature = null; m_active. Point = null; return true; } public override void On. Key. Down(int key. Code, int Shift) { if (key. Code == (int)Keys. Escape) { m_tool. Phase = Tool. Phase. Selecting. Feature; m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { if (Button != (int)Keys. LButton) return; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show(); return; } m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; if (m_map == null || m_active. View == null) return; m_active. Point = m_active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); switch (m_tool. Phase) { case (Tool. Phase. Selecting. Feature): Get. Selected. Feature(); break; case (Tool. Phase. Selecting. Part): Select. And. Convert. Part(); break; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Get. Selected. Feature() { if (m_active. Point == null) return; IPoint mouse. Point = m_active. Point; m_selected. Feature = Selct. Feature. Based. Mouse. Point(mouse. Point ); if (m_selected. Feature != null) m_tool. Phase = Tool. Phase. Selecting. Part; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Select. And. Convert. Part() { if (m_selected. Feature == null) return; IPoint mouse. Point = m_active. Point; IGeometry. Collection geometry. Collection = m_selected. Feature. Shape as IGeometry. Collection; if (geometry. Collection. Geometry. Count == 1) { Message. Box. Show("��的要素不是多部分要素!! ", " 信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); m_tool. Phase = Tool. Phase. Selecting. Feature; m_map. Clear. Selection(); return; } int Part = Find. And. Draw. Convert. Part(geometry. Collection, mouse. Point); Convert. Part. To. Feature(Part, m_selected. Feature); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Ge ography | esri. View. Draw. Phase. esri. View. Geo. Selection, null,
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private int Find. And. Draw. Convert. Part (IGeometry. Collection geometry. Collection, IPoint p. Pt) { IProximity. Operator proximity = geometry. Collection as IProximity. Operator; IPoint nearest. Point = null; int convert. Part = -1; object missing = Type. Missing; int i = 0; IFeature. Class feature. Class = m_selected. Feature. Class as IFeature. Class; switch (feature. Class. Shape. Type) { case esri. Geometry. Type. esri. Geometry. Multipoint: nearest. Point = proximity. Return. Nearest. Point(p. Pt, esri. Segment. Extension. esri. No. Extension); IPoint point = null; for (i = 0; i < geometry. Collection. Geometry. Count; i++) { point = geometry. Collection. get_Geometry(i) as IPoint; if ((point. X == nearest. Point. X) && (point. Y == nearest. Point. Y))
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET case esri. Geometry. Type. esri. Geometry. Polyline: nearest. Point = proximity. Return. Nearest. Point(p. Pt, esri. Segment. Extension. esri. No. Extension); for (i = 0; i < geometry. Collection. Geometry. Count; i++) { IGeometry. Collection polyline = new Polyline. Class(); polyline. Add. Geometry(geometry. Collection. get_Geometry(i), ref missing, ref missing); IRelational. Operator relational. Line = polyline as IRelational. Operator; if (relational. Line. Contains(nearest. Point)) { Flash. Geometry(polyline as IGeometry, 5, 10); convert. Part = i; break; } break;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET case esri. Geometry. Type. esri. Geometry. Polygon: for (i = 0; i < geometry. Collection. Geometry. Count; i++) { IGeometry. Collection polygon = new Polygon. Class(); polygon. Add. Geometry(geometry. Collection. get_Geometry(i), ref missing, ref missing); IRelational. Operator rel. Polygon = polygon as IRelational. Operator; if (rel. Polygon. Contains(p. Pt)) { Flash. Geometry(polygon as IGeometry, 5, 10); convert. Part = i; break; } break; default: break; } if (convert. Part == -1) return -1; return convert. Part; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Convert. Part. To. Feature(int part, IFeature selected. Feature) { IGeometry. Collection geometry. Collection = selected. Feature. Shape as IGeometry. Collection; IFeature. Class feature. Class = selected. Feature. Class as IFeature. Class; IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; if (!(workspace. Edit. Is. Being. Edited())) return; IFeature new. Feature = null;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET try { workspace. Edit. Start. Edit. Operation(); new. Feature = feature. Class. Create. Feature(); IGeometry convert. Part. Geometry = geometry. Collection. get_Geometry(part); //delete the original part. geometry. Collection. Remove. Geometries(part, 1); geometry. Collection. Geometries. Changed(); selected. Feature. Shape = geometry. Collection as IGeometry; selected. Feature. Store(); //check the type of geometry. IPolygon polygon = new Polygon. Class(); IPolyline polyline = new Polyline. Class(); IMultipoint multi. Point = new Multipoint. Class(); object Missing = Type. Missing;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET switch (convert. Part. Geometry. Type) { case esri. Geometry. Type. esri. Geometry. Ring: geometry. Collection = polygon as IGeometry. Collection; geometry. Collection. Add. Geometry (convert. Part. Geometry, ref Missing); break; case esri. Geometry. Type. esri. Geometry. Path: geometry. Collection = polyline as IGeometry. Collection; geometry. Collection. Add. Geometry (convert. Part. Geometry, ref Missing); break; case esri. Geometry. Type. esri. Geometry. Point: geometry. Collection = multi. Point as IGeometry. Collection; geometry. Collection. Add. Geometry (convert. Part. Geometry, ref Missing);
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET new. Feature. Shape = geometry. Collection as IGeometry; IField field = new Field. Class(); IFields fields = selected. Feature. Fields; for (int field. Count = 0; field. Count < fields. Field. Count; field. Count++) { field = fields. get_Field(field. Count); if ((field. Type != esri. Field. Type. Geometry) && (field. Type != esri. Field. Type. OID) && field. Editable) { new. Feature. set_Value(field. Count, selected. Feature. get_Value(field. Count)); } } new. Feature. Store(); workspace. Edit. Stop. Edit. Operation(); } catch (Exception ex) { workspace. Edit. Abort. Edit. Operation(); Message. Box. Show("��部分到要素失�!! " + ex. Message, "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 10. 9 线要素的延伸与修剪
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET 修剪�要素 (Trim) l public sealed class Trim. Polyline. Tool : Base. Tool { IHook. Helper m_hook. Helper = null; IActive. View m_active. View = null; IMap m_map = null; IEngine. Edit. Properties m_engine. Editor = null; IPoint m_first. Point = null; IPoint m_second. Point = null; IPoint m_active. Point = null; IFeature m_first. Feature = null; IFeature m_second. Feature = null; enum Tool. Phase { Select. First. Feature, Select. Second. Feature } Tool. Phase m_tool. Phase;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public Trim. Polyline. Tool() { base. m_category = "空�数据�� "; base. m_caption = "修剪�要素 (Trim)"; base. m_message = "修剪�要素 (Trim)"; base. m_tool. Tip = "修剪�要素 (Trim)"; base. m_name = "Trim. Polyline. Tool"; base. m_bitmap = new Bitmap(Get. Type(), "trim. bmp"); base. m_cursor = new Cursor(Get. Type(), Get. Type(). Name + ". cur"); m_engine. Editor = new Engine. Editor. Class(); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Create(object hook) { m_hook. Helper = new Hook. Helper. Class(); m_hook. Helper. Hook = hook; m_active. View = m_hook. Helper. Active. View; m_map = m_hook. Helper. Focus. Map; m_first. Point = new Point. Class(); m_second. Point = new Point. Class(); m_active. Point = new Point. Class(); } public override void On. Click() { m_tool. Phase = Tool. Phase. Select. First. Feature; ILayer layer = m_engine. Editor. Target. Layer; if (layer == null) { Message. Box. Show("�先启���!! ", "信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); return; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override bool Deactivate() { m_first. Feature = null; m_second. Feature = null; m_first. Point = null; m_second. Point = null; m_active. Point = null; return true; } public override void On. Key. Down(int key. Code, int Shift) { // If the Escape key is used, throw away the calculated point. if (key. Code == (int)Keys. Escape) { m_tool. Phase = Tool. Phase. Select. First. Feature; m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Ge o. Selection, null, m_active. View. Extent); }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l public override void On. Mouse. Down(int Button, int Shift, int X, int Y) { if (m_map == null || m_active. View == null) return; if (Button != (int)Keys. LButton) return; m_active. Point = m_active. View. Screen. Display. Transformation. To. Map. P oint(X, Y); switch (m_tool. Phase) { case (Tool. Phase. Select. First. Feature): Get. First. Feature(); break; case (Tool. Phase. Select. Second. Feature): Get. Second. Feafeature(); break; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Get. First. Feature() { m_first. Point = m_active. Point; m_first. Feature = Selct. Feature. Based. Mouse. Point(m_first. Point); //用 于修剪的目标线 if (m_first. Feature != null) m_tool. Phase = Tool. Phase. Select. Second. Feature; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Get. Second. Feafeature() { //�得需要修剪的�要素,并�行修剪 if (m_first. Feature == null) { m_tool. Phase = Tool. Phase. Select. First. Feature; return; } m_second. Point = m_active. Point; m_second. Feature = Selct. Feature. Based. Mouse. Point(m_second. Point); if (m_second. Feature == null) { m_tool. Phase = Tool. Phase. Select. Second. Feature; return; } Trim. Polyline(m_second. Feature, m_first. Feature, m_second. Point); m_map. Clear. Selection(); m_active. View. Partial. Refresh(esri. View. Draw. Phase. esri. View. Geo graphy | esri. View. Draw. Phase. esri. View. Geo. Selection, null, m_active. View. Extent); m_tool. Phase = Tool. Phase. Select. First. Feature; }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Trim. Polyline (IFeature trim. Feature, IFeature target. Feature, IPoint second. Point) { IGeometry preserved. Geom = null; IGeometry left. Geom = null; IGeometry right. Geom = null; double distance. On. Curve = 0; double nearest. Distance = 0; bool is. Right. Side = false; IPoint out. Point = new Point. Class(); IFeature. Class feature. Class = trim. Feature. Class as IFeature. Class; IDataset dataset = feature. Class as IDataset; IWorkspace. Edit workspace. Edit = dataset. Workspace as IWorkspace. Edit; if (!(workspace. Edit. Is. Being. Edited())) return;
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET try { IGeometry target. Geometry = target. Feature. Shape. Copy; IGeometry trim. Geometry = trim. Feature. Shape. Copy; ITopological. Operator 2 topo = trim. Geometry as ITopological. Operator 2; topo. Is. Known. Simple_2 = false; topo. Simplify(); ITopological. Operator 2 topo 2 = target. Geometry as ITopological. Operator 2; topo 2. Is. Known. Simple_2 = false; topo 2. Simplify(); topo. Cut(target. Geometry as IPolyline, out left. Geom, out right. Geom); ICurve curve = target. Geometry as ICurve; curve. Query. Point. And. Distance (esri. Segment. Extension. esri. No. Extension, second. Point, false,
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET if (is. Right. Side) { preserved. Geom = left. Geom; } else { preserved. Geom = right. Geom; } workspace. Edit. Start. Edit. Operation(); trim. Feature. Shape = preserved. Geom; trim. Feature. Store(); workspace. Edit. Stop. Edit. Operation(); Flash. Geometry(trim. Geometry as IGeometry, 3, 10); } catch (Exception ex) { workspace. Edit. Abort. Edit. Operation(); Message. Box. Show("�要素延伸失�!! " + ex. Message, " 信息提示", Message. Box. Buttons. OK, Message. Box. Icon. Information); } }
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private void Flash. Geometry(IGeometry geometry, int flash. Count, interval) { IScreen. Display display = m_active. View. Screen. Display; ISymbol symbol = Create. Simple. Symbol(geometry. Geometry. Type); display. Start. Drawing(0, (short)esri. Screen. Cache. esri. No. Screen. Cache); display. Set. Symbol(symbol); for (int i = 0; i < flash. Count; i++) { switch (geometry. Geometry. Type) { case ESRI. Arc. GIS. Geometry. esri. Geometry. Type. esri. Geometry. Point: display. Draw. Point(geometry); break; case ESRI. Arc. GIS. Geometry. esri. Geometry. Type. esri. Geometry. Multipoint: display. Draw. Multipoint(geometry); break; case ESRI. Arc. GIS. Geometry. esri. Geometry. Type. esri. Geometry. Polyline: display. Draw. Polyline(geometry); break; case
江西理 大学 – Developing GIS Applications with Arc. Objects using C#. NET l private ISymbol Create. Simple. Symbol(esri. Geometry. Type geometry. Type) { ISymbol symbol = null; switch (geometry. Type) { case esri. Geometry. Type. esri. Geometry. Point: case esri. Geometry. Type. esri. Geometry. Multipoint: ISimple. Marker. Symbol marker. Symbol = new Simple. Marker. Symbol. Class(); marker. Symbol. Color = get. RGB(255, 128); marker. Symbol. Size = 2; symbol = marker. Symbol as ISymbol; break; case esri. Geometry. Type. esri. Geometry. Polyline: case esri. Geometry. Type. esri. Geometry. Path: ISimple. Line. Symbol line. Symbol = new Simple. Line. Symbol. Class(); line. Symbol. Color = get. RGB(255, 128); line. Symbol. Width = 4; symbol = line. Symbol as ISymbol; break; case esri. Geometry. Type. esri. Geometry. Polygon: case esri. Geometry. Type. esri. Geometry. Ring: ISimple. Fill. Symbol fill. Symbol = new Simple. Fill. Symbol. Class(); fill. Symbol. Color = get. RGB(255, 128); symbol = fill. Symbol as ISymbol; break; } symbol. ROP 2 = esri. Raster. Op. Code. esri. ROPNot. XOr. Pen;
- Slides: 197