ArcGIS Explorer Component Help |
GeometryOperations..::.Project Method (Geometry, CoordinateSystem, GeographicTransformation) |
GeometryOperations Class Example See Also |
Assembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public static Geometry Project( Geometry inputGeometry, CoordinateSystem newCoordinateSystem, GeographicTransformation geographicTransformation ) |
Visual Basic (Declaration) |
---|
Public Shared Function Project ( _ inputGeometry As Geometry, _ newCoordinateSystem As CoordinateSystem, _ geographicTransformation As GeographicTransformation _ ) As Geometry |
Parameters
- inputGeometry
- Type: ESRI.ArcGISExplorer.Geometry..::.Geometry
A Geometry to copy and project.
- newCoordinateSystem
- Type: ESRI.ArcGISExplorer.Geometry..::.CoordinateSystem
The coordinate system to project to.
- geographicTransformation
- Type: ESRI.ArcGISExplorer.Geometry..::.GeographicTransformation
A transformation to account for a datum shift; the CoordinateSystem1 and CoordinateSystem2 properties should match the coordinate system of the inputGeometry and the newCoordinateSystem.
Return Value
A new Geometry of the same type as the inputGeometry, with the specified newCoordinateSystem.Remarks
Each Geometry has a specific CoordinateSystem which relates the coordinates of the geometry to locations on the earth. You can change a geometry to use a different CoordinateSystem by projecting it. All geometries drawn on the MapDisplay in ArcGIS Explorer automatically draw using the coordinate system of the display - this includes the geometries which are used to draw Graphics and all types of MapItem - you do not need to add any code for these items to be projected correctly.
However, if you wish to interact with other systems which require location or geometry input or output in a specific coordinate system, you can use the Project method in order to perform this work.
This overload of the Project method allows you to specify a particular GeographicTransformation to apply during the project operation in order to account for a difference in datum between the old and new CoordinateSystems; for more information, see the GeographicTransformation class.
Examples
// Create a Point at Greenwich, UK. By default new Geometries have the WGS 1984 geographical coordinate system. ESRI.ArcGISExplorer.Geometry.Point projectPoint = new ESRI.ArcGISExplorer.Geometry.Point(0, 51.4791); // Create an instance of the CoordinateSystem we want to project the Point into. CoordinateSystem projectInto = CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid; // Retrieve suitable transformations between the two coordinate systems. System.Collections.Generic.IList<GeographicTransformation> suitableTrans = GeographicTransformation.GetTransformations (projectPoint.CoordinateSystem, projectInto); ESRI.ArcGISExplorer.Geometry.Point outputPoint = null; if (suitableTrans.Count > 0) { // Could display a list of suitable transformations to the user for selection. // For brevity here, simply pick the first suitable transformation. GeographicTransformation geoT = suitableTrans[0]; // Project the point using the selected transformation. Cast back to a Point - Project does // not change the type of Geometry. outputPoint = GeometryOperations.Project(projectPoint, projectInto, geoT) as ESRI.ArcGISExplorer.Geometry.Point; } else { // If no transformations are returned, the most likely reason is that there is no // transformation required between the input and output systems, as they have the // same underlying geographic coordinate system. This is not the case for the systems // specified above but may apply to other coordinate system pairs. // In this case, perform the projection without a transformation. outputPoint = GeometryOperations.Project(projectPoint, projectInto) as ESRI.ArcGISExplorer.Geometry.Point; }
' Create a Point at Greenwich, UK. By default new Geometries have the WGS 1984 geographical coordinate system. Dim projectPoint As New ESRI.ArcGISExplorer.Geometry.Point(0, 51.4791) ' Create an instance of the CoordinateSystem we want to project the Point into. Dim projectInto As CoordinateSystem = CoordinateSystem.ProjectedCoordinateSystems.NationalGrids.Europe.BritishNationalGrid ' Retrieve suitable transformations between the two coordinate systems. Dim suitableTrans As System.Collections.Generic.IList(Of GeographicTransformation) = GeographicTransformation.GetTransformations(projectPoint.CoordinateSystem, projectInto) Dim outputPoint As ESRI.ArcGISExplorer.Geometry.Point = Nothing If suitableTrans.Count > 0 Then ' Could display a list of suitable transformations to the user for selection. ' For brevity here, simply pick the first suitable transformation. Dim geoT As GeographicTransformation = suitableTrans(0) ' Project the point using the selected transformation. Cast back to a Point - Project does ' not change the type of Geometry. outputPoint = GeometryOperations.Project(projectPoint, projectInto, geoT) Else ' If no transformations are returned, the most likely reason is that there is no ' transformation required between the input and output systems, as they have the ' same underlying geographic coordinate system. This is not the case for the systems ' specified above but may apply to other coordinate system pairs. ' In this case, perform the projection without a transformation. outputPoint = GeometryOperations.Project(projectPoint, projectInto) End If