busstoptaktik / geodesy

Rust geodesy
Apache License 2.0
66 stars 6 forks source link

Bug: tmerc operation returning incorrect results #59

Closed Rennzie closed 1 year ago

Rennzie commented 1 year ago

I've been testing things with a EPSG:27700 (BNG) to EPSG:3857 (webmerc) pipeline and the round trip result for the tmerc operation is incorrect.

# Full pipeline roundtrip
echo 544748. 258372. | cargo run --features binary --bin kp -- "enu:in | tmerc inv lat_0=49 lon_0=-2 k_0=0.9996012717 x_0=400000 y_0=-100000 ellps=airy | webmerc lat_0=0 lon_0=0 x_0=0 y_0=0 ellps=WGS84 | enu:out" --roundtrip

-190686. 5461518. 0.. NaN

# tmerc only roundtrip
echo 544748. 258372.| cargo run --features binary --bin kp -- "enu:in | tmerc inv lat_0=49 lon_0=-2 k_0=0.9996012717 x_0=400000 y_0=-100000 ellps=airy | gis:out" --roundtrip

-190686. 5461518. 0. NaN

# tmerc Cart -> Geo
echo 544748. 258372. | cargo run --features binary --bin kp -- "enu:in | tmerc inv lat_0=49 lon_0=-2 k_0=0.9996012717 x_0=400000 y_0=-100000 ellps=airy | gis:out

0. 52. 0. NaN  # What I expect

# tmerc Geo -> Cart - Incorrect result
echo 0.118 52. | cargo run --features binary --bin kp -- "gis:in | tmerc  lat_0=49 lon_0=-2 k_0=0.9996012717 x_0=400000 y_0=-100000 ellps=airy | enu:out"

354062. 5719890. 0. NaN # NOT what I expect. Should be 544748. 258372.

I've tested this with kp and with geodesy-wasm which implements the Minimal context internally.

Possibly useful pointers:

The last point I think suggests the tmerc FWD operation is producing incorrect results?


Tested on latest main as of 18/08/2023. I've truncated all results to integers for readability

busstoptaktik commented 1 year ago

Thanks for reporting this - I believe it is now corrected in de9e129

Rennzie commented 1 year ago

Awesome. Thanks for fixing. All working on my end now!

busstoptaktik commented 1 year ago

Awesome - thanks for the feedback, and sorry for taking 3 days to respond: I was mostly offline during the weekend, and did not see your bug report until monday morning

Rennzie commented 1 year ago

Not a problem in the slightest 😄