From 008a0a6b11cef182b02041aecdea2b31c9e5459e Mon Sep 17 00:00:00 2001 From: Dave Albo Date: Wed, 19 Oct 2022 09:49:46 -0600 Subject: [PATCH 1/2] Bug fix due to incorrect indexing when looking for 3 different possible station id's in the lookup file --- src/tools/other/ascii2nc/airnow_locations.cc | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tools/other/ascii2nc/airnow_locations.cc b/src/tools/other/ascii2nc/airnow_locations.cc index 10810c8727..8ddea3cd53 100644 --- a/src/tools/other/ascii2nc/airnow_locations.cc +++ b/src/tools/other/ascii2nc/airnow_locations.cc @@ -96,6 +96,7 @@ bool AirnowLocations::initialize(const string &fileName) string aqsid = data_line[aqsidPtr]; string fullaqsid = data_line[fullaqsidPtr]; string stationid = data_line[sidPtr]; + } double lat = atof(data_line[latPtr]); double lon = atof(data_line[lonPtr]); double elev = atof(data_line[elevPtr]); @@ -150,6 +151,7 @@ bool AirnowLocations::lookupLatLonElev(const string aqsid, double &lat, double & { string method_name = "AirnowLocations::lookupLatLonElev()"; + int index = -1; vector::const_iterator it = find(monitoringSiteAqsid.begin(), monitoringSiteAqsid.end(), aqsid); if (it == monitoringSiteAqsid.end()) { it = find(monitoringSiteStationId.begin(), monitoringSiteStationId.end(), aqsid); @@ -157,10 +159,19 @@ bool AirnowLocations::lookupLatLonElev(const string aqsid, double &lat, double & it = find(monitoringSiteFullAqsid.begin(), monitoringSiteFullAqsid.end(), aqsid); if (it == monitoringSiteFullAqsid.end()) { return false; + } else { + index = (int)(it - monitoringSiteStationId.begin()); } + } else { + index = (int)(it - monitoringSiteFullAqsid.begin()); } + } else { + index = (int)(it - monitoringSiteAqsid.begin()); + } + if (index < 0) { + return false; } - int index = (int)(it - monitoringSiteAqsid.begin()); + lat = monitoringSiteLat[index]; lon = monitoringSiteLon[index]; elev = monitoringSiteElev[index]; From 1ff51a835f389342ba2360fd2ab827d893ca3027 Mon Sep 17 00:00:00 2001 From: Dave Albo Date: Wed, 19 Oct 2022 10:00:34 -0600 Subject: [PATCH 2/2] A stray '}' snuck into the source code --- src/tools/other/ascii2nc/airnow_locations.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tools/other/ascii2nc/airnow_locations.cc b/src/tools/other/ascii2nc/airnow_locations.cc index 8ddea3cd53..17ddcdb666 100644 --- a/src/tools/other/ascii2nc/airnow_locations.cc +++ b/src/tools/other/ascii2nc/airnow_locations.cc @@ -96,7 +96,6 @@ bool AirnowLocations::initialize(const string &fileName) string aqsid = data_line[aqsidPtr]; string fullaqsid = data_line[fullaqsidPtr]; string stationid = data_line[sidPtr]; - } double lat = atof(data_line[latPtr]); double lon = atof(data_line[lonPtr]); double elev = atof(data_line[elevPtr]);