ESRI.ArcGIS.ADF.IMS
Projection Class
Members  Example  See Also 
ESRI.ArcGIS.ADF.IMS.Projection Namespace : Projection Class




Utility class for projecting geometry.

Syntax

Visual Basic (Declaration) 
<SerializableAttribute()>
Public Class Projection 
Visual Basic (Usage)Copy Code
Dim instance As Projection
C# 
[SerializableAttribute()]
public class Projection 

Example

This example projects two points within a Multipoint from geographic (WGS84) to Robinson. Once projected, the points or Multipoint may be displayed on a map which is set to the destination projection (Robinson in this case), used in a query on data in the destination projection, etc. The code assumes an existing MapView object.
C#Copy Code
// Get the connection object from the MapView 

ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection imsConnection = mapView.MapService.Connection; 

  

// Create a geometry object in decimal degrees (WGS84) - add points to a Multipoint 

ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint multiPt = new ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint(); 

ESRI.ArcGIS.ADF.IMS.Geometry.Point pt1 = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(-110.0, 34.0); 

ESRI.ArcGIS.ADF.IMS.Geometry.Point pt2 = new ESRI.ArcGIS.ADF.IMS.Geometry.Point(-75.0, 20.0); 

multiPt.Points.Add(pt1); 

multiPt.Points.Add(pt2); 

  

// Set spatial reference (degrees/WGS84) of the geometry we will project -- this is required 

multiPt.SpatialReference = new ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(4326); 

  

// Set up the destination spatial reference (Robinson) 

ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference spRef =  

    new ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(54030); 

  

// Create an Environment object using machine settings for culture 

ESRI.ArcGIS.ADF.IMS.Administration.Environment envir = 

    new ESRI.ArcGIS.ADF.IMS.Administration.Environment(true); 

  

// Project the geometry to Robinson projection 

ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint projectedMultiPt = (ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint) 

    ESRI.ArcGIS.ADF.IMS.Projection.Projection.Project(multiPt, spRef, imsConnection, envir); 

    
Visual BasicCopy Code
' Get the connection object from the MapView

Dim imsConnection As ESRI.ArcGIS.ADF.Connection.IMS.IMSServerConnection _

    = mapView.MapService.Connection



' Create a geometry object in decimal degrees (WGS84) - add points to a Multipoint

Dim multiPt As New ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint()

Dim pt1 As New ESRI.ArcGIS.ADF.IMS.Geometry.Point(-110.0, 34.0)

Dim pt2 As New ESRI.ArcGIS.ADF.IMS.Geometry.Point(-75.0, 20.0)

multiPt.Points.Add(pt1)

multiPt.Points.Add(pt2)



' Set spatial reference (degrees/WGS84) of the geometry we will project -- this is required

multiPt.SpatialReference = New ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(4326)



' Set up the destination spatial reference (Robinson)

Dim spRef As ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference = _

    New ESRI.ArcGIS.ADF.IMS.SpatialReference.SpatialReference(54030)



' Create an Environment object using machine settings for culture

Dim envir As New ESRI.ArcGIS.ADF.IMS.Administration.Environment(True)



' Project the geometry to Robinson projection

Dim projectedMultiPt As ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint = _

    CType (ESRI.ArcGIS.ADF.IMS.Projection.Projection.Project( _

       multiPt, spRef, imsConnection, envir), _

    ESRI.ArcGIS.ADF.IMS.Geometry.Multipoint)

Remarks

Geometry objects may be projected to a new SpatialReference using the methods in this class. The methods are all static (Shared), so that an instance of the class does not need to be created before using the methods.

Projected geometry objects will be of the same type as the input geometry type, except for Envelope. Unless a method is used with the returnEnvelope parameter set to true, the returned geometry will be Polygon. This is because projecting a rectangle to a different spatial reference transforms the sides of the rectangular envelope to curves. Setting returnEnvelope to true causes only the four corners to be projected and returned as an Envelope.

Inheritance Hierarchy

System.Object
   ESRI.ArcGIS.ADF.IMS.Projection.Projection

See Also

© 2010 All Rights Reserved.