Skip to content

Commit

Permalink
to eliminate refpoints which also have lat/lon attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasbats committed May 16, 2020
1 parent f581291 commit 8264698
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
49 changes: 31 additions & 18 deletions src/RTZassistPanelMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ int RTZassistPanelMain::ExportGPX() {
vector<waypoint> myVectorWaypoints;
// end of placeholders

wxString isRefpoint;

string readFile = "dom_out.txt"; // intermediate file - make temporary?
vector<string> myVector;

Expand All @@ -484,7 +486,7 @@ int RTZassistPanelMain::ExportGPX() {
int c = myVector.size();

for (int z = 0; z < c; z++) {

wxStringTokenizer tokenizer(myVector[z], ":");
while (tokenizer.HasMoreTokens())
{
Expand All @@ -495,6 +497,15 @@ int RTZassistPanelMain::ExportGPX() {
myRoute.routeName = tokenizer.GetNextToken();
}

myWaypoint.b_isRefpoint = false;

if (token == "tag") {
isRefpoint = tokenizer.GetNextToken();
if (isRefpoint == "refpoint") {
myWaypoint.b_isRefpoint = true;
}
}

if (token == "id") {
myWaypoint.id = tokenizer.GetNextToken();
}
Expand All @@ -510,8 +521,9 @@ int RTZassistPanelMain::ExportGPX() {
if (token == "lon") {

myWaypoint.lon = tokenizer.GetNextToken();
myRoute.waypoints.push_back(myWaypoint);

//
if(!myWaypoint.b_isRefpoint) myRoute.waypoints.push_back(myWaypoint); // this eliminates RTZ refpoints, which have lat/lon and could be misinterpreted as waypoints.
//
}
}
}
Expand Down Expand Up @@ -564,21 +576,22 @@ int RTZassistPanelMain::ExportGPX() {
for (int i = 0; i < waypointCount; i++) {

tinyxml2::XMLElement*m_waypoint = doc.NewElement("rtept");
Route->InsertEndChild(m_waypoint);
m_waypoint->SetAttribute("lat", myRoute.waypoints[i].lat.mb_str());
m_waypoint->SetAttribute("lon", myRoute.waypoints[i].lon.mb_str());

tinyxml2::XMLElement* name = doc.NewElement("name");
m_waypoint->InsertFirstChild(name);
name->SetText(myRoute.waypoints[i].name.mb_str());

tinyxml2::XMLElement* symbol = doc.NewElement("sym");
m_waypoint->InsertFirstChild(symbol);
symbol->SetText("diamond");

tinyxml2::XMLElement* type = doc.NewElement("type");
m_waypoint->InsertFirstChild(type);
type->SetText("WPT");

Route->InsertEndChild(m_waypoint);
m_waypoint->SetAttribute("lat", myRoute.waypoints[i].lat.mb_str());
m_waypoint->SetAttribute("lon", myRoute.waypoints[i].lon.mb_str());

tinyxml2::XMLElement* name = doc.NewElement("name");
m_waypoint->InsertFirstChild(name);
name->SetText(myRoute.waypoints[i].name.mb_str());

tinyxml2::XMLElement* symbol = doc.NewElement("sym");
m_waypoint->InsertFirstChild(symbol);
symbol->SetText("diamond");

tinyxml2::XMLElement* type = doc.NewElement("type");
m_waypoint->InsertFirstChild(type);
type->SetText("WPT");

}

Expand Down
1 change: 1 addition & 0 deletions src/RTZassistPanelMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class waypoint
wxString id;
wxString name;
wxString lat, lon;
bool b_isRefpoint;
};

class route
Expand Down

0 comments on commit 8264698

Please sign in to comment.