Getting to Know Arcobjects
Total Page:16
File Type:pdf, Size:1020Kb
Getting to Know ArcObjects Rob Burke ESRI-Redlands Educational Services Developer Summit 2007 1 • Started as an intern 1990 Tenth User Conference, PS • Teach ESRI classes – Desktop, Geodatabase, ArcObjects, raster, Server • Write training materials • Write books • Review books Developer Summit 2007 2 Surveys • Please fill out a survey Developer Summit 2007 3 Intended audience • Anyone wanting to learn about ArcObjects • ArcObjects basics • For programmers and nonnon--programmersprogrammers • Maybe you know – Some ArcGIS – Some programming • Not language specific Developer Summit 2007 4 Lecture Path Interfaces Diagrams What are & COM Implement ArcObjects Under ESRI The ItInter faces Hood Extend the Applications CASE Tech tools Talk Area Wrap-up Engine Extend the Questions Server Geodatabase Developer Summit 2007 5 Parts store for GIS • Building blocks for ArcGIS software products and yours • The most basic GIS parts are programmable objects Map PitPoint Layer Polygon Developer Summit 2007 6 Parts store for GIS • ArcMap and ArcCatalog are built with ArcObjects • Their most basic parts are programmable GIS objects • UdUsers and programmers interact w ihhbjith the same objects • Everyone uses the same parts, ESRI developers and you Map Point Layer Polygon Developer Summit 2007 7 Pieces to create GIS applications or embed • Technically they are called classes (or components) – Over 3,400 ArcObjects classes – Over 21, 000 properties and methods – Grouped into over 70 logical libraries – (not including ArcGIS Server) • Each class corresponds to a basic GIS part Map Point Table Layer Line Row Polygon Field Developer Summit 2007 8 Map class vs map object • There is only one Map class • You make many map objects: World and US • A class is code behind an object’s properties and methods • Objects live in memory and take on your settings Map Developer Summit 2007 9 How do you get ArcObjects • ArcObjects is not a product, by itself • You can’t buy just ArcObjects – You buy an ArcGIS Desktop product – You buy ArcGIS Engine – You buy ArcGIS Server • ArcObjectsArcObjects--relatedrelated files are installed when you install one of the three products Developer Summit 2007 10 Use COM compatible languages • VBA is built into the ArcGIS desktop applications – Visual Basic for Applications – VBA code is stored in map document files (mxd files) • Buy a language and IDE (Development environment) – Visual Basic or C# (Visual Studio 2005) – C++ – Java • UfUse a free open source language an dIDEd IDE – Python – My trail: BASIC, Fortran, SML, AML, Avenue, VB, VBA, Python, C# Developer Summit 2007 11 Compare to Microsoft Access data objects • Access built from a about a hundred objects – Called DAO or data access objects • Users and ppgrogrammers use same obj ects • Applications can mix and match from different libraries Database RecordSet Field Developer Summit 2007 12 Class libraries • COM classes can be mixed and matched • Make your own library of COM classes • Language independent ArcObjects WdWord MyClasses My Application Developer Summit 2007 13 Shapefile to word doc Word Doc Feature Class Developer Summit 2007 14 ArcObjects are building blocks: Desktop • ArcGIS Desktop applications are created with ArcObjects • ArcMap, ArcCatalog, ArcScene, ArcGlobe… Developer Summit 2007 15 ArcObjects are building blocks: Engine • ArcGIS Engine applications are created with ArcObjects • You create stand alone GIS applications • UAObjiUse ArcObjects in nonnon--GIS--centrcentriliiic applications Developer Summit 2007 16 ArcObjects are building blocks: Server • ArcGIS Server Web mapping applications are created with ArcObjects and special Web ADF GIS objects • Author,,p publish, or consume – GIS data, functionality, and geoprocessing – Query, edit, address match, make custom, and more Developer Summit 2007 17 ArcGIS: a complete GIS Applications ArcGIS ArcGIS ArcGIS Web ArcGIS Desktop Engine Explorer Mapping Mobile Application Desktop Engine Developer Kit Developer Kit APIAPI SDK .NET COM .NET COM .NET .NET Java .NET C++ Java ArcObjects ArcGIS Server ArcGIS Online Server Developer Kit Services .NET COM ArcWeb Services Java API ArcSDE REST J2ME JavaScript technology OpenLS SOAP Desktop Ar Data Personal c for MS File SDE (Geodatabase) File Personal Workgroup Enterprise Access Developer Summit 2007 18 Lecture Path Interfaces Diagrams What are & COM Implement ArcObjects Under ESRI The ItInter faces Hood Extend the Applications CASE Tech tools Talk Area Wrap-up Engine Extend the Questions Server Geodatabase Developer Summit 2007 19 Object Model Diagrams • RdRoad maps tthAObjtto the ArcObjects cl asses • Help you write code • BdUMLBased on UML – UifidMdliUnified Modeling L anguage – Symbols show relationships, connections, properties, and methods • > 70 libraries • > 110 posters Developer Summit 2007 20 Where do you get the diagrams? • Install the ArcObjects developer kit – C:C:\\ProgramProgram Files\Files\ArcGISArcGIS\\DeveloperKitDeveloperKit\\DiagramsDiagrams\\*PDF*PDF • Help – Per library • Online – EDN We b s ite – Per library Developer Summit 2007 21 The twelve UML Symbols • Relationships * • Classes • Properties and methods Developer Summit 2007 22 UML symbols • Association Chicken Nest Developer Summit 2007 23 UML symbols • Multiplicity * • Association Farm Chicken * Nest Developer Summit 2007 24 UML symbols • Multiplicity * • Association Farm Chicken * Nest 2 Wings Developer Summit 2007 25 UML symbols • Creates a • Multiplicity * • Association Farm Egg Chicken * Nest 2 Wings Developer Summit 2007 26 UML symbols • Is composed of • Creates a • Multiplicity * • Association Farm Egg Chicken * Nest 2 Wings Developer Summit 2007 27 UML symbols • Is a type of • Is composed of • Creates a • Multiplicity * • Association Bird Farm Egg Chicken * Nest 2 Wings Developer Summit 2007 28 UML class symbols: Abstract class • 2D and not shaded • Objects can not be created from it Bird Abstract Developer Summit 2007 29 UML class symbols: Abstract class • 2D and not shaded • Objects can not be created from it • Holds properties and methods that subclasses inherit Bird Abstract Chicken Developer Summit 2007 30 UML class symbols: CoClass • 3D and shaded • You create objects out of them – DlDeclare a var ibliable – Instantiate an object using the New keyword Bird Farm Abstract CoClass Chicken * Nest CoClass CClCoClass Developer Summit 2007 31 UML class symbols: Class • Other classes create or return these objects • You write code with another object to create or get – You can ’t create an egg without a chicken – You can’t get a wing without an chicken Bird Abstract Farm CoClass Egg Chicken * Nest CoClass CClCoClass 2 Wings Developer Summit 2007 32 UML property symbols • RdRead an d wr ite propert y – These are attributes stored about the object – You can either get or set these properties Chicken Age Color Name Developer Summit 2007 33 UML property symbols • RdRead on ly proper ty – Left half barbell symbol – You can get this property ’s value – But you can’t change it Chicken Age Color Name Wing(side) Developer Summit 2007 34 UML property symbols • WitWrite onl y propert y – Right half barbell symbol – Usually an edit property or like a password – You can change the value, but you can’t get it Chicken Age Color Name Wing(side) Password Developer Summit 2007 35 Property values • EhEach proper thldty holds a val ue • The values are of a certain type: Number, string, date, Boolean, object … • The type appears to the right of the property name – Proppyerty name, a colon, and typ e – Name: String - means that the Name property holds a text string – The Wing property holds Wing objects Chicken Aggge: Integer Color: String Name: String Wing(side): Wing Password: String Developer Summit 2007 36 UML method symbol • MthdMethod – Arrow symbol – Methods are actions the object can perform – Sometimes called behaviors Chicken LayEgg Fly Developer Summit 2007 37 Methods return values • YitdtYou write code to run a meth thdod • Some methods return a value, some don’t • The value’s type appears to the right of the method – Method, colon, and type of its return value – LayyggggEgg: Egg - the LayyggEgg method returns an egg obj ect – The Fly method returns nothing Chicken LayEgg: Egg Fly Developer Summit 2007 38 Reading diagrams • Classes are rectangles • Classes have properties and methods • Get neighboring or connected objects pLayer = pMap.Layer(0) 0 1 Map (data frame) 2 Layer Layer (index): ILayer * 3 AddLayer (ILayer) Feature Class Developer Summit 2007 39 Lecture Path Interfaces Diagrams What are & COM Implement ArcObjects Under ESRI The ItInter faces Hood Extend the Applications CASE Tech tools Talk Area Wrap-up Engine Extend the Questions Server Geodatabase Developer Summit 2007 40 ArcObjects classes are COM • COM compliant – Component object model – Industry standard for creating classes – Programming language independent – COM classes can be reused between applications • COM classes have programmer interfaces – Classes created in one language can communicate with other languages – ArcObjects classes are created in C++ – Use them in C++, VB.NET, C#.NET, VBA, Python, etc. Developer Summit 2007 41 COM classes have interfaces • Object s are rect angl es • Interfaces (lollypops) group properties and methods • GtGet ne ihbiighboring or connect tded obj bjtects pLayer = pMap.Layer(0) • Multiple interfaces Map Layer IMap Layer (index): ILayer * AddLayer (ILayer) Feature IMore Other: Something Class Developer Summit 2007 42 Understanding data types • Intrinsic data types – NbNumbers, s tidttrings,