Skip to content

Commit b9f16fb

Browse files
committed
Remove debugging messages and handle zero rate utilities #1968
Working without issue on Windows
1 parent 8d4f328 commit b9f16fb

File tree

3 files changed

+17
-42
lines changed

3 files changed

+17
-42
lines changed

src/geotools.cpp

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,8 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
188188

189189
wxEasyCurl curl;
190190
wxBusyCursor curs;
191-
wxMessageBox(url, "geocode developer URL");
192-
191+
193192
// SAM issue 1968
194-
/* works from command line and fails in curl.get with invalid key
195-
url.Replace("&", "\\&");
196-
wxMessageBox(url, "updated geocode developer URL");
197-
*/
198193
curl.AddHttpHeader("Content-Type: application/json");
199194
curl.AddHttpHeader("Accept: application/json");
200195

@@ -212,32 +207,10 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
212207
rapidjson::GenericDocument < rapidjson::UTF16<> > reader;
213208
wxString str = curl.GetDataAsString();
214209

215-
// str.Replace("\"", "\\\"");
216-
217-
// std::string str = curl.GetDataAsString().ToStdString();
218-
219-
wxMessageBox(str, "geocode developer URL return string");
220-
221-
222-
// rapidjson::StringStream is(str.c_str());
223-
224-
// doc.ParseStream(is);
225-
226-
227-
// rapidjson::ParseResult ok = reader.Parse((const char*)str.c_str());
228-
// rapidjson::ParseResult ok = reader.ParseStream(is);
229210
rapidjson::ParseResult ok = reader.Parse(str.c_str());
230211

231212

232213
/*
233-
ParseResult ok = doc.Parse("[42]");
234-
if (!ok) {
235-
fprintf(stderr, "JSON parse error: %s (%u)",
236-
GetParseError_En(ok.Code()), ok.Offset());
237-
exit(EXIT_FAILURE);
238-
}
239-
240-
241214
example for "denver, co"
242215
{"info":
243216
{"statuscode":0,"copyright":
@@ -276,7 +249,6 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
276249
}
277250
// check status code
278251
success = false;//overrides success of retrieving data
279-
wxMessageBox(str, "geocode developer reset status code ");
280252

281253
if (reader.HasMember(L"info")) {
282254
if (reader[L"info"].HasMember(L"statuscode")) {
@@ -293,16 +265,13 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
293265
if (!success)
294266
return false;
295267

296-
wxMessageBox(str, "geocode developer success to tz ");
297268

298269

299270
if (tz != 0)
300271
{
301272
success = false;
302273

303274
curl = wxEasyCurl();
304-
// curl.AddHttpHeader("Content-Type: application/json");
305-
// curl.AddHttpHeader("Accept: application/json");
306275

307276

308277

@@ -314,8 +283,6 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
314283
curl.AddHttpHeader("Accept: application/json");
315284

316285

317-
wxMessageBox(url, "geocode developer bing tz URL");
318-
319286
if (showprogress)
320287
{
321288
if (!curl.Get(url, "Geocoding address '" + address + "'..."))
@@ -328,8 +295,6 @@ bool GeoTools::GeocodeDeveloper(const wxString& address, double* lat, double* lo
328295

329296
str = curl.GetDataAsString();
330297

331-
wxMessageBox(str, "geocode developer bing tz URL return string");
332-
333298
reader.Parse(str.c_str());
334299

335300
if (!reader.HasParseError()) {

src/urdb.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,8 +1281,9 @@ int OpenEIUtilityRateDialog::ShowModal()
12811281
return wxDialog::ShowModal();
12821282
}
12831283

1284-
void OpenEIUtilityRateDialog::QueryRates(const wxString &utility_name)
1284+
bool OpenEIUtilityRateDialog::QueryRates(const wxString &utility_name)
12851285
{
1286+
bool ret = true;
12861287
wxBusyInfo busy("Getting available rates...", this);
12871288
lblStatus->SetLabel("Loading rates...");
12881289

@@ -1293,8 +1294,10 @@ void OpenEIUtilityRateDialog::QueryRates(const wxString &utility_name)
12931294
if (!api.QueryUtilityRates(utility_name, mUtilityRates, &err))
12941295
{
12951296
busy.~wxBusyInfo();
1296-
wxMessageBox("Utility Rate Query Error\n\n" + err, "URDB Download Message");
1297-
return;
1297+
// wxMessageBox("Utility Rate Query Error\n\n" + err, "URDB Download Message");
1298+
// return false;
1299+
ret = false;
1300+
mUtilityRates.clear();
12981301
}
12991302

13001303
lblRateStatus->SetLabel(wxString::Format("%d rates available for %s", (int)mUtilityRates.size(), utility_name));
@@ -1305,6 +1308,7 @@ void OpenEIUtilityRateDialog::QueryRates(const wxString &utility_name)
13051308
lblStatus->SetLabel("Ready.");
13061309

13071310
UpdateRateList();
1311+
return true;
13081312
}
13091313

13101314
void OpenEIUtilityRateDialog::UpdateRateList()
@@ -1414,8 +1418,14 @@ void OpenEIUtilityRateDialog::OnEvent(wxCommandEvent &evt)
14141418
UpdateRateList();
14151419
break;
14161420
case ID_lstUtilities:
1417-
QueryRates( lstUtilities->GetStringSelection() );
1418-
lblUtilityCount->SetLabel(wxString::Format("%d utilities", (int)lstUtilities->Count()));
1421+
if (QueryRates(lstUtilities->GetStringSelection())) {
1422+
lblUtilityCount->SetLabel(wxString::Format("%d utilities", (int)lstUtilities->Count()));
1423+
}
1424+
else {
1425+
lstRates->Clear();
1426+
mGUIDList.Clear();
1427+
mUtilityRates.clear();
1428+
}
14191429
break;
14201430
case ID_lstRates:
14211431
UpdateRateData();

src/urdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class OpenEIUtilityRateDialog : public wxDialog
163163
void StartHttp();
164164
void QueryUtilities();
165165
void QueryUtilitiesByZipCode();
166-
void QueryRates(const wxString &utility_name);
166+
bool QueryRates(const wxString &utility_name);
167167
void OnEvent(wxCommandEvent &evt);
168168
void OnTimer(wxTimerEvent &evt);
169169
void UpdateRateList();

0 commit comments

Comments
 (0)