nsat / jspredict

A Javascript port of the popular predict satellite tracking library
Other
50 stars 15 forks source link

units of longitude in APIs #11

Open yxiao1996 opened 2 years ago

yxiao1996 commented 2 years ago

Hello,

Thanks for the amazing library! I'm curious what's the unit for the longitude field in the API signatures.

The document mentions the following:

qth = 3 element array [latitude (degrees), longitude (degrees), altitude (km)]

However, I'm not sure should the longitude field is east longitude or west longitude. Upon my experiment, it looks like east longitude for me. Could you please help me confirm this? Also, could you please add this to the documentation?

Thanks and happy holiday, Yu

thkruz commented 2 years ago

It is relying on the eciToGeodetic function in satellite.js which is bound to +/- pi (https://github.com/shashwatak/satellite-js/blob/1e6c4f0d14de5abab0d52b91a27b70028a0a0221/src/transforms.js)

let longitude = Math.atan2(eci.y, eci.x) - gmst;
  while (longitude < -pi) {
    longitude += twoPi;
  }
  while (longitude > pi) {
    longitude -= twoPi;
  }

If you look at (https://github.com/nsat/jspredict/blob/aef0b170ca46ccfb61572219c11f917ca48fa800/jspredict.js) you can see that there is a second attempt to bind it to +/- 180 degrees implying the author expected E and W

  _boundLongitude: function(longitude) {
      while (longitude < -180) {
        longitude += 360;
      }
      while (longitude > 180) {
        longitude -= 360;
      }
      return longitude
    }
yxiao1996 commented 2 years ago

Hi Theodore,

Thanks for replying! Apology for my terrible geography, but my question is actually quite simple, let me use an example. I'm trying to predict pass overs of a satellite over Hong Kong, and I'm verifying the output of jspredict using https://www.amsat.org/track/.

In this web tool I got to choose whether the longitude is based on East or West. For Hong Kong, I will put in 114 degree and East. On the other hand, I don't get a choice between East and West in jspredict's API, so I'm wondering what's the default.

Thanks, Yu