Changeset 15204 for trunk


Ignore:
Timestamp:
03/30/13 16:38:37 (12 years ago)
Author:
tbretz
Message:
Use some simplifications coming with the new C++ wrapper of libnova
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/InterpreterV8.cc

    r15172 r15204  
    1010
    1111#ifdef HAVE_NOVA
    12 #include <libnova/solar.h>
    13 #include <libnova/lunar.h>
    14 #include <libnova/transform.h>
     12#include "externals/nova.h"
    1513#endif
    1614
     
    16581656    const Time utc = args.Length()==0 ? Time() : Time(v/1000, v%1000);
    16591657
    1660     return Number::New(ln_get_lunar_disk(utc.JD()));
     1658    return Number::New(Nova::GetLunarDisk(utc.JD()));
    16611659}
    16621660
     
    16691667        return ThrowException(String::New("Argument must be a Date"));
    16701668
    1671     ln_hrz_posn hrz;
     1669    Nova::HrzPosn hrz;
    16721670    hrz.alt = 90-GetDataMember(args, "zd");
    16731671    hrz.az  =    GetDataMember(args, "az");
     
    16861684    const Time utc(v/1000, v%1000);
    16871685
    1688     ln_lnlat_posn obs;
    1689     obs.lng = -(17.+53./60+26.525/3600);
    1690     obs.lat =   28.+45./60+42.462/3600;
    1691 
    1692     ln_equ_posn equ;
    1693     ln_get_equ_from_hrz(&hrz, &obs, utc.JD(), &equ);
     1686    const Nova::EquPosn equ = Nova::GetEquFromHrz(hrz, utc.JD());
    16941687
    16951688    // -----------------------------
     
    17071700        return ThrowException(String::New("Argument must be a Date"));
    17081701
    1709     ln_equ_posn equ;
     1702    Nova::EquPosn equ;
    17101703    equ.ra  = GetDataMember(args, "ra")*15;
    17111704    equ.dec = GetDataMember(args, "dec");
     
    17241717    const Time utc(v/1000, v%1000);
    17251718
    1726     ln_lnlat_posn obs;
    1727     obs.lng = -(17.+53./60+26.525/3600);
    1728     obs.lat =   28.+45./60+42.462/3600;
    1729 
    1730     ln_hrz_posn hrz;
    1731     ln_get_hrz_from_equ(&equ, &obs, utc.JD(), &hrz);
     1719    const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(equ, utc.JD());
    17321720
    17331721    Handle<Value> arg[] = { Number::New(90-hrz.alt), Number::New(hrz.az), date };
     
    17401728        return ThrowException(String::New("toLocal must not be called with arguments."));
    17411729
    1742     ln_equ_posn equ;
     1730    Nova::EquPosn equ;
    17431731    equ.ra  = GetDataMember(args, "ra")*15;
    17441732    equ.dec = GetDataMember(args, "dec");
     
    17561744    const Time utc(v/1000, v%1000);
    17571745
    1758     ln_lnlat_posn obs;
    1759     obs.lng = -(17.+53./60+26.525/3600);
    1760     obs.lat =   28.+45./60+42.462/3600;
    1761 
    1762     ln_hrz_posn hrz;
    1763     ln_get_hrz_from_equ(&equ, &obs, utc.JD(), &hrz);
     1746    const Nova::HrzPosn hrz = Nova::GetHrzFromEqu(equ, utc.JD());
    17641747
    17651748    Handle<Value> arg[] = { Number::New(90-hrz.alt), Number::New(hrz.az), date };
     
    17851768    const Time utc(v/1000, v%1000);
    17861769
    1787     ln_equ_posn equ;
    1788     ln_get_lunar_equ_coords_prec(utc.JD(), &equ, 0.01);
     1770    const Nova::EquPosn equ = Nova::GetLunarEquCoords(utc.JD(), 0.01);
    17891771
    17901772    // ----------------------------
     
    18791861}
    18801862
    1881 Handle<Object> InterpreterV8::ConstructRiseSet(const Handle<Value> time, const ln_rst_time &rst, const bool &rc)
     1863Handle<Object> InterpreterV8::ConstructRiseSet(const Handle<Value> time, const Nova::RstTime &rst, const bool &rc)
    18821864{
    18831865    Handle<Object> obj = Object::New();
     
    19521934    const Time utc(v/1000, v%1000);
    19531935
    1954     ln_lnlat_posn obs;
    1955     obs.lng = -(17.+53./60+26.525/3600);
    1956     obs.lat =   28.+45./60+42.462/3600;
    1957 
    1958     // get Julian day from local time
    1959     const double JD = utc.JD();
     1936    Nova::LnLatPosn obs = Nova::ORM();
    19601937
    19611938    ln_rst_time sun;
    1962     const int rc = ln_get_solar_rst_horizon(JD-0.5, &obs, hrz, &sun);
     1939    const int rc = ln_get_solar_rst_horizon(utc.JD()-0.5, &obs, hrz, &sun);
    19631940    Handle<Object> rst = ConstructRiseSet(date, sun, rc);
    19641941    rst->Set(String::New("horizon"), Number::New(hrz));
     
    19841961    const Time utc(v/1000, v%1000);
    19851962
    1986     ln_lnlat_posn obs;
    1987     obs.lng = -(17.+53./60+26.525/3600);
    1988     obs.lat =   28.+45./60+42.462/3600;
    1989 
    1990     // get Julian day from local time
    1991     const double JD = utc.JD();
     1963    Nova::LnLatPosn obs = Nova::ORM();
    19921964
    19931965    ln_rst_time moon;
    1994     const int rc = ln_get_lunar_rst(JD-0.5, &obs, &moon);
     1966    const int rc = ln_get_lunar_rst(utc.JD()-0.5, &obs, &moon);
    19951967    Handle<Object> rst = ConstructRiseSet(date, moon, rc);
    19961968    return handle_scope.Close(rst);
Note: See TracChangeset for help on using the changeset viewer.