Skip to content

Commit

Permalink
Per #2452, fix transposition bug in AirnowLocations::lookupLatLonElev…
Browse files Browse the repository at this point in the history
…() and apply consistent indentation and formatting.
  • Loading branch information
JohnHalleyGotway committed Feb 21, 2023
1 parent 911c312 commit 42a52ff
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/tools/other/ascii2nc/airnow_locations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
// ** P.O.Box 3000, Boulder, Colorado, 80307-3000, USA
// *=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*


////////////////////////////////////////////////////////////////////////


using namespace std;

#include <iostream>
Expand All @@ -26,15 +24,12 @@ using namespace std;

////////////////////////////////////////////////////////////////////////


//
// Code for class AirnowLocations
//


////////////////////////////////////////////////////////////////////////


AirnowLocations::AirnowLocations()
{
//
Expand All @@ -43,27 +38,24 @@ AirnowLocations::AirnowLocations()
monitoringSiteFileName = "Monitoring_Site_Locations_V2.dat";
}


////////////////////////////////////////////////////////////////////////


AirnowLocations::~AirnowLocations()
{
}


////////////////////////////////////////////////////////////////////////

bool AirnowLocations::initialize(const string &fileName)
{
string method_name = "AirnowLocations::initialize() ";
string method_name = "AirnowLocations::initialize()";

monitoringSiteFileName = fileName;
LineDataFile locFile;
if (!locFile.open(monitoringSiteFileName.c_str())) {
mlog << Error << method_name << "->"
<< "can't open input ASCII file \"" << monitoringSiteFileName
<< "\" for reading\n\n";
mlog << Warning << "\n" << method_name << " -> "
<< "can't open input ASCII file \"" << monitoringSiteFileName
<< "\" for reading\n\n";
return false;
}
DataLine data_line;
Expand Down Expand Up @@ -119,12 +111,12 @@ bool AirnowLocations::initialize(const string &fileName)
double lon2 = monitoringSiteLon[index];
double elev2 = monitoringSiteElev[index];
if (lat != lat2 || lon != lon2 || elev != elev2 || aqsid2 != aqsid || stationid2 != stationid) {
mlog << Warning << "AirnowLocations" << method_name << "-> "
<< "Multiple values seen for a single FullAQSID (" << fullaqsid << ")"
<< "Values used: StationId:" << stationid << " Aqsid:" << aqsid << " Lat,Lon,Elev:"
<< lat << "," << lon << "," << elev
<< "Not used StationId:" << stationid2 << " Aqsid:" << aqsid2 << " Lat,Lon,Elev:"
<< lat2 << "," << lon2 << "," << elev2 << "\n\n";
mlog << Warning << "\n" << method_name << " -> "
<< "Multiple values seen for a single FullAQSID (" << fullaqsid << ")"
<< "Values used: StationId:" << stationid << " Aqsid:" << aqsid << " Lat,Lon,Elev:"
<< lat << "," << lon << "," << elev
<< "Not used StationId:" << stationid2 << " Aqsid:" << aqsid2 << " Lat,Lon,Elev:"
<< lat2 << "," << lon2 << "," << elev2 << "\n\n";
}
}
}
Expand Down Expand Up @@ -157,12 +149,12 @@ bool AirnowLocations::lookupLatLonElev(const string aqsid, double &lat, double &
if (it == monitoringSiteStationId.end()) {
it = find(monitoringSiteFullAqsid.begin(), monitoringSiteFullAqsid.end(), aqsid);
if (it == monitoringSiteFullAqsid.end()) {
return false;
return false;
} else {
index = (int)(it - monitoringSiteStationId.begin());
index = (int)(it - monitoringSiteFullAqsid.begin());
}
} else {
index = (int)(it - monitoringSiteFullAqsid.begin());
index = (int)(it - monitoringSiteStationId.begin());
}
} else {
index = (int)(it - monitoringSiteAqsid.begin());
Expand All @@ -188,9 +180,10 @@ bool AirnowLocations::_setPtr(DataLine &data_line, const string &headerName, int
return true;
}
}
mlog << Error << "AirnowLocations::_setPtr() ->"
mlog << Warning << "\nAirnowLocations::_setPtr() -> "
<< "Did not see '" << headerName << "' in the header line of file "
<< monitoringSiteFileName << "\n";
<< monitoringSiteFileName << "\n\n";
return false;
}

////////////////////////////////////////////////////////////////////////

0 comments on commit 42a52ff

Please sign in to comment.