hilld13 / COMP2160Project

0 stars 0 forks source link

Ephemeris Library #16

Closed hilld13 closed 3 years ago

hilld13 commented 3 years ago

https://github.com/singulariti-tech/ephemeris

hilld13 commented 3 years ago

https://github.com/AaronNGray/AndroidSwissEphemerisExample http://www.th-mack.de/international/download/index.html

hilld13 commented 3 years ago

I have been working with the first library set for ephemeris calculations, and I'm getting a hang of how to use it. I think I may be able to import the library into a project, but I will test it with an unrelated project first.

hilld13 commented 3 years ago

oh boy. That first library that I've been working with is a royal pain to integrate. It uses Apache Maven, which seems to be more trouble than I anticipated. The second one is far easier to import. It's really just a matter of putting the jar file into apps/libs and adding it as a library.

I'm checking the data given by the example program, but I think this is the library we'll use. It also has a much simpler interface to work with.

hilld13 commented 3 years ago

Okay. The second library is a lot easier to work with and bring into the project. I also have figured out how to put the current time into it and am working on the location.

hilld13 commented 3 years ago

The ephemeris library returns the Right Ascension and Declination. These values are relative to the earth, not to the observer. There is a method to convert RA and Decl to Azimuth and Elevation.

The ephemeris library uses the following information to calculate the position of the heavenly body:

  1. Time and Date
  2. Location

I am able to use the following code to feed the current time and date into the library to calculate the current position of the body:

    // This extracts the date and time from the calendar
    Calendar cal = Calendar.getInstance();
    int t_second = cal.get(Calendar.SECOND);
    int t_minute = cal.get(Calendar.MINUTE);
    int t_hour = cal.get(Calendar.HOUR_OF_DAY);
    int day = cal.get(Calendar.DATE);
    int month = cal.get(Calendar.MONTH) + 1;
    int year = cal.get(Calendar.YEAR);
    double hour = t_hour + (t_minute / 60.) + (t_second / 3600.);

    // This sets the date and time for the library to use
    SweDate sd = new SweDate(year, month, day, hour);

Extracting the current user location is more of a challenge. I am reading the documentation, but it is not intuitive and I don't understand what is happening yet. The only statements I have right now are:

Class level:
    private Location location = new Location(GPS_PROVIDER);
    private double longitude;
    private double latitude;

public void getLatLong(View view) {
        longitude = location.getLongitude();
        latitude = location.getLatitude();
        ....

The problem is that the returned values are 0.0. I don't know if the problem is the emulator or implementation. I suspect the latter.

hilld13 commented 3 years ago

Forgot to note, I'm working with the Location Manager to get the location.

hilld13 commented 3 years ago

So, I've been working on getting lat and long from the GPS, and I'm kinda tired of trying. The documentation and guides do not explain what is happening and are not helping. I'm going to move back to dealing with the ephemeris libraries and getting the azimuth and elevation calculations out of the library instead of right ascension and declination.

hilld13 commented 3 years ago

So, my testing of the epheremis library is going as well as can be expected.

My test code no longer crashes, I no longer get errors from the ephemeris data files, but I also don't get good data out as far as I can tell.

hilld13 commented 3 years ago

Data from the calculator is good. I have moved these calculations into a new class called EphemerisCalculatorUtility. They can be called as static methods.

public static SweDate timeNow();

public static void calcAzEl(Context context, int planet, SweDate sd, double latitude, double longitude, double[] azel); {
    /*
     *  we have to pass the context in from the caller. Just add "getApplicationContext()" to the argument for context.
     *  planet is one of the SweConst planets. eg, SweConst.SE_MARS
     *  SweDate sd is the date and time SweDate Object. I create a SweDate object called sd in the calling function, then set sd=EphemerisCalculatorUtility.timeNow() .
     *  latitude and longitude is that of the observer
     *  azel is a 4 element double array. Azimuth, Elevation, Right Ascension, Declination
     *  azel is where the results are stored.
     *
     * An example of a call to this function:
     * EphemerisCalculatorUtility.calcAzEl(getApplicationContext(), SweConst.SE_MARS, EphemerisCalculatorUtility.timeNow(), 49.1, -122.9, azelResultArray);
     */