proj5 icon indicating copy to clipboard operation
proj5 copied to clipboard

EPSG ellipsoids

Open temeddix opened this issue 1 year ago • 5 comments

I hope this library supports EPSG coordinates.... then it would be so convenient. Sad to see this came to a halt for a while

temeddix avatar Aug 18 '23 17:08 temeddix

EPSG is a code for two things: an ellipsoid and a projection. You can define your own ellipsoid with custom values if you need:

https://docs.rs/proj5/latest/proj5/struct.Ellipsoid.html

and your own projection by implementing the ToLonLat and FromLonLat traits:

https://docs.rs/proj5/latest/proj5/trait.ToLonLat.html

https://docs.rs/proj5/latest/proj5/trait.FromLonLat.html

Predefined ellipsoids are WGS84, Bessel and others:

  AIRY_1830_ELLIPSOID | Airy (1830)
  AUSTRALIAN_1966_ELLIPSOID | Australian National (1966)
  BESSEL_1841_ELLIPSOID | Bessel (1841)
  CLARKE_1866_ELLIPSOID | Clarke (1866)
  CLARKE_1878_ELLIPSOID | Clarke (1878)
  CLARKE_1880_ELLIPSOID | Clarke (1880)
  EVEREST_1830_ELLIPSOID | Everest (1830)
  EVEREST_1967_MODIFIED_ELLIPSOID | Everest 1830 Modified (1967)
  EVEREST_1967_DEFINITION_ELLIPSOID | Everest 1830 (1967 Definition)
  GRS_1967_ELLIPSOID | GRS-67 (1967)
  GRS_1980_ELLIPSOID | GRS-80 (1979)
  HAYFORD_1910_ELLIPSOID | Hayford (1910)
  HELMERT_1906_ELLIPSOID | Helmert (1906)
  IERS_1989_ELLIPSOID | IERS (1989)
  IERS_2003_ELLIPSOID | IERS (2003)
  INTERNATIONAL_1924_ELLIPSOID | International (1924)
  KRASSOVSKY_1940_ELLIPSOID | Krassovsky (1940)
  MAUPERTUIS_1738_ELLIPSOID | Maupertuis (1738)
  NEW_INTERNATIONAL_1967_ELLIPSOID | New International (1967)
  PLESSIS_1817_ELLIPSOID | Plessis (1817)
  SOUTH_AMERICAN_1969_ELLIPSOID | South American (1969)
  WGS_1966_ELLIPSOID | WGS66 (1966)
  WGS_1972_ELLIPSOID | WGS-72 (1972)
  WGS_1984_ELLIPSOID | WGS-84 (1984)

Currently defined projections are MercatorSystem and UtmSystem and you can convert between the two.

fschutt avatar Aug 18 '23 21:08 fschutt

I'm trying to convert EPSG:5174(Bessel 1841) to WSG84. To my knowledge they use different ellipsoids, but in the code it was stated that 'Conversion between different ellipsoids will cause a panic'. May I ask you if this kind of operation is possible or not?

temeddix avatar Aug 19 '23 03:08 temeddix

How I got here is related to the limitations of proj crate right now.... that one isn't type safe, requires C dependencies that's very tedious to install on the system(which hinders the convenience or cargo), etc..... and I wanted to contribute on areas that I could on this project, at least on the docs or CRS presets.

temeddix avatar Aug 19 '23 03:08 temeddix

@temeddix Possible, but I don't know the math to do it. Technically you'd have ellipsoid A and ellipsoid B and you have the lon / lat coordinates relative to ellipsoid A, you'd need to reproject the coordinate to ellipsoid B.

https://github.com/fschutt/proj5/blob/54a1837b774ed1e694dc1a637e32d8d3a70ed3f6/src/lonlat_buf.rs#L22

I don't know the math to do it, though, the panic is currently commented out.

fschutt avatar Aug 19 '23 10:08 fschutt

@temeddix Use https://github.com/3liz/proj4rs instead, it's more maintained and also has support for transforms between ellipsoids.

fschutt avatar Aug 29 '23 08:08 fschutt