ArcObjects Library Reference (Geometry)  

ISpatialReferenceTolerance.SetDefaultXYTolerance Method

Sets the default cluster tolerance used to control point coalescing in the X and Y dimensions (the equivalent of 1 mm in the current spatial reference units).

[Visual Basic .NET]
Public Sub SetDefaultXYTolerance ( _
)
[C#]
public void SetDefaultXYTolerance (
);
[C++]
HRESULT SetDefaultXYTolerance(
void
);

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Remarks

SetDefaultXYTolerance establishes the default value for the XY tolerance, taking into account the current units of the spatial reference. Any established tolerance will not be changed automatically if the units of the spatial reference are changed. For a ProjectedCoordinateSystem or an UnknownCoordinateSystem, the default tolerance is 1 mm (expressed in the units of the spatial reference) or 2.0 * XYResolution, whichever is larger. For a GeographicCoordinateSystem, it is the angle subtending 1 mm at the equator, or 2.0 * XYResolution, whichever is larger.

The minimum allowable XYTolerance is 2.0 * XYResolution. 

If the value specified by SetDefaultXYTolerance is not greater than or equal to 2.0 * XYResolution, the XYTolerance will be set at 2.0 * XYResolution.

A file-based data source, such as shapefiles, CAD and SDC, that has an UnknownCoordinateSystem and that has an X coordinate data extent that falls between +/-400, will use a tolerance in degrees corresponding to 1mm along the equator (8.98315284119522E-09 degrees).

 

[C#]

    public void SetDefaultXYToleranceExample()
    {
        //The following code example creates a new projected coordinate system,
        //defines the domainextent and default resolution, and sets the default XYTolerance.

        // use activator class with SpatialReferenceEnvironment singleton
        Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
        System.Object obj = Activator.CreateInstance(factoryType);
        ISpatialReferenceFactory3 spatialReferenceFactory = obj as ISpatialReferenceFactory3;

        ISpatialReference spatialRef = spatialReferenceFactory.CreateSpatialReference(32610);
        ISpatialReference projectedCoordinateSystem = spatialReferenceFactory.CreateProjectedCoordinateSystem(32610);

        IControlPrecision2 controlPrecision = projectedCoordinateSystem as IControlPrecision2;
        controlPrecision.IsHighPrecision = true;

        ISpatialReferenceResolution spatialReferenceResolution = projectedCoordinateSystem as ISpatialReferenceResolution;
        spatialReferenceResolution.ConstructFromHorizon();
        ISpatialReferenceTolerance spatialReferenceTolerance = projectedCoordinateSystem as ISpatialReferenceTolerance;
        spatialReferenceTolerance.SetDefaultXYTolerance();
    }


[Visual Basic .NET]

        'The following code example creates a new projected coordinate system,
        'defines the domain extent and default resolution, and sets the default XYTolerance.
        Dim pSpatialReferenceFactory As ISpatialReferenceFactory3
        pSpatialReferenceFactory = New SpatialReferenceEnvironment
        Dim pSpatialReference As ISpatialReference
        pSpatialReference = pSpatialReferenceFactory.CreateProjectedCoordinateSystem(32610)

        Dim pControlPrecision As IControlPrecision2
        pControlPrecision = pSpatialReference
        pControlPrecision.IsHighPrecision = True

        Dim pSRRes As ISpatialReferenceResolution
        pSRRes = pSpatialReference
        pSRRes.ConstructFromHorizon()
        Dim pSRTolerance As ISpatialReferenceTolerance
        pSRTolerance = pSpatialReference

        pSRTolerance.SetDefaultXYTolerance()

See Also

ISpatialReferenceTolerance Interface

.NET Snippets

Make Spatial Reference

.NET Samples

Creating a toolbar of globe tools (Code Files: SpatialReference)

.NET Related Topics

Constructing a high- or low-precision spatial reference | Creating feature classes | How to import or export a spatial reference | Working with GeometryEnvironment