Target *createTargetByString (std::string tar_string, bool debug) { Target *rtar = NULL; LibnovaRaDec raDec; int ret = raDec.parseString (tar_string.c_str ()); if (ret == 0) { std::string new_prefix; // default prefix for new RTS2 sources new_prefix = std::string ("RTS2_"); // set name.. ConstTarget *constTarget = new ConstTarget (); constTarget->setPosition (raDec.getRa (), raDec.getDec ()); std::ostringstream os; rts2core::Configuration::instance ()->getString ("newtarget", "prefix", new_prefix, "RTS2"); os << new_prefix << LibnovaRaComp (raDec.getRa ()) << LibnovaDeg90Comp (raDec.getDec ()); constTarget->setTargetName (os.str ().c_str ()); constTarget->setTargetType (TYPE_OPORTUNITY); return constTarget; } // if it's MPC ephemeris.. rtar = new EllTarget (); ret = ((EllTarget *) rtar)->orbitFromMPC (tar_string.c_str ()); if (ret == 0) return rtar; delete rtar; try { rtar = new TLETarget (); ((TLETarget *) rtar)->orbitFromTLE (tar_string); return rtar; } catch (rts2core::Error &er) { } delete rtar; XmlRpcLogHandler::setVerbosity (debug ? 5 : 0); // try to get target from SIMBAD try { rtar = new rts2db::SimbadTargetDb (tar_string.c_str ()); rtar->load (); rtar->setTargetType (TYPE_OPORTUNITY); return rtar; } catch (rts2core::Error &er) { delete rtar; // MPEC fallback rtar = new rts2db::MPECTarget (tar_string.c_str ()); rtar->load (); return rtar; } }
int TargetApp::processOption (int in_opt) { switch (in_opt) { case 'a': matchAll = true; break; case 'e': if (op & OP_DISABLE) return -1; op |= OP_ENABLE; break; case 'd': if (op & OP_ENABLE) return -1; op |= OP_DISABLE; break; case 'p': new_priority = atof (optarg); op |= OP_PRIORITY; break; case 'b': new_bonus = atof (optarg); op |= OP_BONUS; break; case 't': op |= OP_BONUS_TIME; return parseDate (optarg, &new_bonus_time); case 'n': op |= OP_NEXT_TIME; return parseDate (optarg, &new_next_time); case 'o': op |= OP_NEXT_OBSER; break; case 'c': if (camera) return -1; camera = optarg; break; case 's': if (!camera && !(camera = defaultCamera)) { std::cerr << "Please provide camera name (with -c parameter) before specifing script!" << std::endl; return -1; } // try to parse it.. new_scripts.push_back (CamScript (camera, optarg)); camera = NULL; op |= OP_SCRIPT; break; case 'N': std::cout << pureNumbers; break; case OPT_OBSERVE_SLEW: op |= OP_OBS_SLEW; break; case OPT_OBSERVE_START: op |= OP_OBS_START; break; case OPT_OBSERVE_END: op |= OP_OBS_END; break; case OPT_TEMPDISABLE: tempdis = optarg; op |= OP_TEMPDISABLE; break; case OPT_AIRMASS: parseConstraint (CONSTRAINT_AIRMASS, optarg); op |= OP_CONSTRAINTS; break; case OPT_LUNAR_DISTANCE: parseConstraint (CONSTRAINT_LDISTANCE, optarg); op |= OP_CONSTRAINTS; break; case OPT_LUNAR_ALTITUDE: parseConstraint (CONSTRAINT_LALTITUDE, optarg); op |= OP_CONSTRAINTS; break; case OPT_MAXREPEATS: parseConstraint (CONSTRAINT_MAXREPEATS, optarg); op |= OP_CONSTRAINTS; break; case OPT_PI_NAME: pi = optarg; op |= OP_PI_NAME; break; case OPT_PROGRAM_NAME: program = optarg; op |= OP_PROGRAM_NAME; break; case OPT_SET_PROPER_MOTION: { LibnovaRaDec raDec; if (raDec.parseString (optarg)) { std::cerr << "cannot parse " << optarg << " as RA DEC string" << std::endl; return -1; } raDec.getPos (&pm); op |= OP_SET_PROPER_MOTION; } break; case OPT_DELETE: op |= OP_DELETE; break; case OPT_ID_ONLY: resType = rts2db::ID_ONLY; break; case OPT_NAME_ONLY: resType = rts2db::NAME_ONLY; break; case OPT_RESETC: op |= OP_CONS_RESET; break; case OPT_FORCE: confirmOp = false; break; default: return AppDb::processOption (in_opt); } return 0; }