In this topic
Converter classes
The Web ADF maintains multiple converter classes, each in a different namespace, all with static methods. The namespace provides an indication of which APIs the converter class works with. These classes make the conversion process easier and are by no means comprehensive.
The following table gives a brief summary of the capabilities of each converter class:
Class
|
Description
|
ESRI.ArcGIS.ADF.ArcGISServer.Converter
|
Works with ArcGIS Server Web services, Distributed Component Object Model (DCOM) proxy classes, and the value objects shared by both. Converts from value object to Component Object Model (COM) object and vise versa. Serializes and deserializes value objects.
|
ESRI.ArcGIS.ADF.Converter
|
Works with Web ADF types. Encrypts identity and manages image bitmap creation.
|
ESRI.ArcGIS.ADF.Web.Converter
|
Works with Web ADF types. Converts a .NET DataSet to a Web ADF graphics dataset. Converts a .NET DataTable to a Web ADF graphics layer type.
|
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter
|
Works with ArcGIS Server COM and value object types. Converts to and from Web ADF geometry types, graphics layers, and .NET DataTables.
|
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter
|
Works with ArcIMS types. Converts to and from Web ADF geometry types and units.
|
ESRI.ArcGIS.ADF.Web.UI.WebControls.Converter
|
Used internally for Web ADF controls. Same capabilities as the ESRI.ArcGIS.ADF.Web.Converter and ESRI.ArcGIS.ADF.Converter classes.
|
Some data source APIs maintain their own converter classes.
Geometry
A core task of a geographic information system (GIS) application or service is to work with spatial data—such as retrieving the location of user interaction in a client or defining a spatial filter to select a subset of feature data. In each tier and for each data source, spatial information must be managed. As a result, each tier and data source provides a means for storing and working with geometry.
The following scenario simulates a process in which multiple geometry types must be utilized. The goal of this scenario is to buffer a point from a user click on a map in a browser, display the buffer in the map, and use it to display a subset of features in a feature layer. The process is divided into the following four steps:
-
Get the location of a user click on the map in a browser
The user-entered point in the browser is provided to the Web ADF application in screen units (browser display). The native .NET drawing library (System.Drawing) is used to store the screen geometry. The Web ADF converts the geometry from screen units to map units. The Web ADF maintains its own geometry library to work with Web ADF specific capabilities (such as GraphicsElementLayer or SpatialFilter) and to act as an intermediate type for geometry defined in the client and server tiers. In this case, the Web ADF geometry is a link between screen geometry and ArcGIS Server geometry. -
Use ArcGIS Server local service to buffer the point
The Web ADF cannot buffer a point. An ArcGIS Server local data source can buffer geometry and return the buffer polygon geometry. To work with buffer capabilities in ArcGIS Server local services, convert the Web ADF point to an ArcObjects COM object type point. -
Display the buffer in a Web ADF graphics layer on the map
The ArcGIS Server local service returns an ArcObjects COM polygon type. To render this in a Web ADF graphics layer, convert it to a Web ADF polygon. -
Use the buffer to select features in an ArcIMS service
To use the Web ADF buffer polygon to display a subset of features in a layer in an ArcIMS service, convert the buffer polygon to an ArcIMS polygon type. To query a layer and return a set of features, you can use the Web ADF buffer polygon with IQueryFunctionality. However, since you are applying a definition to a layer, you must work with the ArcIMS API.
These steps are illustrated in the following diagram:
In this scenario, you've used three tiers and four APIs to work with geometry: .NET Framework, Web ADF, ArcGIS Server/ArcObjects COM, and ArcIMS. All the APIs are necessary based on the requirements of the scenario and capabilities of each API. The Web ADF provides the focal point for API interaction; it must also provide the means to integrate types from multiple sources in a single application.
The following sample code snippets provide examples of converting geometry types between different APIs. They are organized by geometry type: point, polyline, and polygon. Each type includes conversion examples from screen (.NET Framework) to Web ADF and Web ADF to data source API, and data source API to Web ADF. Converting from ArcGIS Server ArcObjects COM to SOAP value object types is covered in the ArcGIS Server COM and value objects section.
For the sample code snippets, the following two variables are assumed to be available:
- tooleventargs—Web ADF ToolEventArgs argument for a custom tool
- adf_map—Web ADF Map control
- ArcGIS Server curve-based geometry types are not supported in the Web ADF geometry model. To prepare ArcGIS Server curve types, use the ArcObjects API to densify or generalize the curve and generate geometry defined by a point collection. To do this, use the Densify() or Generalize() method on the ArcObjects curve.
- A set of static methods on the Web ADF Geometry, Point, and Envelope classes (in ESRI.ArcGIS.ADF.Web.Geometry) that are used to convert to and from screen and map units have been overloaded to support map rotation. Some methods of the same name but a different signature have been marked obsolete because they do not support rotated maps. Obsolete methods still work with unrotated map content. The overloads provide a more efficient pattern for transforming Web ADF geometry via the TransformationParams class.
TransformationParams stores parameters needed to convert coordinates between screen and map units. The Map control has a GetTransformationParams() method to return a TransformationParams instance set up using Map properties. The TransformationDirection enumeration allows you to select which direction the transform will take place: either screen to map units (ToMap) or map to screen units (ToScreen). The RotationParams class stores parameters associated with a rotated map extent. The TransformationParams class uses the RotatedParams class to account for rotation when converting coordinates between screen and map units.
A single TransformationParams instance can be created from scratch or retrieved from a Map control and used in multiple geometry conversion calls. TransformationDirection.ToMap is used for ToMap_ methods while TransformationDirection.ToScreen is used with ToScreen_ methods.
Point
The point conversion code samples are shown in this section.
- Screen to Web ADF
PointEventArgs pointargs = (PointEventArgs)tooleventargs;
System.Drawing.Point screen_point = pointargs.ScreenPoint;
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_point =
ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screen_point.X, screen_point.Y,
adf_map.GetTransformationParams(TransformationDirection.ToMap));
- Screen to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();
imgDisp.ImageHeight = (int)adf_map.Height.Value;
imgDisp.ImageWidth = (int)adf_map.Width.Value;
int[] xvalues = new int[1];
xvalues[0] = screen_point.X;
int[] yvalues = new int[1];
yvalues[0] = screen_point.Y;
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(0);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy =
ags_mapresource.MapServerProxy;
ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint =
(ESRI.ArcGIS.ADF.ArcGISServer.MultipointN)ags_mapserverproxy.ToMapPoints
(ags_mapfunctionality.MapDescription, imgDisp, xvalues, yvalues);
ESRI.ArcGIS.ADF.ArcGISServer.PointN value_point =
(ESRI.ArcGIS.ADF.ArcGISServer.PointN)value_multipoint.PointArray[0];
- Screen to ArcIMS
ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)adf_map.GetFunctionality(0)
;
ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;
ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;
ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point =
ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent,
mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height);
- Web ADF to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.PointN value_point =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPoint(adf_point);
- Web ADF to ArcGIS Server ArcObjects
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(ags_local_resource_index);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint)
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(adf_point,
ags_mapresourcelocal.ServerContextInfo.ServerContext);
- Web ADF to ArcIMS
ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point = (ESRI.ArcGIS.ADF.IMS.Geometry.Point)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_point);
- ArcGIS Server SOAP to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPoint(value_point);
- ArcGIS Server ArcObjects to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPoint(com_point);
- ArcIMS to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point =
(ESRI.ArcGIS.ADF.Web.Geometry.Point)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_point);
Polyline
The polyline conversion code samples are shown in this section.
- Screen to Web ADF
VectorEventArgs vectorargs = (VectorEventArgs)tooleventargs;
System.Drawing.Point[] screen_points = vectorargs.Vectors;
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection adf_pointcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
foreach (System.Drawing.Point screen_point in screen_points)
{
adf_pointcollection.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint
(screen_point, adf_map.Extent, adf_map.GetTransformationParams
(TransformationDirection.ToMap));
}
ESRI.ArcGIS.ADF.Web.Geometry.Path adf_path = new ESRI.ArcGIS.ADF.Web.Geometry.Path()
; adf_path.Points = adf_pointcollection;
ESRI.ArcGIS.ADF.Web.Geometry.PathCollection adf_paths = new
ESRI.ArcGIS.ADF.Web.Geometry.PathCollection(); adf_paths.Add(adf_path);
ESRI.ArcGIS.ADF.Web.Geometry.Polyline adf_polyline = new
ESRI.ArcGIS.ADF.Web.Geometry.Polyline(); adf_polyline.Paths = adf_paths;
- Screen to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();
imgDisp.ImageHeight = (int)adf_map.Height.Value;
imgDisp.ImageWidth = (int)adf_map.Width.Value;
int[] xvalues = new int[screen_points.Length];
int[] yvalues = new int[screen_points.Length];
for (int i = 0; i < screen_points.Length; i++)
{
xvalues[i] = screen_points[i].X;
yvalues[i] = screen_points[i].Y;
}
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(0);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy =
ags_mapresource.MapServerProxy;
ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint =
(ESRI.ArcGIS.ADF.ArcGISServer.MultipointN)ags_mapserverproxy.ToMapPoints
(ags_mapfunctionality.MapDescription, imgDisp, xvalues, yvalues);
ESRI.ArcGIS.ADF.ArcGISServer.Path value_path = new ESRI.ArcGIS.ADF.ArcGISServer.Path
();
value_path.PointArray = value_multipoint.PointArray;
ESRI.ArcGIS.ADF.ArcGISServer.Path[] value_paths = new
ESRI.ArcGIS.ADF.ArcGISServer.Path[1];
value_paths.SetValue(value_path, 0);
ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline = new
ESRI.ArcGIS.ADF.ArcGISServer.PolylineN();
value_polyline.PathArray = value_paths;
- Screen to ArcIMS
ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)adf_map.GetFunctionality(0)
;
ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;
ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;
ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection ims_pointcollection = new
ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection();
foreach (System.Drawing.Point screen_point in screen_points)
{
ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point =
ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent,
mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height);
ims_pointcollection.Add(ims_point);
}
ESRI.ArcGIS.ADF.IMS.Geometry.Path ims_path = new ESRI.ArcGIS.ADF.IMS.Geometry.Path();
ims_path.Points = ims_pointcollection;
ESRI.ArcGIS.ADF.IMS.Geometry.Polyline ims_polyline = new
ESRI.ArcGIS.ADF.IMS.Geometry.Polyline();
ims_polyline.Paths.Add(ims_path);
- Web ADF to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPolyline
(adf_polyline);
- Web ADF to ArcGIS Server ArcObjects
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(0);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.Geometry.IPointCollection com_polyline_pointcollection =
(ESRI.ArcGIS.Geometry.IPointCollection)
ags_mapresourcelocal.ServerContextInfo.ServerContext.CreateObject(
"esriGeometry.Polyline");
object Missing = Type.Missing;
foreach (ESRI.ArcGIS.ADF.Web.Geometry.Path new_adf_path in adf_polyline.Paths)
{
ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection =
(ESRI.ArcGIS.Geometry.IPointCollection)
ags_mapresourcelocal.ServerContextInfo.ServerContext.CreateObject(
"esriGeometry.Path");
foreach (ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_point in new_adf_path.Points)
{
ESRI.ArcGIS.Geometry.IPoint com_point = (ESRI.ArcGIS.Geometry.IPoint)
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry
(new_adf_point, ags_mapresourcelocal.ServerContextInfo.ServerContext);
com_pointcollection.AddPoint(com_point, ref Missing, ref Missing);
}
com_polyline_pointcollection.AddPointCollection(com_pointcollection);
}
ESRI.ArcGIS.Geometry.IPolyline com_polyline = (ESRI.ArcGIS.Geometry.IPolyline)
com_polyline_pointcollection;
- Web ADF to ArcIMS
ESRI.ArcGIS.ADF.IMS.Geometry.Polyline ims_polyline =
(ESRI.ArcGIS.ADF.IMS.Geometry.Polyline)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_polyline);
- ArcGIS Server SOAP to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Point new_adf_polyline =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolyline
(value_polyline);
- ArcGIS Server ArcObjects to Web ADF
ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection =
(ESRI.ArcGIS.Geometry.IPointCollection)com_polyline;
ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection
(com_pointcollection);
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection new_adf_pointcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
for (int i = 0; i < new_adf_points.Length - 1; i++)
{
new_adf_pointcollection.Add(new_adf_points[i]);
}
ESRI.ArcGIS.ADF.Web.Geometry.Path new_adf_path = new
ESRI.ArcGIS.ADF.Web.Geometry.Path();
new_adf_path.Points = new_adf_pointcollection;
ESRI.ArcGIS.ADF.Web.Geometry.PathCollection new_adf_pathcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.PathCollection();
adf_pathcollection.Add(new_adf_path);
ESRI.ArcGIS.ADF.Web.Geometry.Polyline new_adf_polyline = new
ESRI.ArcGIS.ADF.Web.Geometry.Polyline();
new_adf_polyline.Paths = new_adf_pathcollection;
- ArcIMS to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Polyline new_adf_polyline =
(ESRI.ArcGIS.ADF.Web.Geometry.Polyline)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_polyline);
Polygon
The polygon conversion code samples are shown in this section.
- Screen to Web ADF
VectorEventArgs vectorargs = (VectorEventArgs)tooleventargs;
System.Drawing.Point[] screen_points = vectorargs.Vectors;
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection adf_pointcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
foreach (System.Drawing.Point screen_point in screen_points)
{
adf_pointcollection.Add(ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint
(screen_point, adf_map.Extent, adf_map.GetTransformationParams
(TransformationDirection.ToMap)));
}
ESRI.ArcGIS.ADF.Web.Geometry.Ring adf_ring = new ESRI.ArcGIS.ADF.Web.Geometry.Ring();
adf_ring.Points = adf_pointcollection;
ESRI.ArcGIS.ADF.Web.Geometry.RingCollection adf_rings = new
ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();
adf_rings.Add(adf_ring);
ESRI.ArcGIS.ADF.Web.Geometry.Polygon adf_polygon = new
ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
adf_polygon.Rings = adf_rings;
- Screen to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay imgDisp = new
ESRI.ArcGIS.ADF.ArcGISServer.ImageDisplay();
imgDisp.ImageHeight = (int)adf_map.Height.Value;
imgDisp.ImageWidth = (int)adf_map.Width.Value;
int[] xvalues = new int[screen_points.Length];
int[] yvalues = new int[screen_points.Length];
for (int i = 0; i < screen_points.Length; i++)
{
xvalues[i] = screen_points[i].X;
yvalues[i] = screen_points[i].Y;
}
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(0);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase ags_mapresource =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceBase)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.ADF.ArcGISServer.MapServerProxy ags_mapserverproxy =
ags_mapresource.MapServerProxy;
ESRI.ArcGIS.ADF.ArcGISServer.MultipointN value_multipoint =
(ESRI.ArcGIS.ADF.ArcGISServer.MultipointN)ags_mapserverproxy.ToMapPoints
(ags_mapfunctionality.MapDescription, imgDisp, xvalues, yvalues);
ESRI.ArcGIS.ADF.ArcGISServer.Ring value_ring = new ESRI.ArcGIS.ADF.ArcGISServer.Ring
();
value_ring.PointArray = value_multipoint.PointArray;
ESRI.ArcGIS.ADF.ArcGISServer.Ring[] value_rings = new
ESRI.ArcGIS.ADF.ArcGISServer.Ring[1];
value_rings.SetValue(value_ring, 0);
ESRI.ArcGIS.ADF.ArcGISServer.PolygonN value_polygon = new
ESRI.ArcGIS.ADF.ArcGISServer.PolygonN();
value_polygon.RingArray = value_rings;
- Screen to ArcIMS
ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality ims_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.IMS.MapFunctionality)adf_map.GetFunctionality(0)
;
ESRI.ArcGIS.ADF.IMS.Carto.MapView mapview = ims_mapfunctionality.MapView;
ESRI.ArcGIS.ADF.IMS.Geometry.Envelope ims_extent = mapview.Extent;
ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection ims_pointcollection = new
ESRI.ArcGIS.ADF.IMS.Geometry.PointCollection();
foreach (System.Drawing.Point screen_point in screen_points)
{
ESRI.ArcGIS.ADF.IMS.Geometry.Point ims_point =
ESRI.ArcGIS.ADF.IMS.Geometry.Point.ToMapPoint(screen_point, ims_extent,
mapview.ImageDescriptor.Width, mapview.ImageDescriptor.Height);
ims_pointcollection.Add(ims_point);
}
ESRI.ArcGIS.ADF.IMS.Geometry.Ring ims_ring = new ESRI.ArcGIS.ADF.IMS.Geometry.Ring();
ims_ring.Points = ims_pointcollection;
ESRI.ArcGIS.ADF.IMS.Geometry.Polygon ims_polygon = new
ESRI.ArcGIS.ADF.IMS.Geometry.Polygon();
ims_polygon.Rings.Add(ims_ring);
- Web ADF to ArcGIS Server SOAP
ESRI.ArcGIS.ADF.ArcGISServer.PolygonN value_polygon =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromAdfPolygon
(adf_polygon);
- Web ADF to ArcGIS Server ArcObjects
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality ags_mapfunctionality =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)
adf_map.GetFunctionality(0);
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal ags_mapresourcelocal =
(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)
ags_mapfunctionality.Resource;
ESRI.ArcGIS.Geometry.IPolygon com_polygon = (ESRI.ArcGIS.Geometry.IPolygon)
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(adf_polygon,
ags_mapresourcelocal.ServerContextInfo.ServerContext);
- Web ADF to ArcIMS
ESRI.ArcGIS.ADF.IMS.Geometry.Polygon ims_polygon =
(ESRI.ArcGIS.ADF.IMS.Geometry.Polygon)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToIMSGeometry(adf_polygon);
- ArcGIS Server SOAP to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToAdfPolygon
(value_polygon);
- ArcGIS Server ArcObjects to Web ADF
If the ArcObjects polygon is generated using the ITopologicalOperator.Buffer() method, call IPolygon.Densify() to generate an adequate point collection for the Web ADF polygon.
// com_polygon.Densify(0,0);
ESRI.ArcGIS.Geometry.IPointCollection com_pointcollection =
(ESRI.ArcGIS.Geometry.IPointCollection)com_polygon;
ESRI.ArcGIS.ADF.Web.Geometry.Point[] new_adf_points =
ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIPointCollection
(com_pointcollection);
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection new_adf_pointcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.PointCollection();
for (int i = 0; i < new_adf_points.Length - 1; i++)
{
new_adf_pointcollection.Add(new_adf_points[i]);
}
ESRI.ArcGIS.ADF.Web.Geometry.Ring new_adf_ring = new
ESRI.ArcGIS.ADF.Web.Geometry.Ring();
new_adf_ring.Points = new_adf_pointcollection;
ESRI.ArcGIS.ADF.Web.Geometry.RingCollection new_adf_ringcollection = new
ESRI.ArcGIS.ADF.Web.Geometry.RingCollection();
new_adf_ringcollection.Add(new_adf_ring);
ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon = new
ESRI.ArcGIS.ADF.Web.Geometry.Polygon();
new_adf_polygon.Rings = new_adf_ringcollection;
- ArcIMS to Web ADF
ESRI.ArcGIS.ADF.Web.Geometry.Polygon new_adf_polygon =
(ESRI.ArcGIS.ADF.Web.Geometry.Polygon)
ESRI.ArcGIS.ADF.Web.DataSources.IMS.Converter.ToADFGeometry(ims_polygon);
ArcGIS Server COM and value objects
When working with ArcGIS Server, the Web ADF controls and the Web ADF Common API (the Common API) use the inherently stateless ArcGIS Server SOAP API, which includes a set of value objects and proxies. An ArcGIS Server Internet data source uses a Web service proxy to serialize value objects to SOAP and work with an ArcGIS Server Web service endpoint. An ArcGIS Server local data source uses a DCOM proxy to serialize value objects to SOAP and work with a server object via the IRequestHandler interface directly.
Whether accessing the SOAP interface of a server object via an Internet or via a local connection, the use and limitations of the stateless ArcGIS Server SOAP API are the same. However, if you are working with an ArcGIS Server local data source, you have access to the server context and ArcObjects API, via COM, on the GIS server.
The ArcGIS Server ArcObjects API has a rich and comprehensive set of the capabilities. The ArcGIS Server SOAP API only exposes a portion of ArcObjects capability (via a SOAP interface). To utilize ArcObjects and work with the Web ADF implementation of ArcGIS Server data sources—which uses the SOAP API—a conversion between ArcObjects COM and SOAP value objects must occur. The following two converter methods are available in the ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter class to accomplish this:
- Converter.COMObjectToValueObject(object, ESRI.ArcGIS.Server.IServerContext, System.Type)—Returns an ArcGIS Server SOAP API value object as shown in the following code:
ESRI.ArcGIS.ADF.ArcGISServer.PolylineN value_polyline =
(ESRI.ArcGIS.ADF.ArcGISServer.PolylineN)
ESRI.ArcGIS.ADF.ArcGISServer.Converter.ComObjectToValueObject(com_polyline,
servercontext, typeof(ESRI.ArcGIS.ADF.ArcGISServer.PolylineN));
- Converter.ValueObjectToCOMObject(object, ESRI.ArcGIS.Server.IServerContext)—Returns an ArcGIS Server ArcObjects API COM object as shown in the following code:
ESRI.ArcGIS.Geometry.IPolyline com_polyline = (ESRI.ArcGIS.Geometry.IPolyline)
ESRI.ArcGIS.ADF.ArcGISServer.Converter.ValueObjectToComObject(value_polyline,
servercontext);
Since the SOAP API represents a subset of the ArcObjects API, every value object has a complimentary COM object. However, not every COM object has a complimentary value object. The following table lists valid conversions between value object and COM object types:
Value object type ESRI.ArcGIS.ADF.ArcGISServer.*
|
ArcObjects COM object type
|
PointN
|
ESRI.ArcGIS.Geometry.IPoint
|
Line
|
ESRI.ArcGIS.Geometry.ILine
|
PolylineN
|
ESRI.ArcGIS.Geometry.IPolyline
|
PolygonN
|
ESRI.ArcGIS.Geometry.IPolygon
|
MapDescription
|
ESRI.ArcGIS.Carto.IMapDescription
|
GraphicsElement[]
|
ESRI.ArcGIS.Carto.IGraphicElements
|
Field
|
ESRI.ArcGIS.Geodatabase.IField
|
RecordSet
|
ESRI.ArcGIS.Geodatabase.IRecordSet
|
Datasets
When working with data sources, you often need to manage and interact with tabular data. In most cases, working with data tables requires using data source-specific API methods, properties, and techniques. The Web ADF provides a set of utility methods to effectively handle data source-specific datasets and work with a common standardized ADO.NET data structure. These methods convert data source-specific tabular data to ADO.NET DataTables and Web ADF GraphicsLayers (extends DataTable).
To convert ArcGIS Server ArcObjects ESRI.ArcGIS.Geodatabase.IRecordSet or ESRI.ArcGIS.ADF.ArcGISServer.RecordSet to ADO.NET System.Data.DataTable, use the following static method in the ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer namespace:
ToDataTable(ESRI.ArcGIS.ADF.ArcGISServer.RecordSet)
The ArcObjects type IRecordSet needs to be converted to a SOAP value object RecordSet first using the ComObjectToValueObject method.
If the ArcGIS Server RecordSet value object has a column that contains geometry value objects, you can convert the RecordSet to a Web ADF feature graphics layer and display it in a Map control. Use the following static method to return ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer:
ToFeatureGraphicsLayer(ESRI.ArcGIS.ADF.ArcGISServer.RecordSet)
The Common API defines an IQueryFunctionality interface that, if implemented by a data source, provides a number of methods to query data layers exposed by the data source. The data returned from a query is in the ADO.NET DataTable format. However, it often contains Web ADF geometry to display as graphics in a Map control. Instead of creating the Web ADF graphics layer from scratch, the ESRI.ArcGIS.ADF.Web.Converter class contains the following static method to create the graphics layer for you:
ToGraphicsLayer(System.Data.DataTable)
If all the Web ADF geometry in the DataTable is the same type, ESRI.ArcGIS.ADF.Web.Display.Graphics.FeatureGraphicsLayer is returned. If the geometry is of different types, ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer is returned. In either case, you can add the graphics layer to a Web ADF graphics resource, if available. The following sample code illustrates how this can be done:
[C#]
System.Data.DataTable datatable = queryfunctionality.Query(null,
layerids[layer_index], adf_spatialfilter);
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicslayer =
Converter.ToGraphicsLayer(datatable, Color.Yellow, Color.Yellow);
ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource graphicsresource = null;
foreach (IGISFunctionality gisfunctionality in gisfunctionalitycollection)
{
if (gisfunctionality.Resource.Name == "Selection")
{
graphicsresource = (ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource)
gfunc.Resource;
graphicsresource.Graphics.Tables.Clear();
}
}
graphicsresource.Graphics.Tables.Add(graphicslayer);
See Also:
Working with graphicsWorking with graphics and core classes
Working with Web tier graphics on the client
Working with layer formats