/*************************************************************************** * (C) Copyright 2006 by GATS, Inc. * 11864 Canon Blvd., STE 101 * Newport News, VA 23606 * * All Rights Reserved. No part of this software or publication may be * reproduced, stored in a retrieval system, or transmitted, in any form * or by any means, electronic, mechanical, photocopying, recording, or * otherwise without the prior written permission of GATS, Inc. * *************************************************************************** * * Class: Ephemeris * * Filename: Ephemeris.cpp * * Description: Ephemeris has member functions to manipulate date events * and process SOFIE Level1 Time Registration for a single event * * Author: C.W.Brown * (757)952-1048 * (757)873-5920 * * ***************************************************************************/ #include "Ephemeris.h" // #include "EventVar.h" // #include // #include using namespace std; Ephemeris::Ephemeris() //!< Default Constructor for Ephemeris Class { } Ephemeris::Ephemeris(ifstream &ephem) //!< Constructor for Ephemeris Class //!< Loads Initial Ephemeris from file { ephStart = 0.0; ephEnd = 0.0; coordSys = -1; numPts = -1; //int *size = new int; //*size = getFileHeader(ephem); getFileHeader(ephem); stateVector = new StateVector[numPts]; //time = new double[numPts]; //delete size; getEphemeris(ephem); } Ephemeris::Ephemeris(int size) //!< Constructor for Ephemeris Class //!< Loads Initial Ephemeris from file { numPts = size; stateVector = new StateVector[size]; //time = new double[size]; } Ephemeris::~Ephemeris() //!< Default Destructor for Ephemeris Class { } //Ephemeris::Ephemeris(mysql Database) //!< Constructor for Ephemeris Class //!< Loads Initial Ephemeris from Database void Ephemeris::calculateTime(int cell){ double jdn; // int doy; int cal[7]; jdn = stateVector[cell].time + MJDN_CONST; jdn2cal(jdn, cal); stateVector[cell].year = cal[0]; stateVector[cell].doy = cal2doy(cal) - cal[0]*1000; stateVector[cell].sec = cal[3] * 3600.0 + cal[4] * 60.0 + cal[5] + cal[6] / 1.0e6; return; } void Ephemeris::getEphemeris(ifstream &ephem) //!< populates stateVector from file //!< file format is white space delimited: //!< 4 Parameters: EphStart EphEnd TimestepN CoordinateSystem //!< Followed by N Lines: //!< Time X Y Z VX VY VZ { //Check Current Location to see if Header Information has been retrieved. int location = ephem.tellg(); //cout << "Location getEph: " << location << endl; if(location==0) //iephem.seekg(0, ios::beg); getFileHeader(ephem); while(!ephem.eof()){ for(int i=0; i> stateVector[i].time; //cout << "Time: " << stateVector[i].time; for(int j=0; j<6; j++) if(j<3) ephem >> stateVector[i].position[j]; else ephem >> stateVector[i].velocity[j-3]; //cout << i << " " << stateVector[i].position[5] << endl; } } return; } void Ephemeris::getEphemeris(Ephemeris &ephem) //!< Function initializes Satellite StateVector by interpolating an Ephemeris //!< stateVector.time must be populated {} void Ephemeris::getFileHeader(ifstream &ephem) //!< Read Ephemeris File header Information { //int location = ephem.tellg(); //cout << "Location getFH: " << location << endl; if(!ephem.eof()) ephem >> ephStart; if(!ephem.eof()) ephem >> ephEnd; if(!ephem.eof()) ephem >> numPts; if(!ephem.eof()) ephem >> timeStep; if(!ephem.eof()) ephem >> coordSys; //ephem.seekg(0, ios::beg); return; } //void Ephemeris::interpolate(Ephemeris &ephem) //!< Interpolates stateVector //{ //} void Ephemeris::writeOutput() //!< Writes the Output of All Member Variables to Event Object Tmp or Level1 //!< Requires No Parameters ... Uses Config for Output Parameters and Locations //!< IS NOT IMPLEMENTED { }