55
EUC 2007 Technical Track EUC 2007 Technical Track Introduction to Development with ArcGIS Juan Castaneda Jonas Pålsson

Introduction to Development With ArcGIS

Embed Size (px)

Citation preview

Page 1: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Introduction to Development with ArcGIS

Juan CastanedaJonas Pålsson

Page 2: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Agenda

• ArcGIS products Overview• Development objects: ArcObjects• Development

– COM– .Net– Java

Page 3: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGISServer

ArcGIS Desktop

ArcGIS Explorer

WebMapping

Application

ArcGIS Engine

ArcGISMobile

DesktopDeveloper Kit

EngineDeveloper Kit API SDK

ArcSDEtechnology

Applications

Services

Data(Geodatabase)

ServerDeveloper Kit

.NET COM .NET COMC++ Java

.NET COM

.NET Java.NET .NETAPI

ArcObjects

JavaArcWeb Services

OpenLS

REST J2ME

SOAP

FileFile Personal Workgroup Enterprise

ArcSD

E

APIJavaScript

ArcGIS Online

Personalfor MSAccess

Desktop

ArcGIS overview

Page 4: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Licensing

• ArcGIS Desktop– ArcView, ArcEditor, ArcInfo

• ArcGIS Server– Functionality / Capacity

• Extensions– Desktop

• 3D, Geostatistics, Network, Schematics Analyst; Publisher, Data Interop., Maplex, ArcPress, etc

– Server• Network Analyst*, Data Interoperability*, Spatial Analyst**, 3D

Analyst**

* = requires Standard or Advanced editions** = requires Advanced edition

Page 5: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Editions and Levels of ArcGIS Server

LevelEdition Edition includes

• ArcSDE• Geodata services for replication

Basic features plus• Map, globe, geocoding, geoprocessing (ArcView tools)• Web ADF

Workgroup EnterpriseBasic • SQL Server

Express• 10 users

• Any supported database• Unlimited users

Standard “ “

Advanced Standard features plus• Advanced geoprocessing• Web editing• Mobile ADF (Enterprise level)

“ “

Func

tiona

lity

Func

tiona

lity

CapacityCapacity

Page 6: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

• Fundation– Building blocks for ArcGIS– Users and programmers interact with the same objects

ArcObjects

Map

Layer

Point

Polygon

Page 7: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

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 partMap Point

Line

Polygon

Table

Row

Field

Layer

Page 8: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

• There is only one Map class, like for this car blueprint• You make many map objects: Map and Sweden Counties. Using

the blueprint to create car objects• A class is code behind an object’s properties and methods • Objects live in memory and take on your settings

Map class vs map object

Map

Blueprint

Objects

Page 9: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Where are 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

• ArcObjects-related files are installed when you install one of the three products

Page 10: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcObjects help

• UML diagrams to organize ArcObjects– 3.400 ArcObjects classes in 70+ libraries– 110 posters

• Found at– Developer help– ArcObjects developer kit– Online

• EDN Web site• Per library

Page 11: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Reading diagrams

• Classes are rectangles• Classes have properties and methods• Get neighboring or connected objects

pLayer = pMap.Layer(0)

Map (data frame)Layer (index): ILayer

AddLayer (ILayer)

Layer

*FeatureClass

0

1

2

3

Page 12: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

• All products share ArcObjects• Desktop extends the core ArcObjects functionality

ArcGIS architecture

ArcGIS Desktop ArcGIS Engine ArcGIS Server

Page 13: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developing with COM

Page 14: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

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.

Page 15: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

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++

• Use a free open source language and IDE– Python

Page 16: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

*

COM classes have interfaces

• Objects are rectangles• Interfaces (lollypops) group properties and methods• Get neighboring or connected objects

pLayer = pMap.Layer(0)• Multiple interfaces

MapLayer (index): ILayer

AddLayer (ILayer)

IMap Layer

FeatureClassOther: SomethingIMore

Page 17: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Understanding data types

• Intrinsic data types– Numbers, strings, dates

• Simple objects (VB, Excel, MapObjects)– One default interface– Hidden

• ArcObjects – Multiple interfaces

Integer

_Button

IPoint

IGeometry

Button

Point

Page 18: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Intrinsic data types and simple objects

'Intrinsic dataDim x As Integer 'Declarex = 4 'SetMsgBox x * 10 'Use

Integer+ (add)- (subtract)* (multiply)/ (divide)

'Simple ObjectDim b as CommandButton 'DeclareSet b = frmClock.cmdTime 'Setb.Caption = “Time” 'Use

CommandbuttonColorEnabledFontCaptionToolTip_CommandButton

On a VBA form

Page 19: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

PointXYZ

IGeometry

IPoint

Projection

• Client code instantiates a class• Client only knows the methods exist but does not know

how they are implemented on the server

Request services

DLLOLBEXE

Third-party developer code(e.g., VBA)

Client code Server class

Client and server environment

Dim p as IPoint

Set p = New Point

p.z = 5280

DEMO

Page 20: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

What COM interfaces provide

• Programming language independence• The ability for functionality in applications to evolve over

time– Add new interfaces without affecting client code– IDog, IDog2, IDog3, IDog4, IDog5– Dim d as IDog works forever

• Interface reuse• Your classes can implement ESRI interfaces!

Page 21: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Implement ESRI interfaces

• Interface module

• Class module– Implement methods– Write your own code

• Developer module– Instantiate class– Call its methods

Client

YourServer

Interface

MsgBox “Grr, Roof!”

ESRI’s ArcObjects code

Your code

Page 22: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developing custom COM components

• Find a similar ArcGIS component• Find out what interfaces it implements

– Look in the Help

• Buttons implement ICommand

ICommandFindButton

esriControlCommands

ArcMap Find command

Page 23: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developer tools for component categories

• Component Category Manager• Oleview

DEMO

Page 24: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

API objects match your experience as a user

• Programmers start the same place users start

WorkspaceFeatureDataset

FeatureClass

FeatureClass

Page 25: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

API objects match your experience as a user

• Programmers start the same place users start • Geodatabase API uses the same (user) terms• Includes any data, not just geodatabase formats

WorkspaceFeatureDataset

FeatureClass

FeatureClass

Page 26: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Extend application & geodatabase

• ICommand, ITool, IExtensionConfig/IExtension, IContentsView, IGxView

• Class Extensions.– Custom Feature Classes– Custom Drawing– Custom property inspection– Validation– Custom Split Policies– Related object notification

• Registration of Custom class with Geodatabase (GUID)• Use CASE tools for class creation

Page 27: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Engine

Two Products• Engine Developer Kit is the toolkit for building custom GIS

and mapping applications

• Engine Runtime is deployable ArcObjects required to run custom Engine applications

Page 28: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developer Controls• MapControl• PageLayoutControl• ToolbarControl• TOCControl• ReaderControl• SceneControl• GlobeControl

Page 29: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

More than 100 tools and commands included

Tools and Commands

Page 30: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Engine Functionality

• Read all supported ESRI data formats including the geodatabase

• Map authoring (create and edit MXD)• ArcGIS level cartography• Query and analysis• Geocoding• Simple editing (shp and pGDB)

“ArcView without the applications”

Page 31: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developer Libraries ArcGIS Server 9.2

• Components– Web ADF Native .Net Assemblies– ArcObjects primary Interop Assemblies

– ArcObjects COM type libraries

– Client-side support files• JavaScript• CSS• Images• Etc.

Page 32: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developing with .Net

Page 33: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

1. Preinstallation – BEFORE installing ArcGIS

• .NET Framework 2.0 required to develop with .NET• Free download from MSDN

Page 34: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

2. ArcGIS Desktop installation

• ArcGIS applications and extensions–ArcMap, ArcCatalog, etc.– May require appropriate license

• Core type libraries• Primary interop assemblies

• Controls–MapControl– PageLayout

Page 35: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

3. Desktop Developer Kit options

• Different installs for language-specific components– COM– .NET– C++

• Help documentation• Tools• Samples• IDE integration

components

Page 36: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Using ArcObjects in .NET

• Library architecture• COM concepts

– Interfaces– GUIDs– Component Categories

• Using COM objects with .NET – COM Interop– COM Callable Wrappers– Runtime Callable Wrappers

• The Application architecture

Page 37: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcObjects and the .NET API

• All ArcObjects types are defined in .NET assemblies provided by ESRI– CCW - Com Callable Wrapper– RCW - Runtime Callable Wrapper

• Installed in GAC when ArcGIS is installed

• Not installed if .NET framework is not installed BEFORE ArcGIS is installed

• Developer tools– ArcGIS Developer Help (.NET)– ILDASM.exe

ArcObjects C++(*.dll)

COM Type Libraries(*.olb)

.NET Assemblies(*.dll)

Interop

Page 38: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS .NET assemblies and namespaces

• All .NET projects must reference the ESRI assemblies– Eg., ESRI.ArcGIS.Carto.dll

• Import namespace to access ArcObjects .NET types– Eg., ESRI.ArcGIS.Carto

• Assemblies have dependencies

'Visual Basic .NET uses the 'Imports' keywordImports ESRI.ArcGIS.CatalogUI Imports ESRI.ArcGIS.ArcMapUIImports ESRI.ArcGIS.Framework. . . 'Visual C# uses the ‘using' keywordusing ESRI.ArcGIS.CatalogUI using ESRI.ArcGIS.ArcMapUIusing ESRI.ArcGIS.Framework

'Visual Basic .NET uses the 'Imports' keywordImports ESRI.ArcGIS.CatalogUI Imports ESRI.ArcGIS.ArcMapUIImports ESRI.ArcGIS.Framework. . . 'Visual C# uses the ‘using' keywordusing ESRI.ArcGIS.CatalogUI using ESRI.ArcGIS.ArcMapUIusing ESRI.ArcGIS.Framework

Page 39: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

.NET interfaces

• .NET interfaces represent the ArcObjects interfaces• Different techniques for QueryInterface

– Implicit casting– Explicit casting

• Use TypeOf to avoid handling InvalidCastException with Implicit casting

Dim point As New PointClassDim geometry As IGeometryIf (TypeOf point Is IGeometry) Then

geometry = pointEnd If

Dim point As New PointClassDim geometry As IGeometryIf (TypeOf point Is IGeometry) Then

geometry = pointEnd If

geometry = point 'Implicit cast in VB.NET geometry = CType(point, IGeometry) 'Explicit cast in VB.NET

geometry = point as IGeometry; 'Explicit cast in C#

geometry = point 'Implicit cast in VB.NET geometry = CType(point, IGeometry) 'Explicit cast in VB.NET

geometry = point as IGeometry; 'Explicit cast in C#

Page 40: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

.Net base classes save time

Public NotInheritable Class RouteFinderCmdInherits BaseCommand

Public Sub New()MyBase.New()MyBase.m_caption = "RouteWindow VB"MyBase.m_category = "ArcObjects .NET Tools"MyBase.m_message = "Toggles view for the RouteFinder window"MyBase.m_name = "ArcObjects .NET Tools_RouteFinderCmd"MyBase.m_toolTip = "Displays or hides Route Finder"MyBase.m_bitmap = New System.Drawing.Bitmap _

(Me.GetType.Assembly.GetManifestResourceStream _("ESRI.ArcObjects.AAON.RouteFinderVB.RouteFinder.bmp"))

End Sub

Public Overrides Sub OnCreate(ByVal hook As Object)…End Sub

Public Overrides Sub OnClick()…End Sub

Public NotInheritable Class RouteFinderCmdInherits BaseCommand

Public Sub New()MyBase.New()MyBase.m_caption = "RouteWindow VB"MyBase.m_category = "ArcObjects .NET Tools"MyBase.m_message = "Toggles view for the RouteFinder window"MyBase.m_name = "ArcObjects .NET Tools_RouteFinderCmd"MyBase.m_toolTip = "Displays or hides Route Finder"MyBase.m_bitmap = New System.Drawing.Bitmap _

(Me.GetType.Assembly.GetManifestResourceStream _("ESRI.ArcObjects.AAON.RouteFinderVB.RouteFinder.bmp"))

End Sub

Public Overrides Sub OnCreate(ByVal hook As Object)…End Sub

Public Overrides Sub OnClick()…End Sub

DEMO

Page 41: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Engine Developer Kit for .NETArcGIS Engine Developer Kit for .NET

•• SDK for developers to build custom ArcGIS applicationsSDK for developers to build custom ArcGIS applications

•• Includes the following:Includes the following:

–– ArcGIS Engine RuntimeArcGIS Engine Runtime

–– .NET developer help system .NET developer help system and Samplesand Samples

–– Rich set of visual development Rich set of visual development componentscomponents

–– Many preMany pre--built commands, built commands, toolbars and menustoolbars and menus UC 2007 Tech SessionUC 2007 Tech Session 4141

Page 42: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Server 9.2: Software Development Kit

• Build and deploy web & enterprise geospatial applications and services

• Productivity boost with out-of-the-box IDE integration• Software Development Kit (SDK) includes :

– .NET components• Web ADF• Mobile ADF

– Java components• Web ADF• Enterprise ADF

Software Development Kit (SDK)Software Development Kit (SDK)

.NET.NET JavaJavaMobileMobile

ArcGISArcGISMobileMobileWeb mapWeb map

ApplicationsApplicationsBusinessBusiness

ApplicationsApplications

EnterpriseEnterpriseWebWeb WebWeb

Integration Environment

Plus thePlus theArcGIS ExplorerArcGIS ExplorerSDK for custom tasksSDK for custom tasks

Page 43: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Web Application Development Framework

• .Net libraries used to build Web GIS applications– Web controls

• AJAX enabled– Support multiple data sources

• ArcGIS Server, ArcIMS, ArcWeb, WMS• Web ADF graphics and consolidation classes

– Task framework• Extensible architecture

• ArcGIS Server Manager– Build web applications

• Supported with .Net and Visual Studio 2005

Page 44: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developer Libraries ArcGIS Server 9.2

• Components– Web ADF Native .Net Assemblies– ArcObjects primary Interop Assemblies

– ArcObjects COM type libraries

– Client-side support files• JavaScript• CSS• Images• Etc.

Page 45: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Server for .Net – Building Mobile Apps

• Use the ArcGIS Server Mobile ADF– Developer solution for mobile Apps– Development of custom server-centric lightweight mobile apps– Direct synchronization with ArcGIS Server– Connected and disconnected– Mobile and desktop platforms– Short and long transactions, versioned editing

• Leverage Mobile Map controls• Leverage .Net Compact Framework• Work with GIS Web Services using the SOAP API• MS .Net/.Net compact Framework 2.0, WM 5.0 – pocket

PC Smartphone, WM Pocket PC 2003, 2003 SE, CE 5.0 and XP

DEMO

Page 46: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Developing with Java

Page 47: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Java-COM Interop Bridge

• Provides a Java API for ArcObjects– Generates Java classes for every ArcObjects class (Point)– Generates Java interfaces for every ArcObjects interface (IPoint)– Generates Java Proxy classes for every interface (IPointProxy)

• Allows Java applications to create ArcObjects and call methods on them using JNI technology

Page 48: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Java in ArcGIS

• ArcGIS Engine• ArcGIS Server

Page 49: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Overview of ArcGIS Engine Java

• Java SDK for developing cross platform desktop GIS Applications.– Windows– Linux– Solaris

• Collection of libraries for mapping, visualization, data management and GIS analysis.

• Create stand alone GIS apps or Embed GIS functions in existing applications

Page 50: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Architecture

ArcObjects

Java Proxies & Visual JavaBeansJava Proxies & Visual JavaBeans

Windows / Solaris / Linux

InteropInterop BridgeBridge

Page 51: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

ArcGIS Server 9.2 Java

• Web ADF– Java Server Faces

• Enterprise Application Development Framework – Supports development of J2EE applications powered by Enterprise

JavaBeans (EJB) technology by providing out-of-the-box EJBs ready to use

• Web services

Page 52: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

More Info

• Visit– EDN http://edn.esri.com– Documentation– Conference proceedings

Page 53: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Summary

• ArcObjects are the base for all the ArcGIS applications

• ArcObjects come with a product: ArcGIS Desktop, ArcGIS Engine or ArcGIS Server

• According to your needs select the product and the license

• Several supported technologies for development

Page 54: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Questions?

Page 55: Introduction to Development With ArcGIS

EUC 2007 Technical TrackEUC 2007 Technical Track

Thank you for coming!