bugGNU Octave - Bugs: bug #67594, mapping-1.4.3: small circle...

 
 

bug #67594: mapping-1.4.3: small circle function argument validation

Submitter:  None
Submitted:  Wed 08 Oct 2025 06:27:20 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  philipnienhuis
Originator Name:  Ryan Powers Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * other
Operating System:  * Other Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Post a Comment

Add a New Comment Rich Markup
   

Discussion

Jump to the original submission

Wed 15 Oct 2025 06:23:07 PM UTC, comment #6: 

Thanks.
I'll set status back to "Confirmed" until I get an opportunity to work on it.

Philip Nienhuis <philipnienhuis>
Group Member
Mon 13 Oct 2025 01:02:18 PM UTC, comment #5: 

Glad to hear the patch was helpful. No credit needed. If I have the time to learn the BIST system before you get to it, I'll take a crack at making those updates as well.

Anonymous
Mon 13 Oct 2025 11:32:20 AM UTC, comment #4: 

I had a chance to try with Matlab r2024a, and indeed it produces the answers you predicted in comment #0.

Your patch seems fine, nice!

Would you like to be credited for the fix? if so, we'll need at minimum your name and if you don't mind your email address as well - the latter for when questions arise later on.

Then:
After having applied it turned out several BIST tests in scxsc.m are now in error. So there is some additional work to be done. Also, I think it would be nice to turn your examples in comment #0 into additional BISTs.
Fine if you'd rather have me tackle this.  But I can do that only later on as I have little opportunity for work on Octave ATM, between other assignments and personal things.  It's also quite a while ago that I was busy with these functions so it'll take some time before I have regained sufficient insight in exactly what to adapt where.

In addition I see that the help texts are a bit sloppy. But I'll fix those.

Philip Nienhuis <philipnienhuis>
Group Member
Thu 09 Oct 2025 02:30:35 PM UTC, comment #3: 


> I also found gcxsc doesn't have a radius check at all.

... for the small circle you mean.

BTW as you seem to be especially interested in these functions (you're the first to comment / provide a bug report on them):
Just for completeness, in patch #9974 there's some discussion on various subjects from the time these functions were developed (the latter by an anonymous contributor).

Philip Nienhuis <philipnienhuis>
Group Member
Wed 08 Oct 2025 10:01:45 PM UTC, comment #2: 

Ah, I didn't realize it would pick mine over the toolbox version. The fix for latitude appears to work as expected:


>> [lat, lon] = gcxsc(0, 0, 90, 0, 90, 90)
lat =
   0   0
lon =
     0   180

>> [lat, lon] = gcxsc(0, 0, 0, 90, 0, 90)
lat =
   0   0
lon =
     0   180

>> [lat, lon] = gcxsc(0, 0, 0, -90, 0, 90)
lat =
   0   0
lon =
   180     0

>> [lat, lon] = gcxsc(0, 0, 0, -90.00001, 0, 90)
error: gcxsc: sc latitude value(s) out of acceptable range [-90, 90]


My testing did reveal a further issue with the radius check. There's a misplaced close parentheses that makes the logic wrong in scxsc. I also found gcxsc doesn't have a radius check at all.

New patch attached corrects both functions to add or fix radius checks. Also fixed some minor indentation inconsistency.

(file #57707)

Anonymous
Wed 08 Oct 2025 09:42:06 PM UTC, comment #1: 

Thanks for the report, I'll have a look.

I'll see if I can use the competition's mapping toolbox for a check.

You can invoke your patched functions by putting them somewhere in a subdirectory and add that to the path - then the original functions will be shadowed.

Philip Nienhuis <philipnienhuis>
Group Member
Wed 08 Oct 2025 06:27:20 PM UTC, original submission:  

This unexpected error report pertains to the mapping toolbox (1.4.3) functions accepting small circles as inputs:

scxsc
gcxsc

1. (applies to both)

Small circle latitudes of ±90° (and ±pi/2 radians) are rejected as invalid, when they should be considered valid.

2. (applies to scxsc)

When the latitude is considered invalid scxsc reports the error incorrectly as an azimuth error.

Background

Small circle notation is a (latitude, longitude) pair representing the center of the circle, and an angular radius away from that point to the circle. An example that is accepted would be a small circle centered on latitude 0°, longitude 90°, with a radius of 90°. This is also a great circle passing through (0°, 0°, with an azimuth of 0°).

There is a validation step to check that the inputs to these functions are between ±90° (or ±pi/2 radians) exclusive. For a great circle, this is a correct check (there is a comment on the check pointing out that at those limit values, azimuth is undefined, and so it cannot be used to create a valid great circle). However, these values are acceptable for a small circle.

If one wants to represent a line of latitude as a small circle, the latitude for the center of the small circle must be ±90°. The gc2sc function, when given the equator as the great circle to convert, produces a correct result. The resulting small circle will be rejected by the small circle functions.

[lat, lon, rad] = gc2sc(0, 0, 90)
lat = -90
lon = 0
rad = 90


I have attached a patch that I believe corrects these behaviors. Unfortunately, I run Octave as a flatpak, and I don't know enough about that system to get the changeset loaded in to test it. Even though it is untested, I didn't want to submit this report without offering possible fixes.

Test

If someone has the MATLAB mapping toolbox available, it would be good to get confirmation that ±90° is accepted as a small circle latitude.

I believe the following two calls should exercise all the unexpected errors I found.

% Cross the equator as GC with the prime meridian as SC. Will
% fail in scxsc with "azimuth" error from the equator's SC
% representation (see above gc2sc)
[lat, lon] = gcxsc(0, 0, 90, 0, 90, 90)
% Should produce lat = [ 0 0 ], lon = [ 0 180 ]

% Cross the prime meridian as GC with the equator as SC. Will
% fail with latitude error from the SC input
[lat, lon] = gcxsc(0, 0, 0, 90, 0, 90)
% Should produce lat = [ 0 0 ], lon = [ 0 180 ]


Anonymous

 

Attached Files

Attached Files
file #57707:  small_circle_revised.patch added by None (3.2KiB - text/x-patch)
file #57706:  small_circle.patch added by None (2.9KiB - text/x-patch - Possible fixes to the issues described)

(Note: upload size limit is set to 16MiB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

 

Dependencies

This item does not depend on any other items.

No items depend on this one.

 

Mail Notification Carbon-Copy List

Carbon-Copy List
  • -email is unavailable- added by philipnienhuis (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    Votes

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    History

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-10-15 philipnienhuis StatusNeed Info Confirmed
    2025-10-13 philipnienhuis StatusIn Progress Need Info
    2025-10-12 philipnienhuis StatusNone In Progress
        Assigned toNone philipnienhuis
    2025-10-08 None Attached File- Added small_circle_revised.patch, #57707
    2025-10-08 philipnienhuis Operating SystemGNU/Linux Other
    2025-10-08 None Attached File- Added small_circle.patch, #57706

    Back to the top

    Powered by Savane 3.16.
    Corresponding source code