Skip to content
Snippets Groups Projects
Commit e74a4df4 authored by Robert Butora's avatar Robert Butora
Browse files

cutout: adds check on adding extra_cards only if not in header (by exact match on key)

parent de089c19
No related branches found
No related tags found
No related merge requests found
......@@ -362,6 +362,18 @@ string fitsfiles::append_card_if_not_in_header(string header, const vector<fits_
// deprecated
// NOT: checks only for _exact_ match on card-key: 'xxxxx____=' ? 'yyyyy____='
bool is_in_header(string& hdr, string& card)
{
for(int offset=0; offset<hdr.size(); offset+=80)
{
string hdr_card_key{ hdr.substr(offset,10) };
if(0 == card.substr(0,10).compare(hdr_card_key)) return true;
}
return false;
}
void append_cards(string& hdr, vector<string> cards)
{
LOG_trace(__func__);
......@@ -374,7 +386,8 @@ void append_cards(string& hdr, vector<string> cards)
{
if(end_card.compare(hdr.substr(hdr_len-80 ,80)) == 0) hdr.erase(hdr_len-80,80);
for(long unsigned int i=0; i<cards.size(); i++) hdr += cards[i];
for(long unsigned int i=0; i<cards.size(); i++)
if( !is_in_header(hdr, cards[i]) ) hdr += cards[i];
hdr += end_card;
}
......@@ -408,7 +421,6 @@ vector<fitsfiles::Hdu> fitsfiles::fname2hdrstr(
bool extra_cards_given = (extra_cards.size() > 0);
if(extra_cards_given)
{
// FIXME check for duplicates before appending
append_cards(header_str, extra_cards);
}
......
......@@ -322,6 +322,7 @@ void database::dbAddSurvey(int sid, const string groups,
{
// FIXME add check that any of cards RESTFREQ RESTFRQ RESTWAV exist:Add only if not!
// current append in fname2hdrstr checks only for _exact_ match on card-key: 'xxxxx____=' ? 'yyyyy____='
ostringstream restfrq;
restfrq.setf(ios::fixed, ios::floatfield);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment