ArcObjects - PowerPoint PPT Presentation

1 / 35
About This Presentation
Title:

ArcObjects

Description:

Wow that's pretty obvious. What did they do before? Answer: Functional programming ... Microsoft lackey who wrote the Wikipedia article on Component Object Model ... – PowerPoint PPT presentation

Number of Views:109
Avg rating:3.0/5.0
Slides: 36
Provided by: ITCLabsand2
Category:
Tags: arcobjects | wiki | wow

less

Transcript and Presenter's Notes

Title: ArcObjects


1
ArcObjects
  • Sara Alspaugh
  • EVSC 468
  • 27 March 2007

2
  • What? Why? How?
  • Where? When? What? Why? What?

3
What
  • ArcObjects is the development platform for the
    ArcGIS family of applications such as ArcMap,
    ArcCatalog, and ArcScene. The ArcObjects software
    components expose the full range of functionality
    available in ArcInfo and ArcView to software
    developers.
  • ArcObjects is a framework that lets you create
    domain-specific components from other components.
    The ArcObjects components collaborate to serve
    every data management and map presentation
    function common to most GIS applications.
    ArcObjects provides an infrastructure for
    application customization that lets you
    concentrate on serving the specific needs of your
    clients.
  • ESRIs ArcObjects Online help system
  • Built using Microsofts Component Object Model
    (COM) technology.

4
What?
5
Hmmlets start with just Objects
  • Look at it like this
  • What do we use computers to do?
  • Store data
  • Perform functions
  • So they came up with this new way to think
    about and design software
  • Objects!
  • Encapsulate data and functions
  • Just like objects in the real worldcan be any
    sort of object
  • For instance, imagine a list. No,a List.
  • Its an object
  • We want to use it to store various pieces of
    information, likethe length of the list (a
    number), the items in the list (other objects
    maybe?)
  • Also we want it to perform certain functionslike
    clear() itself, insert(anItem), and tell us its
    length().

6
You may be thinking
  • Wow thats pretty obvious.
  • What did they do before?
  • Answer
  • Functional programming
  • Instead of objects containing data and
    procedures, just have procedures, that take as
    input other procedures and output other
    procedures and have rules for evaluating those
    procedures and blah blah blah blah
  • Like algebra. Kind of.
  • Much harder (!) to write programs this way.

Yucky!
7
Anywayan Example Object
  • Say we need some way to write a program that
    keeps the time
  • We can make a Clock object!
  • How create a type of that object that generally
    specifies how all clocks are to work, then create
    an instancean actual individual objectof that
    type

Class (or Interfce) Clock Data Integer
hours Integer minutes Integer
seconds String meridiem Functions makeClock(
) makeCopy(aClock) getTime() resetTime(newHo
ur, new Minute, new Second)
8
So back to ArcObjects
9
What about the rest of the definition?
  • Component Object Model (COM) a platform for the
    realization of Object-Oriented Development and
    Deployment
  • Microsoft lackey who wrote the Wikipedia article
    on Component Object Model
  • A protocol or standard
  • More than a technology
  • A methodology
  • A client-server architecture

10
(cont.)
  • A way to produce reliable, reusable,
    language-independent codeat the binary level
  • Essentially, the server is this binary file that
    contains this code needed to create classes of
    objects and run their methods or procedures
  • The objects are the building blocks of any
    software system, and the COM specifies the model
    and requirements for creating them that allows
    them to do what they do

11
How?
  • RPC remote procedure call technology
  • IDL interface description language
  • GUID globally unique identifier
  • Type Library
  • ClassFactories

12
Remote Procedure Call technology
  • Allows a computer program to cause a procedure to
    execute in another address space
  • A.k.a. in another computer
  • A.k.a. the program makes something happen on
    another computer
  • In other words, it is the paradigm for
    implementing this client-server architecture we
    talked about
  • A remote procedure call starts by the client
    (you, or the developeractually your computer)
    sending a request message to a known server
    (ArcObjects!) in order to execute some procedure
    you want to execute using parameters you supply.
    The server then gives a response to the client
    and the client continues along with what it was
    doing.

13
Hey! I want to do this one thing. Here, use
these parameters or whatever.
parameters
Ok...go ahead. Heres how to do it, I guess.
There, its done.
14
Interface Description Language
  • The client and server may not be speaking the
    same language. They may not even be operating on
    the same system. How do they get around that?
  • A computer language to describe software
    components interface (the specification thing
    that says what they are supposed to look like and
    do) in a language-neutral way
  • Thereby enabling communication between software
    components that are written in different
    languages!
  • Interface Description Language files are used to
    generate the code to interface between the client
    and the server.

15
Hei! Ik wil dit een ding doen. Gebruik hier deze
parameters of wat dan ook.
parameters
Ok ... ??????????????,???????,????
The language-neutral IDL file
16
Ok
  • COM provides an IDL file
  • This allows developers to define their objects in
    a language-independent manner
  • P.S
  • COM is a run-time framework
  • What does that mean?
  • Means the types of objects must be identifiable
    at run-time
  • Oh ok.

17
GUID
  • How can we ever possibly identify ever single
    different type of object there is?
  • Globally Unique IDever object has one.
  • Amounts to a 128-bit number guaranteed to be
    unique in the world.
  • An example number
  • E6BDAA76-4D35-11D0-98BE-00805F7CED21
  • 1110 0110 1011 1101 1010 1010 0111 0110 0100 1101
    0011 0101 0001 0001 1101 0000 1001 1000 1011 1110
    0000 0000 1000 0000 0101 1111 0111 1100 1110 1101
    0010 0001
  • Interesting fact It is possible to generate 10
    million GUIDs per second until the year 5770 A.D.
    and each one would be unique.

18
One other thing
  • COM provides a Type Library
  • Compiled from the IDL definition provided by the
    developer
  • Once this library is compiled the language
    compiler must read and appropriately interpret it
    to produce the code necessary for the developer
    to produce the binary code which can be deemed by
    COM part of the COM interface

19
How do we start making (COM)/(Arc) objects?
  • Need two things
  • GUID
  • ClassFactory
  • This is itself a COM object that is contained
    within the servers executable code that creates
    other objects given their unique ID
  • Each object type has its own ClassFactory
  • Waitif you need a ClassFactory to produce an
    object but a ClassFactory is itself an object?
  • DLLdynamic link libraries
  • EXEexecutables
  • Basically there are two different ways to expose
    class factories but we wont get into that

20
(No Transcript)
21
My Graphical Overview
Framework
CoRegisterClassObject()
Components
DllGetClassObject()
SimpleDisplay
SimpleMarkerSymbol
GUID
ClassFactory
Tool
IndexGrid
GUID
GUID
GUID
PolygonElement
GUID
SimpleRenderer
Type Library
My Application
GUID
GUID
Client
Server
22
Common Approaches
  • Customize ArcGIS Desktop applications through
    Visual Basic for Applications (VBA) which is
    embedded in ArcMap and ArcCatalog
  • Building targeted applications that bypass the
    application framework of ArcMap and ArcCatalog

23
Some of the many topics I didnt cover involving
some of what you might need to know to start
developing using Visual Basic (first approach)
  • User-interface standardsVariable
    declarationSuggested naming standardsParentheses
    Order of conditional determinationIndentationDe
    fault propertiesIntermodule referencingMultiple
    property operationsArraysBitwise operatorsType
    suffixesAmbiguous type matchingSimple image
    displayError handlingEvent functions
  • While Wend constructsThe Visual Basic Virtual
    MachineInteracting with the IUnknown
    InterfaceAccessing ArcObjectsWorking With
    HRESULTsWorking with propertiesWorking with
    methodsWorking with eventsPointers to valid
    objects as parametersPassing data between
    modulesUsing the TypeOf keywordUsing the Is
    operatorIterating through a collection

24
Some of the many topics I didnt cover involving
some of what you might need to do it the second
way
  • CODING STANDARDSGENERAL CODING TIPS AND
    RESOURCES   Class diagrams   Object
    browsers   Component help   Code
    wizards   Indexing of collections   Accessing
    collection elements   Enumerator use   Error
    handling   Notification interfaces   Client
    side storage   Property By Value and By
    Reference   Initializing Outbound Interfaces
  • DATABASE CONSIDERATIONS   Edit sessions   Edit
    operations   Recycling and nonrecycling
    cursors   Fetching properties using query
    filters   Marking changed objects   Update and
    insert cursors   Shape and ShapeCopy geometry
    propertyUSING A TYPE LIBRARYCOM DATA
    TYPESUSING COMPONENT CATEGORIESWHICH
    DEVELOPMENT ENVIRONMENT

25
Programming in VB.NET--a simple walkthrough
  • Create a new class library
  • Reference the ESRI object libraries
  • Create a zoom-in command
  • Add Imports statements
  • Implement the ICommand interface
  • Adding code to the members of ICommand
  • Returning the ICommandBitmap property
  • Expose the ZoomIn class to COM
  • Adding COM category registration functions
  • Compiling the project
  • Use the command in ArcMap
  • Stepping through the command with the debugger

26
  • Public Class ZoomIn
  •     Implements ICommand
  •    
  •     Private m_app As IApplication
  •     Private m_enabled As Boolean
  •     Private m_bitmap As System.Drawing.Bitmap
  •     Private m_hBitmap As IntPtr    
  •     Region "COM GUIDs"    ...
  • Public Sub OnCreate(ByVal hook As Object)
    Implements ICommand.OnCreate
  •      If Not (hook Is Nothing) Then
  •         If TypeOf (hook) Is IMxApplication Then
  •            m_app CType(hook, IApplication)
  •            m_enabled True
  •         End If
  •      End If
  •    End Sub
  •  

27
  • Public Sub OnClick() Implements ICommand.OnClick
  •      Dim mxDoc As IMxDocument
    CType(m_app.Document, IMxDocument)
  •      Dim activeView As IActiveView
    mxDoc.ActiveView
  •  
  •      Dim currExtent As IEnvelope
    activeView.Extent
  •      currExtent.Expand(0.5D, 0.5D, True)
  •      activeView.Extent currExtent
  •      activeView.Refresh()
  •    End Sub
  • Public ReadOnly Property Caption() As String
    Implements ICommand.Caption
  •      Get
  •         Return "Zoom In x 0.5 VB.NET"
  •      End Get
  •    End Property
  •  
  •    Public ReadOnly Property Category() As String
    Implements ICommand.Category
  •      Get
  •         Return "Developer Samples"
  •      End Get

28
  • Public ReadOnly Property Enabled() As Boolean
    Implements ICommand.Enabled
  •      Get
  •         Return m_enabled
  •      End Get
  •    End Property
  •  
  •    Public ReadOnly Property HelpContextID() As
    Integer Implements ICommand.HelpContextID
  •      Get
  •         Return 0
  •      End Get
  •    End Property
  •  
  •    Public ReadOnly Property HelpFile() As String
    Implements ICommand.HelpFile
  •      Get
  •        
  •      End Get
  •    End Property
  •  
  •    Public ReadOnly Property Message() As String
    Implements ICommand.Message

29
Programming in C--a simple walkthrough
  • Create a new class library
  • Reference the ESRI object libraries
  • Create a zoom-in command
  • Add a using directive
  • Adding code to the members of ICommand
  • Returning the ICommandBitmap property
  • Expose the ZoomIn class to COM
  • Adding COM category registration functions
  • Compiling the project
  • Use the command in ArcMap
  • Stepping through the command with the debugger

30
  • public class ZoomIn ICommand   private
    IApplication m_app private bool m_enabled
    private System.Drawing.Bitmap m_bitmap private
    IntPtr m_hBitmap
  •    public void OnCreate(object hook)
  •   
  •      if (hook ! null)
  •     
  •         if (hook is IMxApplication)
  •        
  •            m_app (IApplication) hook
  •            m_enabled true
  •        
  •     
  •   

31
  • public void OnClick()
  •   
  •      IMxDocument mxDoc (IMxDocument)
    m_app.Document
  •      IActiveView activeView mxDoc.ActiveView
  •     
  •      IEnvelope currExtent (IEnvelope)
    activeView.Extent
  •      currExtent.Expand(0.5D, 0.5D, true)
  •      activeView.Extent currExtent
  •      activeView.Refresh()  
  •   
  • public string Caption
  •    get
  •   
  •        return "Zoom In x 0.5 C"
  •    
  • public string Category

32
  • public bool Checked
  •   
  •      get
  •     
  •         return false
  •     
  •   
  •    public bool Enabled
  •   
  •      get
  •     
  •         return m_enabled
  •     
  •   
  •    public string Message
  •   
  •      get
  •     
  •         return "Zooms the display to half the
    current extent."

33
(No Transcript)
34
Review!
  • What is/are ArcObjects?
  • A framework
  • A collection of component objects
  • Fairly useful depending on who you are
  • All of the above
  • What does COM stand for?
  • Corruption of Microsoft
  • Communicatiemiddel Oot Maandag
  • Component Object Model
  • Computer Operating Machinery

35
References
  • http//edndoc.esri.com/arcobjects/8.3/
  • http//en.wikipedia.org/wiki/Component_Object_Mode
    l
  • http//en.wikipedia.org/wiki/Remote_procedure_call
  • http//www.songwriting-software.com/images/iMac20
    computer.jpg
  • http//i.cnn.net/cnn/2003/TECH/05/26/your.tech.del
    l/story.dellcomputer.jpg
Write a Comment
User Comments (0)
About PowerShow.com