About the Creating a toolbar of globe tools Sample
[C#]
SpatialReference.cs
using ESRI.ArcGIS.Geometry; namespace GlobeGraphicsToolbar { public class SpatialReferenceFactory { private ISpatialReference _spatialReference; public SpatialReferenceFactory(int xyCoordinateSystem) { _spatialReference = GetSpatialReference(xyCoordinateSystem); } private ISpatialReference GetSpatialReference(int xyCoordinateSystem) { const bool IsHighPrecision = true; ISpatialReference spatialReference; ISpatialReferenceFactory3 spatialReferenceFactory = new SpatialReferenceEnvironmentClass(); spatialReference = spatialReferenceFactory.CreateSpatialReference(xyCoordinateSystem); IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2; controlPrecision.IsHighPrecision = IsHighPrecision; ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution; spatialReferenceResolution.ConstructFromHorizon(); spatialReferenceResolution.SetDefaultXYResolution(); spatialReferenceResolution.SetDefaultZResolution(); spatialReferenceResolution.SetDefaultMResolution(); ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance; spatialReferenceTolerance.SetDefaultXYTolerance(); spatialReferenceTolerance.SetDefaultZTolerance(); spatialReferenceTolerance.SetDefaultMTolerance(); return spatialReference; } public ISpatialReference SpatialReference { get { return _spatialReference; } } } }
[Visual Basic .NET]
SpatialReference.vb
Imports Microsoft.VisualBasic Imports System Imports ESRI.ArcGIS.Geometry Namespace GlobeGraphicsToolbar Public Class SpatialReferenceFactory Private _spatialReference As ISpatialReference Public Sub New(ByVal xyCoordinateSystem As Integer) _spatialReference = GetSpatialReference(xyCoordinateSystem) End Sub Private Function GetSpatialReference(ByVal xyCoordinateSystem As Integer) As ISpatialReference Const IsHighPrecision As Boolean = True Dim spatialReference As ISpatialReference Dim spatialReferenceFactory As ISpatialReferenceFactory3 = New SpatialReferenceEnvironmentClass() spatialReference = spatialReferenceFactory.CreateSpatialReference(xyCoordinateSystem) Dim controlPrecision As IControlPrecision2 = TryCast(spatialReference, IControlPrecision2) controlPrecision.IsHighPrecision = IsHighPrecision Dim spatialReferenceResolution As ISpatialReferenceResolution = TryCast(spatialReference, ISpatialReferenceResolution) spatialReferenceResolution.ConstructFromHorizon() spatialReferenceResolution.SetDefaultXYResolution() spatialReferenceResolution.SetDefaultZResolution() spatialReferenceResolution.SetDefaultMResolution() Dim spatialReferenceTolerance As ISpatialReferenceTolerance = TryCast(spatialReference, ISpatialReferenceTolerance) spatialReferenceTolerance.SetDefaultXYTolerance() spatialReferenceTolerance.SetDefaultZTolerance() spatialReferenceTolerance.SetDefaultMTolerance() Return spatialReference End Function Public ReadOnly Property SpatialReference() As ISpatialReference Get Return _spatialReference End Get End Property End Class End Namespace