Skip to content

Commit

Permalink
Merge pull request seandepagnier#206 from did-g/guid
Browse files Browse the repository at this point in the history
Add GUID to route and position.
  • Loading branch information
seandepagnier authored Jun 8, 2018
2 parents 8ef61d6 + d7415ae commit 536da9d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/RouteMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,19 @@ class IsoChron
typedef std::list<IsoChron*> IsoChronList;

struct RouteMapPosition {
RouteMapPosition(wxString n, double lat0, double lon0)
: Name(n), lat(lat0), lon(lon0) {}
RouteMapPosition(wxString n, double lat0, double lon0, wxString guid = wxEmptyString)
: Name(n), GUID(guid), lat(lat0), lon(lon0) {}

wxString Name;
wxString GUID;
double lat, lon;
};

struct RouteMapConfiguration {
RouteMapConfiguration () : StartLon(0), EndLon(0), grib_is_data_deficient(false) {} /* avoid waiting forever in update longitudes */
bool Update();

wxString RouteGUID; /* Route GUID if any */
wxString Start, End;
wxDateTime StartTime;

Expand Down
14 changes: 11 additions & 3 deletions src/WeatherRouting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void WeatherRouting::AddPosition(double lat, double lon)
AddPosition(lat, lon, pd.GetValue());
}

void WeatherRouting::AddPosition(double lat, double lon, wxString name)
void WeatherRouting::AddPosition(double lat, double lon, wxString name, wxString GUID)
{
for(std::list<RouteMapPosition>::iterator it = RouteMap::Positions.begin();
it != RouteMap::Positions.end(); it++) {
Expand All @@ -430,6 +430,7 @@ void WeatherRouting::AddPosition(double lat, double lon, wxString name)
long index = m_panel->m_lPositions->FindItem(0, name);
(*it).lat = lat;
(*it).lon = lon;
(*it).GUID = wxEmptyString;
m_panel->m_lPositions->SetItem(index, POSITION_LAT, wxString::Format(_T("%.5f"), lat));
m_panel->m_lPositions->SetColumnWidth(POSITION_LAT, wxLIST_AUTOSIZE);
m_panel->m_lPositions->SetItem(index, POSITION_LON, wxString::Format(_T("%.5f"), lon));
Expand All @@ -441,7 +442,7 @@ void WeatherRouting::AddPosition(double lat, double lon, wxString name)
}
}

RouteMap::Positions.push_back(RouteMapPosition(name, lat, lon));
RouteMap::Positions.push_back(RouteMapPosition(name, lat, lon, GUID));
UpdateConfigurations();

wxListItem item;
Expand Down Expand Up @@ -1352,6 +1353,7 @@ bool WeatherRouting::OpenXML(wxString filename, bool reportfailure)

if(!strcmp(e->Value(), "Position")) {
wxString name = wxString::FromUTF8(e->Attribute("Name"));
wxString GUID = wxString::FromUTF8(e->Attribute("GUID"));
double lat = AttributeDouble(e, "Latitude", NAN);
double lon = AttributeDouble(e, "Longitude", NAN);

Expand All @@ -1369,12 +1371,13 @@ bool WeatherRouting::OpenXML(wxString filename, bool reportfailure)
goto skipadd;
}
}
AddPosition(lat, lon, name);
AddPosition(lat, lon, name, GUID);

skipadd:;
} else
if(!strcmp(e->Value(), "Configuration")) {
RouteMapConfiguration configuration;
configuration.RouteGUID = wxString::FromUTF8(e->Attribute("GUID"));
configuration.Start = wxString::FromUTF8(e->Attribute("Start"));
wxDateTime date;
date.ParseISODate(wxString::FromUTF8(e->Attribute("StartDate")));
Expand Down Expand Up @@ -1492,6 +1495,8 @@ void WeatherRouting::SaveXML(wxString filename)
c->SetAttribute("Name", (*it).Name.mb_str());
c->SetAttribute("Latitude", wxString::Format(_T("%.5f"), (*it).lat).mb_str());
c->SetAttribute("Longitude", wxString::Format(_T("%.5f"), (*it).lon).mb_str());
if (!(*it).GUID.IsEmpty())
c->SetAttribute("GUID", (*it).GUID.mb_str());

root->LinkEndChild(c);
}
Expand All @@ -1503,6 +1508,9 @@ void WeatherRouting::SaveXML(wxString filename)
RouteMapConfiguration configuration =
(*it)->routemapoverlay->GetConfiguration();

if (!configuration.RouteGUID.IsEmpty())
c->SetAttribute("GUID", configuration.RouteGUID.mb_str());

c->SetAttribute("Start", configuration.Start.mb_str());
c->SetAttribute("StartDate", configuration.StartTime.FormatISODate().mb_str());
c->SetAttribute("StartTime", configuration.StartTime.FormatISOTime().mb_str());
Expand Down
2 changes: 1 addition & 1 deletion src/WeatherRouting.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class WeatherRouting : public WeatherRoutingBase
void UpdateDisplaySettings();

void AddPosition(double lat, double lon);
void AddPosition(double lat, double lon, wxString name);
void AddPosition(double lat, double lon, wxString name, wxString GUID = wxEmptyString);

void CursorRouteChanged();
void UpdateColumns();
Expand Down

0 comments on commit 536da9d

Please sign in to comment.