Skip to content

Commit

Permalink
allow any class to extract the gpx object data
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Sep 25, 2024
1 parent 4091d24 commit bc2e1ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/gpxfilemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ QVariantList GPXFileModel::createOverlayObjects(int id /*=-1*/)
if (item->type() == GPXObject::Track)
{
const GPXObjectTrack* obj = static_cast<const GPXObjectTrack*>(item);
for (auto const& segment : obj->m_track.segments)
for (auto const& segment : obj->data().segments)
{
std::vector<osmscout::Point> points;
points.reserve(segment.points.size());
Expand All @@ -356,7 +356,7 @@ QVariantList GPXFileModel::createOverlayObjects(int id /*=-1*/)
{
const GPXObjectWayPoint* obj = static_cast<const GPXObjectWayPoint*>(item);
osmscout::OverlayNode* node = new osmscout::OverlayNode();
node->addPoint(obj->m_waypoint.coord.GetLat(), obj->m_waypoint.coord.GetLon());
node->addPoint(obj->data().coord.GetLat(), obj->data().coord.GetLon());
node->setTypeName(OVERLAY_NODE_WAYPOINT_TYPE);
node->setName(obj->name());
QVariant var;
Expand Down
6 changes: 4 additions & 2 deletions src/gpxfilemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class GPXObject : public QObject

class GPXObjectTrack : public GPXObject
{
friend class GPXFileModel;
public:
GPXObjectTrack(const osmscout::gpx::Track& track, int id) : m_track(track), m_id(id) { }
int id() const override { return m_id; }
Expand All @@ -71,14 +70,15 @@ class GPXObjectTrack : public GPXObject
QString description() const override { return QString::fromUtf8(m_track.desc.value_or("").c_str()); }
double length() const { return m_track.GetLength().AsMeter(); }
QString displayColor() const;

const osmscout::gpx::Track& data() const { return m_track; };
private:
const osmscout::gpx::Track& m_track;
int m_id;
};

class GPXObjectWayPoint : public GPXObject
{
friend class GPXFileModel;
public:
GPXObjectWayPoint(const osmscout::gpx::Waypoint& waipoint, int id) : m_waypoint(waipoint), m_id(id) { }
int id() const override { return m_id; }
Expand All @@ -89,6 +89,8 @@ class GPXObjectWayPoint : public GPXObject
double lat() const { return m_waypoint.coord.GetLat(); }
double lon() const { return m_waypoint.coord.GetLon(); }
double elevation() const { return m_waypoint.elevation.value_or(0.0); }

const osmscout::gpx::Waypoint& data() const { return m_waypoint; };
private:
const osmscout::gpx::Waypoint& m_waypoint;
int m_id;
Expand Down

0 comments on commit bc2e1ea

Please sign in to comment.