[Post] the AO beginner's secret is absolutely good !! (Simplified Version)

Source: Internet
Author: User
Tags imap map class polyline

What we need to do most of the time now is to use the AO components provided by ESRI for Modular Assembly tasks. AO has provided many basic underlying functions, and your task is to assemble these underlying functions into a more powerful COM object according to application requirements. We now know that AO is built based on Microsoft's COM technology, so it is very open and scalable. The openness here refers to the selection of development environments with a variety of development tools supporting COM standards, such as VBA, VB, VC ++, and DEPHI, scalability refers to the functionality not provided by AO components. to define a new data format, you can use COM technology to write your own COM components, extends and supplements the AO component library.


As for why AO is based on the COM technology, I personally think that the current and future GIS development will be more and more closely integrated with mainstream IT technologies. After all, any software product will eventually be used, therefore, in addition to providing professional GIS functions, it is extremely important for ease of use and scalability, while the COM technology provides a solution.

How to Develop AO software? For senior AO programmers, I think there must be four major technical barriers:

1. Object-oriented technical ideas;

2. COM technology;

3. Organization and relationship of each component object of AO;

4. Support for various COM development tools and their environments (such as VB, VC, and DEPHI)

What actually belongs to ESRI is nothing more than this AO component library. For those who first entered the AO development field, I personally think (there are other tasks that can be put aside for the moment on COM, but it is still no problem to finish a lot of tasks as you look at them) you can start with the application of ArcGIS Desktop and have an understanding of AO layers and related concepts (such as Map, Layer, View, Label, and supported data formats)


Arcobjects Developer Kit

Help --- contains development Help files: AODev. chm, ArcObjects. chm, etc.

Kits --- the source code of additional developer materials such as projection engine header files, category ID files, and ESRI sample commands (in the latest version 8.2, this code location has changed)

Object Model Diagrams --- including all Object Model Diagrams in PDF Format

Samples --- contains the source code of all sample project files

Utilities --- tools including ESRI object browsers

1.5 AO development resources

1. ArcObjects Developer Help ----- This is the preferred resource for AO development. I personally think it can be comparable to Microsoft's MSDN to a certain extent. Both basic COM and AO object hierarchies of AO are described. In addition, a large number of development examples are provided.

2. ArcObjects Online ----- provides the latest AO Component Library documentation. One of the technical forums on AO is believed to have many unexpected gains;

3. indexing ArcObjects ----- A Very Good AO technical document, which is well organized for AO development and has a large number of examples that can be copied and used at any time;

4. building a Geodatabase-applications are all centered on data. This book is mainly used to design and create geodatabases. However, it understands and master the layers and methods of Geodatabase, it is a good supplement to AO development.

5. Microsoft MSDN-even if your AO development tool is not from Microsoft, it is recommended to install a complete set of MSDN. To learn more and use COM for design and development, MSDN is a treasure.

At the beginning of COM, I think many developers of AO will have different feelings about it. COM is Microsoft's Component Object Model abbreviation. It not only defines the standard for interaction between Component programs, it also provides the environment required for component program running (COM itself needs to implement an API called COM library), which provides components such as the customer's query, and a series of services such as component registration/anti-registration. Generally, the COM library is implemented by the operating system, so we don't have to worry about the details of its implementation, as we often see ActiveX, DirectX, OLEDB is based on the COM technology), mainly used on Microsoft Windows operating system platform. COM is usually published in the format of win32 dynamic link library (DLL) or executable file (EXE.



COM goals and features

The reusability of tokens built on the binary code level (through inclusion and aggregation );

The producer language is unrelated, as long as it can generate a COM compliant standard;

Worker Process transparency for client programs using COM objects;

Objects are one of the basic elements of COM. Unlike objects in C ++, they are encapsulated in a true sense) in addition, the reusability of COM objects is manifested in the inclusion and aggregation of COM objects. One object can fully use all the functions of another object, the reusability of C ++ objects is manifested in the inheritance of c ++ classes. (The difference between COM and C ++ is emphasized !! I ignored this stuff for one year)



An interface is an interface of a component object. It contains the data structure of a group of functions. Through this data structure, the customer code can call the functions of the component object, component Objects are accessed through interfaces. The interface design must meet the following requirements:

1. It must be inherited directly or indirectly from the IUNKNOWN interface (this interface is missing in AO );

2. The interface must have a unique identifier. The interface is immutable. Once an IID is assigned and published, no factors in the interface definition can be changed.

Developing with COM means using interfaces, which can also be called interface-based design models. All communication between objects is performed through their interfaces. The COM interface is abstract, meaning that the related interfaces are not implemented, and the Code related to the interfaces comes from a class implementation. How to implement an interface is different for different objects. Therefore, an object only inherits the type of the interface, rather than its implementation. This is called type inheritance. Functions are abstracted and implemented using classes. In COM, classes and interfaces are generally treated as "what to do" and "how to do". Interfaces define what an object can do and Classes define how to do it. (This section is the essence of understanding COM)

The COM class provides Code related to one or more interfaces, so functional entities are encapsulated in the class. Several Classes can have the same interface, but their implementations may be very different. By implementing these interfaces, COM implements object-oriented polymorphism. COM does not support multiple inheritance concepts. However, this is not a drawback because a class can implement multiple interfaces.


The Interface of the COM object can be a dual Interface. The dual Interface is different from the general Interface (Custom Interface) because the dual Interface is inherited from the basic Interface Idispatch of Automation, common interfaces are inherited directly from the Iunknown interface. The default interface model is dual interface model and dual interface model.


COM call can be unidirectional (that is, the client program creates a component object, and then the client program calls the functions provided by the object and releases the object as appropriate), which is usually called an inbound interface.


If a COM Object supports one or more interfaces that actively communicate with the customer program, this interface is called an outbound interface because these interfaces are not implemented by the object but implemented by the customer program.


A Type Library is used as the binary version of an Interface Definition Language (IDL) file. It is a collection of COM objects and interfaces, and compiled into a binary file, such as OLB, DLL, or OCX. To support a component set that does not depend on the development language tool, all related data about the ArcObjects library is packaged into esricore. the olb Type Library includes a binary description of all coclasses, interfaces, methods, and server types.


Microsoft provides multiple COM interfaces for the Type Library. The two interfaces are ITypeInfo and ItypeLib. Using standard COM interfaces, different development tools and compilers can obtain coclasses and interface-related information supported by a specific library.


In chapter 2, we talked about many COM concepts, such as classes, objects, interfaces, methods, etc, so how does an actual AO development reflect these COM concepts? Since AO is based on COM. In this section, I will use the VB code to describe how to use the AO Object and introduce how to read the OMD (Object Model digoal.

3.1 Use of AO objects

Let's start this journey directly with AO-related code, if you think so. :)

Dim pMap as IMap

Set pMap = New Map

PMap. name = "Map name:-Tour"

.........................

.........................

Pmap. ClearLayers

Pmap. Clear // ERROR

How to run this code is the content of the next chapter. First, let's take a look at why the code is written like this. There are many mysteries in it.

Dim pMap as Imap

We know that access to objects in COM is implemented through interfaces. Therefore, you cannot directly call properties or execute methods using their names, just like many visual controls. This statement defines an interface variable, fortunately, VB has demonstrated all this ). This interface variable does not work, because the interface is defined on the object, so the next step should be to generate an object, and the object comes from it --- class.

So we have the code Set pMap = New Map.

In this sentence, the Map object is not simply an instance, and the pMap interface variable in the above sentence is used as the default Interface of the object. OK. Now we can use this interface to modify the map name, or call the ClearLayer method to delete all layers in the map. Let's take a look at the execution of the last sentence-errors may occur. The reason is very simple. Methods or attributes in different interfaces can only be accessed through their interfaces, the Clear method belongs to IactiveView, another interface of the Map class. You can use the Query Interface to 'failed' to IactiveView. The Code is as follows:

Dim mView as IactiveView

Set mview = pmap

Mview. clear


There are three classes in OMD: abstract class, CoClass, and general Class ). The main purpose of an abstract class is to define a public interface for its subclass. An abstract class will delay some or all of its implementations to the subclass. Therefore, an abstract class cannot be instantiated. A component class object can be directly created. Although common class objects cannot be directly created, they can be created as an attribute of other classes or instantiated from other classes.

Dataset or Geometry classes in AO are examples of abstract classes. A Geometry type object cannot be created, but a Polyline can be created. This Polyline Object actually implements the interface defined in Geometry on the basis of the class, so the interface defined in the base class object can be accessed from the coclass

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.