Skip to content

Commit b1fc809

Browse files
committed
NSRDB advanced download fixes
* Improve identification of lat/lon pair as input * Remove location string from file name to avoid wfcheck failure when string contains some unicode characters, e.g., cyrillic.
1 parent 33f4921 commit b1fc809

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/nsrdb.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,22 @@ void NSRDBDialog::GetResources()
547547

548548
wxString locname = "";
549549

550+
// determine whether address is lat/lon pair
550551
bool is_addr = false;
551-
const wxChar* locChars = location.c_str();
552-
for (int i = 0; i < (int)location.Len(); i++)
553-
{
554-
if (isalpha(locChars[i]))
555-
is_addr = true;
552+
wxUniChar c;
553+
bool d, a;
554+
for (wxString::const_iterator it = location.begin(); it != location.end(); ++it) {
555+
c = *it;
556+
d = wxIsdigit(c);
557+
a = wxIsalpha(c);
558+
if (!d && a) {
559+
if (c != 'n' && c != 's' && c != 'e' && c != 'w') {
560+
is_addr = true;
561+
}
562+
}
563+
556564
}
565+
557566
double lat, lon;
558567
if (is_addr) //entered an address instead of a lat/long
559568
{
@@ -648,7 +657,6 @@ void NSRDBDialog::GetResources()
648657

649658
m_txtLatLon->SetValue(wxString::Format("%f,%f", lat, lon));
650659

651-
652660
if (!reader.HasMember("outputs")) return; // error message?
653661
if (!reader["outputs"].IsArray()) return; // error message?
654662

@@ -705,7 +713,8 @@ void NSRDBDialog::GetResources()
705713
&& (name.Lower() != "philippines") // basic solar resource data only tamb, dhi, dni, ghi, wind (not enough data for CSP or PV thermal models)
706714
&& (name.Lower() != "vietnam")) // // basic solar resource data only tamb, dhi, dni, ghi, wind (not enough data for CSP or PV thermal models)
707715
{
708-
m_links.push_back(LinkInfo(name, displayName, year, URL, interval, location));
716+
//m_links.push_back(LinkInfo(name, displayName, year, URL, interval, location));
717+
m_links.push_back(LinkInfo(name, displayName, year, URL, interval, locname));
709718

710719
// enable list, search, and buttons
711720
m_chlResources->Enable();

0 commit comments

Comments
 (0)