ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Core.DeviceLocation Namespace / SerialPortDeviceLocationSource Class / GetSpatialReference Method
Example

In This Topic
    GetSpatialReference Method (SerialPortDeviceLocationSource)
    In This Topic
    Returns the spatial coordinate system the coordinates will be emitted from a local device such as GPS/GNSS. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Overrides Function GetSpatialReference() As SpatialReference
    public override SpatialReference GetSpatialReference()

    Return Value

    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run
    Example
    Get Current Device Location Source and Properties
    {
        // Check if a device is connected
        bool isConnected = DeviceLocationService.Instance.IsDeviceConnected();
        if (!isConnected)
            return; // no device connected
                    // Get the current device location source
        var src = DeviceLocationService.Instance.GetSource();
        // Check if the source is a SerialPortDeviceLocationSource
        //Set values for the SerialPortDeviceLocationSource
        if (src is SerialPortDeviceLocationSource serialPortSrc)
        {
            var port = serialPortSrc.ComPort;
            var antennaHeight = serialPortSrc.AntennaHeight;
            var dataBits = serialPortSrc.DataBits;
            var baudRate = serialPortSrc.BaudRate;
            var parity = serialPortSrc.Parity;
            var stopBits = serialPortSrc.StopBits;
    
            // retrieving spatial reference needs the MCT
            var sr = await QueuedTask.Run(() =>
            {
                return serialPortSrc.GetSpatialReference();
            });
    
        }
        //Get current device location properties being used.
        var dlProps = DeviceLocationService.Instance.GetProperties();
        var accuracy = dlProps.AccuracyThreshold;
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also