ICAROUS
|
#include <SequenceReader.h>
Public Member Functions | |
SequenceReader () | |
SequenceReader (const std::string &filename) | |
virtual void | open (const std::string &filename) |
virtual void | open (std::istream *in) |
int | sequenceSize () const |
void | setWindowSize (int s) |
int | getWindowSize () const |
void | setActive (double tm) |
void | setFirstActive () |
void | setLastActive () |
bool | hasEntry (const std::string &name, double time) |
Position | getSequencePosition (const std::string &name, double time) |
Velocity | getSequenceVelocity (const std::string &name, double time) |
void | setEntry (double time, const std::string &name, const Position &p, const Velocity &v) |
void | clearSingletons () |
void | removeAircraft (const std::vector< std::string > &alist) |
std::vector< double > | sequenceKeys () |
std::vector< double > | sequenceKeysUpTo (int n, double tm) |
bool | hasExtraColumnData (double time, const std::string &acName, const std::string &colname) const |
double | getExtraColumnValue (double time, const std::string &acName, const std::string &colname) const |
bool | getExtraColumnBool (double time, const std::string &acName, const std::string &colname) const |
std::string | getExtraColumnString (double time, const std::string &acName, const std::string &colname) const |
bool | hasExtraColumnData (int ac, const std::string &colname) const |
double | getExtraColumnValue (int ac, const std::string &colname) const |
bool | getExtraColumnBool (int ac, const std::string &colname) const |
std::string | getExtraColumnString (int ac, const std::string &colname) const |
![]() | |
StateReader () | |
ParameterData & | getParametersRef () |
ParameterData | getParameters () const |
void | updateParameterData (ParameterData &p) const |
int | size () const |
AircraftState | getAircraftState (int i) const |
std::vector< AircraftState > | getAircraftStateList () const |
Position | getPosition (int ac) const |
Velocity | getVelocity (int ac) const |
std::string | getName (int ac) const |
double | getTime (int ac) const |
bool | isLatLon () const |
std::vector< std::string > | getExtraColumnList () const |
std::string | getExtraColumnUnits (const std::string &colname) const |
bool | hasExtraColumnData (int ac, const std::string &colname) const |
double | getExtraColumnValue (int ac, const std::string &colname) const |
bool | getExtraColumnBool (int ac, const std::string &colname) const |
std::string | getExtraColumnString (int ac, const std::string &colname) const |
bool | hasError () const |
bool | hasMessage () const |
std::string | getMessage () |
std::string | getMessageNoClear () const |
Private Types | |
typedef std::pair< Position, Velocity > | DataPoint |
typedef std::map< std::string, DataPoint > | SequenceEntry |
typedef std::map< double, SequenceEntry > | SequenceEntryMap |
typedef std::map< Triple< double, std::string, int >, Triple< double, bool, std::string > > | allExtraTblType |
Private Member Functions | |
void | loadfile () |
void | buildActive (double tm) |
Private Attributes | |
int | windowSize |
SequenceEntryMap | sequenceTable |
std::vector< std::string > | nameIndex |
std::set< std::string > | names |
allExtraTblType | allExtracolumnValues |
Additional Inherited Members | |
![]() | |
enum | { NAME , LAT_SX , LON_SY , ALT_SZ , TRK_VX , GS_VY , VS_VZ , TM_CLK } |
typedef std::map< std::pair< int, int >, Triple< double, bool, std::string > > | extraTblType |
![]() | |
int | altHeadings (const std::string &s1, const std::string &s2, const std::string &s3, const std::string &s4) const |
int | altHeadings (const std::string &s1, const std::string &s2, const std::string &s3) const |
int | altHeadings (const std::string &s1, const std::string &s2) const |
double | parseClockTime (const std::string &s) const |
int | getIndex (const std::string &s) const |
![]() | |
extraTblType | extracolumnValues |
ErrorLog | error |
SeparatedInput | input |
std::vector< AircraftState > | states |
bool | hasRead |
bool | latlon |
bool | trkgsvs |
bool | clock |
std::vector< int > | head |
bool | interpretUnits |
![]() | |
static const int | definedColumns = TM_CLK + 1 |
This reads in and stores a set of aircraft states, possibly over time, (and parameters) from a file The Aircraft states are stored in an ArrayList<AircraftState>.
This can read state/history files as well as sequence files (slight variations on history files).
State files consist of comma or space-separated values, with one point per line. Required columns include aircraft name, 3 position columns (either x[nmi]/y[nmi]/z[ft] or latitude[deg]/longitude[deg]/altitude[ft]) and 3 velocity columns (either vx[kn]/vy[kn]/vz[fpm] or track[deg]/gs[kn]/vs[fpm]).
An optional column is time [s]. If it is included, a "history" will be build if an aircraft has more than one entry. If it is not included, only the last entry for an aircraft will be stored.
It is necessary to include a header line that defines the column ordering. The column definitions are not case sensitive. There is also an optional header line, immediately following the column definition, that defines the unit type for each column (the defaults are listed above).
If points are consecutive for the same aircraft, subsequent name fields may be replaced with a double quotation mark ("). The aircraft name is case sensitive, so US54A != Us54a != us54a.
Any empty line or any line starting with a hash sign (#) is ignored.
Files may also include parameter definitions prior to other data. Parameter definitions are of the form <key> = <value>, one per line, where <key> is a case-insensitive alphanumeric word and <value> is either a numeral or string. The <value> may include a unit, such as "dist = 50 [m]". Note that parameters require a space on either side of the equals sign. Note that it is possible to also update the stored parameter values (or store additional ones) through API calls.
Parameters can be interpreted as double values, strings, or Boolean values, and the user is required to know which parameter is interpreted as which type.
If the optional parameter "filetype" is specified, its value must be "state", "history", or "sequence" for this reader to accept the file without error.
This allows for arbitrary additional user-defined columns. New columns' information may be accessed by the get getNewColumnValue(), getNewColumnBoolean(), or getNewColumnString() methods. The 2-parameter versions (index, column) inherited from StateReader will only return the last active values for a given aircraft (which may be blank). To retrieve values at arbitrary times, use the 3-parameter versions (time, name, column). New columns are assumed unitless unless units are specified.
larcfm::SequenceReader::SequenceReader | ( | ) |
A new, empty StateReader. This may be used to store parameters, but nothing else.
void larcfm::SequenceReader::clearSingletons | ( | ) |
remove any time-point entries for which there is only one aircraft (and so no chance of conflict)
bool larcfm::SequenceReader::getExtraColumnBool | ( | double | time, |
const std::string & | acName, | ||
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft at a given time, interpreted as a boolean, or false if there is no info
time | |
acName | |
colname |
Returns the column value associated with a given aircraft at a given time, interpreted as a boolean, or false if there is no info
bool larcfm::StateReader::getExtraColumnBool | ( | int | ac, |
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft, interpreted as a boolean, or false if there is no info
std::string larcfm::SequenceReader::getExtraColumnString | ( | double | time, |
const std::string & | acName, | ||
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft at a given time, interpreted as a string, or the empty string if there is no info
time | |
acName | |
colname |
Returns the column value associated with a given aircraft at a given time, interpreted as a string, or the empty string if there is no info
std::string larcfm::StateReader::getExtraColumnString | ( | int | ac, |
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft, interpreted as a string, or the empty string if there is no info
double larcfm::SequenceReader::getExtraColumnValue | ( | double | time, |
const std::string & | acName, | ||
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft at a given time, interpreted as a double, or NaN if there is no info
time | |
acName | |
colname |
Returns the column value associated with a given aircraft at a given time, interpreted as a double, or NaN if there is no info
double larcfm::StateReader::getExtraColumnValue | ( | int | ac, |
const std::string & | colname | ||
) | const |
Returns the column value associated with a given aircraft, interpreted as a double, or NaN if there is no info
Position larcfm::SequenceReader::getSequencePosition | ( | const std::string & | name, |
double | time | ||
) |
Returns the Position entry for a given name and time. If no entry for this name and time, returns a zero position and sets a warning.
name | |
time |
Returns the Position entry for a given name and time. If no entry for this name and time, returns a zero position and sets a warning.
Velocity larcfm::SequenceReader::getSequenceVelocity | ( | const std::string & | name, |
double | time | ||
) |
Returns the Velocity entry for a given name and time. If no entry for this name and time, returns a zero velocity and sets a warning.
name | |
time |
Returns the Velocity entry for a given name and time. If no entry for this name and time, returns a zero velocity and sets a warning.
int larcfm::SequenceReader::getWindowSize | ( | ) | const |
Returns the current window size
Returns the current window size
bool larcfm::SequenceReader::hasEntry | ( | const std::string & | name, |
double | time | ||
) |
Returns true if an entry exists for the given name and time
name | |
time |
Returns true if an entry exists for the given name and time
bool larcfm::SequenceReader::hasExtraColumnData | ( | double | time, |
const std::string & | acName, | ||
const std::string & | colname | ||
) | const |
Return true if the given aircraft has data for the indicated column at the inicated time.
time | |
acName | |
colname |
Updates a ParameterData with new parameters based on user columns for a given aircraft at a given time.
bool larcfm::StateReader::hasExtraColumnData | ( | int | ac, |
const std::string & | colname | ||
) | const |
Return true if the given aircraft has data for the indicated column.
ac | |
colname |
|
virtual |
Read a new file into an existing StateReader. Parameters are preserved if they are not specified in the file.
Reimplemented from larcfm::StateReader.
|
virtual |
Read a new stream into an existing StateReader. Parameters are preserved if they are not specified in the file.
Reimplemented from larcfm::StateReader.
void larcfm::SequenceReader::removeAircraft | ( | const std::vector< std::string > & | alist | ) |
This purges all references of a given set of aircraft from this reader. This then resets the active time to the last time in the list
alist | List of aircraft identifiers |
vector< double > larcfm::SequenceReader::sequenceKeys | ( | ) |
Returns a sorted list of all sequence keys
vector< double > larcfm::SequenceReader::sequenceKeysUpTo | ( | int | n, |
double | tm | ||
) |
a list of n > 0 sequence keys, stopping at the given time (inclusive)
int larcfm::SequenceReader::sequenceSize | ( | ) | const |
Return the number of sequence entries in the file
Return the number of sequence entries in the file
void larcfm::SequenceReader::setActive | ( | double | tm | ) |
Given a sequence key, set the active set of states. If no such key exists, the active set is left empty.
tm | Sequence key (time) |
void larcfm::SequenceReader::setEntry | ( | double | time, |
const std::string & | name, | ||
const Position & | p, | ||
const Velocity & | v | ||
) |
sets a particular entry without reading in from a file
time | |
name | |
p | |
v |
void larcfm::SequenceReader::setFirstActive | ( | ) |
Set the first entry to be the active one.
void larcfm::SequenceReader::setLastActive | ( | ) |
Set the last entry to be the active one.
void larcfm::SequenceReader::setWindowSize | ( | int | s | ) |
Sets the window size for the active sequence set
s | new window size |
Sets the window size for the active sequence set
s | > 0 |