Research of GIS applications development based on ArcObjects components Ya-ru Bai,Yan Qu,Xin Lu IBM Technology of China,610052,Chengdu Abstract. COM-based GIS software application development is the new generation of Geographic Information System development direction. In the pape,we introduced the hierarchical structure of ArcObjects components and the relationship between the component objects.We also discuss the development patterns of component GIS and display the design and implementation method of GIS applications based on ArcObjects components library. To improve the functional limitations of the original ArcObjects components, we propose the development method combined with customized components to extend its application function and give the detailed demonstration of components design through application programming examples. Keywords:Georgraphic Information System , ArcObjects , COM technology 1 Introduction The COM-based technology have become a tendency in modern software development.The component technology radically overcomed the basic flaws of traditional software development technology-low code usablity,high degree of coupling and long-time development cycle.The COM-based GIS software is one of the main stream production of GIS platform.It can not only implement the rapid construction of application software based on components and functional reorganization,but provides visual and standard interfaces,which make the GIS development much more convienent.In this paper,we will dicuss how to develop the GIS application software with COM-based technology. We will also show the research on the application development technology and patterns based on the ArcObjects library(AO) and improve some developing limitations of the ArcObjects components.With the consideration of the user-defined ArcObjects componets functions,we enlarge the application functions and enhance the software development efficiency. 1.1 ArcGIS and ArcObjects The production of ArcGIS from ESRI is one of the most powerful and popular georgraphic information system platform.The platform has many advatages such as comprehensive functions,flexibility and wide deployment etc.The software itself is based on the components library(ArcObjects).The ArcObjects library includs all the functions of ArcGIS and these components all support the COM standard,which can offer call interface to application software.These software productions such as the desktop GIS of ArcGIS9.x,embeded GIS,GIS server and mobile GIS,are all implemented with ArcObjects components library.In the desktop software productionArcView,ArcInfo,ArcEditor,all contain three applicaton modules:ArcMap,ArcCatalog and ArcScene which are all based on the AO components library.Therefore,strong GIS application system can be created with AO components library. 2 The GIS development based on AO components. Three different development patterns can be used with AO components library.It is essential to understand the hierachical strctrue and relationships of ArcObjects components as well as the object model of AO components. 2.1 The development patterns The three developent patterns are as follows: (1)VBA By using the customed method embeded in the desktop software ArcMap,we can apply the ArcObjects library components to ultilize the application function and its extension.It is easy and convinence to customize the VBA method,but it can fail to run and suffer a problem of mobility when operated without desktop software. (2)Developing the EXE application program In VB,VC++,.Net developing evironment,we can provide visual control component such as MapControl,TOCControl to implement the EXE application program with ArcObjects library components.This approach can build user-defined application environment.The application program would not rely on the ArcGIS desktop software and can run independently with great flexibility but can be difficult to develop. (3)Creating User-Customized components User-Customized components can be made through ICOMMAND,ITOOL interface in ArcObjects.These components can be intergrated into the ArcGIS environment,and applied in the first two developing methods.As to VBA macro language for ArcMap customization,this method has the advantage of code capsulation.Users at terminal can not see the original codes but this developing pattern needs high level of programming skills. 2.2 The hierachy relationship structure of AO components. The ArbObjects provides more than 1100 independent COM components,the hierachy relationship structure is showed in Figure.1. Figure. 1 The hierachy relationship structrue of AO components. In the hierachy structrue,Application is at the top of the structrue.Application objects can visit Display,Document and Extension Objects.The Display Objects exhibit the data such as function of the map symbols,graphic edition,coordination transforation and screen control.Document denotes the entire map files including one or more Map Objects where every Map Object can contain serveral Layer Objects.FeatureLayer is the most common Layer working for displaying the data layer.Extension Objects offer the add-in functions for ArcGIS application program.Mastering the AO components’ hierachy relationship structrue can help developing the application with approprieate interface,attributes and method. 2.3 Object Model of AO components AO components are consisted of three different types of class:Abstract Class,CoClass and Class.The relationship for each Class is showed in Figure3. Figure.2 The Object Model of AO components Components objects can be created directly.For instance,in VB,Dim pPonint As New Point can create a Point Object.Class Object can not be created directly but it can be used as a attribute of other specific class.It also can be applied through other class,such as FeatureLayer with a instance of pFeatureLayer can call the FeatureLayer’s attributes to implement the FeatureClass.The following program can do the same task: Dim pFeaClass as IFeatureClass Set pFeaClass = pFeatureLayer.FeatureClass Abstract Class provides a template for the subclass which ultilize all or parts of the functions of the Abstract Class through the inheritance.Geometry Class is a Abstract Class in the AO and Polyline can be created as a child class of Geometry.In Polyline objects ,we can implement the interface defined in the Geomery Class.Thus we can visit the Geometry defined interface through Polyline Objects. 2.4 AO component function ArcObjects components library provides 11 control conponents which include 2 chief exclusive conponent function:MapControl and PageLayoutControl.These component functions build up the georgraphic view windows.MapControl component provides a view window similar to the Layout View in the ArcMap in order to edit the Map display,graphic element,spatial and attributes data query,map data analysis and map element labeling etc.PageLayoutControl component function mainly focus on display plane edition such as display data operating and map decorations.In ArcMap,most function can be implemented through these two component functions. 2.5 Developing environment configuration of AO ArcGIS adopts an open developing environment that supports four mainstream IDEs:COM(VB,VC++,Delphi,MainWin),.NET(VB.NET and C#),Java and C++.The GIS application system development need to choose proper developing environment for specific situation.Here we take the VB environment as an example to demonstrate how to deploy the developing environment configuration for ArcObject components. Visual Basic from Microsoft Crop is the very primitive visual developing tools.In the VB IDE,we first need to import the ESRI Object Library by [References] program.Then open the Components dialog box and select the Control options we need ,for example ESRI Object Library,ESRI TOCControl,ESRI ToolbarControl so forth.These control componnets can be “drag and use” as common ones. 3. GIS application based on AO component library In the following passage,we proposed a environmental georgraphic information system to introduce the developing process of construct application software based on AO components library.The process will show the correct method to implement the AO library and creat the user-defined components. 3.1 Implementation of basic functions The basic function of the GIS system is map displaying.We can add the MapControl components in the ArcObject library into the interface window to implement the map displaying.MapControl components supports mxd,shp,lyr and other types of map file.It can also display the data from GeoDataBase as a map format. Another key function of the GIS system is the Spatial Information Maintenance.We can implement this function as following steps: (1)Adding the new Layer. Firstly,we defined a IfeatrueLayer interface variable named pFeatLayer and instantiate it.Next,use MapControl component interface to call the AddLayer attributes to create the new layer.The following code can be a referece: //Initialize pFeaLayer variable Dim pFeaLayer As New FeatureLayer //Add a new layer pFeaLayer in MapControl MapControl1.ActiveView.FocusMap.AddLayer pFeaLayer (2)Add new spatial element to the layer Suppose pFeatLayer is a feature layer of Point type,clicking on MapControl position can added a Point object.The operation can be as follows: Private Sub mapControl1_OnMouseDown(ByVal_ Button As Long, ByVal Shift As Long, ByVal X As _ Long, ByVal Y As Long, ByVal mapX As Double, _ ByVal mapY As Double) …… //Open the Edition zone Dim pFeature As IFeature Dim pPoint As New Point //Get the dot object when clicking Set pPoint = mapControl1.ActiveView.Screen_ Display.DisplayTransformation.ToMapPoint(X,Y) //Instantiate a pFeature object Set pFeature = pFeatLayer.FeatureClass. _ CreateFeature //Assgin a new value to the new created pFeature object attributes Set pFeature.Shape = pPoint …… //Close the Edition zone End Sub 3.2 Extent the AO component function The GIS platform can provide limited component functions.The ArcObjects component library can not satisfy the users’ need by only supporting the standard symbol components.In this paper,we discuss how to extent the AO components function with user-defined ones. User can original adopt AO objects to build up interfaces like ITool and ICommand as well as Command Component like Button or Tool.These defined components can be added to the application program to enhance the AO components library.The Figure 4 shows the Command Components Relationship. Figure3. The Command Components Relationship The ICommand , ITool , IToolControl , ICommandSubType and ImultiItem interfaces are most useful in creating user-defined command.User can ultilize the Button,Tool ,ToolControl and MultiItem four commands. In the environment GIS system,we defined the ActiveX control-Map Measure Tool to measure the perimeter and area of any polygon. In order to create this measuring control,we firstly need to build up a new ActiveX Dll project.In the Project we have a new measure class module(measure.cls) and window frmMeasure.frm.As the measure tool will be ultilized as a Tool Control,we need to build a ICommand and ITool interfaces in this class module.ICommand interface defines the action and attribute of this measuring tool such as the name ,type,icon,creating event,clicking event and status.ITool interfaces are defined as mouse moving ,clicking ,right clicking and keyboard commands.In the window of frmMeasure.frm,a text control named TxtResult is included for output the measuring result. Compile the measure class into DLL and register it in the project system,we can then add the class into the toolbox as a control components and use it into applications. The measure.cls class module is the core part of this project.Parts of the codes can be as follows: Private Sub ICommand_OnClick() FloatWindow frmMeasure, True frmMeasure.Show End Sub Draw the Polygon through OnMouseDown function,the code can be: Private Sub ITool_OnMouseDown(ByVal Button As_ Long, ByVal Shift As Long, ByVal x As Long, _ByVal y As Long) // Get the dot object when clicking Set pPnt = g_pActiveview.ScreenDisplay._ DisplayTransformation.ToMapPoint(x, y) Set g_pPoint = pPnt If m_pNewPolyFeedback Is Nothing Then //Instantiate InewPolygonFeedback interface variable //m_pNewPolyFeedback Set m_pNewPolyFeedback = New_ NewPolygonFeedBack // m_pScrD is a IscreenDisplay interface variable Set m_pNewPolyFeedback.Display = m_pScrD //Set pPnt as a m_pNewPolyFeedback startpoint m_pNewPolyFeedback.Start pPnt Else //Add element pPnt to m_pNewPolyFeedback object m_pNewPolyFeedback.AddPoint pPnt End If End Sub The function os OnMouseMove can track the mouse by NewPolygonFeedback objects.Its code are as follows: Private Sub ITool_OnMouseMove(ByVal Button As_ Long, ByVal Shift As Long, ByVal x As Long,_ ByVal y As Long) Dim pPnt As IPoint Set pPnt = m_pScrD.DisplayTransformation._ ToMapPoint(x, y) If Not m_pNewPolyFeedback Is Nothing Then m_pNewPolyFeedback.MoveTo pPnt End If End Sub The OnDblClick function can output the map result when double clicking.The code can be as follows: Private Sub ITool_OnDblClick() Set pPolygon = m_pNewPolyFeedback.Stop Set pArea = pPolygon frmMeasure.TxtResult.Text = "Area：" & Abs(_pArea.Area) & Chr(10) & "Perimeter：" &～ pPolygon.Length Set m_pNewPolyFeedback = Nothing End Sub The measuring tool can be applied into any AO components software and avoid the code repetition,which enhances the program developing efficiency. 4 Conclusion The COM-based GIS platform promotes the GIS software development.As the GIS application software requirements continue to increase,the developing efficiency can be a serious issue.The COM-based technology creates the GIS software with a method similar to building up the toy bricks for the user need.This method generate a much easier and more conviencet developing process.The user-defined components extent the functions of original ArcObjects components.By boding these two technologies together,problems in the system can be solved in a better way. 5 References  ESRI.Getting started with ArcGIS. Redlands, CA:ESRI Inc, 2004.  ESRI.Exploring ArcObjects. Environmental Systems Research Institute, Inc.2001.  ESRI.ArcGIS developer help[R] ．Environment Systems Research Institute, Inc.  USA:ESRI. ArcObjects developer help for Visual Basic, 2002.  Wang Q.Environmental geographical information system [M] .Beijing:Science Press, 2004.  Li Bin.A component perspective on geographic information services [J].Cartography and Geographic Information Science ,2001 , 27 (1) : 75～86.