[ 
https://issues.apache.org/jira/browse/SIS-537?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Emmanuel Giasson updated SIS-537:
---------------------------------
    Description: 
The Oblique Stereographic transform projects just fine in forward, but the 
reverse transform offset almost half the longitudes by nearly 180 degrees. 
h2. Bug location and suggested fix

Problem seems to be in 
{{org/apache/sis/referencing/operation/projection/ObliqueStereographic.java}}

method {{inverseTransform(...)}}

{{    ...}}

{{    final double i = atan(x / (h + y));}}
{{    final double j = atan(x / (g - y)) - i;}}
{{    ...}}
{{    final double λ = j + 2*i;}}

EPSG Guidance notes (for instance, p.71 of 
[https://www.iogp.org/wp-content/uploads/2019/09/373-07-02.pdf)] uses atan2 
instead of atan, which effectively fixes the +/- 180 degrees issue in this 
case. Actually, it's not exactly 180 degrees since it is possible for {{i}} to 
be correct with either atan or atan2, and only for {{j}} to be 180 degrees off. 
h2. To reproduce

With the following transformation, project POINT(30 45) then reverse project. 
Result is POINT(-149.84855267371876 45.000000000000014) but should be near the 
original point instead.

Param_MT["Oblique Stereographic",
  Parameter["semi_major", 6378137.0, Unit["metre", 1]],
  Parameter["semi_minor", 6356752.314245179, Unit["metre", 1]],
  Parameter["Latitude of natural origin", 45.0, Unit["degree", 
0.017453292519943295]],
  Parameter["Longitude of natural origin", -70.0, Unit["degree", 
0.017453292519943295]]]

  was:
The Oblique Stereographic transform projects just fine in forward, but the 
reverse transform offset almost half the longitudes by nearly 180 degrees. 
h2. Bug location and suggested fix

Problem seems to be in 
{{org/apache/sis/referencing/operation/projection/ObliqueStereographic.java}}

method {{inverseTransform(...)}}

{{    ...}}

{{    final double i = atan(x / (h + y));}}
{{    final double j = atan(x / (g - y)) - i;}}
{{    ...}}
{{    final double λ = j + 2*i;}}

EPSG Guidance notes (for instance, p.71 of 
[https://www.iogp.org/wp-content/uploads/2019/09/373-07-02.pdf)] uses atan2 
instead of atan, which effectively fixes the +/- 180 degrees issue in this 
case. Actually, it's not exactly 180 degrees since it is possible for {{i}} to 
be correct with either atan or atan2, and only for {{j}} to be 180 degrees off. 
h2. To reproduce

With the following transformation, project POINT(30 45) then reverse project. 
Result is POINT(-149.84855267371876 45.000000000000014)

Param_MT["Oblique Stereographic",
  Parameter["semi_major", 6378137.0, Unit["metre", 1]],
  Parameter["semi_minor", 6356752.314245179, Unit["metre", 1]],
  Parameter["Latitude of natural origin", 45.0, Unit["degree", 
0.017453292519943295]],
  Parameter["Longitude of natural origin", -70.0, Unit["degree", 
0.017453292519943295]]]


> Oblique Stereographic: Wrong longitude in reverse transform + suggested fix 
> ----------------------------------------------------------------------------
>
>                 Key: SIS-537
>                 URL: https://issues.apache.org/jira/browse/SIS-537
>             Project: Spatial Information Systems
>          Issue Type: Bug
>          Components: Referencing
>    Affects Versions: 1.1
>            Reporter: Emmanuel Giasson
>            Priority: Major
>
> The Oblique Stereographic transform projects just fine in forward, but the 
> reverse transform offset almost half the longitudes by nearly 180 degrees. 
> h2. Bug location and suggested fix
> Problem seems to be in 
> {{org/apache/sis/referencing/operation/projection/ObliqueStereographic.java}}
> method {{inverseTransform(...)}}
> {{    ...}}
> {{    final double i = atan(x / (h + y));}}
> {{    final double j = atan(x / (g - y)) - i;}}
> {{    ...}}
> {{    final double λ = j + 2*i;}}
> EPSG Guidance notes (for instance, p.71 of 
> [https://www.iogp.org/wp-content/uploads/2019/09/373-07-02.pdf)] uses atan2 
> instead of atan, which effectively fixes the +/- 180 degrees issue in this 
> case. Actually, it's not exactly 180 degrees since it is possible for {{i}} 
> to be correct with either atan or atan2, and only for {{j}} to be 180 degrees 
> off. 
> h2. To reproduce
> With the following transformation, project POINT(30 45) then reverse project. 
> Result is POINT(-149.84855267371876 45.000000000000014) but should be near 
> the original point instead.
> Param_MT["Oblique Stereographic",
>   Parameter["semi_major", 6378137.0, Unit["metre", 1]],
>   Parameter["semi_minor", 6356752.314245179, Unit["metre", 1]],
>   Parameter["Latitude of natural origin", 45.0, Unit["degree", 
> 0.017453292519943295]],
>   Parameter["Longitude of natural origin", -70.0, Unit["degree", 
> 0.017453292519943295]]]



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to