Changeset 14690 for trunk/FACT++/src


Ignore:
Timestamp:
11/25/12 12:44:56 (12 years ago)
Author:
tbretz
Message:
Bettr support for circumpolar objects added 'isUp' proprty to th object returned by th horizon functions.
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

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

    r14689 r14690  
    15191519}
    15201520
    1521 Handle<Object> InterpreterV8::ConstructRiseSet(const Handle<Value> time, const ln_rst_time &rst)
     1521Handle<Object> InterpreterV8::ConstructRiseSet(const Handle<Value> time, const ln_rst_time &rst, const bool &rc)
    15221522{
    15231523    Handle<Object> obj = Object::New();
    15241524    obj->Set(String::New("time"), time, ReadOnly);
    1525     if (rst.transit<0)
     1525
     1526    const uint64_t v = uint64_t(time->NumberValue());
     1527    const double jd = Time(v/1000, v%1000).JD();
     1528
     1529    const bool isUp = rc>0 ||
     1530        (rst.rise<rst.set && (jd>rst.rise && jd<rst.set)) ||
     1531        (rst.rise>rst.set && (jd<rst.set  || jd>rst.rise));
     1532
     1533    obj->Set(String::New("isUp"), Boolean::New(rc>=0 && isUp), ReadOnly);
     1534
     1535    if (rc!=0)
    15261536        return obj;
    15271537
     
    15331543
    15341544    obj->Set(String::New("rise"), rise, ReadOnly);
    1535     obj->Set(String::New("set"),  set, ReadOnly);
     1545    obj->Set(String::New("set"), set, ReadOnly);
    15361546    obj->Set(String::New("transit"), trans, ReadOnly);
     1547
    15371548    return obj;
    15381549}
     
    15581569        if (str==string("civil").substr(0, str.length()))
    15591570            hrz = LN_SOLAR_CIVIL_HORIZON;
    1560         if (str==string("nautic").substr(0, str.length()))
     1571        if (str==string("nautical").substr(0, str.length()))
    15611572            hrz = LN_SOLAR_NAUTIC_HORIZON;
    15621573        if (str==string("astronomical").substr(0, str.length()))
     
    15831594
    15841595    ln_rst_time sun;
    1585     const bool rc = ln_get_solar_rst_horizon(JD-0.5, &obs, hrz, &sun);
    1586     if (rc)
    1587         sun.transit = -1;
    1588 
    1589     Handle<Object> rst = ConstructRiseSet(date, sun);
     1596    const int rc = ln_get_solar_rst_horizon(JD-0.5, &obs, hrz, &sun);
     1597    Handle<Object> rst = ConstructRiseSet(date, sun, rc);
    15901598    rst->Set(String::New("horizon"), Number::New(hrz));
    15911599    return handle_scope.Close(rst);
     
    16151623
    16161624    ln_rst_time moon;
    1617     const bool rc = ln_get_lunar_rst(JD-0.5, &obs, &moon);
    1618 
    1619     if (rc)
    1620         moon.transit = -1;
    1621 
    1622     Handle<Object> rst = ConstructRiseSet(date, moon);
     1625    const int rc = ln_get_lunar_rst(JD-0.5, &obs, &moon);
     1626    Handle<Object> rst = ConstructRiseSet(date, moon, rc);
    16231627    return handle_scope.Close(rst);
    16241628};
  • trunk/FACT++/src/InterpreterV8.h

    r14689 r14690  
    105105    static v8::Handle<v8::Value> MoonHorizon(const v8::Arguments &args);
    106106    static v8::Handle<v8::Value> SunHorizon(const v8::Arguments &args);
    107     static v8::Handle<v8::Object> ConstructRiseSet(const v8::Handle<v8::Value>, const ln_rst_time &);
     107    static v8::Handle<v8::Object> ConstructRiseSet(const v8::Handle<v8::Value>, const ln_rst_time &, const bool &);
    108108#endif
    109109
Note: See TracChangeset for help on using the changeset viewer.