示例#1
0
bool SynscanDriver::Goto(double ra, double dec)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    TargetRA = ra;
    TargetDE = dec;

    if (isSimulation())
        return true;

    // INDI is JNow. Synscan Controll uses J2000 Epoch
    ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };

    epochPos.ra  = ra * 15.0;
    epochPos.dec = dec;

    // For Alt/Az mounts, we must issue Goto Alt/Az
    if (m_isAltAz)
    {
        struct ln_lnlat_posn lnobserver;
        struct ln_hrz_posn lnaltaz;

        lnobserver.lng = LocationN[LOCATION_LONGITUDE].value;
        if (lnobserver.lng > 180)
            lnobserver.lng -= 360;
        lnobserver.lat = LocationN[LOCATION_LATITUDE].value;
        ln_get_hrz_from_equ(&epochPos, &lnobserver, ln_get_julian_from_sys(), &lnaltaz);
        /* libnova measures azimuth from south towards west */
        double az = range360(lnaltaz.az + 180);
        double al = lnaltaz.alt;

        return GotoAzAlt(az, al);
    }

    // Synscan accepts J2000 coordinates so we need to convert from JNow to J2000
    ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);

    // Mount deals in J2000 coords.
    uint32_t n1 = J2000Pos.ra  / 360  * 0x100000000;
    uint32_t n2 = J2000Pos.dec / 360 * 0x100000000;

    LOGF_DEBUG("Goto - JNow RA: %g JNow DE: %g J2000 RA: %g J2000 DE: %g", ra, dec, J2000Pos.ra / 15.0, J2000Pos.dec);


    snprintf(cmd, SYN_RES, "r%08X,%08X", n1, n2);
    if (sendCommand(cmd, res, 18))
    {
        TrackState = SCOPE_SLEWING;
        HorizontalCoordsNP.s = IPS_BUSY;
        IDSetNumber(&HorizontalCoordsNP, nullptr);
        return true;
    }

    return false;
}
示例#2
0
bool   ScopeINDI::GetCoordinates(double *ra, double *dec, double *siderealTime)
{
    bool err = true;
    if (coord_prop) {
	INumber *raprop = IUFindNumber(coord_prop,"RA");
	INumber *decprop = IUFindNumber(coord_prop,"DEC");
	if (raprop && decprop) {
	    *ra = raprop->value;   // hours
	    *dec = decprop->value; // degrees
	    err = false;
	}
	if (SiderealTime_prop) {   // LX200 only
	    INumber *stprop = IUFindNumber(coord_prop,"LST"); 
	    if (stprop){
		*siderealTime = stprop->value;
	    }
	}
	else {
	   #ifdef LIBNOVA
	   double lat,lon;
	   double jd = ln_get_julian_from_sys();
	   *siderealTime = ln_get_apparent_sidereal_time (jd);
	   if (!GetSiteLatLong(&lat,&lon)) 
	      *siderealTime = *siderealTime + (lon/15);
	   #else
	   *siderealTime = 0;
	   #endif
	}
    }
    return err;
}
示例#3
0
bool SynscanDriver::Sync(double ra, double dec)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    TargetRA = ra;
    TargetDE = dec;

    if (isSimulation())
        return true;

    // INDI is JNow. Synscan Controll uses J2000 Epoch
    ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };

    epochPos.ra  = ra * 15.0;
    epochPos.dec = dec;

    // Synscan accepts J2000 coordinates so we need to convert from JNow to J2000
    ln_get_equ_prec2(&epochPos, ln_get_julian_from_sys(), JD2000, &J2000Pos);

    // Mount deals in J2000 coords.
    uint32_t n1 = J2000Pos.ra  / 360 * 0x100000000;
    uint32_t n2 = J2000Pos.dec / 360 * 0x100000000;

    LOGF_DEBUG("Sync - JNow RA: %g JNow DE: %g J2000 RA: %g J2000 DE: %g", ra, dec, J2000Pos.ra / 15.0, J2000Pos.dec);

    snprintf(cmd, SYN_RES, "s%08X,%08X", n1, n2);
    return sendCommand(cmd, res, 18);
}
示例#4
0
文件: ieqpro.cpp 项目: mp77/indi
bool IEQPro::SetDefaultPark()
{
    // By default set RA to HA
    SetAxis1Park(ln_get_apparent_sidereal_time(ln_get_julian_from_sys()));

    // Set DEC to 90 or -90 depending on the hemisphere
    SetAxis2Park( (HemisphereS[HEMI_NORTH].s == ISS_ON) ? 90 : -90);

    return true;
}
示例#5
0
bool ScopeSim::Goto(double r, double d)
{
    targetRA  = r;
    targetDEC = d;
    char RAStr[64], DecStr[64];

    fs_sexa(RAStr, targetRA, 2, 3600);
    fs_sexa(DecStr, targetDEC, 2, 3600);

    ln_equ_posn lnradec { 0, 0 };

    lnradec.ra  = (currentRA * 360) / 24.0;
    lnradec.dec = currentDEC;

    ln_get_hrz_from_equ(&lnradec, &lnobserver, ln_get_julian_from_sys(), &lnaltaz);
    /* libnova measures azimuth from south towards west */
    double current_az = range360(lnaltaz.az + 180);
    //double current_alt =lnaltaz.alt;

    if (current_az > MIN_AZ_FLIP && current_az < MAX_AZ_FLIP)
    {
        lnradec.ra  = (r * 360) / 24.0;
        lnradec.dec = d;

        ln_get_hrz_from_equ(&lnradec, &lnobserver, ln_get_julian_from_sys(), &lnaltaz);

        double target_az = range360(lnaltaz.az + 180);

        //if (targetAz > currentAz && target_az > MIN_AZ_FLIP && target_az < MAX_AZ_FLIP)
        if (target_az >= current_az && target_az > MIN_AZ_FLIP)
        {
            forceMeridianFlip = true;
        }
    }

    TrackState = SCOPE_SLEWING;

    EqNP.s = IPS_BUSY;

    DEBUGF(INDI::Logger::DBG_SESSION, "Slewing to RA: %s - DEC: %s", RAStr, DecStr);
    return true;
}
示例#6
0
double ScopeSim::getAzimuth(double r, double d)
{
    ln_equ_posn lnradec { 0, 0 };
    ln_hrz_posn altaz { 0, 0 };

    lnradec.ra  = (r * 360) / 24.0;
    lnradec.dec = d;

    ln_get_hrz_from_equ(&lnradec, &lnobserver, ln_get_julian_from_sys(), &altaz);

    /* libnova measures azimuth from south towards west */
    return (range360(altaz.az + 180));
}
示例#7
0
bool SynscanDriver::GotoAzAlt(double az, double alt)
{
    char cmd[SYN_RES] = {0}, res[SYN_RES] = {0};

    if (isSimulation())
        return true;

    if (m_isAltAz == false)
    {
        // For EQ Mount, we convert Parking Az/Alt to RA/DE and go to there.
        struct ln_lnlat_posn observer;
        ln_hrz_posn horizontalPos;
        ln_equ_posn equatorialPos;

        observer.lng = LocationN[LOCATION_LONGITUDE].value;
        if (observer.lng > 180)
            observer.lng -= 360;
        observer.lat = LocationN[LOCATION_LATITUDE].value;

        horizontalPos.az = az + 180;
        if (horizontalPos.az > 360)
            horizontalPos.az -= 360;
        horizontalPos.alt = alt;

        ln_get_equ_from_hrz(&horizontalPos, &observer, ln_get_julian_from_sys(), &equatorialPos);
        return Goto(equatorialPos.ra / 15.0, equatorialPos.dec);
    }

    // Az/Alt to encoders
    uint32_t n1 = az  / 360.0 * 0x100000000;
    uint32_t n2 = alt / 360.0 * 0x100000000;

    LOGF_DEBUG("Goto - Az: %.2f Alt: %.2f", az, alt);

    snprintf(cmd, SYN_RES, "b%08X,%08X", n1, n2);
    if (sendCommand(cmd, res, 18))
    {
        TrackState = SCOPE_SLEWING;
        HorizontalCoordsNP.s = IPS_BUSY;
        IDSetNumber(&HorizontalCoordsNP, nullptr);
        return true;
    }

    return false;
}
示例#8
0
文件: ieqpro.cpp 项目: mp77/indi
/* Constructor */
IEQPro::IEQPro()
{
    set_ieqpro_device(getDeviceName());

    //ctor
    currentRA=ln_get_apparent_sidereal_time(ln_get_julian_from_sys());
    currentDEC=90;

    scopeInfo.gpsStatus     = GPS_OFF;
    scopeInfo.systemStatus  = ST_STOPPED;
    scopeInfo.trackRate     = TR_SIDEREAL;
    scopeInfo.slewRate      = SR_1;
    scopeInfo.timeSource    = TS_RS232;
    scopeInfo.hemisphere    = HEMI_NORTH;

    DBG_SCOPE = INDI::Logger::getInstance().addDebugLevel("Scope Verbose", "SCOPE");

    SetTelescopeCapability(TELESCOPE_CAN_PARK | TELESCOPE_CAN_SYNC | TELESCOPE_CAN_GOTO | TELESCOPE_CAN_ABORT | TELESCOPE_HAS_TIME | TELESCOPE_HAS_LOCATION,9);
}
示例#9
0
ln_hrz_posn SynscanDriver::getAltAzPosition(double ra, double dec)
{
    ln_lnlat_posn Location { 0, 0 };
    ln_equ_posn Eq { 0, 0 };
    ln_hrz_posn AltAz { 0, 0 };

    // Set the current location
    Location.lat = LocationN[LOCATION_LATITUDE].value;
    Location.lng = LocationN[LOCATION_LONGITUDE].value;

    Eq.ra  = ra * 360.0 / 24.0;
    Eq.dec = dec;
    ln_get_hrz_from_equ(&Eq, &Location, ln_get_julian_from_sys(), &AltAz);
    AltAz.az -= 180;
    if (AltAz.az < 0)
        AltAz.az += 360;

    return AltAz;
}
示例#10
0
void Driver::setSimulation(bool enable)
{
    m_Simulation = enable;

    simData.ra_guide_rate = 0.5;
    simData.de_guide_rate = 0.5;
    simData.pier_state = IOP_PIER_WEST;
    simData.cw_state = IOP_CW_NORMAL;
    simData.JD = ln_get_julian_from_sys();
    simData.utc_offset_minutes = 3 * 60;
    simData.day_light_saving = false;

    simData.simInfo.gpsStatus = GPS_DATA_OK;
    simData.simInfo.hemisphere = HEMI_NORTH;
    simData.simInfo.slewRate = SR_6;
    simData.simInfo.timeSource = TS_GPS;
    simData.simInfo.trackRate = TR_SIDEREAL;
    simData.simInfo.longitude = 48.1;
    simData.simInfo.latitude  = 29.5;
}
示例#11
0
文件: ieqpro.cpp 项目: mp77/indi
void IEQPro::getStartupData()
{
    DEBUG(INDI::Logger::DBG_DEBUG, "Getting firmware data...");
    if (get_ieqpro_firmware(PortFD, &firmwareInfo))
    {
        IUSaveText(&FirmwareT[0], firmwareInfo.Model.c_str());
        IUSaveText(&FirmwareT[1], firmwareInfo.MainBoardFirmware.c_str());
        IUSaveText(&FirmwareT[2], firmwareInfo.ControllerFirmware.c_str());
        IUSaveText(&FirmwareT[3], firmwareInfo.RAFirmware.c_str());
        IUSaveText(&FirmwareT[4], firmwareInfo.DEFirmware.c_str());

        FirmwareTP.s = IPS_OK;
        IDSetText(&FirmwareTP, NULL);
    }

    DEBUG(INDI::Logger::DBG_DEBUG, "Getting guiding rate...");
    double guideRate=0;
    if (get_ieqpro_guide_rate(PortFD, &guideRate))
    {
        GuideRateN[0].value = guideRate;
        IDSetNumber(&GuideRateNP, NULL);
    }

    double HA = ln_get_apparent_sidereal_time(ln_get_julian_from_sys());
    double DEC = (HemisphereS[HEMI_NORTH].s == ISS_ON) ? 90 : -90;

    if (InitPark())
    {
        // If loading parking data is successful, we just set the default parking values.
        SetAxis1ParkDefault(HA);
        SetAxis2ParkDefault(DEC);
    }
    else
    {
        // Otherwise, we set all parking data to default in case no parking data is found.
        SetAxis1Park(HA);
        SetAxis2Park(DEC);
        SetAxis1ParkDefault(HA);
        SetAxis2ParkDefault(DEC);
    }

    double utc_offset;
    int yy, dd, mm, hh, minute, ss;
    if (get_ieqpro_utc_date_time(PortFD, &utc_offset, &yy, &mm, &dd, &hh, &minute, &ss))
    {
        char isoDateTime[32];
        char utcOffset[8];

        snprintf(isoDateTime, 32, "%04d-%02d-%02dT%02d:%02d:%02d", yy, mm, dd, hh, minute, ss);
        snprintf(utcOffset, 8, "%4.2f", utc_offset);

        IUSaveText(IUFindText(&TimeTP, "UTC"), isoDateTime);
        IUSaveText(IUFindText(&TimeTP, "OFFSET"), utcOffset);

        DEBUGF(INDI::Logger::DBG_SESSION, "Mount UTC offset is %s. UTC time is %s", utcOffset, isoDateTime);

        IDSetText(&TimeTP, NULL);
    }

    // Get Longitude and Latitude from mount
    double longitude=0,latitude=0;
    if (get_ieqpro_latitude(PortFD, &latitude) && get_ieqpro_longitude(PortFD, &longitude))
    {
        // Convert to INDI standard longitude (0 to 360 Eastward)
        if (longitude < 0)
            longitude += 360;

        LocationN[LOCATION_LATITUDE].value = latitude;
        LocationN[LOCATION_LONGITUDE].value= longitude;
        LocationNP.s = IPS_OK;

        IDSetNumber(&LocationNP, NULL);
    }

    if (isSimulation())
    {
        if (isParked())
            set_sim_system_status(ST_PARKED);
        else
            set_sim_system_status(ST_STOPPED);
    }
}
示例#12
0
double get_local_sidereal_time(double longitude)
{
    double SD = ln_get_apparent_sidereal_time(ln_get_julian_from_sys()) - (360.0 - longitude) / 15.0;

    return range24(SD);
}
示例#13
0
bool SynscanDriver::ReadScopeStatus()
{
    if (isSimulation())
    {
        mountSim();
        return true;
    }

    char res[SYN_RES] = {0};

    // Goto in progress?
    if (sendCommand("L", res))
        m_MountInfo[MI_GOTO_STATUS] = res[0];

    // Pier side
    if (m_isAltAz == false && sendCommand("p", res))
    {
        m_MountInfo[MI_POINT_STATUS] = res[0];
        // INDI and mount pier sides are opposite to each other
        setPierSide(res[0] == 'W' ? PIER_EAST : PIER_WEST);
    }

    if (readTracking())
    {
        if (TrackState == SCOPE_SLEWING)
        {
            if (isSlewComplete())
            {
                TrackState = (m_TrackingFlag == 2) ? SCOPE_TRACKING : SCOPE_IDLE;
                HorizontalCoordsNP.s = (m_TrackingFlag == 2) ? IPS_OK : IPS_IDLE;
                IDSetNumber(&HorizontalCoordsNP, nullptr);
            }
        }
        else if (TrackState == SCOPE_PARKING)
        {
            if (isSlewComplete())
            {
                HorizontalCoordsNP.s = IPS_IDLE;
                IDSetNumber(&HorizontalCoordsNP, nullptr);
                TrackState = SCOPE_PARKED;
                SetTrackEnabled(false);
                SetParked(true);
            }
        }
        else if (TrackState == SCOPE_IDLE && m_TrackingFlag > 0)
            TrackState = SCOPE_TRACKING;
        else if (TrackState == SCOPE_TRACKING && m_TrackingFlag == 0)
            TrackState = SCOPE_IDLE;
    }

    sendStatus();

    // Get Precise RA/DE
    memset(res, 0, SYN_RES);
    if (!sendCommand("e", res))
        return false;

    uint32_t n1 = 0, n2 = 0;
    sscanf(res, "%x,%x#", &n1, &n2);
    double ra  = static_cast<double>(n1) / 0x100000000 * 360.0;
    double de  = static_cast<double>(n2) / 0x100000000 * 360.0;

    ln_equ_posn epochPos { 0, 0 }, J2000Pos { 0, 0 };
    J2000Pos.ra  = range360(ra);
    J2000Pos.dec = rangeDec(de);

    // Synscan reports J2000 coordinates so we need to convert from J2000 to JNow
    ln_get_equ_prec2(&J2000Pos, JD2000, ln_get_julian_from_sys(), &epochPos);

    CurrentRA = epochPos.ra / 15.0;
    CurrentDE = epochPos.dec;

    char Axis1Coords[MAXINDINAME] = {0}, Axis2Coords[MAXINDINAME] = {0};
    fs_sexa(Axis1Coords, J2000Pos.ra / 15.0, 2, 3600);
    fs_sexa(Axis2Coords, J2000Pos.dec, 2, 3600);
    LOGF_DEBUG("J2000 RA <%s> DE <%s>", Axis1Coords, Axis2Coords);
    memset(Axis1Coords, 0, MAXINDINAME);
    memset(Axis2Coords, 0, MAXINDINAME);
    fs_sexa(Axis1Coords, CurrentRA, 2, 3600);
    fs_sexa(Axis2Coords, CurrentDE, 2, 3600);
    LOGF_DEBUG("JNOW  RA <%s> DE <%s>", Axis1Coords, Axis2Coords);

    //  Now feed the rest of the system with corrected data
    NewRaDec(CurrentRA, CurrentDE);

    // Get precise az/alt
    memset(res, 0, SYN_RES);
    if (!sendCommand("z", res))
        return false;

    sscanf(res, "%x,%x#", &n1, &n2);
    double az  = static_cast<double>(n1) / 0x100000000 * 360.0;
    double al  = static_cast<double>(n2) / 0x100000000 * 360.0;
    al = rangeDec(al);

    HorizontalCoordsN[AXIS_AZ].value = az;
    HorizontalCoordsN[AXIS_ALT].value = al;

    memset(Axis1Coords, 0, MAXINDINAME);
    memset(Axis2Coords, 0, MAXINDINAME);
    fs_sexa(Axis1Coords, az, 2, 3600);
    fs_sexa(Axis2Coords, al, 2, 3600);
    LOGF_DEBUG("AZ <%s> ALT <%s>", Axis1Coords, Axis2Coords);

    IDSetNumber(&HorizontalCoordsNP, nullptr);

    return true;
}
示例#14
0
int main (int argc, char* argv[])
{
	double JD;
	struct ln_rect_posn moon;
	struct ln_equ_posn equ;
	struct ln_lnlat_posn ecl;
	struct ln_lnlat_posn observer;
	struct ln_rst_time rst;
	struct ln_zonedate rise, transit, set;
	
	/* observers location (Edinburgh), used to calc rst */
	observer.lat = 55.92; /* 55.92 N */
	observer.lng = -3.18; /* 3.18 W */
	
	/* get the julian day from the local system time */
	JD = ln_get_julian_from_sys();
	printf ("JD %f\n",JD);
	
	/* get the lunar geopcentric position in km, earth is at 0,0,0 */
	ln_get_lunar_geo_posn (JD, &moon, 0);
	printf ("lunar x %f  y %f  z %f\n",moon.X, moon.Y, moon.Z);
	
	/* Long Lat */
	ln_get_lunar_ecl_coords (JD, &ecl, 0);
	printf ("lunar long %f  lat %f\n",ecl.lng, ecl.lat);
	
	/* RA, DEC */
	ln_get_lunar_equ_coords (JD, &equ);
	printf ("lunar RA %f  Dec %f\n",equ.ra, equ.dec);
	
	/* moon earth distance */
	printf ("lunar distance km %f\n", ln_get_lunar_earth_dist(JD));
	
	/* lunar disk, phase and bright limb */
	printf ("lunar disk %f\n", ln_get_lunar_disk(JD));
	printf ("lunar phase %f\n", ln_get_lunar_phase(JD));
	printf ("lunar bright limb %f\n", ln_get_lunar_bright_limb(JD));
	
	/* rise, set and transit time */
	if (ln_get_lunar_rst (JD, &observer, &rst) == 1) 
		printf ("Moon is circumpolar\n");
	else {
		ln_get_local_date (rst.rise, &rise);
		ln_get_local_date (rst.transit, &transit);
		ln_get_local_date (rst.set, &set);
		print_date ("Rise", &rise);
		print_date ("Transit", &transit);
		print_date ("Set", &set);
	}
	
	/* rise, set and transit time */
	if (ln_get_lunar_rst (JD - 24, &observer, &rst) == 1) 
		printf ("Moon is circumpolar\n");
	else {
		ln_get_local_date (rst.rise, &rise);
		ln_get_local_date (rst.transit, &transit);
		ln_get_local_date (rst.set, &set);
		print_date ("Rise", &rise);
		print_date ("Transit", &transit);
		print_date ("Set", &set);
	}
	
	/* rise, set and transit time */
	if (ln_get_lunar_rst (JD - 25, &observer, &rst) == 1) 
		printf ("Moon is circumpolar\n");
	else {
		ln_get_local_date (rst.rise, &rise);
		ln_get_local_date (rst.transit, &transit);
		ln_get_local_date (rst.set, &set);
		print_date ("Rise", &rise);
		print_date ("Transit", &transit);
		print_date ("Set", &set);
	}
	
	return 0;
}
示例#15
0
int main(int argc, char **argv) {

  int i;
  char errmsg[128];

  // time stuff
  double simJD;		// Julian day, simulated
  struct ln_date date;	// date structure
  struct ln_zonedate zdate;	// date structure, includes gmtoff (seconds east of UTC)
  int year,month,day;
  double hour;

  // location stuff
  struct ln_lnlat_posn observer;
  int got_meridian = 0;
  double s_meridian = 0.0;

  // astronomy stuff
  float sunPos[3];
  int tsolar;
  int isSun = FALSE;
  int isSky = FALSE;
  int isMoon = FALSE;
  int isStars = FALSE;

  // atmosphere stuff
  float turbidity = 2.45;	// gensky default, also near europe average
  double gprefl = 0.2;		// deciduous forest

  // set defaults ---------------------------------------

  // set to my house in Newton Center
  observer.lat = 42.36;
  observer.lng = -71.06;	// note: east longitude (use west for cli)

  // set the julian date to right now
  simJD = ln_get_julian_from_sys();

  //(void) ln_get_local_date (simJD, &date);
  //fprintf(stdout,"# %4d-%02d-%02d %2d:%02d:%02d\n",
  //        date.years,date.months,date.days,
  //        date.hours,date.minutes,(int)date.seconds);

  // create the time string for the current date
  (void) ln_get_date (simJD, &date);
  //fprintf(stdout,"# UTC now: %4d-%02d-%02d %2d:%02d:%02d\n",
  //        date.years,date.months,date.days,
  //        date.hours,date.minutes,(int)date.seconds);

  // 14400 for 4 hours behind UTC
  //(void) ln_date_to_zonedate (&date, &zdate, -14400);
  //fprintf(stdout,"# Local time now: %4d-%02d-%02d %2d:%02d:%02d\n",
  //        zdate.years,zdate.months,zdate.days,
  //        zdate.hours,zdate.minutes,(int)zdate.seconds);

  // and use those as defaults (really only to set the year)
  year = date.years;
  month = date.months;
  day = date.days;
  hour = date.hours + date.minutes/60. + date.seconds/3600.;

  // parse command-line arguments -----------------------
  // 1st arg is month number
  // 2nd arg is day
  // 3rd arg is 24-hour decimal hours (can add "EST" or other time zone to string!)
  // -a latitude (North assumed)
  // -o longitude (West assumed)

  // use code from gensky.c

        progname = argv[0];
        if (argc < 4)
                userror("arg count");
        month = atoi(argv[1]);
        if (month < 1 || month > 12)
                userror("bad month");
        day = atoi(argv[2]);
        if (day < 1 || day > 31)
                userror("bad day");
        got_meridian = cvthour(argv[3], &hour, &tsolar, &s_meridian);
        for (i = 4; i < argc; i++)
                if (argv[i][0] == '-' || argv[i][0] == '+')
                        switch (argv[i][1]) {
                        case 'y':
                                year = atoi(argv[++i]);
                                break;
                        case 't':
                                turbidity = atof(argv[++i]);
                                break;
                        case 'g':
                                gprefl = atof(argv[++i]);
                                break;
                        case 'a':
				// keep in degrees!
                                //observer.lat = atof(argv[++i]) * (PI/180);
                                observer.lat = atof(argv[++i]);
                                break;
                        case 'o':
				// note negative to match gensky behavior!
                                //observer.lng = -atof(argv[++i]) * (PI/180);
                                observer.lng = -atof(argv[++i]);
                                break;
                        case 'm':
                                if (got_meridian) {
                                        ++i;
                                        break;          /* time overrides */
                                }
				// keep in degrees
                                //s_meridian = atof(argv[++i]) * (PI/180);
                                s_meridian = atof(argv[++i]);
                                break;
                        default:
                                sprintf(errmsg, "unknown option: %s", argv[i]);
                                userror(errmsg);
                        }
                else
                        userror("bad option");

        // if no meridian, assume local time?
        if (!got_meridian) s_meridian = -observer.lng;
        // check for meridian far away from observer location
        if (fabs(s_meridian+observer.lng) > 45.)
                fprintf(stderr,
        "%s: warning: %.1f hours btwn. standard meridian and longitude\n",
                        progname, (-observer.lng-s_meridian)/15.);

        printhead(argc, argv);

        //fprintf(stdout,"tsolar %d\n",tsolar);
        //fprintf(stdout,"got_meridian %d\n",got_meridian);
        //fprintf(stdout,"s_meridian %g\n",s_meridian);
        //fprintf(stdout,"observer.lng %g\n",observer.lng);


  // convert the time -----------------------------------

  // change date to match input
  //date.years = year;
  //date.months = month;
  //date.days = day;
  //date.hours = floor(hour);
  //simJD = ln_get_julian_day(&date);
  //fprintf(stdout,"# jd %15.10e\n",simJD);

  zdate.years = year;
  zdate.months = month;
  zdate.days = day;
  zdate.hours = floor(hour);
  zdate.minutes = floor(60.*(hour-(double)(zdate.hours)));
  zdate.seconds = 3600.*(hour-(double)(zdate.hours)-(double)(zdate.minutes)/60.);
  zdate.gmtoff = 86400 - (long)(240.*s_meridian);
  fprintf(stdout,"# Using time: %4d-%02d-%02d %2d:%02d:%02d\n",
          zdate.years,zdate.months,zdate.days,
          zdate.hours,zdate.minutes,(int)zdate.seconds);
  simJD = ln_get_julian_local_date(&zdate);
  fprintf(stdout,"# Julian day: %15.10e\n",simJD);

  // write output ---------------------------------------

  // compute and write the sun "light" and "source" descriptions
  isSun = writeSun (simJD, observer, turbidity, sunPos);

  // always write the sky dome
  isSky = writeSky (turbidity, sunPos);

  // place the moon if it is above the horizon
  isMoon = writeMoon (simJD, observer);

  // place the three brightest planets if they are above the horizon
  writePlanets (simJD, observer);

  // if the sky is dim enough, place stars
  isStars = writeStars (simJD, sunPos[2], observer);
  (void) writeSkyStarMix (sunPos[2]);

  // if there is cloud geometry available, place it
  //writeClouds ();

  // create a material for the ground haze
  writeHaze (isSun,isSky,isMoon,isStars);

  // ANSI C requires main to return int
  return 0;
}
char* getAltazFromName(char* objStr) {
	char* auxStr = malloc(sizeof(char) * 10);
	struct ln_equ_posn equ;
	int encontrado = 0;
	double ra, dec;

	// Extraigo la fecha en formato JD
	double JD = ln_get_julian_from_sys();

	// Probamos con el sol
	sprintf(auxStr, "sol");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_solar_equ_coords(JD, &equ);
		fprintf(stdout, "sol  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con la luna
	sprintf(auxStr, "luna");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_lunar_equ_coords(JD, &equ);
		fprintf(stdout, "luna  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con mercurio
	sprintf(auxStr, "mercurio");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_mercury_equ_coords(JD, &equ);
		fprintf(stdout, "mercurio  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con venus
	sprintf(auxStr, "venus");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_venus_equ_coords(JD, &equ);
		fprintf(stdout, "venus  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con marte
	sprintf(auxStr, "marte");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_mars_equ_coords(JD, &equ);
		fprintf(stdout, "marte  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con jupiter
	sprintf(auxStr, "jupiter");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_jupiter_equ_coords(JD, &equ);
		fprintf(stdout, "jupiter  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con saturno
	sprintf(auxStr, "saturno");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_saturn_equ_coords(JD, &equ);
		fprintf(stdout, "saturno  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con urano
	sprintf(auxStr, "urano");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_uranus_equ_coords(JD, &equ);
		fprintf(stdout, "urano  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con neptuno
	sprintf(auxStr, "neptuno");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_neptune_equ_coords(JD, &equ);
		fprintf(stdout, "neptuno  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Probamos con pluton
	sprintf(auxStr, "pluton");
	if (strcmp(objStr, auxStr) == 0) {
		ln_get_pluto_equ_coords(JD, &equ);
		fprintf(stdout, "pluton  RA %f  Dec %f\n", equ.ra, equ.dec);
		encontrado = 1;
	}

	// Si encontré algo
	if (encontrado == 1) {
		// Creo la cadena y la devuelvo
	    struct ln_hrz_posn objAltAz = getAltazFromRadecInDate(equ, JD);
	    char* strResp = traduceCoordenadasString(objAltAz);
	    return strResp;
	}else{
		char* strResp = malloc(sizeof(char) * 40);
		sprintf(strResp, "{\"resp\":\"ko','msg':'Objeto desconocido'}");
	    return strResp;
	}
}
示例#17
0
		virtual int info ()
		{
			setTelRaDec (dummyPos.ra, dummyPos.dec);
			julian_day->setValueDouble (ln_get_julian_from_sys ());
			return Telescope::info ();
		}