-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LAEA projection odd handling of NaN #3596
Comments
Also, I'm pretty sure this line is the "problem": Lines 85 to 87 in f7e8883
And I noticed that NaN from x/y space (inverse transformation) produces NaN in degrees. |
I would say that handling of NaN or more generally non-finite input x,y coordinates is unspecified behavior currently in PROJ, and I'm not sure we need to specify it. This should be rather dealt on your side. |
Thanks for the quick response. I can understand that. I guess my only argument against that is consistency between the different projections and even the forward and inverse transformation of a single projection. The behavior being undefined is still an answer to this, but unfortunate for performance on my end. Related: #2376 I suppose a PR "fixing" the laea projection would not be accepted? |
I also noticed @kbevers's commit (kbevers@b606396) where mercator was rewritten but still "NaNs are properly handled". |
I'm not opposed to this being fixed, but this should be fixed somewhere higher in the chain than in each individual projection, conversion or transformation method. Probably in proj_trans() itself. |
Yeah, I suppose we've just been depending on the idea that any math on NaN should be producing a NaN. This is one of the few cases where the conditions just worked out toward a non-NaN result. |
I'm finally starting to look into this. I assume you all would like a test. Could you point me to a good spot to add the test(s)? Somewhere that has similar checks perhaps? Also, I ran the tests locally and I get a couple failures, is this expected?
|
test/gie/builtins.gie could be a potential host, but I'm not sure it accepts NaN coordinates currently. That might require extending src/apps/gie.cpp. Otherwise in test/unit/gie_self_tests.cpp
if run on master without any change, no that's not expected. Tests run fine on all our CI platforms. Maybe check that PROJ_NETWORK=ON is not set in your environment, as I suspect it could cause issues (just trying in my dev env, I see the same tests that fail for you fail for me when I define PROJ_NETWORK=ON) |
Yep, that was it. Thanks. I was building based on a conda-forge environment and the PROJ in there must have turned that on.
The docs at the top of this file say it is autogenerated or at least partially. Should I still modify that or should I put stuff in |
filed as #3599
ah yes, more_builtins.gie makes more sense
short answer is yes I guess. More at https://proj.org/apps/gie.html |
Example of problem
Pyproj example of the in-code issue:
Problem description
Short answer: LAEA projections convert NaN degrees to 0. Other projections (ex. mercator, LCC, etc) return NaN.
I've filed a bug with pyproj which is my primary way of using the PROJ library: pyproj4/pyproj#1239
I'm not familiar enough with the PROJ C API to quickly make an example in C so I tried using
cs2cs
, but as you can see above something weird happens with the formatting even though my understanding is that strtod should accept "NaN" to represent NaN.Expected Output
I expect projection transformations of NaN to return NaN on either side of the transformation (forward or inverse).
Environment Information
proj
):Rel. 9.0.0, March 1st, 2022
Installation method
The text was updated successfully, but these errors were encountered: