Working with the ArcGIS Server ArcObjects API |
Introduction to the ArcGIS Server ArcObjects API
This section will focus on working with ArcObjects in .NET using the ArcGIS Server ArcObjects API. The Web ADF and Mobile ADF provide additional developer components to enhance working within a specific application environment. In both products, the ArcGIS Server ArcObjects API is available for use when accessing ArcGIS Server data sources. See the sections titled Developing Web Applications using the Web ADF and Developing Mobile Applications using the Mobile ADF for more information.
这一篇着重讨论如何使用.NET的AO类库操作ArcGISServer的ArcObjects。Web ADF和MobileADF提供了额外的开发组件以增强在特定的环境下程序功能。在这两种产品中,the ArcGIS Server ArcObjects API 是可用的当访问ArcGISServer的数据源的时候。具体细节请参考以下两篇:。
In simple terms, ArcObjects are a set of COM components. To work with ArcObjects in the .NET development environment, a collection of .NET primary interop assemblies and COM object libraries have been generated to manage .NET-COM interaction. ArcObjects components are installed with the ArcGIS Desktop, ArcGIS Engine, or ArcGIS Server products. They can be accessed locally on any machine where they've been installed. To access ArcObjects remotely using ArcGIS Server (via distributed COM or DCOM), only the .NET primary interop assemblies and COM object libraries must be installed on the client machine. The COM object libraries act as proxies to ArcObjects components on a remote server. The ArcGIS Server API provides the environment for a developer to work with and manage ArcObjects remotely, via ArcGIS Server. Both the Web ADF and Mobile ADF for the Microsoft .NET Framework include the .NET primary interop assemblies and ArcObjects proxies. A more detailed discussion is included below.
简单来说,ArcObjects是一组COM组件。为了在.NET开发环境中使用AO,一组.NET primary interop assemblies和COM类库被生成出来管理.net和COM对象之间的交互。AO组件随着ArcGIS Desktop, ArcGIS Engine, or ArcGIS Server产品安装而存在。它可以在任何安装过他们的机器本地访问到。如果要通过ArcGISServer远程访问(通过分布式的COM或者DCOM)AO类库,只有通过安装在客户端的.net-COM类库。COM类库作为ArcObjects组件访问远程服务代理。AS api通过ArcGISServer为开发者提供远程操作AO对象的环境。同样的,Web ADF和Mobile ADF for .NET Framework也有同样的.net-com组件转换代理。下面有更更细致的讨论。
PS:COM组件在非.net环境下,是微软在.net之前的组件技术,一般来说,产品升级会将之前的COM组件覆盖,无法进行版本升级。.net实现了平稳升级的方式,即一个类库可以存在多个版本,即使名字一样。使用.Net环境还能将不同的操作系统的区别屏蔽,因为.NET本身就是一个软件运行虚拟环境,提供了多种语言的解释执行环境。为了使用原来的COM组件,一般使用代理模式来访问,在.net中构造一个类,AO是ESRI所有软件的基础,所有的产品都是基于该类库,升级到.net环境下,只需要安标准增加一系列的代理类就平稳的在.NET中使用原有的ArcObjects COM组件了。
It is possible to write a number of different types of applications using ArcGIS Server. The developer who works with the ArcGIS Server ArcObjects API using the Microsoft .NET Framework can build server applications, such as Web applications, Web services, desktop client application, and mobile applications.
使用ArcGISServer非常可能写出大量的不同的应用程序。开发者使用ms.NET框架开发基于AS ArcObjects API,可以构建服务器应用软件,例如web程序,web 服务,桌面程序以及移动应用。
ArcGIS Engine developers can build desktop applications that work with ArcObjects both locally and remotely via ArcGIS Server. ArcGIS Desktop developers can extend the ArcGIS Desktop applications to include functionality that makes use of the GIS server. In both of these cases, the deployment of the application itself requires an ArcGIS Engine runtime deployment license or an ArcGIS Desktop license.
Engine开发者使用AO类库构建出的桌面应用程序可以本地和远程访问通过ArcGISServer.Desktop开发者可以通过开发扩展插件形式来增加使用GISServer的功能。这两种情况下,应用程序本身需要 engine runtime或者桌面许可才能运行起来。
In the case of ArcGIS Desktop and ArcGIS Engine, developers who write desktop applications that use the server will have ArcObjects installed locally, on the machine where the application is both developed and deployed. When using these products to write applications that use ArcGIS Server, you must follow the same programming guidelines as a developer using the ArcGIS Server API to build a server application, such as a Web application that is deployed within a Web server. The only difference is that in the case of the desktop application, each instance of your application is bound to a single user session (though there might be multiple instances of your application running at any time), while Web applications or Web services are multiuser/multi-session applications.
Engine和Desktop开发者需要在本地装有一套AO类库,这套类库用来构建开发环境和部署环境。使用这两种产品开发使用ArcGISserver的程序时,你必须遵循和基于AS api开发的程序同样的规范,例如部署在Web服务器中的web app.唯一不同的地方是桌面程序每一个实例只能是单用户会话,而web app或者web 服务可以多用户多线程使用。
The Web ADF for the Microsoft .NET Framework does not include ArcObjects components. Instead, the ADF includes .NET primary interop assemblies and ArcObjects COM object libraries, also known as proxy objects. Applications that are built and deployed using Web ADF must follow the coding guidelines of the server, or they won't work. Those aspects of the coding guidelines will become more apparent in subsequent topics.
Web ADF for ms.NET框架不包含AO组件,但包含一套.net交互代理类和ArcObject COM组件作为代理类使用。基于ADF开发和部署的应用程序要遵循服务器编码规范,否则它们不会运行。这些规范会在稍后的话题中逐渐变的明显起来。
A proxy object is a local representation of a remote object. The proxy object controls access to the remote object by forcing all interaction with the remote object to be via the proxy object. The supported interfaces and methods on a proxy object are the same as those supported by the remote object. You can make method calls on, and get and set properties of, a proxy object as if you were working directly with the remote object.
代理对象是远程对象的本地表征。代理对象使用强制手段保正必须通过它才能和远程对象进行交互。代理对象与远程对象拥有相同的接口和方法。你使用代理对象调用方法、get和set属性就如同你直接访问远程对象一样。
The ArcGIS Server ArcObjects API
Programming with the ArcGIS Server ArcObjects API is all about remotely programming ArcObjects. Programming ArcObjects remotely is the same as programming ArcObjects for use in desktop applications, but there are some additional details and programming guidelines you need to follow. You need to understand:
How to connect to the server.
How to get objects that are running within the server.
How to create new objects within the server.
The best ways for working with remote ArcObjects.
使用AS API写程序的内容几乎是等于在远程ao编程。远程AO编程和使用AO开发desktop程序一样,不过有特别的以下细节需要注意,你必须明白:
1. 如何连接到server
2. 如何在server得到服务器对象
3. 如何在server中创建一个对象
4. 最佳操作远程ao对象的方法
The rest of programming the server is just programming ArcObjects. Each aspect of programming the server listed above will be described in more detail in the following sections.
接下来剩下的编码仅仅就是操作ao。上面提到的每一个话题都会在接下来的详细讲述。
ArcGIS Server developers have access to both the Web ADF and the ArcGIS Server API. While the Web ADF provides a set Web controls and convenience classes to work with multiple data sources, it may be necessary to work with functionality specifically available in ArcObjects via ArcGIS Server. The Web ADF provides a means to access ArcGIS Server specifically, see the Web ADF section titled Access a data source specific API. Of course, you can build almost any application type and choose to work only with ArcGIS Server via the ArcObjects API. Building practical applications requires knowledge of the object libraries that compose the ArcGIS Server. The libraries contained within the ArcGIS Server are summarized below. The diagrams that accompany this section indicate the library architecture of the ArcGIS Server. Understanding the library structure, their dependencies, and basic functionality will help you as a developer navigate through the components of ArcGIS Server. The libraries are discussed in dependency order, which is shown in the diagram below using a number in the upper right corner of the library block.
ArcGIS Server开发者可以使用web adf和 ArcGIS server api连接。Web adf提供一系列的web空间和便利的类来访问多种数据源,它必须特别的使用functionality经由ArcGIS Server来操作ao。Web adf提供了一种访问arcgis Server的特别的手段,可以参考这篇文章。当然,你也可以仅仅使用 ao api来构建任何类型程序来使用arcgis server.构建一个实用性的应用程序需要一些构成ArcGISserver的组件库的知识。这些类库简单介绍一下:下面的图表指出了arcGISServer的类库架构。理解类库的结构、依赖关系以及基本的方法将有助于你彻底的作为一个开发者来操作ArcGIS Server组件。这个类库是依照依赖关系进行讨论的,每一个都接下来按照右上角的编号进行详细说明。
For a comprehensive discussion on each library, refer to the library overview topics, a part of the library reference section of the ArcGIS Developer Help system.
Object libraries are logical collections of the programmable ArcObjects components, ranging from fine-grained objects (for example, individual geometry objects) to coarse-grained objects, which aggregate logical collections of functionality (for example, an ArcMap object to work with map documents). Programmers can use a number of standards-based APIs (COM, .NET, Java, and C++) to work with ArcObjects on the server. These same libraries are also used to program with ArcGIS Desktop and ArcGIS Engine.
对象类库是一种对可用于编程的AO组件的逻辑上的分类,范围从细粒度的对象(例如 独立的geometry对象)到粗粒度的对象,粗粒度对象是一种功能的逻辑组合体(例如ArcMap对象操作map 文档).程序员使用多种标准api在server上操作ao对象。这些相同的类库也可以用来操作桌面和engine。
System
The System library is the lowest level library in the ArcGIS architecture. The library contains components that expose services used by the other libraries composing ArcGIS. There are a number of interfaces defined within System that can be implemented by the developer. The developer does not extend this library but can extend the ArcGIS system by implementing interfaces contained within this library.
这个类库在ArcGISServer结构中处于最底层类库。它包含这样一些暴露出自己服务的构件:被其他组件使用并组合成ArcGIS的组件。它在System中是大量的接口,程序员可以实现他们,来扩展ArcGIS system功能。但不可以扩展该类库。
SystemUI
The SystemUI library contains the interface definitions for user interface components that can be extended within the ArcGIS system. These include the ICommand, ITool, and IToolControl interfaces. The objects contained within this library are utility objects available to the developer to simplify some user interface developments. The developer does not extend this library but can extend the ArcGIS system by implementing interfaces contained within this library.
SystemUI类库包含UI组件接口定义,可以扩展ArcGIS system.他们包含 ICommand ,ITool,IToolControl接口。这些对象是非常简便的工具用来简化UI开发。开发者不能扩展该类库只能实现已有的接口来扩展功能。
Geometry
The Geometry library handles the geometry, or shape, of features stored in feature classes or other graphical elements. The fundamental geometry objects that most users will interact with are Point, MultiPoint, Polyline, and Polygon. Besides those top-level entities are geometries that serve as building blocks for polylines and polygons. Those are the primitives that compose the geometries. They are Segments, Paths, and Rings. Polylines and polygons are composed of a sequence of connected segments that form a path. A segment consists of two distinguished points, the start and the end point, and an element type that defines the curve from start to end. The types of segments are CircularArc, Line, EllipticArc, and BezierCurve. All geometry objects can have Z, M, and IDs associated with their vertices. The fundamental geometry objects all support geometric operations such as Buffer and Clip . The geometry primitives are not meant to be extended by developers.
Geometry类库用于处理存在要素类或者其他图形元素中的要素的元素—geometry或shape。大部分用户交互的基本geometry对象是Point,MultiPoint,Polyline以及Polygon.除此之外,这些顶级对象还是构建复杂多部件形式的Polylines或者Polygons的基础。他们是构成几何体的基础类型,他们是Segments,paths,和Rings。Polylines和Polygons是由有序的互相连接的segments组成的。一个segment是由两个不同的点构成,起点和终点,并且和一个元素类型定了curve的起始点方向。这些segments是CircularArc,Line,EllipticArc,和BezierCurve.所有的geometry对象都有z,m和关联了他们的节点的IDs.基础geometry对象空间操作,例如缓冲和裁剪。但是不能用来扩展。
Entities within a GIS refer to real-world features; the location of these real-world features is defined by a geometry along with a spatial reference. Spatial reference objects, for both projected and geographic coordinate systems, are included in the Geometry library. Developers can extend the spatial reference system by adding new spatial references and projections between spatial references.
在GIS中,一个实体关联一个真实世界的要素;这些真实世界的要素的位置是用一个特定的空间坐标系定义下的geometry来定义的。空间参考对象指的是投影和地理坐标系统,他们也包含在此类库中。开发者可以增加空间参考系和投影来扩展空间参考系统
Display
The Display library contains objects used for the display of GIS data. In addition to the main display objects responsible for the actual output of the image, the library contains objects that represent symbols and colors used to control the properties of entities drawn on the display. The library also contains objects that provide the user with visual feedback when interacting with the display. Developers most often interact with Display through a view similar to the ones provided by the Map or PageLayout objects. All parts of the library can be extended; commonly extended areas are symbols, colors, and display feedbacks.
Display类库包含用来显示GIS数据的对象。为了展现主要的对象响应周边的图,该类库包含了用来控制实体属性的符号和颜色对象。Display库还包含了与展示相关的交互反馈的可视化组件。开发者在大多数时间通过类似于Map 和PageLayout对象的组件进行交互编码的,所有的该类库中的类都可以扩展,一般扩展symbols,colors和display feedbacks;
Server
The Server library contains objects that allow you to connect and work with ArcGIS Servers. Developers gain access to an ArcGIS Server using the GISServerConnection object. The GISServerConnection object gives access to the ServerObjectManager. Using this object, a developer works with ServerContext objects to manipulate ArcObjects running on the server. The Server library is not extended by developers. Developers can also use the GISClient library when interacting with the ArcGIS Server.
Server类库包含允许你连接和使用Server的组件。开发者通过使用GISServerConnection 对象连接Server,该对象给出了访问到ServerObjectManager 接口方法 。使用该(ServerObjectManager)对象,开发者能通过ServerContext 对象对服务器中的AO对象操作。Server类库不支持扩展,开发者在与服务器交互式后同时能使用 GISClient类库 开发。
Output
The Output library is used to create graphical output to devices, such as printers and plotters, and hardcopy formats such as enhanced metafiles and raster image formats (JPG, BMP, and so on). The developer uses the objects in the library with other parts of the ArcGIS system to create graphical output. Usually these would be objects in the Display and Carto libraries. Developers can extend the Output library for custom devices and export formats.
该类库用来创建图像,并输出到外设中,如打印机和plotters,硬拷贝格式和元数据文件以及栅格数据格式。开发者配合着其他类库来使用该类库对象进行创建图像输出,常见的其数据来源于Display和Carto类库,开发者能够自定义输出设备和格式。
GeoDatabase
The GeoDatabase library provides the programming API for the geodatabase. The geodatabase is a repository of geographic data built on standard industry and object relational database technology. The objects within the library provide a unified programming model for all supported data sources within ArcGIS. The GeoDatabase library defines many of the interfaces that are implemented by data source providers higher in the architecture. The geodatabase can be extended by developers to support specialized types of data objects (features, classes, and so forth); in addition, it can have custom vector data sources added using the PlugInDataSource objects. The native data types supported by the geodatabase cannot be extended.
GeoDatabase类库提供了访问GeoDatabase的接口。GeoDatabase是建立在工业标准之上的对象关系型地理数据库。该类库中的对象提供了对ArcGIS支持的数据源统一的访问模型。GeoDatabase类库定义了一系列接口,这些接口被数据提供者所实现。Geodatabase可以被扩展以支持特定类型数据对象(features,classes,以及其他);另外,它还有自定义使用PlugInDataSource对象构造的的矢量数据源。原生的数据类型不能被扩展。
GISClient
The GISClient library allows developers to consume Web services; these Web services can be provided by ArcIMS and ArcGIS Server. The library includes objects for connecting to GIS servers to make use of Web services. There is support for ArcIMS Image and Feature Services. The library provides a common programming model for working with ArcGIS Server objects in a stateless manner either directly or through a Web service catalog. The ArcObjects components running on the ArcGIS Server are not accessible through the GISClient interface. To gain direct access to ArcObjects components running on the server, you should use functionality in the Server library.
GISClient类库允许开发者使用WebServices;这些WebService可以是ArcIMS和GiserServer提供的。类库包含连接到GISServer并使用WebService的对象。支持ArcIMS Image和Feature Services.类库提供了无状态的一般的访问GISServer模型,要么是直接连接要么是通过WebService catalog。在GISServer中生存的AO对象不能通过GISClient接口进行访问。为了能直接访问在服务器中的AO对象,你需要使用Server类库中的functionality组件。
DataSourcesFile
The DataSourcesFile library contains the implementation of the GeoDatabase API for file-based data sources. These file-based data sources include shapefile, coverage, triangulated irregular network (TIN), computer-aided drafting (CAD), smart data compression (SDC), and vector product format (VPF). The DataSourcesFile library is not extended by developers.
数据源DataSourcFile类库包含了访问文件型GeoDatabase 的api实现。这些文件型数据源包括,shapefile,coverage,triangulated irregular network(TIN),CAD,SDC,VPF。该类库不能扩展。
DataSourcesGDB
The DataSourcesGDB library contains the implementation of the GeoDatabase API for the database data sources. These data sources include Microsoft Access and relational database management systems supported by ArcSDE桰BM DB2, Informix, Microsoft SQL Server, and Oracle. The DataSourcesGDB library is not extended by developers.
该类库包含了实现访问基于数据库的GeoDatabase api类。这些数据源包括,ms access。。。
DataSourcesOleDB
The DataSourcesOleDB library contains the implementation of the GeoDatabase API for the Microsoft OLE DB data sources. This library is only available on the Microsoft Windows operating system. These data sources include any OLE DB-supported data provider and text file workspaces. The DataSourcesOleDB library is not extended by developers.
DataSourcesRaster
The DataSourcesRaster library contains the implementation of the GeoDatabase API for the raster data sources. These data sources include relational database management systems supported by ArcSDE桰BM DB2, Informix, Microsoft SQL Server, and Oracle梐long with supported Raster Data Objects (RDO) raster file formats. Developers do not extend this library when support for new raster formats is required; rather, they extend RDO. The DataSourcesRaster library is not extended by developers.
A Raster Data Object is a COM API that provides display and analysis support for file- based raster data.
GeoDatabaseDistributed
The GeoDatabaseDistributed library supports distributed access to an enterprise geodatabase by providing tools for importing data into and exporting data out of a geodatabase. The GeoDatabaseDistributed library is not extended by developers.
该类库支持分布式访问企业级空间数据库,并提供导入导出工具。
Carto
The Carto library supports the creation and display of maps; these maps can consist of data in one map or a page with many maps and associated marginalia. The PageLayout object is a container for hosting one or more maps and their associated marginalia: North arrows, legends, scale bars, and so on. The Map object is a container of layers. The Map object has properties that operate on all layers within the map spatial reference, map scale, and so on along with methods that manipulate the map's layers. There are many different types of layers that can be added to a map. Different data sources often have an associated layer responsible for displaying the data on the map: vector features are handled by the FeatureLayer object, raster data by the RasterLayer, TIN data by the TinLayer, and so on. Layers can, if required, handle all the drawing operations for their associated data, but it is more common for layers to have an associated Renderer object. The properties of the Renderer object control how the data is displayed in the map. Renderers commonly use symbols from the Display library for the actual drawing; the renderer simply matches a particular symbol with the properties of the entity that is to be drawn. A Map object, along with a PageLayout object, can contain elements. An element has geometry to define its location on the map or page, along with behavior that controls the display of the element. There are elements for basic shapes, text labels, complex marginalia, and so on. The Carto library also contains support for map annotation and dynamic labeling.
该类库支持创建和显示maps,这些maps可以由一个map中的数据或者一个有许多map和地图附件的page组成。PageLayout 对象是一个容器,用来包含多个map和他们附属的地图挂件,如指北针、图例、比例尺以及其他。Map对象是Layer对象的容器。Map对象有一系列的通用属性作用于所有的Layers,像空间参考、地图比例,Map对象同样有一系列的方法作用于所有的Layers。有许多不同类型的Layer能加载到一个map中,不同的数据源对应着不同的数据layer在map中进行显示:矢量数据要使用FeatureLayer 对象进行处理,栅格数据要用 RasterLayer 对象进行承载,其他也是如此。除非有需求,layers要处理所有的数据渲染操作,否则,更为普遍的方式是使用与之关联的Renderer对象。Renderer的属性控制着数据如何在map中的显示,借助于Display中的symbols对象,Renderer为实际的图画配上符号;Renderer通常使用特定的symbol来显示实体的一些属性值。Map对象和PageLayout 对象能够盛放elements对象。每一个element对象都有一个geometry值来定位自己在map中的位置,它还定义了一些方法。Carto类库有支持map 注释和动态标签的功能。
Although developers can directly make use of the Map or PageLayout objects in their applications, it is more common for developers to use a higher level object such as the MapControl, PageLayoutControl, or an ArcGIS application. These higher level objects simplify some tasks, although they always provide access to the lower level Map and PageLayout objects, allowing the developer fine control of the objects.
尽管开发者能够直接在程序中使用map或者PageLayout对象,但是更为通用的方式是使用更为高层的对象例如MapControl,PageLayoutControl,或者ArcGIS application.这些高级对象简化了一些任务,但是依然提供了访问低级对象的接口,使得开发者能够有效的操控这些control对象。
The ArcGIS Server uses the MapServer object to work with a Map.
The Map and PageLayout objects are not the only objects in Carto that expose the behavior of map and page drawing. The MxdServer and MapServer objects both support the rendering of maps and pages, but instead of rendering to a window, these objects render directly to a file.
Map和PageLayout对象不是唯一能够输出map和page图画的对象,在Carto中,MxdServer和MapServer对象都支持渲染map和pages,但不是输出到window中,而是直接渲染到一个file中。
Using the MapDocument object, developers can persist the state of the map and page layout within a map document (.mxd), which can be used in ArcMap or one of the ArcGIS controls.
The Carto library is commonly extended in a number of areas. Custom renderers, layers, and so forth, are common. A custom layer is often the easiest method of adding custom data support to a mapping application.
Location
The Location library contains objects that support geocoding and working with route events. The geocoding functionality can be accessed through fine-grained objects for full control, or the GeocodeServer objects offers a simplified API. Developers can create their own geocoding objects. The linear referencing functionality provides objects for adding events to linear features and rendering these events using a variety of drawing options. The developer can extend the linear reference functionality.
NetworkAnalyst
The NetworkAnalyst library contains objects for working with network datasets. Developers can extend this library by creating new network servers. A license for the Network Analyst extension of the ArcGIS Engine Runtime Network option is required to make use of the objects in this library.
NetworkAnalysis
The NetworkAnalysis library provides objects for populating a geodatabase with network data and objects to analyze the network when it is loaded in the geodatabase. Developers can extend this library to support custom network tracing. The library is meant to work with utility networks: gas lines, electricity supply lines, and so on.
GeoAnalyst
The GeoAnalyst library contains objects that support core spatial analysis functions. These functions are used within both the SpatialAnalyst and 3DAnalyst libraries. Developers can extend the library by creating a new type of raster operation. A license for either the ArcGIS Spatial Analyst or 3D Analyst extension or the ArcGIS Engine Runtime Spatial or 3D extension is required to make use of the objects in this library.
3DAnalyst
The 3DAnalyst library contains objects for working with 3D scenes in a similar way that the Carto library contains objects for working with 2D maps. The Scene object is one of the main objects of the library since it is the container for data similar to the Map object. The Camera and Target objects specify how the scene is viewed regarding the positioning of the features relative to the observer. A scene consists of one or more layers; these layers specify the data in the scene and how the data is drawn.
It is not common for developers to extend this library. A license for either the ArcGIS 3D Analyst extension or the ArcGIS Engine Runtime 3D extension is required to work with objects in this library.
GlobeCore
The GlobeCore library contains objects for working with globe data in a similar way that the Carto library contains objects for working with 2D maps. The Globe object is one of the main objects of the library since it is the container for data similar to the Map object. The GlobeCamera object specifies how the globe is viewed regarding the positioning of the globe relative to the observer. The globe can have one or more layers; these layers specify the data on the globe and how the data is drawn.
It is not common for developers to extend this library. A license for either the ArcGIS 3D Analyst extension or the ArcGIS Engine Runtime 3D extension is required to work with objects in this library.
SpatialAnalyst
The SpatialAnalyst library contains objects for performing spatial analysis on raster and vector data. Developers most commonly consume the objects within this library and do not extend it. A license for either the ArcGIS Spatial Analyst extension or the ArcGIS Engine Runtime Spatial extension is required to work with objects in this library.