I have a Garmin Edge 1030. When I am riding a course, the data field Dist. to Next shows the remaining distance to the next course point (situation 1). When I am riding off course, this data field shows a value that I think is the smallest distance between my current location and the nearest point on the course (situation 2). There is no documentation on the behavior of situation 2 in the Edge 1030 manual, but from experience, I believe that this is indeed the case. When I am riding off course, the value in this field decreases as I am nearing the course, and becomes 0 when I am back on course.
According to the API documentation, the attribute offCourseDistance in class Toybox.Activity.Info contains the distance to the nearest point on the current course in meters. Therefore, I assume that this attribute contains the value that is displayed in the data field Dist. to Next when I am riding off course (situation 2). I have tested this with a data field that shows info.offCourseDistance (in fact, it logs info.offCourseDistance with a System.println statement). However, the value of offCourseDistance is always null. It is even null when I am riding a course and I deliberately go off course. In this case, the data field Dist. to Next shows the distance between my location and the nearest point on the course, and I expected info.offCourseDistance to contain the same value. But obviously it does not.
Is this a bug? Is this intended behavior? If so, when does offCourseDistance have a non-null value? Does it matter if the Off Course Warnings setting on the Edge is on or off?
(As a side note, the API documentation is sometimes very minimal. For example, it would be useful if the documentation on e.g. the offCourseDistance attribute indicated when the value equals 0.0, and when the value equals null (for example, if there is no course, or whatever). The simulator does not help in these cases, in the simulator offCourseDistance is always 0. The simulator does not simulate the Edge 1030 in this case.
The lack of useful documentation is not limited to offCourseDistance. For example, from trial and error I have learned that info.elapsedDistance equals null when the timer on my Edge is not active, but info.timerTime equals 0 in this case. I am sure that there is a good reason for elapsedDistance to be null instead of 0 and for timerTime to be 0 instead of null, but I cannot think of one. Documentation on the values of attributes that a developer can expect in certain situations would be a great improvement.)