radcheb / Adhan

High precision prayer time library
MIT License
13 stars 4 forks source link

how to get param from method? #12

Closed Cyrillius closed 4 years ago

Cyrillius commented 7 years ago

Hello! I want to retrieve the paramaters of a corresponding methods. I have done something like this:

calculation_method method;
switch(Factory::methodFunction.getMethod())                                         // list of supported methods
{
    case 1: 
        method = EGYPTIAN;
        break;                              
    case 2: 
        method = KARACHI;
        break;                          
    case 3: 
        method = GULF; 
        break;                      
    case 4: 
        method = UMM_AL_QURA;
        break;                          
    case 5: 
        method = QATAR; 
        break;                          
    case 6: 
        method = MOON_SIGHTING_COMMITTEE;
        break;              
    case 7:                                                                 // Personal method selected
        method = OTHER;
        conf = new_calculation_parameters(Factory::methodFunction.getFajr(), 
        Factory::methodFunction.getIsha());
        conf.highLatitudeRule = MIDDLE_OF_THE_NIGHT;
        // Get the Asr ratio
        conf.madhab = (madhab_t) Factory::methodFunction.getAsr();          
        conf.highLatitudeRule = (high_latitude_rule_t) Factory::methodFunction.getHighLat();                
        // Get the High Latitude calculation method 
        break;
    default: break;
}

But it's incomplete...

I need a method like this:

calculation_parameters_t *calculation_parameters = getParameters(&method);

How can I perform this ?

radcheb commented 7 years ago

There is already a similar function:

src/calculation_parameters.c:59 calculation_parameters_t getParameters(calculation_method calculation_method1); Full body:

calculation_parameters_t getParameters(calculation_method calculation_method1){
    calculation_method default_method = OTHER;
    switch(calculation_method1){
        case MUSLIM_WORLD_LEAGUE:
            return new_calculation_parameters3(18.0, 17.0, calculation_method1);
        case EGYPTIAN:
            return new_calculation_parameters3(20.0, 18.0, calculation_method1);
        case KARACHI:
            return new_calculation_parameters3(18.0, 18.0, calculation_method1);
        case UMM_AL_QURA:
            return new_calculation_parameters4(18.5, 90, calculation_method1);
        case GULF:
            return new_calculation_parameters4(19.5, 90, calculation_method1);
        case MOON_SIGHTING_COMMITTEE:
            return new_calculation_parameters3(18.0, 18.0, calculation_method1);
        case NORTH_AMERICA:
            return new_calculation_parameters3(15.0, 15.0, calculation_method1);
        case KUWAIT:
            return new_calculation_parameters3(18.0, 17.5, calculation_method1);
        case QATAR:
            return new_calculation_parameters4(18.0, 90, calculation_method1);
        case OTHER:
            return new_calculation_parameters3(0, 0, calculation_method1);
        default:
            return new_calculation_parameters3(0, 0, default_method);
    }

Is this ok @Cyrillius ?

Cyrillius commented 6 years ago

The implementation respect this guidance. But I still have a problem with the result (already discussed via e-mail) . here is the problem: astrolab - 6

radcheb commented 6 years ago

Je pense qu'il y a un paramètre différent avec Muslim pro. Ce code:

    coordinates_t coordinates = {48.853409, 2.348800};
    calculation_method method = OTHER;
    calculation_parameters_t calculation_parameters = new_calculation_parameters(12.0, 12.0);
    calculation_parameters.highLatitudeRule = TWILIGHT_ANGLE;
    time_t calculation_time = resolve_time_2(2017, 11, 5);
    prayer_times_t prayer_times = new_prayer_times2(&coordinates, calculation_time, &calculation_parameters);

Renvoie les bons horaires:

 Date        Fajr        Sunrise     Dhuhr       Asr         Maghrib     Ishaa
 11/05/17    05:33AM     06:44AM     11:35AM     01:58PM     04:24PM     05:35PM

Ce qui correspond aux résultat de muslim pro. Mais si je change le madhab l'horaire de l'Asr change:

    coordinates_t coordinates = {48.853409, 2.348800};
    calculation_method method = OTHER;
    calculation_parameters_t calculation_parameters = new_calculation_parameters(12.0, 12.0);
    calculation_parameters.highLatitudeRule = TWILIGHT_ANGLE;
    calculation_parameters.madhab = HANAFI;

    time_t calculation_time = resolve_time_2(2017, 11, 5);
    prayer_times_t prayer_times = new_prayer_times2(&coordinates, calculation_time, &calculation_parameters);

Je trouve exactement comme vous:

 Date        Fajr        Sunrise     Dhuhr       Asr         Maghrib     Ishaa
 11/05/17    05:33AM     06:44AM     11:35AM     02:37PM     04:24PM     05:35PM

Pourriez vous reteser ?

Cyrillius commented 6 years ago

Oui je fais le test lundi et je vous tiens au courant. Si on utilise l'application payante que je crois que vous possédez le même problème persiste? Ca vient peut-être de Muslim Pro ..

Cyrillius commented 6 years ago

Alors j'ai fait le test et effectivement lorsque le madhab n'est pas configuré à Hanafi j'ai partout quelques minutes de différence. Avez-vous pu tester avec l'application payantede iphone? En tout cas avec ce site le problème persiste: https://www.islamicfinder.org/prayer-times/

Je suppose donc que c'est plutôt un problème de la librairie des prières avec le madhab

radcheb commented 6 years ago

J'ai testé avec islamicfinder et c'est le mêm résultat: screenshot from 2018-01-24 13-43-52_edited